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

Hong Zhang hzhang at mcs.anl.gov
Mon Aug 27 09:00:24 CDT 2007


See ~petsc/src/mat/examples/tests/ex58f.F on
how to use MatGetRow() from Fortran.

Hong

On Mon, 27 Aug 2007, Ben Tay wrote:

> 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