Date: 2026-03-01T05:25:00+00:00

Actual source code: shell.h

      1: #pragma once

      3: #include <petsc/private/matimpl.h>
      4: #include <petsc/private/vecimpl.h>

      6: struct _MatShellOps {
      7:   /*   3 */ PetscErrorCode (*mult)(Mat, Vec, Vec);
      8:   /*   5 */ PetscErrorCode (*multtranspose)(Mat, Vec, Vec);
      9:   /*  17 */ PetscErrorCode (*getdiagonal)(Mat, Vec);
     10:   /*  32 */ PetscErrorCode (*getdiagonalblock)(Mat, Mat *);
     11:   /*  43 */ PetscErrorCode (*copy)(Mat, Mat, MatStructure);
     12:   /*  60 */ PetscErrorCode (*destroy)(Mat);
     13:   /* 121 */ PetscErrorCode (*multhermitiantranspose)(Mat, Vec, Vec);
     14: };

     16: struct _n_MatShellMatFunctionList {
     17:   PetscErrorCode (*symbolic)(Mat, Mat, Mat, void **);
     18:   PetscErrorCode (*numeric)(Mat, Mat, Mat, void *);
     19:   PetscErrorCode (*destroy)(void *);
     20:   MatProductType ptype;
     21:   char          *composedname; /* string to identify routine with double dispatch */
     22:   char          *resultname;   /* result matrix type */

     24:   struct _n_MatShellMatFunctionList *next;
     25: };
     26: typedef struct _n_MatShellMatFunctionList *MatShellMatFunctionList;

     28: typedef struct {
     29:   struct _MatShellOps ops[1];

     31:   /* The user will manage the scaling and shifts for the MATSHELL, not the default */
     32:   PetscBool managescalingshifts;

     34:   /* support for MatScale, MatShift and MatMultAdd */
     35:   PetscScalar vscale, vshift;
     36:   Vec         dshift;
     37:   Vec         left, right;
     38:   Vec         left_work, right_work;
     39:   Vec         left_add_work, right_add_work;

     41:   /* support for MatAXPY */
     42:   Mat              axpy;
     43:   PetscScalar      axpy_vscale;
     44:   Vec              axpy_left, axpy_right;
     45:   PetscObjectState axpy_state;

     47:   /* support for ZeroRows/Columns operations */
     48:   IS         zrows;
     49:   IS         zcols;
     50:   Vec        zvals;
     51:   Vec        zvals_w;
     52:   VecScatter zvals_sct_r;
     53:   VecScatter zvals_sct_c;

     55:   /* MatMat operations */
     56:   MatShellMatFunctionList matmat;

     58:   /* user defined context */
     59:   PetscContainer ctxcontainer;
     60: } Mat_Shell;

     62: PETSC_INTERN PetscErrorCode MatAssemblyEnd_Shell(Mat X, MatAssemblyType assembly);