# MatSNESMFSetFunction

Sets the function used in applying the matrix free.

### Synopsis

    #include "petscsnes.h"
    PetscErrorCode PETSCSNES_DLLEXPORT MatSNESMFSetFunction(Mat mat,Vec v,PetscErrorCode (*func)(SNES,Vec,Vec,void *),void *funcctx)

Collective on Mat

### Input Parameters

| mat | - the matrix free matrix created via MatCreateSNESMF()
| v | - workspace vector
| func | - the function to use
| funcctx | - optional function context passed to function

### Notes

If you use this you MUST call MatAssemblyBegin()/MatAssemblyEnd() on the matrix free matrix inside your compute Jacobian routine

If this is not set then it will use the function set with SNESSetFunction()

### Keywords

SNES, matrix-free, function

### See Also

MatCreateSNESMF(),MatSNESMFGetH(),
MatSNESMFSetHHistory(), MatSNESMFResetHHistory(), MatSNESMFKSPMonitor(), SNESetFunction()

Level:advanced
Location:src/snes/mf/snesmfj.c
Index of all SNESMF routines
Table of Contents for all manual pages
Index of all manual pages