petsc-3.7.1 2016-05-15
Report Typos and Errors

# MatMFFDSetFunction

Sets the function used in applying the matrix free.

### Synopsis

    #include "petscmat.h"
    PetscErrorCode  MatMFFDSetFunction(Mat mat,PetscErrorCode (*func)(void*,Vec,Vec),void *funcctx)

Logically Collective on Mat Many br

### Input Parameters

| mat | - the matrix free matrix created via MatCreateSNESMF() or MatCreateMFFD() Many br
| func | - the function to use Many br
| funcctx | - optional function context passed to function Many br

### Calling Sequence of func

        func (void *funcctx, Vec x, Vec f)

| funcctx | - user provided context Many br
| x | - input vector Many br
| f | - computed output function Many br

Many br

### Notes

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

If this is not set then it will use the function set with SNESSetFunction() if MatCreateSNESMF() was used. Many br

### Keywords

SNES, matrix-free, function

### See Also

MatCreateSNESMF(),MatMFFDGetH(), MatCreateMFFD(), MATMFFD,
MatMFFDSetHHistory(), MatMFFDResetHHistory(), SNESetFunction() Many br

Level:advanced
Location:src/mat/impls/mffd/mffd.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/snes/examples/tutorials/ex22.c.html