wierd behaviour from MatGetRow?

Barry Smith bsmith at mcs.anl.gov
Thu Sep 27 09:40:43 CDT 2007


 Toby,

   From the manual page for MatGetRow()

  Caution:
   Do not try to change the contents of the output arrays (cols and vals).
   In some cases, this may corrupt the matrix.

  You can use MatZeroRows() to zero out some rows. Similarly you
can use MatGetSubmatrix() to extract out certain rows and columns
that you wish to solve with.

   Barry



On Thu, 27 Sep 2007, Toby D. Young wrote:

> 
> 
> 
> 
> Hello,
> 
> I apologize in advance if this message is garbled.
> 
> I'm trying to set non-zero values of a column to zero, so I do the
> following:
> 
> MatGetRow()     <- get the column numbers of non-zero elements
> MatSetValues()  <- set those elements to zero
> MatGetRow()     <- check that element is set to zero
> 
> The output from my program gives:
> 
>    num = 0x56f024        <- pointer to column number
>    values = 0.666667     <- it's value
>    num = 0x56f024        <- pointer to column number
>    values = 0            <- it's value
> 
> So it looks like it has worked the matrix value is zero!
> 
> ...but if the matrix element has been set to zero, why does MatGetRow
> tell mne this? Should not MatGetRow see that it is zero and return
> nothing? 
> 
> Is this behaviour be correct? I'd be interested to know it seems like
> a riddle to me.
> 
> Thanks.
> 
> Best,
> 	Toby
> 
> 
> 
> 




More information about the petsc-users mailing list