<div dir="ltr"><div><div><div><div>What exactly is the problem? Don't you get good performances with the first option? I think it is good enough. However, I think it is safer to make sure that the scalars have the same type. i.e. sometimes you will get problems passing numerical values to PETSc functions if they are written as integers when a scalar is expected and vice versa. So I think you should rather define <br><br></div>one=1.0d0<br><br></div>and then<br><br>VecAXPY(y, -one, r);<br><br></div>Best<br><br></div>Timothée<br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-22 14:07 GMT+01:00 Florian Lindner <span dir="ltr"><<a href="mailto:mailinglists@xgm.de" target="_blank">mailinglists@xgm.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
what is the best / most efficient way to compute:<br>
<br>
y = y - A * b<br>
<br>
with vectors b, y and matrix A:<br>
<br>
* VecAXPY: I need to compute A*b first<br>
<br>
MatMult(A, b, r);<br>
VecAXPY(y, -1, r);<br>
<br>
* VecWAXPY: Same case, but I don't reuse y<br>
<br>
MatMult(A, b, r);<br>
VecWAXPY(w, -1, r, y);<br>
<br>
* VecAYPX: Don't work, because I need to multiply r = A*b with -1<br>
<br>
Is there anything else I have overseen, or should I just go with VecAXPY?<br>
<br>
Best,<br>
Florian<br>
</blockquote></div><br></div>