:orphan:
# MatGetOrdering
Gets a reordering for a matrix to reduce fill or to improve numerical stability of LU factorization. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatGetOrdering(Mat mat, MatOrderingType type, IS *rperm, IS *cperm)
```
Collective


## Input Parameters

- ***mat -*** the matrix
- ***type -*** type of reordering, one of the following


```none
      MATORDERINGNATURAL_OR_ND - Nested dissection unless matrix is SBAIJ then it is natural
      MATORDERINGNATURAL - Natural
      MATORDERINGND - Nested Dissection
      MATORDERING1WD - One-way Dissection
      MATORDERINGRCM - Reverse Cuthill-McKee
      MATORDERINGQMD - Quotient Minimum Degree
      MATORDERINGEXTERNAL - Use an ordering internal to the factorzation package and do not compute or use PETSc's
```



## Output Parameters

- ***rperm -*** row permutation indices
- ***cperm -*** column permutation indices



## Options Database Key

- ***-mat_view_ordering draw -*** plots matrix nonzero structure in new ordering
- ***-pc_factor_mat_ordering_type <nd,natural,..> -*** ordering to use with `PC`s based on factorization, `MATLU`, `MATILU`, MATCHOLESKY`, `MATICC`





## Notes
This DOES NOT actually reorder the matrix; it merely returns two index sets
that define a reordering. This is usually not used directly, rather use the
options `PCFactorSetMatOrderingType()`

The user can define additional orderings; see `MatOrderingRegister()`.

These are generally only implemented for sequential sparse matrices.

Some external packages that PETSc can use for direct factorization such as SuperLU_DIST do not accept orderings provided by
this call.

If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and utilizes one built into the factorization package


## See Also
 `MatOrderingRegister()`, `PCFactorSetMatOrderingType()`, `MatColoring`, `MatColoringCreate()`, `MatOrderingType`, `Mat`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/order/sorder.c.html#MatGetOrdering">src/mat/order/sorder.c</A>

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


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


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