<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">It already checks for zeros. See VecPointwiseDivide_Seq in </span>src/vec/vec/impls/seq/bvec2.c</div><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 3, 2019, at 5:12 PM, Matthew Knepley via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Jan 3, 2019 at 11:01 AM Florian Lindner via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:<br class=""></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 class="">
<br class="">
Happy New Year Everybody!<br class="">
<br class="">
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 class="">
<br class="">
What is the best way to do so, especially performance wise?<br class="">
<br class="">
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 class="">
<br class="">
Any better ideas?<br class=""></blockquote><div class=""><br class=""></div><div class="">I would write VecAbsMin() yourself,</div><div class=""><br class=""></div><div class=""><a href="https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-299" class="">https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-299</a><br class=""></div><div class=""><a href="https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-1510" class="">https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/vec/vec/utils/vinv.c#lines-1510</a><br class=""></div><div class=""><br class=""></div><div class="">It should only be about 8 lines.</div><div class=""><br class=""></div><div class="">  Thanks,</div><div class=""><br class=""></div><div class="">    Matt</div><div class=""> <br class=""></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 class="">
Florian<br class="">
</blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class=""></div></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></body></html>