int MatCreateShell(MPI_Comm comm,int m,int n,int M,int N,void *ctx,Mat *A)
Collective on MPI_Comm
MatCreateShell(comm,m,n,M,N,ctx,&mat);
MatShellSetOperation(mat,MATOP_MULT,mult);
[ Use matrix for operations that have been set ]
MatDestroy(mat);
PETSc requires that matrices and vectors being used for certainoperations are partitioned accordingly. For example, whencreating a shell matrix, A, that supports parallel matrix- vectorproducts using MatMult(A,x,y) the user should set the numberof local matrix rows to be the number of local elements of thecorresponding result vector, y. Note that this is information isrequired for use of the matrix interface routines, even thoughthe shell matrix may not actually be physically partitioned. For example,
Vec x, y
Mat A
VecCreate(comm,PETSC_DECIDE,M,&y);
VecCreate(comm,PETSC_DECIDE,N,&x);
VecGetLocalSize(y,&m);
MatCreateShell(comm,m,N,M,N,ctx,&A);
MatShellSetOperation(mat,MATOP_MULT,mult);
MatMult(A,x,y);
MatDestroy(A);
VecDestroy(y); VecDestroy(x);
Location: src/mat/impls/shell/shell.c
Matrix Index
Table of Contents