<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div><div> I see that currently VecPow is used only in a small number of places including:</div><div><br></div><div> <span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures; color: rgb(200, 20, 201);">ksp/ksp/utils/lmvm/diagbrdn/diagbrdn.c</span><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures; color: rgb(46, 174, 187);">:</span><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;"> PetscCall(</span><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures; color: rgb(180, 36, 25);"><b>VecPow</b></span><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;">(ldb->U, ldb->beta - 1));</span></div><div><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;"><br></span></div><div><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;"><br></span></div> I am unsure if the usage here requires the special handling of negative numbers.<div><br></div><div> I was wrong and it is not used in the semi-smooth code, that access the vector elements directly.</div><div><br></div><div> If could be we can strip out all the special infinity cases completely.</div><div><br><div><br></div><div> Barry</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Nov 14, 2024, at 9:56 AM, Stefano Zampini <stefano.zampini@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div>That is a very old bug! Can you make an MR to just call PetscPowScalar in a loop here <a href="https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/blob/main/src/vec/vec/utils/projection.c*L1022__;Iw!!G_uCfscf7eWS!bbSdSMnU5KpH03jHI7aV5j4WLGQ3yPvxWzR6Lwr14QLy_7EJ2MNT-qhL6J1x6z3vpF6M5GQk9lMQkMoLJ_JNSn1mqwqict4$">https://gitlab.com/petsc/petsc/-/blob/main/src/vec/vec/utils/projection.c#L1022</a> ?</div><div><br></div><div>Thanks<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno gio 14 nov 2024 alle ore 17:39 Peder Jørgensgaard Olesen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg166266278254764509">
<div dir="ltr">
<div id="m_-1022651371127264465Signature">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt;">
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.</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt;">
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().</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt;">
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.</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt;">
Best,</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt;">
Peder</div>
</div>
</div>
</div></blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Stefano</div>
</div></blockquote></div><br></div></div></body></html>