:orphan:
# MatCreateNest
Creates a new `MATNEST` matrix containing several nested submatrices, each stored separately 
## Synopsis
```
#include "petscmat.h"   
PetscErrorCode MatCreateNest(MPI_Comm comm, PetscInt nr, const IS is_row[], PetscInt nc, const IS is_col[], const Mat a[], Mat *B)
```
Collective


## Input Parameters

- ***comm -*** Communicator for the new `MATNEST`
- ***nr -*** number of nested row blocks
- ***is_row -*** index sets for each nested row block, or `NULL` to make contiguous
- ***nc -*** number of nested column blocks
- ***is_col -*** index sets for each nested column block, or `NULL` to make contiguous
- ***a -*** row-aligned array of nr*nc submatrices, empty submatrices can be passed using `NULL`



## Output Parameter

- ***B -*** new matrix





## See Also
 [](ch_matrices), `Mat`, `MATNEST`, `MatCreate()`, `VecCreateNest()`, `DMCreateMatrix()`, `MatNestSetSubMat()`,
`MatNestGetSubMat()`, `MatNestGetLocalISs()`, `MatNestGetSize()`,
`MatNestGetISs()`, `MatNestSetSubMats()`, `MatNestGetSubMats()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/nest/matnest.c.html#MatCreateNest">src/mat/impls/nest/matnest.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex27.c.html">src/ksp/ksp/tutorials/ex27.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex81.c.html">src/ksp/ksp/tutorials/ex81.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex70.c.html">src/snes/tutorials/ex70.c</A><BR>
<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/mat/impls/nest/matnest.c)


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