Actual source code: petscmat.h

      1: /*
      2:      Include file for the matrix component of PETSc
      3: */
      4: #ifndef __PETSCMAT_H
     6:  #include petscvec.h

      9: /*S
     10:      Mat - Abstract PETSc matrix object

     12:    Level: beginner

     14:   Concepts: matrix; linear operator

     16: .seealso:  MatCreate(), MatType, MatSetType()
     17: S*/
     18: typedef struct _p_Mat*           Mat;

     20: /*E
     21:     MatType - String with the name of a PETSc matrix or the creation function
     22:        with an optional dynamic library name, for example
     23:        http://www.mcs.anl.gov/petsc/lib.a:mymatcreate()

     25:    Level: beginner

     27: .seealso: MatSetType(), Mat
     28: E*/
     29: #define MatType const char*
     30: #define MATSAME            "same"
     31: #define MATSEQMAIJ         "seqmaij"
     32: #define MATMPIMAIJ         "mpimaij"
     33: #define MATMAIJ            "maij"
     34: #define MATIS              "is"
     35: #define MATMPIROWBS        "mpirowbs"
     36: #define MATSEQAIJ          "seqaij"
     37: #define MATMPIAIJ          "mpiaij"
     38: #define MATAIJ             "aij"
     39: #define MATSHELL           "shell"
     40: #define MATSEQBDIAG        "seqbdiag"
     41: #define MATMPIBDIAG        "mpibdiag"
     42: #define MATBDIAG           "bdiag"
     43: #define MATSEQDENSE        "seqdense"
     44: #define MATMPIDENSE        "mpidense"
     45: #define MATDENSE           "dense"
     46: #define MATSEQBAIJ         "seqbaij"
     47: #define MATMPIBAIJ         "mpibaij"
     48: #define MATBAIJ            "baij"
     49: #define MATMPIADJ          "mpiadj"
     50: #define MATSEQSBAIJ        "seqsbaij"
     51: #define MATMPISBAIJ        "mpisbaij"
     52: #define MATSBAIJ           "sbaij"
     53: #define MATDAAD            "daad"
     54: #define MATMFFD            "mffd"
     55: #define MATNORMAL          "normal"
     56: #define MATLRC             "lrc"
     57: #define MATSEQAIJSPOOLES   "seqaijspooles"
     58: #define MATMPIAIJSPOOLES   "mpiaijspooles"
     59: #define MATSEQSBAIJSPOOLES "seqsbaijspooles"
     60: #define MATMPISBAIJSPOOLES "mpisbaijspooles"
     61: #define MATAIJSPOOLES      "aijspooles"
     62: #define MATSBAIJSPOOLES    "sbaijspooles"
     63: #define MATSUPERLU         "superlu"
     64: #define MATSUPERLU_DIST    "superlu_dist"
     65: #define MATUMFPACK         "umfpack"
     66: #define MATESSL            "essl"
     67: #define MATLUSOL           "lusol"
     68: #define MATAIJMUMPS        "aijmumps"
     69: #define MATSBAIJMUMPS      "sbaijmumps"
     70: #define MATDSCPACK         "dscpack"
     71: #define MATMATLAB          "matlab"
     72: #define MATSEQCSRPERM      "seqcsrperm"
     73: #define MATMPICSRPERM      "mpicsrperm"
     74: #define MATCSRPERM         "csrperm"
     75: #define MATSEQCRL          "seqcrl"
     76: #define MATMPICRL          "mpicrl"
     77: #define MATCRL             "crl"
     78: #define MATPLAPACK         "plapack"
     79: #define MATSCATTER         "scatter"
     80: #define MATBLOCKMAT        "blockmat"
     81: #define MATCOMPOSITE       "composite"
     82: #define MATSEQFFTW         "seqfftw"

     84: /* Logging support */
     85: #define    MAT_FILE_COOKIE 1211216    /* used to indicate matrices in binary files */

     92: /*E
     93:     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
     94:      or MatGetSubMatrix() are to be reused to store the new matrix values.

     96:     Level: beginner

     98:    Any additions/changes here MUST also be made in include/finclude/petscmat.h

    100: .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices(), MatConvert()
    101: E*/
    102: typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;

    104: EXTERN PetscErrorCode  MatInitializePackage(const char[]);

    106: EXTERN PetscErrorCode  MatCreate(MPI_Comm,Mat*);
    107: PetscPolymorphicFunction(MatCreate,(MPI_Comm comm),(comm,&A),Mat,A)
    108: PetscPolymorphicFunction(MatCreate,(),(PETSC_COMM_WORLD,&A),Mat,A)
    109: EXTERN PetscErrorCode  MatSetSizes(Mat,PetscInt,PetscInt,PetscInt,PetscInt);
    110: EXTERN PetscErrorCode  MatSetType(Mat,MatType);
    111: EXTERN PetscErrorCode  MatSetFromOptions(Mat);
    112: EXTERN PetscErrorCode  MatSetUpPreallocation(Mat);
    113: EXTERN PetscErrorCode  MatRegisterAll(const char[]);
    114: EXTERN PetscErrorCode  MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat));

    116: EXTERN PetscErrorCode  MatSetOptionsPrefix(Mat,const char[]);
    117: EXTERN PetscErrorCode  MatAppendOptionsPrefix(Mat,const char[]);
    118: EXTERN PetscErrorCode  MatGetOptionsPrefix(Mat,const char*[]);

    120: /*MC
    121:    MatRegisterDynamic - Adds a new matrix type

    123:    Synopsis:
    124:    PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat))

    126:    Not Collective

    128:    Input Parameters:
    129: +  name - name of a new user-defined matrix type
    130: .  path - path (either absolute or relative) the library containing this solver
    131: .  name_create - name of routine to create method context
    132: -  routine_create - routine to create method context

    134:    Notes:
    135:    MatRegisterDynamic() may be called multiple times to add several user-defined solvers.

    137:    If dynamic libraries are used, then the fourth input argument (routine_create)
    138:    is ignored.

    140:    Sample usage:
    141: .vb
    142:    MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a,
    143:                "MyMatCreate",MyMatCreate);
    144: .ve

    146:    Then, your solver can be chosen with the procedural interface via
    147: $     MatSetType(Mat,"my_mat")
    148:    or at runtime via the option
    149: $     -mat_type my_mat

    151:    Level: advanced

    153:    Notes: ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
    154:          If your function is not being put into a shared library then use VecRegister() instead

    156: .keywords: Mat, register

    158: .seealso: MatRegisterAll(), MatRegisterDestroy()

    160: M*/
    161: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    162: #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
    163: #else
    164: #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
    165: #endif

    167: EXTERN PetscErrorCode  MatRegisterAll(const char[]);

    171: EXTERN PetscErrorCode  MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*);
    172: EXTERN PetscErrorCode  MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*);
    173: EXTERN PetscErrorCode  MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
    174: PetscPolymorphicFunction(MatCreateSeqAIJ,(PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[]),(PETSC_COMM_SELF,m,n,nz,nnz,&A),Mat,A)
    175: PetscPolymorphicFunction(MatCreateSeqAIJ,(PetscInt m,PetscInt n,PetscInt nz),(PETSC_COMM_SELF,m,n,nz,PETSC_NULL,&A),Mat,A)
    176: PetscPolymorphicFunction(MatCreateSeqAIJ,(PetscInt m,PetscInt n,const PetscInt nnz[]),(PETSC_COMM_SELF,m,n,0,nnz,&A),Mat,A)
    177: PetscPolymorphicFunction(MatCreateSeqAIJ,(PetscInt m,PetscInt n),(PETSC_COMM_SELF,m,n,0,PETSC_NULL,&A),Mat,A)
    178: PetscPolymorphicSubroutine(MatCreateSeqAIJ,(PetscInt m,PetscInt n,PetscInt nz,Mat *A),(PETSC_COMM_SELF,m,n,nz,PETSC_NULL,A))
    179: PetscPolymorphicSubroutine(MatCreateSeqAIJ,(PetscInt m,PetscInt n,const PetscInt nnz[],Mat *A),(PETSC_COMM_SELF,m,n,0,nnz,A))
    180: PetscPolymorphicSubroutine(MatCreateSeqAIJ,(PetscInt m,PetscInt n,Mat *A),(PETSC_COMM_SELF,m,n,0,PETSC_NULL,A))
    181: EXTERN PetscErrorCode  MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
    182: PetscPolymorphicFunction(MatCreateMPIAIJ,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,const PetscInt nnz[],PetscInt onz,const PetscInt onnz[]),(comm,m,n,M,N,nz,nnz,onz,onnz,&A),Mat,A)
    183: PetscPolymorphicFunction(MatCreateMPIAIJ,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz),(comm,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,&A),Mat,A)
    184: PetscPolymorphicFunction(MatCreateMPIAIJ,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[]),(comm,m,n,M,N,0,nnz,0,onz,&A),Mat,A)
    185: PetscPolymorphicFunction(MatCreateMPIAIJ,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N),(comm,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,&A),Mat,A)
    186: PetscPolymorphicSubroutine(MatCreateMPIAIJ,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz,Mat *A),(comm,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,A))
    187: PetscPolymorphicSubroutine(MatCreateMPIAIJ,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[],Mat *A),(comm,m,n,M,N,0,nnz,0,onz,A))
    188: PetscPolymorphicSubroutine(MatCreateMPIAIJ,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,Mat *A),(comm,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,A))
    189: PetscPolymorphicFunction(MatCreateMPIAIJ,(PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,const PetscInt nnz[],PetscInt onz,const PetscInt onnz[]),(PETSC_COMM_WORLD,m,n,M,N,nz,nnz,onz,onnz,&A),Mat,A)
    190: PetscPolymorphicFunction(MatCreateMPIAIJ,(PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz),(PETSC_COMM_WORLD,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,&A),Mat,A)
    191: PetscPolymorphicFunction(MatCreateMPIAIJ,(PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[]),(PETSC_COMM_WORLD,m,n,M,N,0,nnz,0,onz,&A),Mat,A)
    192: PetscPolymorphicFunction(MatCreateMPIAIJ,(PetscInt m,PetscInt n,PetscInt M,PetscInt N),(PETSC_COMM_WORLD,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,&A),Mat,A)
    193: PetscPolymorphicSubroutine(MatCreateMPIAIJ,(PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz,Mat *A),(PETSC_COMM_WORLD,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,A))
    194: PetscPolymorphicSubroutine(MatCreateMPIAIJ,(PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[],Mat *A),(PETSC_COMM_WORLD,m,n,M,N,0,nnz,0,onz,A))
    195: PetscPolymorphicSubroutine(MatCreateMPIAIJ,(PetscInt m,PetscInt n,PetscInt M,PetscInt N,Mat *A),(PETSC_COMM_WORLD,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,A))
    196: EXTERN PetscErrorCode  MatCreateMPIAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat *);
    197: EXTERN PetscErrorCode  MatCreateMPIAIJWithSplitArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],PetscInt[],PetscInt[],PetscScalar[],Mat*);

    199: EXTERN PetscErrorCode  MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
    200: EXTERN PetscErrorCode  MatCreateSeqBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
    201: EXTERN PetscErrorCode  MatCreateMPIBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
    202: EXTERN PetscErrorCode  MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
    203: PetscPolymorphicFunction(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[]),(PETSC_COMM_SELF,bs,m,n,nz,nnz,&A),Mat,A)
    204: PetscPolymorphicFunction(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz),(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,&A),Mat,A)
    205: PetscPolymorphicFunction(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[]),(PETSC_COMM_SELF,bs,m,n,0,nnz,&A),Mat,A)
    206: PetscPolymorphicFunction(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n),(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,&A),Mat,A)
    207: PetscPolymorphicSubroutine(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,Mat *A),(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,A))
    208: PetscPolymorphicSubroutine(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[],Mat *A),(PETSC_COMM_SELF,bs,m,n,0,nnz,A))
    209: PetscPolymorphicSubroutine(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,Mat *A),(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,A))
    210: EXTERN PetscErrorCode  MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
    211: PetscPolymorphicFunction(MatCreateMPIBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,const PetscInt nnz[],PetscInt onz,const PetscInt onnz[]),(comm,bs,m,n,M,N,nz,nnz,onz,onnz,&A),Mat,A)
    212: PetscPolymorphicFunction(MatCreateMPIBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz),(comm,bs,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,&A),Mat,A)
    213: PetscPolymorphicFunction(MatCreateMPIBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[]),(comm,bs,m,n,M,N,0,nnz,0,onz,&A),Mat,A)
    214: PetscPolymorphicFunction(MatCreateMPIBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N),(comm,bs,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,&A),Mat,A)
    215: PetscPolymorphicSubroutine(MatCreateMPIBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz,Mat *A),(comm,bs,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,A))
    216: PetscPolymorphicSubroutine(MatCreateMPIBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[],Mat *A),(comm,bs,m,n,M,N,0,nnz,0,onz,A))
    217: PetscPolymorphicSubroutine(MatCreateMPIBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,Mat *A),(comm,bs,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,A))
    218: PetscPolymorphicFunction(MatCreateMPIBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,const PetscInt nnz[],PetscInt onz,const PetscInt onnz[]),(PETSC_COMM_WORLD,bs,m,n,M,N,nz,nnz,onz,onnz,&A),Mat,A)
    219: PetscPolymorphicFunction(MatCreateMPIBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz),(PETSC_COMM_WORLD,bs,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,&A),Mat,A)
    220: PetscPolymorphicFunction(MatCreateMPIBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[]),(PETSC_COMM_WORLD,bs,m,n,M,N,0,nnz,0,onz,&A),Mat,A)
    221: PetscPolymorphicFunction(MatCreateMPIBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N),(PETSC_COMM_WORLD,bs,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,&A),Mat,A)
    222: PetscPolymorphicSubroutine(MatCreateMPIBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz,Mat *A),(PETSC_COMM_WORLD,bs,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,A))
    223: PetscPolymorphicSubroutine(MatCreateMPIBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[],Mat *A),(PETSC_COMM_WORLD,bs,m,n,M,N,0,nnz,0,onz,A))
    224: PetscPolymorphicSubroutine(MatCreateMPIBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,Mat *A),(PETSC_COMM_WORLD,bs,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,A))
    225: EXTERN PetscErrorCode  MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*);
    226: EXTERN PetscErrorCode  MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
    227: PetscPolymorphicFunction(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[]),(PETSC_COMM_SELF,bs,m,n,nz,nnz,&A),Mat,A)
    228: PetscPolymorphicFunction(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz),(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,&A),Mat,A)
    229: PetscPolymorphicFunction(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[]),(PETSC_COMM_SELF,bs,m,n,0,nnz,&A),Mat,A)
    230: PetscPolymorphicFunction(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n),(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,&A),Mat,A)
    231: PetscPolymorphicSubroutine(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,Mat *A),(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,A))
    232: PetscPolymorphicSubroutine(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[],Mat *A),(PETSC_COMM_SELF,bs,m,n,0,nnz,A))
    233: PetscPolymorphicSubroutine(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,Mat *A),(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,A))
    234: EXTERN PetscErrorCode  MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
    235: PetscPolymorphicFunction(MatCreateMPISBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,const PetscInt nnz[],PetscInt onz,const PetscInt onnz[]),(comm,bs,m,n,M,N,nz,nnz,onz,onnz,&A),Mat,A)
    236: PetscPolymorphicFunction(MatCreateMPISBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz),(comm,bs,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,&A),Mat,A)
    237: PetscPolymorphicFunction(MatCreateMPISBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[]),(comm,bs,m,n,M,N,0,nnz,0,onz,&A),Mat,A)
    238: PetscPolymorphicFunction(MatCreateMPISBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N),(comm,bs,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,&A),Mat,A)
    239: PetscPolymorphicSubroutine(MatCreateMPISBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz,Mat *A),(comm,bs,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,A))
    240: PetscPolymorphicSubroutine(MatCreateMPISBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[],Mat *A),(comm,bs,m,n,M,N,0,nnz,0,onz,A))
    241: PetscPolymorphicSubroutine(MatCreateMPISBAIJ,(MPI_Comm comm,PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,Mat *A),(comm,bs,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,A))
    242: PetscPolymorphicFunction(MatCreateMPISBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,const PetscInt nnz[],PetscInt onz,const PetscInt onnz[]),(PETSC_COMM_WORLD,bs,m,n,M,N,nz,nnz,onz,onnz,&A),Mat,A)
    243: PetscPolymorphicFunction(MatCreateMPISBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz),(PETSC_COMM_WORLD,bs,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,&A),Mat,A)
    244: PetscPolymorphicFunction(MatCreateMPISBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[]),(PETSC_COMM_WORLD,bs,m,n,M,N,0,nnz,0,onz,&A),Mat,A)
    245: PetscPolymorphicFunction(MatCreateMPISBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N),(PETSC_COMM_WORLD,bs,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,&A),Mat,A)
    246: PetscPolymorphicSubroutine(MatCreateMPISBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,PetscInt nz,PetscInt nnz,Mat *A),(PETSC_COMM_WORLD,bs,m,n,M,N,nz,PETSC_NULL,nnz,PETSC_NULL,A))
    247: PetscPolymorphicSubroutine(MatCreateMPISBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt nnz[],const PetscInt onz[],Mat *A),(PETSC_COMM_WORLD,bs,m,n,M,N,0,nnz,0,onz,A))
    248: PetscPolymorphicSubroutine(MatCreateMPISBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,Mat *A),(PETSC_COMM_WORLD,bs,m,n,M,N,0,PETSC_NULL,0,PETSC_NULL,A))
    249: EXTERN PetscErrorCode  MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*);
    250: PetscPolymorphicFunction(MatCreateShell,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,void *ctx),(comm,m,n,M,N,ctx,&A),Mat,A)
    251: PetscPolymorphicFunction(MatCreateShell,(PetscInt m,PetscInt n,PetscInt M,PetscInt N,void *ctx),(PETSC_COMM_WORLD,m,n,M,N,ctx,&A),Mat,A)
    252: EXTERN PetscErrorCode  MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*);
    253: EXTERN PetscErrorCode  MatCreateNormal(Mat,Mat*);
    254: PetscPolymorphicFunction(MatCreateNormal,(Mat mat),(mat,&A),Mat,A)
    255: EXTERN PetscErrorCode  MatCreateLRC(Mat,Mat,Mat,Mat*);
    256: EXTERN PetscErrorCode  MatCreateIS(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,ISLocalToGlobalMapping,Mat*);
    257: EXTERN PetscErrorCode  MatCreateSeqCRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
    258: EXTERN PetscErrorCode  MatCreateMPICRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
    259: EXTERN PetscErrorCode  MatCreateScatter(MPI_Comm,VecScatter,Mat*);
    260: EXTERN PetscErrorCode  MatScatterSetVecScatter(Mat,VecScatter);
    261: EXTERN PetscErrorCode  MatScatterGetVecScatter(Mat,VecScatter*);
    262: EXTERN PetscErrorCode  MatCreateBlockMat(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,Mat*);
    263: EXTERN PetscErrorCode  MatCompositeAddMat(Mat,Mat);
    264: EXTERN PetscErrorCode  MatCompositeMerge(Mat);
    265: EXTERN PetscErrorCode  MatCreateComposite(MPI_Comm,PetscInt,const Mat*,Mat*);
    266: EXTERN PetscErrorCode  MatCreateSeqFFTW(MPI_Comm,PetscInt,const PetscInt[],Mat*);

    268: EXTERN PetscErrorCode  MatSetUp(Mat);
    269: EXTERN PetscErrorCode  MatDestroy(Mat);

    271: EXTERN PetscErrorCode  MatConjugate(Mat);
    272: EXTERN PetscErrorCode  MatRealPart(Mat);
    273: EXTERN PetscErrorCode  MatImaginaryPart(Mat);

    275: /* ------------------------------------------------------------*/
    276: EXTERN PetscErrorCode  MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
    277: EXTERN PetscErrorCode  MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
    278: EXTERN PetscErrorCode  MatSetValuesRow(Mat,PetscInt,const PetscScalar[]);
    279: EXTERN PetscErrorCode  MatSetValuesRowLocal(Mat,PetscInt,const PetscScalar[]);

    281: /*S
    282:      MatStencil - Data structure (C struct) for storing information about a single row or
    283:         column of a matrix as index on an associated grid.

    285:    Level: beginner

    287:   Concepts: matrix; linear operator

    289: .seealso:  MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil()
    290: S*/
    291: typedef struct {
    292:   PetscInt k,j,i,c;
    293: } MatStencil;

    295: EXTERN PetscErrorCode  MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
    296: EXTERN PetscErrorCode  MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
    297: EXTERN PetscErrorCode  MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt);

    299: EXTERN PetscErrorCode  MatSetColoring(Mat,ISColoring);
    300: EXTERN PetscErrorCode  MatSetValuesAdic(Mat,void*);
    301: EXTERN PetscErrorCode  MatSetValuesAdifor(Mat,PetscInt,void*);

    303: /*E
    304:     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
    305:      to continue to add values to it

    307:     Level: beginner

    309: .seealso: MatAssemblyBegin(), MatAssemblyEnd()
    310: E*/
    311: typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
    312: EXTERN PetscErrorCode  MatAssemblyBegin(Mat,MatAssemblyType);
    313: EXTERN PetscErrorCode  MatAssemblyEnd(Mat,MatAssemblyType);
    314: EXTERN PetscErrorCode  MatAssembled(Mat,PetscTruth*);

    320: /*MC
    321:    MatSetValue - Set a single entry into a matrix.

    323:    Synopsis:
    324:    PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode);

    326:    Not collective

    328:    Input Parameters:
    329: +  m - the matrix
    330: .  row - the row location of the entry
    331: .  col - the column location of the entry
    332: .  value - the value to insert
    333: -  mode - either INSERT_VALUES or ADD_VALUES

    335:    Notes:
    336:    For efficiency one should use MatSetValues() and set several or many
    337:    values simultaneously if possible.

    339:    Level: beginner

    341: .seealso: MatSetValues(), MatSetValueLocal()
    342: M*/
    343: #define MatSetValue(v,i,j,va,mode) \
    344:   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
    345:    MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))

    347: #define MatGetValue(v,i,j,va) \
    348:   ((MatSetValue_Row = i,MatSetValue_Column = j,0) || \
    349:    MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va))

    351: #define MatSetValueLocal(v,i,j,va,mode) \
    352:   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
    353:    MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))

    355: /*E
    356:     MatOption - Options that may be set for a matrix and its behavior or storage

    358:     Level: beginner

    360:    Any additions/changes here MUST also be made in include/finclude/petscmat.h

    362: .seealso: MatSetOption()
    363: E*/
    364: typedef enum {MAT_ROW_ORIENTED,MAT_COLUMN_ORIENTED,MAT_ROWS_SORTED,
    365: /*3-4*/       MAT_COLUMNS_SORTED,MAT_NO_NEW_NONZERO_LOCATIONS,
    366: /*5-6*/       MAT_YES_NEW_NONZERO_LOCATIONS,MAT_SYMMETRIC,
    367: /*7-8*/       MAT_STRUCTURALLY_SYMMETRIC,MAT_NO_NEW_DIAGONALS,
    368: /*9-10*/      MAT_YES_NEW_DIAGONALS,MAT_INODE_LIMIT_1,
    369: /*11-13*/     MAT_INODE_LIMIT_2,MAT_INODE_LIMIT_3,MAT_INODE_LIMIT_4,
    370: /*14-15*/     MAT_INODE_LIMIT_5,MAT_IGNORE_OFF_PROC_ENTRIES,
    371: /*16-17*/     MAT_ROWS_UNSORTED,MAT_COLUMNS_UNSORTED,
    372: /*18*/        MAT_NEW_NONZERO_LOCATION_ERR,
    373: /*19-20*/     MAT_NEW_NONZERO_ALLOCATION_ERR,MAT_USE_HASH_TABLE,
    374: /*21-22*/     MAT_KEEP_ZEROED_ROWS,MAT_IGNORE_ZERO_ENTRIES,
    375:               MAT_USE_INODES,MAT_DO_NOT_USE_INODES,
    376: /*25-26*/     MAT_NOT_SYMMETRIC,MAT_HERMITIAN,
    377:               MAT_NOT_STRUCTURALLY_SYMMETRIC,MAT_NOT_HERMITIAN,
    378: /*29-30*/     MAT_SYMMETRY_ETERNAL,MAT_NOT_SYMMETRY_ETERNAL,
    379:               MAT_USE_COMPRESSEDROW,MAT_DO_NOT_USE_COMPRESSEDROW,
    380: /*33-34*/     MAT_IGNORE_LOWER_TRIANGULAR,MAT_ERROR_LOWER_TRIANGULAR,
    381:               MAT_GETROW_UPPERTRIANGULAR} MatOption;
    383: EXTERN PetscErrorCode  MatSetOption(Mat,MatOption);
    384: EXTERN PetscErrorCode  MatGetType(Mat,MatType*);
    385: PetscPolymorphicFunction(MatGetType,(Mat mat),(mat,&t),MatType,t)

    387: EXTERN PetscErrorCode  MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]);
    388: EXTERN PetscErrorCode  MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
    389: EXTERN PetscErrorCode  MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
    390: EXTERN PetscErrorCode  MatGetRowUpperTriangular(Mat);
    391: EXTERN PetscErrorCode  MatRestoreRowUpperTriangular(Mat);
    392: EXTERN PetscErrorCode  MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
    393: EXTERN PetscErrorCode  MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
    394: EXTERN PetscErrorCode  MatGetColumnVector(Mat,Vec,PetscInt);
    395: EXTERN PetscErrorCode  MatGetArray(Mat,PetscScalar *[]);
    396: PetscPolymorphicFunction(MatGetArray,(Mat mat),(mat,&a),PetscScalar*,a)
    397: EXTERN PetscErrorCode  MatRestoreArray(Mat,PetscScalar *[]);
    398: EXTERN PetscErrorCode  MatGetBlockSize(Mat,PetscInt *);
    399: PetscPolymorphicFunction(MatGetBlockSize,(Mat mat),(mat,&a),PetscInt,a)
    400: EXTERN PetscErrorCode  MatSetBlockSize(Mat,PetscInt);

    402: EXTERN PetscErrorCode  MatMult(Mat,Vec,Vec);
    403: EXTERN PetscErrorCode  MatMultAdd(Mat,Vec,Vec,Vec);
    404: PetscPolymorphicSubroutine(MatMultAdd,(Mat A,Vec x,Vec y),(A,x,y,y))
    405: EXTERN PetscErrorCode  MatMultTranspose(Mat,Vec,Vec);
    406: EXTERN PetscErrorCode  MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*);
    407: PetscPolymorphicFunction(MatIsTranspose,(Mat A,Mat B,PetscReal tol),(A,B,tol,&t),PetscTruth,t)
    408: PetscPolymorphicFunction(MatIsTranspose,(Mat A,Mat B),(A,B,0,&t),PetscTruth,t)
    409: EXTERN PetscErrorCode  MatMultTransposeAdd(Mat,Vec,Vec,Vec);
    410: PetscPolymorphicSubroutine(MatMultTransposeAdd,(Mat A,Vec x,Vec y),(A,x,y,y))
    411: EXTERN PetscErrorCode  MatMultConstrained(Mat,Vec,Vec);
    412: EXTERN PetscErrorCode  MatMultTransposeConstrained(Mat,Vec,Vec);
    413: EXTERN PetscErrorCode  MatMatSolve(Mat,Mat,Mat);

    415: /*E
    416:     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
    417:   its numerical values copied over or just its nonzero structure.

    419:     Level: beginner

    421:    Any additions/changes here MUST also be made in include/finclude/petscmat.h

    423: .seealso: MatDuplicate()
    424: E*/
    425: typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;

    427: EXTERN PetscErrorCode  MatConvert(Mat,MatType,MatReuse,Mat*);
    428: PetscPolymorphicFunction(MatConvert,(Mat A,MatType t),(A,t,MAT_INITIAL_MATRIX,&a),Mat,a)
    429: EXTERN PetscErrorCode  MatDuplicate(Mat,MatDuplicateOption,Mat*);
    430: PetscPolymorphicFunction(MatDuplicate,(Mat A,MatDuplicateOption o),(A,o,&a),Mat,a)
    431: PetscPolymorphicFunction(MatDuplicate,(Mat A),(A,MAT_COPY_VALUES,&a),Mat,a)

    433: /*E
    434:     MatStructure - Indicates if the matrix has the same nonzero structure

    436:     Level: beginner

    438:    Any additions/changes here MUST also be made in include/finclude/petscmat.h

    440: .seealso: MatCopy(), KSPSetOperators(), PCSetOperators()
    441: E*/
    442: typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure;

    444: EXTERN PetscErrorCode  MatCopy(Mat,Mat,MatStructure);
    445: EXTERN PetscErrorCode  MatView(Mat,PetscViewer);
    446: EXTERN PetscErrorCode  MatIsSymmetric(Mat,PetscReal,PetscTruth*);
    447: PetscPolymorphicFunction(MatIsSymmetric,(Mat A,PetscReal tol),(A,tol,&t),PetscTruth,t)
    448: PetscPolymorphicFunction(MatIsSymmetric,(Mat A),(A,0,&t),PetscTruth,t)
    449: EXTERN PetscErrorCode  MatIsStructurallySymmetric(Mat,PetscTruth*);
    450: PetscPolymorphicFunction(MatIsStructurallySymmetric,(Mat A),(A,&t),PetscTruth,t)
    451: EXTERN PetscErrorCode  MatIsHermitian(Mat,PetscTruth*);
    452: PetscPolymorphicFunction(MatIsHermitian,(Mat A),(A,&t),PetscTruth,t)
    453: EXTERN PetscErrorCode  MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*);
    454: EXTERN PetscErrorCode  MatIsHermitianKnown(Mat,PetscTruth*,PetscTruth*);
    455: EXTERN PetscErrorCode  MatLoad(PetscViewer,MatType,Mat*);
    456: PetscPolymorphicFunction(MatLoad,(PetscViewer v,MatType t),(v,t,&a),Mat,a)

    458: EXTERN PetscErrorCode  MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
    459: EXTERN PetscErrorCode  MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
    460: EXTERN PetscErrorCode  MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
    461: EXTERN PetscErrorCode  MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);

    463: /*S
    464:      MatInfo - Context of matrix information, used with MatGetInfo()

    466:    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE

    468:    Level: intermediate

    470:   Concepts: matrix^nonzero information

    472: .seealso:  MatGetInfo(), MatInfoType
    473: S*/
    474: typedef struct {
    475:   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
    476:   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
    477:   PetscLogDouble block_size;                         /* block size */
    478:   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
    479:   PetscLogDouble memory;                             /* memory allocated */
    480:   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
    481:   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
    482:   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
    483:   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
    484: } MatInfo;

    486: /*E
    487:     MatInfoType - Indicates if you want information about the local part of the matrix,
    488:      the entire parallel matrix or the maximum over all the local parts.

    490:     Level: beginner

    492:    Any additions/changes here MUST also be made in include/finclude/petscmat.h

    494: .seealso: MatGetInfo(), MatInfo
    495: E*/
    496: typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
    497: EXTERN PetscErrorCode  MatGetInfo(Mat,MatInfoType,MatInfo*);
    498: EXTERN PetscErrorCode  MatValid(Mat,PetscTruth*);
    499: EXTERN PetscErrorCode  MatGetDiagonal(Mat,Vec);
    500: EXTERN PetscErrorCode  MatGetRowMax(Mat,Vec,PetscInt[]);
    501: EXTERN PetscErrorCode  MatGetRowMin(Mat,Vec,PetscInt[]);
    502: EXTERN PetscErrorCode  MatGetRowMaxAbs(Mat,Vec,PetscInt[]);
    503: EXTERN PetscErrorCode  MatGetRowSum(Mat,Vec);
    504: EXTERN PetscErrorCode  MatTranspose(Mat,Mat*);
    505: PetscPolymorphicFunction(MatTranspose,(Mat A),(A,&t),Mat,t)
    506: EXTERN PetscErrorCode  MatPermute(Mat,IS,IS,Mat *);
    507: PetscPolymorphicFunction(MatPermute,(Mat A,IS is1,IS is2),(A,is1,is2,&t),Mat,t)
    508: EXTERN PetscErrorCode  MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *);
    509: EXTERN PetscErrorCode  MatDiagonalScale(Mat,Vec,Vec);
    510: EXTERN PetscErrorCode  MatDiagonalSet(Mat,Vec,InsertMode);
    511: EXTERN PetscErrorCode  MatEqual(Mat,Mat,PetscTruth*);
    512: PetscPolymorphicFunction(MatEqual,(Mat A,Mat B),(A,B,&t),PetscTruth,t)
    513: EXTERN PetscErrorCode  MatMultEqual(Mat,Mat,PetscInt,PetscTruth*);
    514: EXTERN PetscErrorCode  MatMultAddEqual(Mat,Mat,PetscInt,PetscTruth*);
    515: EXTERN PetscErrorCode  MatMultTransposeEqual(Mat,Mat,PetscInt,PetscTruth*);
    516: EXTERN PetscErrorCode  MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscTruth*);

    518: EXTERN PetscErrorCode  MatNorm(Mat,NormType,PetscReal *);
    519: PetscPolymorphicFunction(MatNorm,(Mat A,NormType t),(A,t,&n),PetscReal,n)
    520: EXTERN PetscErrorCode  MatZeroEntries(Mat);
    521: EXTERN PetscErrorCode  MatZeroRows(Mat,PetscInt,const PetscInt [],PetscScalar);
    522: EXTERN PetscErrorCode  MatZeroRowsIS(Mat,IS,PetscScalar);
    523: EXTERN PetscErrorCode  MatZeroColumns(Mat,PetscInt,const PetscInt [],const PetscScalar*);
    524: EXTERN PetscErrorCode  MatZeroColumnsIS(Mat,IS,const PetscScalar*);

    526: EXTERN PetscErrorCode  MatUseScaledForm(Mat,PetscTruth);
    527: EXTERN PetscErrorCode  MatScaleSystem(Mat,Vec,Vec);
    528: EXTERN PetscErrorCode  MatUnScaleSystem(Mat,Vec,Vec);

    530: EXTERN PetscErrorCode  MatGetSize(Mat,PetscInt*,PetscInt*);
    531: EXTERN PetscErrorCode  MatGetLocalSize(Mat,PetscInt*,PetscInt*);
    532: EXTERN PetscErrorCode  MatGetOwnershipRange(Mat,PetscInt*,PetscInt*);
    533: EXTERN PetscErrorCode  MatGetOwnershipRanges(Mat,const PetscInt**);

    535: EXTERN PetscErrorCode  MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
    536: EXTERN PetscErrorCode  MatDestroyMatrices(PetscInt,Mat *[]);
    537: EXTERN PetscErrorCode  MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *);
    538: EXTERN PetscErrorCode  MatGetSubMatrixRaw(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscInt,MatReuse,Mat *);
    539: EXTERN PetscErrorCode  MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*);
    540: EXTERN PetscErrorCode  MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*);
    541: EXTERN PetscErrorCode  MatMerge_SeqsToMPISymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*);
    542: EXTERN PetscErrorCode  MatMerge_SeqsToMPINumeric(Mat,Mat);
    543: EXTERN PetscErrorCode  MatDestroy_MPIAIJ_SeqsToMPI(Mat);
    544: EXTERN PetscErrorCode  MatGetLocalMat(Mat,MatReuse,Mat*);
    545: EXTERN PetscErrorCode  MatGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*);
    546: EXTERN PetscErrorCode  MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*);
    547: EXTERN PetscErrorCode  MatGetBrowsOfAoCols(Mat,Mat,MatReuse,PetscInt**,PetscScalar**,Mat*);
    548: #if defined (PETSC_USE_CTABLE)
    549:  #include petscctable.h
    550: EXTERN PetscErrorCode  MatGetCommunicationStructs(Mat, Vec *, PetscTable *, VecScatter *);
    551: #else
    552: EXTERN PetscErrorCode  MatGetCommunicationStructs(Mat, Vec *, PetscInt *[], VecScatter *);
    553: #endif

    555: EXTERN PetscErrorCode  MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt);

    557: EXTERN PetscErrorCode  MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
    558: EXTERN PetscErrorCode  MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*);
    559: EXTERN PetscErrorCode  MatMatMultNumeric(Mat,Mat,Mat);

    561: EXTERN PetscErrorCode  MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*);
    562: EXTERN PetscErrorCode  MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*);
    563: EXTERN PetscErrorCode  MatPtAPNumeric(Mat,Mat,Mat);

    565: EXTERN PetscErrorCode  MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*);
    566: EXTERN PetscErrorCode  MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*);
    567: EXTERN PetscErrorCode  MatMatMultTransposeNumeric(Mat,Mat,Mat);

    569: EXTERN PetscErrorCode  MatAXPY(Mat,PetscScalar,Mat,MatStructure);
    570: EXTERN PetscErrorCode  MatAYPX(Mat,PetscScalar,Mat,MatStructure);
    571: EXTERN PetscErrorCode  MatCompress(Mat);

    573: EXTERN PetscErrorCode  MatScale(Mat,PetscScalar);
    574: EXTERN PetscErrorCode  MatShift(Mat,PetscScalar);

    576: EXTERN PetscErrorCode  MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
    577: EXTERN PetscErrorCode  MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
    578: EXTERN PetscErrorCode  MatZeroRowsLocal(Mat,PetscInt,const PetscInt [],PetscScalar);
    579: EXTERN PetscErrorCode  MatZeroRowsLocalIS(Mat,IS,PetscScalar);
    580: EXTERN PetscErrorCode  MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
    581: EXTERN PetscErrorCode  MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

    583: EXTERN PetscErrorCode  MatStashSetInitialSize(Mat,PetscInt,PetscInt);
    584: EXTERN PetscErrorCode  MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*);

    586: EXTERN PetscErrorCode  MatInterpolate(Mat,Vec,Vec);
    587: EXTERN PetscErrorCode  MatInterpolateAdd(Mat,Vec,Vec,Vec);
    588: PetscPolymorphicSubroutine(MatInterpolateAdd,(Mat A,Vec x,Vec y),(A,x,y,y))
    589: EXTERN PetscErrorCode  MatRestrict(Mat,Vec,Vec);
    590: EXTERN PetscErrorCode  MatGetVecs(Mat,Vec*,Vec*);
    591: EXTERN PetscErrorCode  MatGetRedundantMatrix(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*);

    593: /*MC
    594:    MatPreallocateInitialize - Begins the block of code that will count the number of nonzeros per
    595:        row in a matrix providing the data that one can use to correctly preallocate the matrix.

    597:    Synopsis:
    598:    PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)

    600:    Collective on MPI_Comm

    602:    Input Parameters:
    603: +  comm - the communicator that will share the eventually allocated matrix
    604: .  nrows - the number of LOCAL rows in the matrix
    605: -  ncols - the number of LOCAL columns in the matrix

    607:    Output Parameters:
    608: +  dnz - the array that will be passed to the matrix preallocation routines
    609: -  ozn - the other array passed to the matrix preallocation routines

    612:    Level: intermediate

    614:    Notes:
    615:    See the chapter in the users manual on performance for more details

    617:    Do not malloc or free dnz and onz, that is handled internally by these routines

    619:    Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices)

    621:   Concepts: preallocation^Matrix

    623: .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
    624:           MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal()
    625: M*/
    626: #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
    627: { \
    628:   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
    629:   _4_PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
    630:   _4_PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
    631:   _4_MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
    632:   _4_MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;

    634: /*MC
    635:    MatPreallocateSymmetricInitialize - Begins the block of code that will count the number of nonzeros per
    636:        row in a matrix providing the data that one can use to correctly preallocate the matrix.

    638:    Synopsis:
    639:    PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)

    641:    Collective on MPI_Comm

    643:    Input Parameters:
    644: +  comm - the communicator that will share the eventually allocated matrix
    645: .  nrows - the number of LOCAL rows in the matrix
    646: -  ncols - the number of LOCAL columns in the matrix

    648:    Output Parameters:
    649: +  dnz - the array that will be passed to the matrix preallocation routines
    650: -  ozn - the other array passed to the matrix preallocation routines

    653:    Level: intermediate

    655:    Notes:
    656:    See the chapter in the users manual on performance for more details

    658:    Do not malloc or free dnz and onz, that is handled internally by these routines

    660:   Concepts: preallocation^Matrix

    662: .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
    663:           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
    664: M*/
    665: #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \
    666: { \
    667:   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__end; \
    668:   _4_PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
    669:   _4_PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
    670:   _4_MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\
    671:   _4_MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;

    673: /*MC
    674:    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
    675:        inserted using a local number of the rows and columns

    677:    Synopsis:
    678:    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)

    680:    Not Collective

    682:    Input Parameters:
    683: +  map - the mapping between local numbering and global numbering
    684: .  nrows - the number of rows indicated
    685: .  rows - the indices of the rows
    686: .  ncols - the number of columns in the matrix
    687: .  cols - the columns indicated
    688: .  dnz - the array that will be passed to the matrix preallocation routines
    689: -  ozn - the other array passed to the matrix preallocation routines

    692:    Level: intermediate

    694:    Notes:
    695:    See the chapter in the users manual on performance for more details

    697:    Do not malloc or free dnz and onz, that is handled internally by these routines

    699:   Concepts: preallocation^Matrix

    701: .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
    702:           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
    703: M*/
    704: #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
    705: {\
    706:   PetscInt __l;\
    707:   _4_ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
    708:   _4_ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
    709:   for (__l=0;__l<nrows;__l++) {\
    710:     _4_MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
    711:   }\
    712: }
    713:
    714: /*MC
    715:    MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
    716:        inserted using a local number of the rows and columns

    718:    Synopsis:
    719:    PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)

    721:    Not Collective

    723:    Input Parameters:
    724: +  map - the mapping between local numbering and global numbering
    725: .  nrows - the number of rows indicated
    726: .  rows - the indices of the rows
    727: .  ncols - the number of columns in the matrix
    728: .  cols - the columns indicated
    729: .  dnz - the array that will be passed to the matrix preallocation routines
    730: -  ozn - the other array passed to the matrix preallocation routines

    733:    Level: intermediate

    735:    Notes:
    736:    See the chapter in the users manual on performance for more details

    738:    Do not malloc or free dnz and onz that is handled internally by these routines

    740:   Concepts: preallocation^Matrix

    742: .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
    743:           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
    744: M*/
    745: #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
    746: {\
    747:   PetscInt __l;\
    748:   _4_ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
    749:   _4_ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
    750:   for (__l=0;__l<nrows;__l++) {\
    751:     _4_MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
    752:   }\
    753: }

    755: /*MC
    756:    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
    757:        inserted using a local number of the rows and columns

    759:    Synopsis:
    760:    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)

    762:    Not Collective

    764:    Input Parameters:
    765: +  row - the row
    766: .  ncols - the number of columns in the matrix
    767: -  cols - the columns indicated

    769:    Output Parameters:
    770: +  dnz - the array that will be passed to the matrix preallocation routines
    771: -  ozn - the other array passed to the matrix preallocation routines

    774:    Level: intermediate

    776:    Notes:
    777:    See the chapter in the users manual on performance for more details

    779:    Do not malloc or free dnz and onz that is handled internally by these routines

    781:   Concepts: preallocation^Matrix

    783: .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
    784:           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
    785: M*/
    786: #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
    787: { PetscInt __i; \
    788:   if (row < __rstart) SETERRQ2(PETSC_ERR_ARG_OUTOFRANGE,"Trying to set preallocation for row %D less than first local row %D",row,__rstart);\
    789:   if (row >= __rstart+__tmp) SETERRQ2(PETSC_ERR_ARG_OUTOFRANGE,"Trying to set preallocation for row %D greater than last local row %D",row,__rstart+__tmp-1);\
    790:   for (__i=0; __i<nc; __i++) {\
    791:     if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \
    792:     else dnz[row - __rstart]++;\
    793:   }\
    794: }

    796: /*MC
    797:    MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
    798:        inserted using a local number of the rows and columns

    800:    Synopsis:
    801:    PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)

    803:    Not Collective

    805:    Input Parameters:
    806: +  nrows - the number of rows indicated
    807: .  rows - the indices of the rows
    808: .  ncols - the number of columns in the matrix
    809: .  cols - the columns indicated
    810: .  dnz - the array that will be passed to the matrix preallocation routines
    811: -  ozn - the other array passed to the matrix preallocation routines

    814:    Level: intermediate

    816:    Notes:
    817:    See the chapter in the users manual on performance for more details

    819:    Do not malloc or free dnz and onz that is handled internally by these routines

    821:   Concepts: preallocation^Matrix

    823: .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
    824:           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
    825: M*/
    826: #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\
    827: { PetscInt __i; \
    828:   for (__i=0; __i<nc; __i++) {\
    829:     if (cols[__i] >= __end) onz[row - __rstart]++; \
    830:     else if (cols[__i] >= row) dnz[row - __rstart]++;\
    831:   }\
    832: }

    834: /*MC
    835:    MatPreallocateFinalize - Ends the block of code that will count the number of nonzeros per
    836:        row in a matrix providing the data that one can use to correctly preallocate the matrix.

    838:    Synopsis:
    839:    PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz)

    841:    Collective on MPI_Comm

    843:    Input Parameters:
    844: +  dnz - the array that will be passed to the matrix preallocation routines
    845: -  ozn - the other array passed to the matrix preallocation routines

    848:    Level: intermediate

    850:    Notes:
    851:    See the chapter in the users manual on performance for more details

    853:    Do not malloc or free dnz and onz that is handled internally by these routines

    855:   Concepts: preallocation^Matrix

    857: .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
    858:           MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal()
    859: M*/
    860: #define MatPreallocateFinalize(dnz,onz) 0;_4_PetscFree(dnz);CHKERRQ(_4_ierr);}

    864: /* Routines unique to particular data structures */
    865: EXTERN PetscErrorCode  MatShellGetContext(Mat,void **);
    866: PetscPolymorphicFunction(MatShellGetContext,(Mat A),(A,&t),void*,t)
    867: EXTERN PetscErrorCode  MatBDiagGetData(Mat,PetscInt*,PetscInt*,PetscInt*[],PetscInt*[],PetscScalar***);

    869: EXTERN PetscErrorCode  MatInodeAdjustForInodes(Mat,IS*,IS*);
    870: EXTERN PetscErrorCode  MatInodeGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *);

    872: EXTERN PetscErrorCode  MatSeqAIJSetColumnIndices(Mat,PetscInt[]);
    873: EXTERN PetscErrorCode  MatSeqBAIJSetColumnIndices(Mat,PetscInt[]);
    874: EXTERN PetscErrorCode  MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
    875: EXTERN PetscErrorCode  MatCreateSeqBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
    876: EXTERN PetscErrorCode  MatCreateSeqSBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);

    878: #define MAT_SKIP_ALLOCATION -4

    880: EXTERN PetscErrorCode  MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
    881: PetscPolymorphicSubroutine(MatSeqBAIJSetPreallocation,(Mat A,PetscInt bs,const PetscInt nnz[]),(A,bs,0,nnz))
    882: EXTERN PetscErrorCode  MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
    883: PetscPolymorphicSubroutine(MatSeqSBAIJSetPreallocation,(Mat A,PetscInt bs,const PetscInt nnz[]),(A,bs,0,nnz))
    884: EXTERN PetscErrorCode  MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]);
    885: PetscPolymorphicSubroutine(MatSeqAIJSetPreallocation,(Mat A,const PetscInt nnz[]),(A,0,nnz))
    886: EXTERN PetscErrorCode  MatSeqDensePreallocation(Mat,PetscScalar[]);
    887: EXTERN PetscErrorCode  MatSeqBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);

    889: EXTERN PetscErrorCode  MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
    890: PetscPolymorphicSubroutine(MatMPIBAIJSetPreallocation,(Mat A,PetscInt bs,const PetscInt nnz[],const PetscInt onz[]),(A,bs,0,nnz,0,onz))
    891: EXTERN PetscErrorCode  MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
    892: EXTERN PetscErrorCode  MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
    893: EXTERN PetscErrorCode  MatSeqAIJSetPreallocationCSR(Mat,const PetscInt [],const PetscInt [],const PetscScalar []);
    894: EXTERN PetscErrorCode  MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]);
    895: EXTERN PetscErrorCode  MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
    896: EXTERN PetscErrorCode  MatMPIBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
    897: EXTERN PetscErrorCode  MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]);
    898: EXTERN PetscErrorCode  MatMPIDenseSetPreallocation(Mat,PetscScalar[]);
    899: EXTERN PetscErrorCode  MatSeqDenseSetPreallocation(Mat,PetscScalar[]);
    900: EXTERN PetscErrorCode  MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]);
    901: EXTERN PetscErrorCode  MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]);
    902: EXTERN PetscErrorCode  MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]);
    903: EXTERN PetscErrorCode  MatAdicSetLocalFunction(Mat,void (*)(void));

    905: EXTERN PetscErrorCode  MatSeqDenseSetLDA(Mat,PetscInt);
    906: EXTERN PetscErrorCode  MatDenseGetLocalMatrix(Mat,Mat*);

    908: EXTERN PetscErrorCode  MatStoreValues(Mat);
    909: EXTERN PetscErrorCode  MatRetrieveValues(Mat);

    911: EXTERN PetscErrorCode  MatDAADSetCtx(Mat,void*);

    913: /*
    914:   These routines are not usually accessed directly, rather solving is
    915:   done through the KSP and PC interfaces.
    916: */

    918: /*E
    919:     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
    920:        with an optional dynamic library name, for example
    921:        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()

    923:    Level: beginner

    925:    Cannot use const because the PC objects manipulate the string

    927: .seealso: MatGetOrdering()
    928: E*/
    929: #define MatOrderingType char*
    930: #define MATORDERING_NATURAL   "natural"
    931: #define MATORDERING_ND        "nd"
    932: #define MATORDERING_1WD       "1wd"
    933: #define MATORDERING_RCM       "rcm"
    934: #define MATORDERING_QMD       "qmd"
    935: #define MATORDERING_ROWLENGTH "rowlength"
    936: #define MATORDERING_DSC_ND    "dsc_nd"
    937: #define MATORDERING_DSC_MMD   "dsc_mmd"
    938: #define MATORDERING_DSC_MDF   "dsc_mdf"
    939: #define MATORDERING_CONSTRAINED "constrained"
    940: #define MATORDERING_IDENTITY  "identity"
    941: #define MATORDERING_REVERSE   "reverse"

    943: EXTERN PetscErrorCode  MatGetOrdering(Mat,const MatOrderingType,IS*,IS*);
    944: EXTERN PetscErrorCode  MatGetOrderingList(PetscFList *list);
    945: EXTERN PetscErrorCode  MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*));

    947: /*MC
    948:    MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the
    949:                                matrix package.

    951:    Synopsis:
    952:    PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering))

    954:    Not Collective

    956:    Input Parameters:
    957: +  sname - name of ordering (for example MATORDERING_ND)
    958: .  path - location of library where creation routine is
    959: .  name - name of function that creates the ordering type,a string
    960: -  function - function pointer that creates the ordering

    962:    Level: developer

    964:    If dynamic libraries are used, then the fourth input argument (function)
    965:    is ignored.

    967:    Sample usage:
    968: .vb
    969:    MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a,
    970:                "MyOrder",MyOrder);
    971: .ve

    973:    Then, your partitioner can be chosen with the procedural interface via
    974: $     MatOrderingSetType(part,"my_order)
    975:    or at runtime via the option
    976: $     -pc_factor_mat_ordering_type my_order

    978:    ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.

    980: .keywords: matrix, ordering, register

    982: .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll()
    983: M*/
    984: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    985: #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
    986: #else
    987: #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
    988: #endif

    990: EXTERN PetscErrorCode  MatOrderingRegisterDestroy(void);
    991: EXTERN PetscErrorCode  MatOrderingRegisterAll(const char[]);

    995: EXTERN PetscErrorCode  MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);

    997: /*S
    998:    MatFactorInfo - Data passed into the matrix factorization routines

    1000:    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE

    1002:    Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.

    1004:    Level: developer

    1006: .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(),
    1007:           MatFactorInfoInitialize()

    1009: S*/
    1010: typedef struct {
    1011:   PetscReal     shiftnz;        /* scaling of identity added to matrix to prevent zero pivots */
    1012:   PetscReal     shiftpd;        /* if true, shift until positive pivots */
    1013:   PetscReal     shift_fraction; /* record shift fraction taken */
    1014:   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
    1015:   PetscReal     dt;             /* drop tolerance */
    1016:   PetscReal     dtcol;          /* tolerance for pivoting */
    1017:   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
    1018:   PetscReal     fill;           /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */
    1019:   PetscReal     levels;         /* ICC/ILU(levels) */
    1020:   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
    1021:                                    factorization may be faster if do not pivot */
    1022:   PetscReal     zeropivot;      /* pivot is called zero if less than this */
    1023: } MatFactorInfo;

    1025: EXTERN PetscErrorCode  MatFactorInfoInitialize(MatFactorInfo*);
    1026: EXTERN PetscErrorCode  MatCholeskyFactor(Mat,IS,MatFactorInfo*);
    1027: EXTERN PetscErrorCode  MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
    1028: EXTERN PetscErrorCode  MatCholeskyFactorNumeric(Mat,MatFactorInfo*,Mat*);
    1029: EXTERN PetscErrorCode  MatLUFactor(Mat,IS,IS,MatFactorInfo*);
    1030: EXTERN PetscErrorCode  MatILUFactor(Mat,IS,IS,MatFactorInfo*);
    1031: EXTERN PetscErrorCode  MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
    1032: EXTERN PetscErrorCode  MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
    1033: EXTERN PetscErrorCode  MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
    1034: EXTERN PetscErrorCode  MatICCFactor(Mat,IS,MatFactorInfo*);
    1035: EXTERN PetscErrorCode  MatLUFactorNumeric(Mat,MatFactorInfo*,Mat*);
    1036: EXTERN PetscErrorCode  MatILUDTFactor(Mat,IS,IS,MatFactorInfo*,Mat *);
    1037: EXTERN PetscErrorCode  MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*);
    1038: EXTERN PetscErrorCode  MatSolve(Mat,Vec,Vec);
    1039: EXTERN PetscErrorCode  MatForwardSolve(Mat,Vec,Vec);
    1040: EXTERN PetscErrorCode  MatBackwardSolve(Mat,Vec,Vec);
    1041: EXTERN PetscErrorCode  MatSolveAdd(Mat,Vec,Vec,Vec);
    1042: EXTERN PetscErrorCode  MatSolveTranspose(Mat,Vec,Vec);
    1043: EXTERN PetscErrorCode  MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
    1044: EXTERN PetscErrorCode  MatSolves(Mat,Vecs,Vecs);

    1046: EXTERN PetscErrorCode  MatSetUnfactored(Mat);

    1048: /*E
    1049:     MatSORType - What type of (S)SOR to perform

    1051:     Level: beginner

    1053:    May be bitwise ORd together

    1055:    Any additions/changes here MUST also be made in include/finclude/petscmat.h

    1057:    MatSORType may be bitwise ORd together, so do not change the numbers

    1059: .seealso: MatRelax(), MatPBRelax()
    1060: E*/
    1061: typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
    1062:               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
    1063:               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
    1064:               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
    1065: EXTERN PetscErrorCode  MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
    1066: EXTERN PetscErrorCode  MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);

    1068: /*
    1069:     These routines are for efficiently computing Jacobians via finite differences.
    1070: */

    1072: /*E
    1073:     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
    1074:        with an optional dynamic library name, for example
    1075:        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()

    1077:    Level: beginner

    1079: .seealso: MatGetColoring()
    1080: E*/
    1081: #define MatColoringType const char*
    1082: #define MATCOLORING_NATURAL "natural"
    1083: #define MATCOLORING_SL      "sl"
    1084: #define MATCOLORING_LF      "lf"
    1085: #define MATCOLORING_ID      "id"

    1087: EXTERN PetscErrorCode  MatGetColoring(Mat,MatColoringType,ISColoring*);
    1088: EXTERN PetscErrorCode  MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,MatColoringType,ISColoring *));

    1090: /*MC
    1091:    MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the
    1092:                                matrix package.

    1094:    Synopsis:
    1095:    PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring))

    1097:    Not Collective

    1099:    Input Parameters:
    1100: +  sname - name of Coloring (for example MATCOLORING_SL)
    1101: .  path - location of library where creation routine is
    1102: .  name - name of function that creates the Coloring type, a string
    1103: -  function - function pointer that creates the coloring

    1105:    Level: developer

    1107:    If dynamic libraries are used, then the fourth input argument (function)
    1108:    is ignored.

    1110:    Sample usage:
    1111: .vb
    1112:    MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a,
    1113:                "MyColor",MyColor);
    1114: .ve

    1116:    Then, your partitioner can be chosen with the procedural interface via
    1117: $     MatColoringSetType(part,"my_color")
    1118:    or at runtime via the option
    1119: $     -mat_coloring_type my_color

    1121:    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.

    1123: .keywords: matrix, Coloring, register

    1125: .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll()
    1126: M*/
    1127: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    1128: #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
    1129: #else
    1130: #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
    1131: #endif

    1135: EXTERN PetscErrorCode  MatColoringRegisterAll(const char[]);
    1136: EXTERN PetscErrorCode  MatColoringRegisterDestroy(void);
    1137: EXTERN PetscErrorCode  MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*);

    1139: /*S
    1140:      MatFDColoring - Object for computing a sparse Jacobian via finite differences
    1141:         and coloring

    1143:    Level: beginner

    1145:   Concepts: coloring, sparse Jacobian, finite differences

    1147: .seealso:  MatFDColoringCreate()
    1148: S*/
    1149: typedef struct _p_MatFDColoring* MatFDColoring;

    1151: EXTERN PetscErrorCode  MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
    1152: EXTERN PetscErrorCode  MatFDColoringDestroy(MatFDColoring);
    1153: EXTERN PetscErrorCode  MatFDColoringView(MatFDColoring,PetscViewer);
    1154: EXTERN PetscErrorCode  MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*);
    1155: EXTERN PetscErrorCode  MatFDColoringGetFunction(MatFDColoring,PetscErrorCode (**)(void),void**);
    1156: EXTERN PetscErrorCode  MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
    1157: EXTERN PetscErrorCode  MatFDColoringSetFrequency(MatFDColoring,PetscInt);
    1158: EXTERN PetscErrorCode  MatFDColoringGetFrequency(MatFDColoring,PetscInt*);
    1159: EXTERN PetscErrorCode  MatFDColoringSetFromOptions(MatFDColoring);
    1160: EXTERN PetscErrorCode  MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
    1161: EXTERN PetscErrorCode  MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
    1162: EXTERN PetscErrorCode  MatFDColoringSetRecompute(MatFDColoring);
    1163: EXTERN PetscErrorCode  MatFDColoringSetF(MatFDColoring,Vec);
    1164: EXTERN PetscErrorCode  MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]);
    1165: /*
    1166:     These routines are for partitioning matrices: currently used only
    1167:   for adjacency matrix, MatCreateMPIAdj().
    1168: */

    1170: /*S
    1171:      MatPartitioning - Object for managing the partitioning of a matrix or graph

    1173:    Level: beginner

    1175:   Concepts: partitioning

    1177: .seealso:  MatPartitioningCreate(), MatPartitioningType
    1178: S*/
    1179: typedef struct _p_MatPartitioning* MatPartitioning;

    1181: /*E
    1182:     MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function
    1183:        with an optional dynamic library name, for example
    1184:        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()

    1186:    Level: beginner

    1188: .seealso: MatPartitioningCreate(), MatPartitioning
    1189: E*/
    1190: #define MatPartitioningType const char*
    1191: #define MAT_PARTITIONING_CURRENT  "current"
    1192: #define MAT_PARTITIONING_SQUARE   "square"
    1193: #define MAT_PARTITIONING_PARMETIS "parmetis"
    1194: #define MAT_PARTITIONING_CHACO    "chaco"
    1195: #define MAT_PARTITIONING_JOSTLE   "jostle"
    1196: #define MAT_PARTITIONING_PARTY    "party"
    1197: #define MAT_PARTITIONING_SCOTCH   "scotch"

    1200: EXTERN PetscErrorCode  MatPartitioningCreate(MPI_Comm,MatPartitioning*);
    1201: EXTERN PetscErrorCode  MatPartitioningSetType(MatPartitioning,MatPartitioningType);
    1202: EXTERN PetscErrorCode  MatPartitioningSetNParts(MatPartitioning,PetscInt);
    1203: EXTERN PetscErrorCode  MatPartitioningSetAdjacency(MatPartitioning,Mat);
    1204: EXTERN PetscErrorCode  MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]);
    1205: EXTERN PetscErrorCode  MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []);
    1206: EXTERN PetscErrorCode  MatPartitioningApply(MatPartitioning,IS*);
    1207: EXTERN PetscErrorCode  MatPartitioningDestroy(MatPartitioning);

    1209: EXTERN PetscErrorCode  MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning));

    1211: /*MC
    1212:    MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the
    1213:    matrix package.

    1215:    Synopsis:
    1216:    PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning))

    1218:    Not Collective

    1220:    Input Parameters:
    1221: +  sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis
    1222: .  path - location of library where creation routine is
    1223: .  name - name of function that creates the partitioning type, a string
    1224: -  function - function pointer that creates the partitioning type

    1226:    Level: developer

    1228:    If dynamic libraries are used, then the fourth input argument (function)
    1229:    is ignored.

    1231:    Sample usage:
    1232: .vb
    1233:    MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a,
    1234:                "MyPartCreate",MyPartCreate);
    1235: .ve

    1237:    Then, your partitioner can be chosen with the procedural interface via
    1238: $     MatPartitioningSetType(part,"my_part")
    1239:    or at runtime via the option
    1240: $     -mat_partitioning_type my_part

    1242:    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.

    1244: .keywords: matrix, partitioning, register

    1246: .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll()
    1247: M*/
    1248: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    1249: #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
    1250: #else
    1251: #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
    1252: #endif

    1256: EXTERN PetscErrorCode  MatPartitioningRegisterAll(const char[]);
    1257: EXTERN PetscErrorCode  MatPartitioningRegisterDestroy(void);

    1259: EXTERN PetscErrorCode  MatPartitioningView(MatPartitioning,PetscViewer);
    1260: EXTERN PetscErrorCode  MatPartitioningSetFromOptions(MatPartitioning);
    1261: EXTERN PetscErrorCode  MatPartitioningGetType(MatPartitioning,MatPartitioningType*);

    1263: EXTERN PetscErrorCode  MatPartitioningParmetisSetCoarseSequential(MatPartitioning);

    1265: EXTERN PetscErrorCode  MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal);
    1266: EXTERN PetscErrorCode  MatPartitioningJostleSetCoarseSequential(MatPartitioning);

    1268: typedef enum {MP_CHACO_MULTILEVEL_KL,MP_CHACO_SPECTRAL,MP_CHACO_LINEAR,MP_CHACO_RANDOM, MP_CHACO_SCATTERED} MPChacoGlobalType;
    1269: EXTERN PetscErrorCode  MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
    1270: typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType;
    1271: EXTERN PetscErrorCode  MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
    1272: EXTERN PetscErrorCode  MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal);
    1273: typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType;
    1274: EXTERN PetscErrorCode  MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType);
    1275: EXTERN PetscErrorCode  MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
    1276: EXTERN PetscErrorCode  MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);

    1278: #define MP_PARTY_OPT "opt"
    1279: #define MP_PARTY_LIN "lin"
    1280: #define MP_PARTY_SCA "sca"
    1281: #define MP_PARTY_RAN "ran"
    1282: #define MP_PARTY_GBF "gbf"
    1283: #define MP_PARTY_GCF "gcf"
    1284: #define MP_PARTY_BUB "bub"
    1285: #define MP_PARTY_DEF "def"
    1286: EXTERN PetscErrorCode  MatPartitioningPartySetGlobal(MatPartitioning, const char*);
    1287: #define MP_PARTY_HELPFUL_SETS "hs"
    1288: #define MP_PARTY_KERNIGHAN_LIN "kl"
    1289: #define MP_PARTY_NONE "no"
    1290: EXTERN PetscErrorCode  MatPartitioningPartySetLocal(MatPartitioning, const char*);
    1291: EXTERN PetscErrorCode  MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal);
    1292: EXTERN PetscErrorCode  MatPartitioningPartySetBipart(MatPartitioning,PetscTruth);
    1293: EXTERN PetscErrorCode  MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth);

    1295: typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType;
    1296: EXTERN PetscErrorCode  MatPartitioningScotchSetArch(MatPartitioning,const char*);
    1297: EXTERN PetscErrorCode  MatPartitioningScotchSetMultilevel(MatPartitioning);
    1298: EXTERN PetscErrorCode  MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType);
    1299: EXTERN PetscErrorCode  MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal);
    1300: EXTERN PetscErrorCode  MatPartitioningScotchSetHostList(MatPartitioning,const char*);
    1301: typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType;
    1302: EXTERN PetscErrorCode  MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType);
    1303: EXTERN PetscErrorCode  MatPartitioningScotchSetMapping(MatPartitioning);
    1304: EXTERN PetscErrorCode  MatPartitioningScotchSetStrategy(MatPartitioning,char*);

    1306: /*
    1307:     If you add entries here you must also add them to finclude/petscmat.h
    1308: */
    1309: typedef enum { MATOP_SET_VALUES=0,
    1310:                MATOP_GET_ROW=1,
    1311:                MATOP_RESTORE_ROW=2,
    1312:                MATOP_MULT=3,
    1313:                MATOP_MULT_ADD=4,
    1314:                MATOP_MULT_TRANSPOSE=5,
    1315:                MATOP_MULT_TRANSPOSE_ADD=6,
    1316:                MATOP_SOLVE=7,
    1317:                MATOP_SOLVE_ADD=8,
    1318:                MATOP_SOLVE_TRANSPOSE=9,
    1319:                MATOP_SOLVE_TRANSPOSE_ADD=10,
    1320:                MATOP_LUFACTOR=11,
    1321:                MATOP_CHOLESKYFACTOR=12,
    1322:                MATOP_RELAX=13,
    1323:                MATOP_TRANSPOSE=14,
    1324:                MATOP_GETINFO=15,
    1325:                MATOP_EQUAL=16,
    1326:                MATOP_GET_DIAGONAL=17,
    1327:                MATOP_DIAGONAL_SCALE=18,
    1328:                MATOP_NORM=19,
    1329:                MATOP_ASSEMBLY_BEGIN=20,
    1330:                MATOP_ASSEMBLY_END=21,
    1331:                MATOP_COMPRESS=22,
    1332:                MATOP_SET_OPTION=23,
    1333:                MATOP_ZERO_ENTRIES=24,
    1334:                MATOP_ZERO_ROWS=25,
    1335:                MATOP_LUFACTOR_SYMBOLIC=26,
    1336:                MATOP_LUFACTOR_NUMERIC=27,
    1337:                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
    1338:                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
    1339:                MATOP_SETUP_PREALLOCATION=30,
    1340:                MATOP_ILUFACTOR_SYMBOLIC=31,
    1341:                MATOP_ICCFACTOR_SYMBOLIC=32,
    1342:                MATOP_GET_ARRAY=33,
    1343:                MATOP_RESTORE_ARRAY=34,
    1344:                MATOP_DUPLICATE=35,
    1345:                MATOP_FORWARD_SOLVE=36,
    1346:                MATOP_BACKWARD_SOLVE=37,
    1347:                MATOP_ILUFACTOR=38,
    1348:                MATOP_ICCFACTOR=39,
    1349:                MATOP_AXPY=40,
    1350:                MATOP_GET_SUBMATRICES=41,
    1351:                MATOP_INCREASE_OVERLAP=42,
    1352:                MATOP_GET_VALUES=43,
    1353:                MATOP_COPY=44,
    1354:                MATOP_PRINT_HELP=45,
    1355:                MATOP_SCALE=46,
    1356:                MATOP_SHIFT=47,
    1357:                MATOP_DIAGONAL_SHIFT=48,
    1358:                MATOP_ILUDT_FACTOR=49,
    1359:                MATOP_GET_BLOCK_SIZE=50,
    1360:                MATOP_GET_ROW_IJ=51,
    1361:                MATOP_RESTORE_ROW_IJ=52,
    1362:                MATOP_GET_COLUMN_IJ=53,
    1363:                MATOP_RESTORE_COLUMN_IJ=54,
    1364:                MATOP_FDCOLORING_CREATE=55,
    1365:                MATOP_COLORING_PATCH=56,
    1366:                MATOP_SET_UNFACTORED=57,
    1367:                MATOP_PERMUTE=58,
    1368:                MATOP_SET_VALUES_BLOCKED=59,
    1369:                MATOP_GET_SUBMATRIX=60,
    1370:                MATOP_DESTROY=61,
    1371:                MATOP_VIEW=62,
    1372:                MATOP_GET_MAPS=63,
    1373:                MATOP_USE_SCALED_FORM=64,
    1374:                MATOP_SCALE_SYSTEM=65,
    1375:                MATOP_UNSCALE_SYSTEM=66,
    1376:                MATOP_SET_LOCAL_TO_GLOBAL_MAP=67,
    1377:                MATOP_SET_VALUES_LOCAL=68,
    1378:                MATOP_ZERO_ROWS_LOCAL=69,
    1379:                MATOP_GET_ROW_MAX=70,
    1380:                MATOP_CONVERT=71,
    1381:                MATOP_SET_COLORING=72,
    1382:                MATOP_SET_VALUES_ADIC=73,
    1383:                MATOP_SET_VALUES_ADIFOR=74,
    1384:                MATOP_FD_COLORING_APPLY=75,
    1385:                MATOP_SET_FROM_OPTIONS=76,
    1386:                MATOP_MULT_CON=77,
    1387:                MATOP_MULT_TRANSPOSE_CON=78,
    1388:                MATOP_ILU_FACTOR_SYMBOLIC_CON=79,
    1389:                MATOP_PERMUTE_SPARSIFY=80,
    1390:                MATOP_MULT_MULTIPLE=81,
    1391:                MATOP_SOLVE_MULTIPLE=82,
    1392:                MATOP_GET_INERTIA=83,
    1393:                MATOP_LOAD=84,
    1394:                MATOP_IS_SYMMETRIC=85,
    1395:                MATOP_IS_HERMITIAN=86,
    1396:                MATOP_IS_STRUCTURALLY_SYMMETRIC=87,
    1397:                MATOP_PB_RELAX=88,
    1398:                MATOP_GET_VECS=89,
    1399:                MATOP_MAT_MULT=90,
    1400:                MATOP_MAT_MULT_SYMBOLIC=91,
    1401:                MATOP_MAT_MULT_NUMERIC=92,
    1402:                MATOP_PTAP=93,
    1403:                MATOP_PTAP_SYMBOLIC=94,
    1404:                MATOP_PTAP_NUMERIC=95,
    1405:                MATOP_MAT_MULTTRANSPOSE=96,
    1406:                MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97,
    1407:                MATOP_MAT_MULTTRANSPOSE_NUMERIC=98,
    1408:                MATOP_PTAP_SYMBOLIC_SEQAIJ=99,
    1409:                MATOP_PTAP_NUMERIC_SEQAIJ=100,
    1410:                MATOP_PTAP_SYMBOLIC_MPIAIJ=101,
    1411:                MATOP_PTAP_NUMERIC_MPIAIJ=102,
    1412:                MATOP_SET_VALUES_ROW = 105,
    1413:                MATOP_GET_ROW_UTRIANGULAR=108,
    1414:                MATOP_RESTORE_ROW_UTRIANGULAR=109,
    1415:                MATOP_MATSOLVE=110,
    1416:                MATOP_GET_REDUNDANTMATRIX=111
    1417:              } MatOperation;
    1418: EXTERN PetscErrorCode  MatHasOperation(Mat,MatOperation,PetscTruth*);
    1419: EXTERN PetscErrorCode  MatShellSetOperation(Mat,MatOperation,void(*)(void));
    1420: EXTERN PetscErrorCode  MatShellGetOperation(Mat,MatOperation,void(**)(void));
    1421: EXTERN PetscErrorCode  MatShellSetContext(Mat,void*);

    1423: /*
    1424:    Codes for matrices stored on disk. By default they are
    1425:  stored in a universal format. By changing the format with
    1426:  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
    1427:  be stored in a way natural for the matrix, for example dense matrices
    1428:  would be stored as dense. Matrices stored this way may only be
    1429:  read into matrices of the same time.
    1430: */
    1431: #define MATRIX_BINARY_FORMAT_DENSE -1

    1433: EXTERN PetscErrorCode  MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
    1434: EXTERN PetscErrorCode  MatISGetLocalMat(Mat,Mat*);

    1436: /*S
    1437:      MatNullSpace - Object that removes a null space from a vector, i.e.
    1438:          orthogonalizes the vector to a subsapce

    1440:    Level: advanced

    1442:   Concepts: matrix; linear operator, null space

    1444:   Users manual sections:
    1445: .   Section 4.15 Solving Singular Systems

    1447: .seealso:  MatNullSpaceCreate()
    1448: S*/
    1449: typedef struct _p_MatNullSpace* MatNullSpace;

    1451: EXTERN PetscErrorCode  MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*);
    1452: EXTERN PetscErrorCode  MatNullSpaceSetFunction(MatNullSpace,PetscErrorCode (*)(Vec,void*),void*);
    1453: EXTERN PetscErrorCode  MatNullSpaceDestroy(MatNullSpace);
    1454: EXTERN PetscErrorCode  MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
    1455: EXTERN PetscErrorCode  MatNullSpaceAttach(Mat,MatNullSpace);
    1456: EXTERN PetscErrorCode  MatNullSpaceTest(MatNullSpace,Mat);

    1458: EXTERN PetscErrorCode  MatReorderingSeqSBAIJ(Mat,IS);
    1459: EXTERN PetscErrorCode  MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
    1460: EXTERN PetscErrorCode  MatSeqSBAIJSetColumnIndices(Mat,PetscInt *);
    1461: EXTERN PetscErrorCode  MatSeqBAIJInvertBlockDiagonal(Mat);

    1463: EXTERN PetscErrorCode  MatCreateMAIJ(Mat,PetscInt,Mat*);
    1464: EXTERN PetscErrorCode  MatMAIJRedimension(Mat,PetscInt,Mat*);
    1465: EXTERN PetscErrorCode  MatMAIJGetAIJ(Mat,Mat*);

    1467: EXTERN PetscErrorCode  MatComputeExplicitOperator(Mat,Mat*);

    1469: EXTERN PetscErrorCode  MatDiagonalScaleLocal(Mat,Vec);

    1471: EXTERN PetscErrorCode  MatCreateMFFD(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
    1472: EXTERN PetscErrorCode  MatMFFDSetBase(Mat,Vec,Vec);
    1473: EXTERN PetscErrorCode  MatMFFDSetFunction(Mat,PetscErrorCode(*)(void*,Vec,Vec),void*);
    1474: EXTERN PetscErrorCode  MatMFFDSetFunctioni(Mat,PetscErrorCode (*)(void*,PetscInt,Vec,PetscScalar*));
    1475: EXTERN PetscErrorCode  MatMFFDSetFunctioniBase(Mat,PetscErrorCode (*)(void*,Vec));
    1476: EXTERN PetscErrorCode  MatMFFDAddNullSpace(Mat,MatNullSpace);
    1477: EXTERN PetscErrorCode  MatMFFDSetHHistory(Mat,PetscScalar[],PetscInt);
    1478: EXTERN PetscErrorCode  MatMFFDResetHHistory(Mat);
    1479: EXTERN PetscErrorCode  MatMFFDSetFunctionError(Mat,PetscReal);
    1480: EXTERN PetscErrorCode  MatMFFDSetPeriod(Mat,PetscInt);
    1481: EXTERN PetscErrorCode  MatMFFDGetH(Mat,PetscScalar *);
    1482: EXTERN PetscErrorCode  MatMFFDSetFromOptions(Mat);
    1483: EXTERN PetscErrorCode  MatMFFDCheckPositivity(void*,Vec,Vec,PetscScalar*);
    1484: EXTERN PetscErrorCode  MatMFFDSetCheckh(Mat,PetscErrorCode (*)(void*,Vec,Vec,PetscScalar*),void*);
    1485: EXTERN PetscErrorCode  MatMFFDDSSetUmin(Mat,PetscReal);

    1488: typedef struct _p_MatMFFD* MatMFFD;

    1490: /*E
    1491:     MatMFFDType - algorithm used to compute the h used in computing matrix-vector products via differencing of the function

    1493:    Level: beginner

    1495: .seealso: MatMFFDSetType(), MatMFFDRegister()
    1496: E*/
    1497: #define MatMFFDType const char*
    1498: #define MATMFFD_DS  "ds"
    1499: #define MATMFFD_WP  "wp"

    1501: EXTERN PetscErrorCode  MatMFFDSetType(Mat,MatMFFDType);
    1502: EXTERN PetscErrorCode  MatMFFDRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatMFFD));

    1504: /*MC
    1505:    MatMFFDRegisterDynamic - Adds a method to the MatMFFD registry.

    1507:    Synopsis:
    1508:    PetscErrorCode MatMFFDRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(MatMFFD))

    1510:    Not Collective

    1512:    Input Parameters:
    1513: +  name_solver - name of a new user-defined compute-h module
    1514: .  path - path (either absolute or relative) the library containing this solver
    1515: .  name_create - name of routine to create method context
    1516: -  routine_create - routine to create method context

    1518:    Level: developer

    1520:    Notes:
    1521:    MatMFFDRegisterDynamic() may be called multiple times to add several user-defined solvers.

    1523:    If dynamic libraries are used, then the fourth input argument (routine_create)
    1524:    is ignored.

    1526:    Sample usage:
    1527: .vb
    1528:    MatMFFDRegisterDynamic("my_h",/home/username/my_lib/lib/libO/solaris/mylib.a,
    1529:                "MyHCreate",MyHCreate);
    1530: .ve

    1532:    Then, your solver can be chosen with the procedural interface via
    1533: $     MatMFFDSetType(mfctx,"my_h")
    1534:    or at runtime via the option
    1535: $     -snes_mf_type my_h

    1537: .keywords: MatMFFD, register

    1539: .seealso: MatMFFDRegisterAll(), MatMFFDRegisterDestroy()
    1540: M*/
    1541: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    1542: #define MatMFFDRegisterDynamic(a,b,c,d) MatMFFDRegister(a,b,c,0)
    1543: #else
    1544: #define MatMFFDRegisterDynamic(a,b,c,d) MatMFFDRegister(a,b,c,d)
    1545: #endif

    1547: EXTERN PetscErrorCode  MatMFFDRegisterAll(const char[]);
    1548: EXTERN PetscErrorCode  MatMFFDRegisterDestroy(void);
    1549: EXTERN PetscErrorCode  MatMFFDDefaultSetUmin(Mat,PetscReal);
    1550: EXTERN PetscErrorCode  MatMFFDWPSetComputeNormU(Mat,PetscTruth);

    1553: EXTERN PetscErrorCode  PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
    1554: EXTERN PetscErrorCode  PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);

    1557: #endif