Skip to main content
`Ctrl`+`K`

# 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.

## Note

If either of the matrix is “matrix-free”, meaning the matrix entries are not stored explicitly then equality is determined by comparing the results of several matrix-vector product using randomly created vectors, see `MatMultEqual()`.

## See Also

Matrices, `Mat`, `MatMultEqual()`

## 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/baij.c
MatEqual_ConstantDiagonal() in src/mat/impls/cdiagonal/cdiagonal.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

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages