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
one=1.0d0 and then VecAXPY(y, -one, r); Best Timothée 2016-12-22 14:07 GMT+01:00 Florian Lindner <[email protected]>: > Hello, > > what is the best / most efficient way to compute: > > y = y - A * b > > with vectors b, y and matrix A: > > * VecAXPY: I need to compute A*b first > > MatMult(A, b, r); > VecAXPY(y, -1, r); > > * VecWAXPY: Same case, but I don't reuse y > > MatMult(A, b, r); > VecWAXPY(w, -1, r, y); > > * VecAYPX: Don't work, because I need to multiply r = A*b with -1 > > Is there anything else I have overseen, or should I just go with VecAXPY? > > Best, > Florian >
