Skip to main content
`Ctrl`+`K`

# MatStructure

Indicates if two matrices have the same nonzero structure

## Synopsis

    typedef enum {
      DIFFERENT_NONZERO_PATTERN,
      SUBSET_NONZERO_PATTERN,
      SAME_NONZERO_PATTERN,
      UNKNOWN_NONZERO_PATTERN
    } MatStructure;

## Values

- `SAME_NONZERO_PATTERN` - the two matrices have identical nonzero patterns

- `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns

- `SUBSET_NONZERO_PATTERN` - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix

- `UNKNOWN_NONZERO_PATTERN` - there is no known relationship between the nonzero patterns. In this case the implementations may try to detect a relationship to optimize the operation

## Note

Certain matrix operations (such as `MatAXPY()`) can run much faster if the sparsity pattern of the matrices are the same. But actually determining if the patterns are the same may be costly. This provides a way for users who know something about the sparsity patterns to provide this information to certain PETSc routines.

## See Also

Matrices, `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()`

## Level

beginner

## Location

include/petscmat.h

## Examples

src/ksp/ksp/tutorials/ex34.c
src/tao/unconstrained/tutorials/spectraladjointassimilation.c
src/tao/tutorials/ex4.c
src/ksp/ksp/tutorials/ex19.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/ksp/ksp/tutorials/ex29.c
src/mat/tutorials/ex9.c

## Examples

src/tao/pde_constrained/tutorials/hyperbolic.c
src/ksp/pc/tutorials/ex4.c
src/ksp/ksp/tutorials/ex76.c

## Examples

src/tao/pde_constrained/tutorials/elliptic.c
src/tao/unconstrained/tutorials/burgers_spectral.c
src/ksp/ksp/tutorials/ex77f.F90
src/ksp/ksp/tutorials/ex76.c
src/tao/pde_constrained/tutorials/parabolic.c
src/ksp/ksp/tutorials/ex77.c
src/ksp/ksp/tutorials/ex21.c
src/ksp/ksp/tutorials/ex79.c
src/tao/pde_constrained/tutorials/hyperbolic.c

## Examples

src/ksp/ksp/tutorials/ex76.c

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