petsc-3.7.1 2016-05-15
Report Typos and Errors

MatShellSetOperation

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

Synopsis

#include "petscmat.h" 
PetscErrorCode  MatShellSetOperation(Mat mat,MatOperation op,void (*f)(void))
Logically Collective on Mat Many br

Input Parameters

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

Many br

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 Many broperations, which all have the form MATOP_<OPERATION>, where Many br<OPERATION> is the name (in all capital letters) of the Many bruser interface routine (e.g., MatMult() -> MATOP_MULT). Many br

All user-provided functions (execept for MATOP_DESTROY) should have the same calling Many brsequence as the usual matrix interface routines, since they Many brare intended to be accessed via the usual matrix interface Many brroutines, e.g., Many br

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

In particular each function MUST return an error code of 0 on success and Many brnonzero on failure. Many br

Within each user-defined routine, the user should call Many brMatShellGetContext() to obtain the user-defined context that was Many brset by MatCreateShell(). Many br

Fortran Notes: For MatCreateVecs() the user code should check if the input left or right matrix is -1 and in that case not Many brgenerate a matrix. See src/mat/examples/tests/ex120f.F Many br

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
src/snes/examples/tutorials/ex12.c.html
src/ts/examples/tutorials/ex22f_mf.F90.html
src/tao/unconstrained/examples/tutorials/eptorsion1.c.html
src/tao/bound/examples/tutorials/plate2.c.html
src/tao/pde_constrained/examples/tutorials/elliptic.c.html
src/tao/pde_constrained/examples/tutorials/parabolic.c.html
src/tao/pde_constrained/examples/tutorials/hyperbolic.c.html