#include "petscmat.h" PetscErrorCode MatSetOperation(Mat mat,MatOperation op,void (*f)(void))Logically Collective on Mat
mat | - the matrix | |
op | - the name of the operation | |
f | - the function that provides the operation |
extern PetscErrorCode usermult(Mat,Vec,Vec);
ierr = MatCreateXXX(comm,...&A);
ierr = MatSetOperation(A,MATOP_MULT,(void(*)(void))usermult);
All user-provided functions (except 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.
This routine is distinct from MatShellSetOperation() in that it can be called on any matrix type.