[petsc-users] MatSetValues for nonzeros of a sparse matrix
Jed Brown
jed at 59A2.org
Wed Jan 13 09:33:46 CST 2010
On Wed, 13 Jan 2010 09:21:20 -0600, Matthew Knepley <knepley at gmail.com> wrote:
> Should be
>
> for(int r = 0; r < 4; ++r) {
> MatSetValues(A, 1, idxm[r], 1, idxn[r], &valuesMat[r*4+r], INSERT_VALUES);
actually
MatSetValues(A, 1, &idxm[r], 1, &idxn[r], &valuesMat[r*4+r], INSERT_VALUES);
or
MatSetValue(A, idxm[r], idxn[r], valuesMat[r*4+r], INSERT_VALUES);
But considering that
> Also I keep the row and column indices of the non-zero values and as
> well the non-zeros values in arrays of proper type.
you should loop over rows and insert all entries of that row at once.
Jed
More information about the petsc-users
mailing list