[petsc-users] VecPow clarification

Barry Smith bsmith at petsc.dev
Fri Nov 15 11:19:25 CST 2024


https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/merge_requests/8012__;!!G_uCfscf7eWS!Y4coa74DKQZeRI4FvkVAj8dOc1biQzDAjzXBDqgLJKStN2JFpB7w-WYstcURUd-AykeTfuH7q6YeUPfb3eIQD2s$ 


> On Nov 14, 2024, at 9:39 AM, Peder Jørgensgaard Olesen via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Given a vector containing roots of unity, v[i] = exp(i*k*x[i]) I wanted to compute the vector u[i]=exp(i*n*k*x[i]), for some real number n. From the face of it this should be easily achieved with VecPow, as u[i] = v[i]^n.
> 
> That didn't work as expected, though I got around it using VecGetArray() and a loop with PetscPowComplex(). The source designated in the docs (src/vec/vec/utils/projection.c) reveals that VecPow() maps v[i] to PETSC_INFINITY when the PetscRealPart(v[i]) < 0, unless the power is any of 0, ±0.5, ±1 or ±2. Even in the simple case of a purely real vector (with negative entries) raised to any other integer power, the results would not be what one might  reasonably expect from the description of VecPow().
> 
> While I do have a solution suiting my need, I'm left wondering what might be the rationale for VecPow working the way it does.
> 
> Best,
> Peder

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241115/eb86ed7e/attachment-0001.html>


More information about the petsc-users mailing list