[petsc-users] inserting into sparse matricies

Jed Brown jed at 59A2.org
Fri Mar 26 10:28:26 CDT 2010


On Fri, 26 Mar 2010 11:18:08 -0400, John-Michael Fischer <fischej at umich.edu> wrote:
> I have a vector of values I want to insert into a sparse matrix as a
> row.  My vector contains non-zero values at their proper positions in
> the row and zero's elsewhere.

How did you get this vector with all the explicit zeros?

There is an option MAT_IGNORE_ZERO_ENTRIES, but I don't think you want
to use it here.

> Alternatively, I was thinking I could assemble a vector with the
> indecies of the non-zero elements, then use that in the call to
> MatSetValues with a row vector of non-zero values only - but I wanted
> to ask first since this seems like a common usage pattern for PETSC
> sparse mat's.

Usually you only compute the nonzero entries.

Jed


More information about the petsc-users mailing list