# MatCreateSubMatrixFree
Creates a reduced matrix by masking a full matrix. 
## Synopsis
```
#include "petsctao.h" 
#include "submatfree.h" 
PetscErrorCode MatCreateSubMatrixFree(Mat mat, IS Rows, IS Cols, Mat *J)
```
Collective


## Input Parameters

- ***mat -*** matrix of arbitrary type
- ***Rows -*** the rows that will be in the submatrix
- ***Cols -*** the columns that will be in the submatrix



## Output Parameters

- ***J -*** New matrix





## Note
The caller is responsible for destroying the input objects after matrix J has been destroyed.


## See Also
 `MatCreate()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/matrix/submatfree.c.html#MatCreateSubMatrixFree">src/tao/matrix/submatfree.c</A>


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


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