# MatGetNonzeroState
Returns a 64 bit integer representing the current state of nonzeros in the matrix. If the matrix has had no new nonzero locations added to (or removed from) the matrix since the previous call then the value will be the same, otherwise it will be larger 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatGetNonzeroState(Mat mat, PetscObjectState *state)
```
Not Collective


## Input Parameter

- ***A  -*** the matrix



## Output Parameter

- ***state -*** the current state



## Notes
You can only compare states from two different calls to the SAME matrix, you cannot compare calls between
different matrices

Use `PetscObjectStateGet()` to check for changes to the numerical values in a matrix

Use the result of `PetscObjectGetId()` to compare if a previously checked matrix is the same as the current matrix, do not compare object pointers.




## See Also
 `PetscObjectStateGet()`, `PetscObjectGetId()`

## Level
intermediate

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


---
[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)  
