:orphan:
# MatEliminateZeros
eliminate the nondiagonal zero entries in place from the nonzero structure of a sparse `Mat` in place, meaning the same memory is used for the matrix, and no new memory is allocated. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatEliminateZeros(Mat A)
```
Collective


## Input Parameter

- ***A -*** the matrix





## Developer Note
The entries in the sparse matrix data structure are shifted to fill in the unneeded locations in the data. Thus the end
of the arrays in the data structure are unneeded.


## See Also
 [](ch_matrices), `Mat`, `MatCreate()`, `MatCreateGraph()`, `MatChop()`

## Level
intermediate

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

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/mpiaij.c.html#MatEliminateZeros_MPIAIJ">MatEliminateZeros_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aij.c.html#MatEliminateZeros_SeqAIJ">MatEliminateZeros_SeqAIJ in src/mat/impls/aij/seq/aij.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](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
