# DMDASetGetMatrix
Sets the routine used by the `DMDA` to allocate a matrix. 
## Synopsis
```
#include "petscdmda.h"   
PetscErrorCode DMDASetGetMatrix(DM da, PetscErrorCode (*f)(DM, Mat *))
```
Logically Collective on da


## Input Parameters

- ***da -*** the `DMDA` object
- ***f -*** the function that allocates the matrix for that specific DMDA





## Note
See `DMDASetBlockFills()` that provides a simple way to provide the nonzero structure for
the diagonal and off-diagonal blocks of the matrix


## Fortran Note
Not supported from Fortran


## See Also
 `DM`, `DMDA`, `DMCreateMatrix()`, `DMDASetBlockFills()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/da/da.c.html#DMDASetGetMatrix">src/dm/impls/da/da.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/impls/da/da.c)


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