petsc-3.14.6 2021-03-30
Report Typos and Errors

MatShellSetMatProductOperation

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

Synopsis

#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

Input Parameters

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)

Usage

     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 ]

Notes

MATPRODUCT_ABC is not supported yet. Not supported in Fortran. If the symbolic phase is not specified, MatSetUp() is called on the result matrix that must have its type set if Ctype is NULL. Any additional data needed by the matrix product needs to be returned during the symbolic phase and destroyed with the destroy callback. PETSc will take care of calling the user-defined callbacks. It is allowed to specify the same callbacks for different Btype matrix types. The couple (Btype,ptype) uniquely identifies the operation: the last specified callbacks takes precedence.

See Also

MatCreateShell(), MatShellGetContext(), MatShellGetOperation(), MatShellSetContext(), MatSetOperation(), MatProductType, MatType, MatSetUp()

Level

advanced

Location

src/mat/impls/shell/shell.c

Implementations

MatShellSetMatProductOperation_Shell(Mat A,MatProductType ptype,PetscErrorCode (*symbolic)(Mat,Mat,Mat,void**),PetscErrorCode (*numeric)(Mat,Mat,Mat,void*),PetscErrorCode (*destroy) in src/mat/impls/shell/shell.c

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages