[petsc-users] set the diagonal for zero row

Matthew Knepley knepley at gmail.com
Mon Aug 10 07:02:10 CDT 2015


On Mon, Aug 10, 2015 at 3:57 AM, Hoang Giang Bui <hgbk2008 at gmail.com> wrote:

> Dear list
>
> What is the best way to search for complete zero rows of the matrix and
> set the diagonal to 1.0? In my thinking, the solution would be:
> + extract the max absolute values of each row by using MatGetRowMaxAbs
> + Compare the value with some tolerance and put into the zero row list
> + Extract the diagonal of the matrix by MatGetDiagonal
> + modify the vector of diagonal
> + set the diagonal back by using MatDiagonalSet
>
> THis seem to be overly complicated. Is there an all-in-one solution,
> similar to MatZeroRowsColumns?
>

I don't think there is anything better than checking the MaxAbs, and
calling MatZeroRows() on the indices with a 0.0

  Thanks,

     Matt


> Best regards
> Giang
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150810/7150b2d9/attachment.html>


More information about the petsc-users mailing list