MatOperation — PETSc 3.25.4 documentation

Skip to main content
`Ctrl`+`K`

# MatOperation

Identifies one of the operations stored in a `Mat`’s function table, for example `MATOP_MULT` or `MATOP_LUFACTOR`

## Synopsis

    typedef enum {
      MATOP_SET_VALUES                = 0,
      MATOP_GET_ROW                   = 1,
      MATOP_RESTORE_ROW               = 2,
      MATOP_MULT                      = 3,
      MATOP_MULT_ADD                  = 4,
      MATOP_MULT_TRANSPOSE            = 5,
      MATOP_MULT_TRANSPOSE_ADD        = 6,
      MATOP_SOLVE                     = 7,
      MATOP_SOLVE_ADD                 = 8,
      MATOP_SOLVE_TRANSPOSE           = 9,
      MATOP_SOLVE_TRANSPOSE_ADD       = 10,
      MATOP_LUFACTOR                  = 11,
      MATOP_CHOLESKYFACTOR            = 12,
      MATOP_SOR                       = 13,
      MATOP_TRANSPOSE                 = 14,
      MATOP_GETINFO                   = 15,
      MATOP_EQUAL                     = 16,
      MATOP_GET_DIAGONAL              = 17,
      MATOP_DIAGONAL_SCALE            = 18,
      MATOP_NORM                      = 19,
      MATOP_ASSEMBLY_BEGIN            = 20,
      MATOP_ASSEMBLY_END              = 21,
      MATOP_SET_OPTION                = 22,
      MATOP_ZERO_ENTRIES              = 23,
      MATOP_ZERO_ROWS                 = 24,
      MATOP_LUFACTOR_SYMBOLIC         = 25,
      MATOP_LUFACTOR_NUMERIC          = 26,
      MATOP_CHOLESKY_FACTOR_SYMBOLIC  = 27,
      MATOP_CHOLESKY_FACTOR_NUMERIC   = 28,
      MATOP_SETUP                     = 29,
      MATOP_ILUFACTOR_SYMBOLIC        = 30,
      MATOP_ICCFACTOR_SYMBOLIC        = 31,
      MATOP_GET_DIAGONAL_BLOCK        = 32,
      MATOP_SET_INF                   = 33,
      MATOP_DUPLICATE                 = 34,
      MATOP_FORWARD_SOLVE             = 35,
      MATOP_BACKWARD_SOLVE            = 36,
      MATOP_ILUFACTOR                 = 37,
      MATOP_ICCFACTOR                 = 38,
      MATOP_AXPY                      = 39,
      MATOP_CREATE_SUBMATRICES        = 40,
      MATOP_INCREASE_OVERLAP          = 41,
      MATOP_GET_VALUES                = 42,
      MATOP_COPY                      = 43,
      MATOP_GET_ROW_MAX               = 44,
      MATOP_SCALE                     = 45,
      MATOP_SHIFT                     = 46,
      MATOP_DIAGONAL_SET              = 47,
      MATOP_ZERO_ROWS_COLUMNS         = 48,
      MATOP_SET_RANDOM                = 49,
      MATOP_GET_ROW_IJ                = 50,
      MATOP_RESTORE_ROW_IJ            = 51,
      MATOP_GET_COLUMN_IJ             = 52,
      MATOP_RESTORE_COLUMN_IJ         = 53,
      MATOP_FDCOLORING_CREATE         = 54,
      MATOP_COLORING_PATCH            = 55,
      MATOP_SET_UNFACTORED            = 56,
      MATOP_PERMUTE                   = 57,
      MATOP_SET_VALUES_BLOCKED        = 58,
      MATOP_CREATE_SUBMATRIX          = 59,
      MATOP_DESTROY                   = 60,
      MATOP_VIEW                      = 61,
      MATOP_CONVERT_FROM              = 62,
      MATOP_MATMAT_MULT_SYMBOLIC      = 63,
      MATOP_MATMAT_MULT_NUMERIC       = 64,
      MATOP_SET_LOCAL_TO_GLOBAL_MAP   = 65,
      MATOP_SET_VALUES_LOCAL          = 66,
      MATOP_ZERO_ROWS_LOCAL           = 67,
      MATOP_GET_ROW_MAX_ABS           = 68,
      MATOP_GET_ROW_MIN_ABS           = 69,
      MATOP_CONVERT                   = 70,
      MATOP_HAS_OPERATION             = 71,
      MATOP_FD_COLORING_APPLY         = 72,
      MATOP_SET_FROM_OPTIONS          = 73,
      MATOP_FIND_ZERO_DIAGONALS       = 74,
      MATOP_MULT_MULTIPLE             = 75,
      MATOP_SOLVE_MULTIPLE            = 76,
      MATOP_GET_INERTIA               = 77,
      MATOP_LOAD                      = 78,
      MATOP_IS_SYMMETRIC              = 79,
      MATOP_IS_HERMITIAN              = 80,
      MATOP_IS_STRUCTURALLY_SYMMETRIC = 81,
      MATOP_SET_VALUES_BLOCKEDLOCAL   = 82,
      MATOP_CREATE_VECS               = 83,
      MATOP_MAT_MULT_SYMBOLIC         = 84,
      MATOP_MAT_MULT_NUMERIC          = 85,
      MATOP_PTAP_NUMERIC              = 86,
      MATOP_MAT_TRANSPOSE_MULT_SYMBO  = 87,
      MATOP_MAT_TRANSPOSE_MULT_NUMER  = 88,
      MATOP_BIND_TO_CPU               = 89,
      MATOP_PRODUCTSETFROMOPTIONS     = 90,
      MATOP_PRODUCTSYMBOLIC           = 91,
      MATOP_PRODUCTNUMERIC            = 92,
      MATOP_CONJUGATE                 = 93,
      MATOP_VIEW_NATIVE               = 94,
      MATOP_SET_VALUES_ROW            = 95,
      MATOP_REAL_PART                 = 96,
      MATOP_IMAGINARY_PART            = 97,
      MATOP_GET_ROW_UPPER_TRIANGULAR  = 98,
      MATOP_RESTORE_ROW_UPPER_TRIANG  = 99,
      MATOP_MAT_SOLVE                 = 100,
      MATOP_MAT_SOLVE_TRANSPOSE       = 101,
      MATOP_GET_ROW_MIN               = 102,
      MATOP_GET_COLUMN_VECTOR         = 103,
      MATOP_GET_SEQ_NONZERO_STRUCTUR  = 104,
      MATOP_CREATE                    = 105,
      MATOP_GET_GHOSTS                = 106,
      MATOP_GET_LOCAL_SUB_MATRIX      = 107,
      MATOP_RESTORE_LOCALSUB_MATRIX   = 108,
      MATOP_MULT_DIAGONAL_BLOCK       = 109,
      MATOP_HERMITIAN_TRANSPOSE       = 110,
      MATOP_MULT_HERMITIAN_TRANSPOSE  = 111,
      MATOP_MULT_HERMITIAN_TRANS_ADD  = 112,
      MATOP_GET_MULTI_PROC_BLOCK      = 113,
      MATOP_FIND_NONZERO_ROWS         = 114,
      MATOP_GET_COLUMN_NORMS          = 115,
      MATOP_INVERT_BLOCK_DIAGONAL     = 116,
      MATOP_INVERT_VBLOCK_DIAGONAL    = 117,
      MATOP_CREATE_SUB_MATRICES_MPI   = 118,
      MATOP_SET_VALUES_BATCH          = 119,
      MATOP_TRANSPOSE_MAT_MULT_SYMBO  = 120,
      MATOP_TRANSPOSE_MAT_MULT_NUMER  = 121,
      MATOP_TRANSPOSE_COLORING_CREAT  = 122,
      MATOP_TRANS_COLORING_APPLY_SPT  = 123,
      MATOP_TRANS_COLORING_APPLY_DEN  = 124,
      MATOP_RART_NUMERIC              = 125,
      MATOP_SET_BLOCK_SIZES           = 126,
      MATOP_RESIDUAL                  = 127,
      MATOP_FDCOLORING_SETUP          = 128,
      MATOP_FIND_OFFBLOCK_ENTRIES     = 129,
      MATOP_MPICONCATENATESEQ         = 130,
      MATOP_DESTROYSUBMATRICES        = 131,
      MATOP_MAT_TRANSPOSE_SOLVE       = 132,
      MATOP_GET_VALUES_LOCAL          = 133,
      MATOP_CREATE_GRAPH              = 134,
      MATOP_TRANSPOSE_SYMBOLIC        = 135,
      MATOP_ELIMINATE_ZEROS           = 136,
      MATOP_GET_ROW_SUM_ABS           = 137,
      MATOP_GET_FACTOR                = 138,
      MATOP_GET_BLOCK_DIAGONAL        = 139, /* NOTE: caller of the two op functions owns the returned matrix */
      MATOP_GET_VBLOCK_DIAGONAL       = 140, /* and need to destroy it after use. */
      MATOP_COPY_HASH_TO_XAIJ         = 141,
      MATOP_GET_CURRENT_MEM_TYPE      = 142,
      MATOP_ZERO_ROWS_COLUMNS_LOCAL   = 143,
      MATOP_ADOT                      = 144,
      MATOP_ANORM                     = 145,
      MATOP_ADOT_LOCAL                = 146,
      MATOP_ANORM_LOCAL               = 147
    } MatOperation;

