[petsc-users] Retrieving Individual Values from a Parallel Matrix
Adam Byrd
adam1.byrd at gmail.com
Thu Jul 28 12:44:32 CDT 2011
Dear All,
I'm attempting to find the most efficient/simple way to collectively
retrieve just a handful of values (local and non local) from a parallel
matrix. I'm filling two 4x4 arrays with 4 values from 8 different rows of
the solution matrix of a previous solve. So far, MatGetSubMatrices looks my
only option (MatGetValues and MatGetRow can only get local values), but
seems unlikely to be the most efficient way to do this unless I am able to
change the row and column ordering when creating the submatrix. It appears
to retain the relative ordering of the rows and columns from the original
matrix. Essentially, I'm trying to do this:
myArray[n][m] = myPetscMat[i][j]
This is the code I'm rewriting to work collectively on a parallel matrix:
for(int i=0; i<4; i++)
{
ierr = MatGetRow(inverseHamiltonian, isl[i]-1, &nonZeros, PETSC_NULL,
&rowValues);CHKERRQ(ierr);
for(int j=0; j<4; j++)
{
gaml[i][j] = rowValues[isr[j]-1];
} //endfor
ierr = MatRestoreRow(inverseHamiltonian, isl[i]-1, &nonZeros, PETSC_NULL,
&rowValues);CHKERRQ(ierr);
} //endfor
for(int j=0; j<4; j++)
{
ierr = MatGetRow(inverseHamiltonian, isr[j]-1, &nonZeros, PETSC_NULL,
&rowValues);CHKERRQ(ierr);
for(int i=0; i<4; i++)
{
gamrr[i][j] = conj(rowValues[isl[i]-1]);
} //endfor
ierr = MatRestoreRow(inverseHamiltonian, isr[j]-1, &nonZeros, PETSC_NULL,
&rowValues);CHKERRQ(ierr);
} //endfor
where isr[] and isl[] contain arbitrary, unsorted indices.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110728/4327ab15/attachment.htm>
More information about the petsc-users
mailing list