# MatGetLocalSubMatrix
Gets a reference to a submatrix specified in local numbering 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatGetLocalSubMatrix(Mat mat, IS isrow, IS iscol, Mat *submat)
```
Not Collective


## Input Parameters

- ***mat -*** matrix to extract local submatrix from
- ***isrow -*** local row indices for submatrix
- ***iscol -*** local column indices for submatrix



## Output Parameter

- ***submat -*** the submatrix





## Notes
`submat` should be disposed of with `MatRestoreLocalSubMatrix()`.

Depending on the format of `mat`, the returned submat may not implement `MatMult()`.  Its communicator may be
the same as mat, it may be `PETSC_COMM_SELF`, or some other subcomm of `mat`'s.

`submat` always implements `MatSetValuesLocal()`.  If `isrow` and `iscol` have the same block size, then
`MatSetValuesBlockedLocal()` will also be implemented.

`mat` must have had a `ISLocalToGlobalMapping` provided to it with `MatSetLocalToGlobalMapping()`.
Matrices obtained with `DMCreateMatrix()` generally already have the local to global mapping provided.


## See Also
 `Mat`, `MatRestoreLocalSubMatrix()`, `MatCreateLocalRef()`, `MatSetLocalToGlobalMapping()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatGetLocalSubMatrix">src/mat/interface/matrix.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex28.c.html">src/snes/tutorials/ex28.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex14.c.html">src/ts/tutorials/ex14.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/is/matis.c.html#MatGetLocalSubMatrix_IS">MatGetLocalSubMatrix_IS in src/mat/impls/is/matis.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/nest/matnest.c.html#MatGetLocalSubMatrix_Nest">MatGetLocalSubMatrix_Nest in src/mat/impls/nest/matnest.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matrix.c)


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