:orphan:
# 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





## Usage
```none
      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_<OPERATION>, where
<OPERATION> 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
 [](ch_matrices), `Mat`, `MatSetOperation()`, `MatCreateShell()`, `MatShellGetContext()`, `MatShellGetOperation()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatGetOperation">src/mat/interface/matrix.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex29.c.html">src/ksp/ksp/tutorials/ex29.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex34.c.html">src/ksp/ksp/tutorials/ex34.c</A><BR>


---
[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)  
