#include "petscmat.h" PetscErrorCode MatShellSetOperation(Mat mat,MatOperation op,void (*f)(void))Logically Collective on Mat
|mat||- the shell matrix|
|op||- the name of the operation|
|f||- the function that provides the operation.|
extern PetscErrorCode usermult(Mat,Vec,Vec);
ierr = MatCreateShell(comm,m,n,M,N,ctx,&A);
ierr = MatShellSetOperation(A,MATOP_MULT,(void(*)(void))usermult);
All user-provided functions (execept for MATOP_DESTROY) 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)
In particular each function MUST return an error code of 0 on success and nonzero on failure.
Within each user-defined routine, the user should call MatShellGetContext() to obtain the user-defined context that was set by MatCreateShell().
Fortran Notes: For MatCreateVecs() the user code should check if the input left or right matrix is -1 and in that case not generate a matrix. See src/mat/examples/tests/ex120f.F
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages