MatEliminateZeros — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# MatEliminateZeros

eliminate the nondiagonal zero entries in place from the nonzero structure of a sparse `Mat` in place, meaning the same memory is used for the matrix, and no new memory is allocated.

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatEliminateZeros(Mat A, PetscBool keep)

Collective

## Input Parameters

- A - the matrix

- keep - if for a given row of `A`, the diagonal coefficient is zero, indicates whether it should be left in the structure or eliminated as well

## Developer Note

The entries in the sparse matrix data structure are shifted to fill in the unneeded locations in the data. Thus the end of the arrays in the data structure are unneeded.

## See Also

Matrices, `Mat`, `MatCreate()`, `MatCreateGraph()`, `MatFilter()`

## Level

intermediate

## Location

src/mat/interface/matrix.c

## Implementations

MatEliminateZeros_MPIAIJ() in src/mat/impls/aij/mpi/mpiaij.c
MatEliminateZeros_SeqAIJ() in src/mat/impls/aij/seq/aij.c
MatEliminateZeros_MPIBAIJ() in src/mat/impls/baij/mpi/mpibaij.c
MatEliminateZeros_SeqBAIJ() in src/mat/impls/baij/seq/baij.c
MatEliminateZeros_MPISBAIJ() in src/mat/impls/sbaij/mpi/mpisbaij.c
MatEliminateZeros_SeqSBAIJ() in src/mat/impls/sbaij/seq/sbaij.c

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