# MatShellSetOperation

Allows user to set a matrix operation for a shell matrix.

### Synopsis

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

Collective on Mat

### Input Parameters

| mat | - the shell matrix
| op | - the name of the operation
| f | - the function that provides the operation.

### Usage

         extern PetscErrorCode usermult(Mat,Vec,Vec);

         ierr = MatCreateShell(comm,m,n,M,N,ctx,&A);

         ierr = MatShellSetOperation(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).

All user-provided functions should have the same calling sequence as the usual matrix interface routines, since they are intended to be accessed via the usual matrix interface routines, e.g.,

          MatMult(Mat,Vec,Vec) -> usermult(Mat,Vec,Vec)

Within each user-defined routine, the user should call MatShellGetContext() to obtain the user-defined context that was set by MatCreateShell().

### Keywords

matrix, shell, set, operation

### See Also

MatCreateShell(), MatShellGetContext(), MatShellGetOperation(), MatShellSetContext()

Level:advanced
Location: src/mat/impls/shell/shell.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/ksp/examples/tutorials/ex14f.F.html