[petsc-users] Elementwise pow/exponential-function on PETSc-vectors and matrices

Matthew Knepley knepley at gmail.com
Tue Jan 5 09:34:14 CST 2021


On Tue, Jan 5, 2021 at 10:24 AM Roland Richter <roland.richter at ntnu.no>
wrote:

> Hei,
>
> is there a function to square/cube etc. each element of a matrix or
> vector in PETSc? It is rather useful for things like intensity
> calculations (I = |E|^2), and should work also for distributed matrices.
>

We don't have that. We tend to shy away from functions in the interface,
since it makes cross-language
things hard. However,

1) I would be willing to add functions that you want, like square or cube,
if you think it will make things easier for you.

2) We could consider adding Vec/MatPointwiseFunction(A, f) where you apply
a function f pointwise to each entry.

  Thanks,

     Matt


> Thanks!
>
> Regards,
>
> Roland Richter
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210105/99da6d72/attachment.html>


More information about the petsc-users mailing list