:orphan:
# MatColoringCreate
Creates a matrix coloring context. 
## Synopsis
```
#include "petscmat.h"  
PetscErrorCode MatColoringCreate(Mat m, MatColoring *mcptr)
```
Collective


## Input Parameter

- ***comm -*** MPI communicator



## Output Parameter

- ***mcptr -*** the new `MatColoring` context



## Options Database Keys

- ***-mat_coloring_type -*** the type of coloring algorithm used. See `MatColoringType`.
- ***-mat_coloring_maxcolors -*** the maximum number of relevant colors, all nodes not in a color are in maxcolors+1
- ***-mat_coloring_distance -*** compute a distance 1,2,... coloring.
- ***-mat_coloring_view -*** print information about the coloring and the produced index sets
- ***-mat_coloring_test -*** debugging option that prints all coloring incompatibilities
- ***-mat_is_coloring_test -*** debugging option that throws an error if MatColoringApply() generates an incorrect iscoloring





## Notes
A distance one coloring is useful, for example, multi-color SOR.

A distance two coloring is for the finite difference computation of Jacobians (see `MatFDColoringCreate()`).

Coloring of matrices can be computed directly from the sparse matrix nonzero structure via the `MatColoring` object or from the mesh from which the
matrix comes from with `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors).

Some coloring types only support distance two colorings


## See Also
 `MatColoringSetFromOptions()`, `MatColoring`, `MatColoringApply()`, `MatFDColoringCreate()`, `DMCreateColoring()`, `MatColoringType`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/color/interface/matcoloring.c.html#MatColoringCreate">src/mat/color/interface/matcoloring.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex16.c.html">src/mat/tutorials/ex16.c</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/color/impls/greedy/greedy.c.html#MatColoringCreate_Greedy">MatColoringCreate_Greedy in src/mat/color/impls/greedy/greedy.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/color/impls/jp/jp.c.html#MatColoringCreate_JP">MatColoringCreate_JP in src/mat/color/impls/jp/jp.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/color/impls/minpack/color.c.html#MatColoringCreate_SL">MatColoringCreate_SL in src/mat/color/impls/minpack/color.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/color/impls/minpack/color.c.html#MatColoringCreate_LF">MatColoringCreate_LF in src/mat/color/impls/minpack/color.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/color/impls/minpack/color.c.html#MatColoringCreate_ID">MatColoringCreate_ID in src/mat/color/impls/minpack/color.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/color/impls/natural/natural.c.html#MatColoringCreate_Natural">MatColoringCreate_Natural in src/mat/color/impls/natural/natural.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/color/impls/power/power.c.html#MatColoringCreate_Power">MatColoringCreate_Power in src/mat/color/impls/power/power.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/color/interface/matcoloring.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)  
