MatIsSymmetric — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# MatIsSymmetric

Test whether a matrix is symmetric

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatIsSymmetric(Mat A, PetscReal tol, PetscBool *flg)

Collective

## Input Parameters

- A - the matrix to test

- tol - difference between value and its transpose less than this amount counts as equal (use 0.0 for exact transpose)

## Output Parameter

- flg - the result

## Notes

For real numbers `MatIsSymmetric()` and `MatIsHermitian()` return identical results

If the matrix does not yet know if it is symmetric or not this can be an expensive operation, also available `MatIsSymmetricKnown()`

One can declare that a matrix is symmetric with `MatSetOption`(mat,`MAT_SYMMETRIC`,`PETSC_TRUE`) and if it is known to remain symmetric after changes to the matrices values one can call `MatSetOption`(mat,`MAT_SYMMETRY_ETERNAL`,`PETSC_TRUE`)

## See Also

Matrices, `Mat`, `MatTranspose()`, `MatIsTranspose()`, `MatIsHermitian()`, `MatIsStructurallySymmetric()`, `MatSetOption()`, `MatIsSymmetricKnown()`, `MAT_SYMMETRIC`, `MAT_SYMMETRY_ETERNAL`

## Level

intermediate

## Location

src/mat/interface/matrix.c

## Examples

src/ksp/ksp/tutorials/ex57f.F90
src/ksp/ksp/tutorials/ex72.c

## Implementations

MatIsSymmetric_SeqDense() in src/mat/impls/dense/seq/dense.c
MatIsSymmetric_IS() in src/mat/impls/is/matis.c

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