MatGetOperation — PETSc 3.22.5 documentation

Skip to main content
`Ctrl`+`K`

# MatGetOperation

Gets a matrix operation for any matrix type.

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatGetOperation(Mat mat, MatOperation op, void (**f)(void))

Not Collective

## Input Parameters

- mat - the matrix

- op - the name of the operation

## Output Parameter

- f - the function that provides the operation

## Example Usage

      PetscErrorCode (*usermult)(Mat, Vec, Vec);

      MatGetOperation(A, MATOP_MULT, (void (**)(void))&usermult);

## Notes

See the file include/petscmat.h for a complete list of matrix operations, which all have the form MATOP_, where is the name (in all capital letters) of the user interface routine (e.g., `MatMult()` -> `MATOP_MULT`).

This routine is distinct from `MatShellGetOperation()` in that it can be called on any matrix type.

## See Also

Matrices, `Mat`, `MatSetOperation()`, `MatCreateShell()`, `MatShellGetContext()`, `MatShellGetOperation()`

## Level

developer

## Location

src/mat/interface/matrix.c

## Examples

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

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