## Notes

Use `MatSetOperation()` to install a custom implementation of a given operation on a `Mat` (typically a `MATSHELL`), `MatGetOperation()` to retrieve the currently installed implementation, and `MatHasOperation()` to test whether one is installed.

The numeric values are part of the binary interface used by the petsc4py bindings; if any of these enum values are changed, the `dMatOps` dictionary in `src/binding/petsc4py/src/petsc4py/PETSc/libpetsc4py.pyx` must be updated to match.

## See Also

Matrices, `Mat`, `MATSHELL`, `MatSetOperation()`, `MatGetOperation()`, `MatHasOperation()`, `MatShellSetOperation()`, `MatShellGetOperation()`

## Level

developer

## Location

include/petscmat.h

## Examples

src/tao/pde_constrained/tutorials/elliptic.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/tao/pde_constrained/tutorials/parabolic.c

## Examples

src/tao/pde_constrained/tutorials/parabolic.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/tao/bound/tutorials/jbearing2.c

## Examples

src/tao/pde_constrained/tutorials/parabolic.c
src/mat/tutorials/ex20f.F90
src/tao/pde_constrained/tutorials/hyperbolic.c

## Examples

src/mat/tutorials/ex20f.F90
src/snes/tutorials/ex36.c

## Examples

src/mat/tutorials/ex8.c

## Examples

src/tao/pde_constrained/tutorials/elliptic.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/tao/leastsquares/tutorials/tomography.c
src/ksp/ksp/tutorials/ex14f.F90
src/tao/unconstrained/tutorials/eptorsion1.c
src/tao/unconstrained/tutorials/eptorsion3.c
src/snes/tutorials/ex36.c
src/tao/pde_constrained/tutorials/parabolic.c
src/snes/tutorials/ex12.c
src/tao/bound/tutorials/plate2.c

## Examples

src/ksp/ksp/tutorials/ex34.c
src/ksp/ksp/tutorials/ex29.c

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