:orphan:
# SNESPruneJacobianColor
Remove nondiagonal zeros in the Jacobian matrix and update the `MatMFFD` coloring information. 
## Synopsis
```
#include "petscsnes.h"  
#include "petscdm.h"    
PetscErrorCode SNESPruneJacobianColor(SNES snes, Mat J, Mat B)
```
Collective


## Input Parameters

- ***snes -*** the `SNES` context
- ***J -*** Jacobian matrix (not altered in this routine)
- ***B -*** newly computed Jacobian matrix to use with preconditioner (generally the same as `J`)





## Notes
This function improves the `MatMFFD` coloring performance when the Jacobian matrix is overallocated or contains
many constant zeros entries, which is typically the case when the matrix is generated by a `DM`
and multiple fields are involved.

Users need to make sure that the Jacobian matrix is properly filled to reflect the sparsity
structure. For `MatMFFD` coloring, the values of nonzero entries are not important. So one can
usually call `SNESComputeJacobian()` with randomized input vectors to generate a dummy Jacobian.
`SNESComputeJacobian()` should be called before `SNESSolve()` but after `SNESSetUp()`.


## See Also
 `SNESComputeJacobianDefaultColor()`, `MatEliminateZeros()`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/interface/snesj2.c.html#SNESPruneJacobianColor">src/snes/interface/snesj2.c</A>


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


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