Is this the correct way to use MatGetRow? Something wrong here

Ben Tay zonexo at gmail.com
Mon Aug 27 06:19:06 CDT 2007


Hi,

I'm trying to view a particular row of a matrix. This 's what I do in my 
loops:

real(8):: vector(64)

II=36

impl_mat_i=4.

call MatSetValue(A_mat_uv,II,II,impl_mat_i,ADD_VALUES,ierr)

call MatAssemblyBegin(A_mat_uv,MAT_FINAL_ASSEMBLY,ierr)

call MatAssemblyEnd(A_mat_uv,MAT_FINAL_ASSEMBLY,ierr)


call MatGetRow(A_mat_uv,II,PETSC_NULL,PETSC_NULL,vector,ierr)

call MatRestoreRow(A_mat_uv,II,PETSC_NULL,PETSC_NULL,vector,ierr)

When I look at "vector" using visual fortran debugger, I saw many 
different values in it, but I only added 1 value in 1 location. However, 
just before I use MatSetValue, I also called MatGetRow. It was initially 
all zero.

But, if I use call 
MatSetValue(A_mat_uv,II,*1*,impl_mat_i,ADD_VALUES,ierr) instead of II, I 
see only 4 in vector(1).

What happening? Where did all the other values come from? Also, is this 
the best way to view a particular row of a matrix? I tried to use

call MatGetValues(A_mat_uv,1,36,64,1,vector,ierr) to get 1 row of values 
from the 36th row.There are 64 columns in total. Seems like it's the 
wrong way. Can you please show me the correct way?

Thank you.




More information about the petsc-users mailing list