:orphan:
# DMShellSetMatrix
sets a template matrix associated with the `DMSHELL` 
## Synopsis
```
#include "petscdmshell.h"  
PetscErrorCode DMShellSetMatrix(DM dm, Mat J)
```
Collective


## Input Parameters

- ***dm -*** `DMSHELL`
- ***J -*** template matrix





## Developer Note
To avoid circular references, if `J` is already associated to the same `DM`, then `MatDuplicate`(`SHARE_NONZERO_PATTERN`) is called, followed by removing the `DM` reference from the private template.


## See Also
 `DM`, `DMSHELL`, `DMCreateMatrix()`, `DMShellSetCreateMatrix()`, `DMShellSetContext()`, `DMShellGetContext()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/shell/dmshell.c.html#DMShellSetMatrix">src/dm/impls/shell/dmshell.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex73f90t.F90.html">src/snes/tutorials/ex73f90t.F90</A><BR>


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


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