[petsc-users] Changing the diagonal of a matrix via a vector

Xiangdong Liang xdliang at gmail.com
Wed Apr 27 10:57:13 CDT 2011


Hello everyone,

I am a novice to Petsc and parallel computing. I have created a mpi sparse
matrix A (size n-by-n) and a parallel vector b (size n-by-1). Now I want to
modify the diagonal of A by adding the values of vector b. Namely, A(i,i) =
A(i,i) + b(i) and all the off-diagonal elements remains the same. I am
worrying that when I use MatSetValue or MatSetValues, b(i) may not be
accessed by some particular processor since VecGetValues can only get values
on the same processor. One possible solution I am thinking  is converting
vector b to a diagonal matrix B and then do the MatAXPY operation. However,
using MatSetValue to set diagonal elements of B,  B(i,i) = b(i),  still
faces the similar problem. Can anyone give me some suggestion? Thanks.

Best,
Xiangdong

P.S. When I compiled my program, I get warnings like that: warning: return
makes pointer from integer without a cast. Actually, these lines are
standard Petsc functions like that:

ierr = VecCreate(PETSC_COMM_WORLD,&x);CHKERRQ(ierr);
ierr = VecDestroy(x); CHKERRQ(ierr);

How can I get rid of these warnings?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110427/b1c63a14/attachment.htm>


More information about the petsc-users mailing list