:orphan: # MatGetTrace Gets the trace of a matrix. The sum of the diagonal entries. ## Synopsis ``` #include "petscmat.h" PetscErrorCode MatGetTrace(Mat mat, PetscScalar *trace) ``` Collective ## Input Parameter - ***mat -*** the matrix ## Output Parameter - ***trace -*** the sum of the diagonal entries ## See Also [](ch_matrices), `Mat` ## Level advanced ## Location src/mat/interface/matrix.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)