# MatPermute
Creates a new matrix with rows and columns permuted from the original. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatPermute(Mat mat, IS row, IS col, Mat *B)
```
Collective on mat


## Input Parameters

- ***mat -*** the matrix to permute
- ***row -*** row permutation, each processor supplies only the permutation for its rows
- ***col -*** column permutation, each processor supplies only the permutation for its columns



## Output Parameters

- ***B -*** the permuted matrix





## Note
The index sets map from row/col of permuted matrix to row/col of original matrix.
The index sets should be on the same communicator as mat and have the same local sizes.


## Developer Note
If you want to implement `MatPermute()` for a matrix type, and your approach doesn't
exploit the fact that row and col are permutations, consider implementing the
more general `MatCreateSubMatrix()` instead.


## See Also
 `MatGetOrdering()`, `ISAllGather()`, `MatCreateSubMatrix()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatPermute">src/mat/interface/matrix.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex10.c.html">src/ksp/ksp/tutorials/ex10.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex18.c.html">src/ksp/ksp/tutorials/ex18.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/mpiaij.c.html#MatPermute_MPIAIJ">MatPermute_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aij.c.html#MatPermute_SeqAIJ">MatPermute_SeqAIJ in src/mat/impls/aij/seq/aij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/baij/mpi/mpibaij.c.html#MatPermute_MPIBAIJ">MatPermute_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/normal/normm.c.html#MatPermute_Normal">MatPermute_Normal in src/mat/impls/normal/normm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/normal/normmh.c.html#MatPermute_NormalHermitian">MatPermute_NormalHermitian in src/mat/impls/normal/normmh.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sbaij/seq/sbaij.c.html#MatPermute_SeqSBAIJ">MatPermute_SeqSBAIJ in src/mat/impls/sbaij/seq/sbaij.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matrix.c)


[Index of all Mat routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
