:orphan:
# SNESSetUseMatrixFree
indicates that `SNES` should use matrix free finite difference matrix vector products to apply the Jacobian. 
## Synopsis
```
#include "petscsnes.h"  
PetscErrorCode SNESSetUseMatrixFree(SNES snes, PetscBool mf_operator, PetscBool mf)
```
Logically Collective


## Input Parameters

- ***snes -*** `SNES` context
- ***mf_operator -*** use matrix-free only for the Amat used by `SNESSetJacobian()`, this means the user provided Pmat will continue to be used
- ***mf -*** use matrix-free for both the Amat and Pmat used by `SNESSetJacobian()`, both the Amat and Pmat set in `SNESSetJacobian()` will be ignored. With
this option no matrix element based preconditioners can be used in the linear solve since the matrix won't be explicitly available



## Options Database Keys

- ***-snes_mf_operator -*** use matrix free only for the mat operator
- ***-snes_mf -*** use matrix-free for both the mat and pmat operator
- ***-snes_fd_color -*** compute the Jacobian via coloring and finite differences.
- ***-snes_fd -*** compute the Jacobian via finite differences (slow)





## Note
`SNES` supports three approaches for computing (approximate) Jacobians: user provided via `SNESSetJacobian()`, matrix-free, and computing explicitly with
finite differences and coloring using `MatFDColoring`. It is also possible to use automatic differentiation and the `MatFDColoring` object.


## See Also
 [](ch_snes), `SNES`, `SNESGetUseMatrixFree()`, `MatCreateSNESMF()`, `SNESComputeJacobianDefaultColor()`

## Level
intermediate

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


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