[petsc-users] Question about matrix permutation

abhyshr at mcs.anl.gov abhyshr at mcs.anl.gov
Fri Jan 29 09:43:05 CST 2010


Instead of calling MatGetSubMatrix to get each submatrix you can use MatGetSubMatrices to extract several submatrices at once. See http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatGetSubMatrices.html#MatGetSubMatrices.
----- "Jed Brown" <jed at 59A2.org> wrote:

> On Fri, 29 Jan 2010 15:54:36 +0100, Michel Cancelliere
> <michel.cancelliere at polito.it> wrote:
> > Hi all,
> > 
> > I'm implementing a preconditioner that involves to extract some
> submatrices,
> > the system matrix is of type seqbaij, and i need to permute some
> rows and
> > columns before extract the submatrices.
> 
> How big are these submatrices relative to the whole thing?  The way
> MatGetSubMatrix is implemented, it needs sorted index sets, but you
> could extract the submatrix and then sort.  It's not clear to me if
> this
> optimization is important for performance in the context that
> MatGetSubMatrix is normally used (i.e. a reasonable amount of work is
> done with the submatrix).  And it would certainly not have a
> performance
> impact to branch to a generic implementation when the index sets are
> unsorted.
> 
> > I'm trying to use MatPermute() but i should need create and
> additional
> > matrix
> 
> If the submatrix is much smaller than the original, this is probably
> not
> a problem.  If it's large, and there isn't a better way to solve the
> problem, then maybe MatGetSubMatrix should support unsorted index
> sets.
> 
> > and it seems not to work with baij matrices
> 
> It should work with MPIBAIJ matrices, it looks like it was never
> implemented for SeqBAIJ, but this could be done fairly easily.
> 
> Jed


More information about the petsc-users mailing list