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

Shrirang Abhyankar abhyshr at mcs.anl.gov
Mon Aug 15 08:20:11 CDT 2011


There is no API for Ax - r, you can do
MatMult(A,x,b)
VecAXPY(b,-1.0,r)



On Aug 15, 2011, at 3:14 AM, "Gong Ding" <gdiso at ustc.edu> wrote:

> 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