[petsc-users] Any beautiful way to calculate b=Ax-r

Gong Ding gdiso at ustc.edu
Mon Aug 15 03:13:39 CDT 2011


Hi,
I have a linear system f(x)=Ax-b=r
For solving it, I must build rhs vector b=Ax-r.
However, I can't find some direct API to do this.
MatMultAdd only support b=Ax+r.

At preset, I am using 
VecSet(L, -1.0);
VecPointwiseMult(r, r, L); // r <- -r
MatMultAdd(A, x, r, b);

Any better method?

Gong Ding









More information about the petsc-users mailing list