# MatFDColoringApply
Given a matrix for which a `MatFDColoring` context has been created, computes the Jacobian for a function via finite differences. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatFDColoringApply(Mat J, MatFDColoring coloring, Vec x1, void *sctx)
```
Collective


## Input Parameters

- ***mat -*** location to store Jacobian
- ***coloring -*** coloring context created with `MatFDColoringCreate()`
- ***x1 -*** location at which Jacobian is to be computed
- ***sctx -*** context required by function, if this is being used with the SNES solver then it is `SNES` object, otherwise it is null



## Options Database Keys

- ***-mat_fd_type -*** "wp" or "ds"  (see `MATMFFD_WP` or `MATMFFD_DS`)
- ***-mat_fd_coloring_view -*** Activates basic viewing or coloring
- ***-mat_fd_coloring_view draw -*** Activates drawing of coloring
- ***-mat_fd_coloring_view ::ascii_info -*** Activates viewing of coloring info





## See Also
 `MatFDColoring`, `MatFDColoringCreate()`, `MatFDColoringDestroy()`, `MatFDColoringView()`, `MatFDColoringSetFunction()`, `MatFDColoringSetValues()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/matfd/fdmatrix.c.html#MatFDColoringApply">src/mat/matfd/fdmatrix.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/fdmpiaij.c.html#MatFDColoringApply_BAIJ">MatFDColoringApply_BAIJ in src/mat/impls/aij/mpi/fdmpiaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/fdmpiaij.c.html#MatFDColoringApply_AIJ">MatFDColoringApply_AIJ in src/mat/impls/aij/mpi/fdmpiaij.c</A><BR>


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


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