<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Jan 3, 2019 at 11:01 AM Florian Lindner via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
Happy New Year Everybody!<br>
<br>
I get a vector from a linear solve and is used a divisor in VecPointwiseDivide. Clearly, I must check for zero entries before doing the division.<br>
<br>
What is the best way to do so, especially performance wise?<br>
<br>
The only way I come up with so far, is to VecCopy, VecAbs and then check for VecMin > eps. The VecCopy kind of scares me for the performance draw back. I haven't found something like a VecAbsMin.<br>
<br>
Any better ideas?<br></blockquote><div><br></div><div>I would write VecAbsMin() yourself,</div><div><br></div><div><a href="https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-299">https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-299</a><br></div><div><a href="https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-1510">https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-1510</a><br></div><div><br></div><div>It should only be about 8 lines.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Thanks,<br>
Florian<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div></div></div>