[petsc-users] How to compute y = y - A*b
Timothée Nicolas
timothee.nicolas at gmail.com
Thu Dec 22 07:15:07 CST 2016
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 <mailinglists at xgm.de>:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20161222/126d62b1/attachment.html>
More information about the petsc-users
mailing list