# MatGetDiagonalBlock
Returns the part of the matrix associated with the on-process coupling 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatGetDiagonalBlock(Mat A, Mat *a)
```
Not Collective


## Input Parameters

- ***A -*** the matrix



## Output Parameters

- ***a -*** the diagonal part (which is a SEQUENTIAL matrix)





## Notes
See the manual page for `MatCreateAIJ()` for more information on the "diagonal part" of the matrix.

Use caution, as the reference count on the returned matrix is not incremented and it is used as part of `A`'s normal operation.


## See Also
 `Mat`, `MatCreateAIJ()`, `MATAIJ`, `MATBAIJ`, `MATSBAIJ`

## Level
advanced

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

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex76.c.html">src/ksp/ksp/tutorials/ex76.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/mpiaijpc.c.html#MatGetDiagonalBlock_MPIAIJ">MatGetDiagonalBlock_MPIAIJ in src/mat/impls/aij/mpi/mpiaijpc.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/baij/mpi/mpibaij.c.html#MatGetDiagonalBlock_MPIBAIJ">MatGetDiagonalBlock_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/mpi/mpidense.c.html#MatGetDiagonalBlock_MPIDense">MatGetDiagonalBlock_MPIDense in src/mat/impls/dense/mpi/mpidense.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/htool/htool.cxx.html#MatGetDiagonalBlock_Htool">MatGetDiagonalBlock_Htool in src/mat/impls/htool/htool.cxx</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/is/matis.c.html#MatGetDiagonalBlock_IS">MatGetDiagonalBlock_IS in src/mat/impls/is/matis.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/kaij/kaij.c.html#MatGetDiagonalBlock_MPIKAIJ">MatGetDiagonalBlock_MPIKAIJ in src/mat/impls/kaij/kaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/normal/normm.c.html#MatGetDiagonalBlock_Normal">MatGetDiagonalBlock_Normal in src/mat/impls/normal/normm.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/normal/normmh.c.html#MatGetDiagonalBlock_NormalHermitian">MatGetDiagonalBlock_NormalHermitian in src/mat/impls/normal/normmh.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sbaij/mpi/mpisbaij.c.html#MatGetDiagonalBlock_MPISBAIJ">MatGetDiagonalBlock_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sell/mpi/mpisell.c.html#MatGetDiagonalBlock_MPISELL">MatGetDiagonalBlock_MPISELL in src/mat/impls/sell/mpi/mpisell.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)  
