:orphan:
# MatFDColoringSetFunction
Sets the function to use for computing the Jacobian. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatFDColoringSetFunction(MatFDColoring matfd, PetscErrorCode (*f)(void), void *fctx)
```
Logically Collective


## Input Parameters

- ***coloring -*** the coloring context
- ***f -*** the function
- ***fctx -*** the optional user-defined function context



## Calling sequence with `SNES` of `f`
```none
PetscErrorCode f(SNES snes, Vec in, Vec out, void *fctx)
```

- ***snes -*** the nonlinear solver `SNES` object
- ***in -*** the location where the Jacobian is to be computed
- ***out -*** the location to put the computed function value
- ***fctx -*** the function context



## Calling sequence without `SNES` of `f`
```none
PetscErrorCode f(void *dummy, Vec in, Vec out, void *fctx)
```

- ***dummy -*** an unused parameter
- ***in -*** the location where the Jacobian is to be computed
- ***out -*** the location to put the computed function value
- ***fctx -*** the function context





## Note
This function is usually used automatically by `SNES` (when one uses `SNESSetJacobian()` with the argument
`SNESComputeJacobianDefaultColor()`) and only needs to be used by someone computing a matrix via coloring directly by
calling `MatFDColoringApply()`


## Fortran Note
In Fortran you must call `MatFDColoringSetFunction()` for a coloring object to
be used without `SNES` or within the `SNES` solvers.


## See Also
 `Mat`, `MatFDColoring`, `MatFDColoringCreate()`, `MatFDColoringGetFunction()`, `MatFDColoringSetFromOptions()`

## Level
advanced

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex14.c.html">src/snes/tutorials/ex14.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/unconstrained/tutorials/minsurf2.c.html">src/tao/unconstrained/tutorials/minsurf2.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](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
