#include "petscmat.h" PetscErrorCode MatShellSetMatProductOperation(Mat A,MatProductType ptype,PetscErrorCode (*symbolic)(Mat,Mat,Mat,void**),PetscErrorCode (*numeric)(Mat,Mat,Mat,void*),PetscErrorCode (*destroy)(void *),MatType Btype,MatType Ctype)Logically Collective on Mat
A | - the shell matrix | |
ptype | - the product type | |
symbolic | - the function for the symbolic phase (can be NULL) | |
numeric | - the function for the numerical phase | |
destroy | - the function for the destruction of the needed data generated during the symbolic phase (can be NULL) | |
Btype | - the matrix type for the matrix to be multiplied against | |
Ctype | - the matrix type for the result (can be NULL) |
extern PetscErrorCode usersymbolic(Mat,Mat,Mat,void**);
extern PetscErrorCode usernumeric(Mat,Mat,Mat,void*);
extern PetscErrorCode userdestroy(void*);
MatCreateShell(comm,m,n,M,N,ctx,&A);
MatShellSetMatProductOperation(A,MATPRODUCT_AB,usersymbolic,usernumeric,userdestroy,MATSEQAIJ,MATDENSE);
[ create B of type SEQAIJ etc..]
MatProductCreate(A,B,NULL,&C);
MatProductSetType(C,MATPRODUCT_AB);
MatProductSetFromOptions(C);
MatProductSymbolic(C); -> actually runs the user defined symbolic operation
MatProductNumeric(C); -> actually runs the user defined numeric operation
[ use C = A*B ]