:orphan:
# MatEqual
Compares two matrices.
## Synopsis
```
#include "petscmat.h"
PetscErrorCode MatEqual(Mat A, Mat B, PetscBool *flg)
```
Collective
## Input Parameters
- ***A -*** the first matrix
- ***B -*** the second matrix
## Output Parameter
- ***flg -*** `PETSC_TRUE` if the matrices are equal; `PETSC_FALSE` otherwise.
## See Also
[](ch_matrices), `Mat`
## Level
intermediate
## Location
src/mat/interface/matrix.c
## Examples
src/ksp/ksp/tutorials/ex83f.F90
## Implementations
MatEqual_MPIAdj in src/mat/impls/adj/mpi/mpiadj.c
MatEqual_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c
MatEqual_SeqAIJ in src/mat/impls/aij/seq/aij.c
MatEqual_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c
MatEqual_SeqBAIJ in src/mat/impls/baij/seq/baij2.c
MatEqual_MPIDense in src/mat/impls/dense/mpi/mpidense.c
MatEqual_SeqDense in src/mat/impls/dense/seq/dense.c
MatEqual_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c
MatEqual_SeqSBAIJ in src/mat/impls/sbaij/seq/sbaij2.c
MatEqual_MPISELL in src/mat/impls/sell/mpi/mpisell.c
MatEqual_SeqSELL in src/mat/impls/sell/seq/sell.c
---
[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)