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

Roland Richter roland.richter at ntnu.no
Tue Jan 5 09:33:20 CST 2021


Hei,

one solution would then be to iterate over all local rows and use
VecPointwiseMult (n-1)-times for x^n if I would like to apply that to a
matrix?

Thanks,

regards,

Roland

Am 05.01.21 um 16:30 schrieb Pierre Seize:
> Hi,
>
> For Vec there is
> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSqrtAbs.html
> and
> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecPointwiseMult.html,
> I think it's what you're looking for. I don't know if there is the
> same for Mat.
>
> Pierre
>
> On 05/01/21 16:24, Roland Richter 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.
>>
>> Thanks!
>>
>> Regards,
>>
>> Roland Richter
>>
>


More information about the petsc-users mailing list