[petsc-users] MatSetValue

Barry Smith bsmith at mcs.anl.gov
Tue Jan 21 14:25:08 CST 2014


On Jan 21, 2014, at 1:22 PM, Que Cat <quecat001 at gmail.com> wrote:

> Hi Petsc-users,
> I confused about the MatSetValue from the manual.
> For example, I need to assembly three values A[0,1]=1 , A[3,2]=10 , A[5,2]=20 to the parallel matrix A. I can create a dense subblock matrix values that has dimension of m=1, n=3: values=[1 10 20], idxm=[0 3 5], idxn=[1 2 2].

   No this does not do that. the above idxm, idxn does not mean you are setting entries (0,1) (3,2) (5,2) it means you are setting the 1, 2 and 2 columns of the 0th, 3rd and 5th rows so 9 = 3x3 values. (which doesn’t make sense since you won’t set the 2 columns twice). 
> But the manual says that "the value to be put in row idxm[i] and column idxn[j] is located in values[i*n+j]". So, for example i=1,j=1 will add values[1*3+1] to the matrix, which does not exist in values. What do I misunderstand the manual? We can set separate value to the parallel matrix, but it says that it is better to set a subblock matrix.
> Thank you.
> 
> Que.



More information about the petsc-users mailing list