1 /* 2 Include file for the matrix component of PETSc 3 */ 4 #ifndef __PETSCMAT_H 5 #define __PETSCMAT_H 6 #include "petscvec.h" 7 PETSC_EXTERN_CXX_BEGIN 8 9 /*S 10 Mat - Abstract PETSc matrix object 11 12 Level: beginner 13 14 Concepts: matrix; linear operator 15 16 .seealso: MatCreate(), MatType, MatSetType() 17 S*/ 18 typedef struct _p_Mat* Mat; 19 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() 24 25 Level: beginner 26 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 MATSEQDENSE "seqdense" 41 #define MATMPIDENSE "mpidense" 42 #define MATDENSE "dense" 43 #define MATSEQBAIJ "seqbaij" 44 #define MATMPIBAIJ "mpibaij" 45 #define MATBAIJ "baij" 46 #define MATMPIADJ "mpiadj" 47 #define MATSEQSBAIJ "seqsbaij" 48 #define MATMPISBAIJ "mpisbaij" 49 #define MATSBAIJ "sbaij" 50 #define MATDAAD "daad" 51 #define MATMFFD "mffd" 52 #define MATNORMAL "normal" 53 #define MATLRC "lrc" 54 #define MATSEQAIJSPOOLES "seqaijspooles" 55 #define MATMPIAIJSPOOLES "mpiaijspooles" 56 #define MATSEQSBAIJSPOOLES "seqsbaijspooles" 57 #define MATMPISBAIJSPOOLES "mpisbaijspooles" 58 #define MATAIJSPOOLES "aijspooles" 59 #define MATSBAIJSPOOLES "sbaijspooles" 60 #define MATSUPERLU "superlu" 61 #define MATSUPERLU_DIST "superlu_dist" 62 #define MATUMFPACK "umfpack" 63 #define MATESSL "essl" 64 #define MATLUSOL "lusol" 65 #define MATAIJMUMPS "aijmumps" 66 #define MATSBAIJMUMPS "sbaijmumps" 67 #define MATDSCPACK "dscpack" 68 #define MATMATLAB "matlab" 69 #define MATSEQCSRPERM "seqcsrperm" 70 #define MATMPICSRPERM "mpicsrperm" 71 #define MATCSRPERM "csrperm" 72 #define MATSEQCRL "seqcrl" 73 #define MATMPICRL "mpicrl" 74 #define MATCRL "crl" 75 #define MATPLAPACK "plapack" 76 #define MATSCATTER "scatter" 77 #define MATBLOCKMAT "blockmat" 78 #define MATCOMPOSITE "composite" 79 #define MATSEQFFTW "seqfftw" 80 81 /* Logging support */ 82 #define MAT_FILE_COOKIE 1211216 /* used to indicate matrices in binary files */ 83 extern PetscCookie PETSCMAT_DLLEXPORT MAT_COOKIE; 84 extern PetscCookie PETSCMAT_DLLEXPORT MAT_FDCOLORING_COOKIE; 85 extern PetscCookie PETSCMAT_DLLEXPORT MAT_PARTITIONING_COOKIE; 86 extern PetscCookie PETSCMAT_DLLEXPORT MAT_NULLSPACE_COOKIE; 87 extern PetscCookie PETSCMAT_DLLEXPORT MATMFFD_COOKIE; 88 89 /*E 90 MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices() 91 or MatGetSubMatrix() are to be reused to store the new matrix values. 92 93 Level: beginner 94 95 Any additions/changes here MUST also be made in include/finclude/petscmat.h 96 97 .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices(), MatConvert() 98 E*/ 99 typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse; 100 101 /*E 102 MatGetSubMatrixOption - Indicates if matrices obtained from a call to MatGetSubMatrices() 103 include the matrix values. Currently it is only used by MatGetSeqNonzerostructure(). 104 105 Level: beginner 106 107 .seealso: MatGetSeqNonzerostructure() 108 E*/ 109 typedef enum {MAT_DO_NOT_GET_VALUES,MAT_GET_VALUES} MatGetSubMatrixOption; 110 111 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInitializePackage(const char[]); 112 113 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreate(MPI_Comm,Mat*); 114 PetscPolymorphicFunction(MatCreate,(MPI_Comm comm),(comm,&A),Mat,A) 115 PetscPolymorphicFunction(MatCreate,(),(PETSC_COMM_WORLD,&A),Mat,A) 116 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetSizes(Mat,PetscInt,PetscInt,PetscInt,PetscInt); 117 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetType(Mat,MatType); 118 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetFromOptions(Mat); 119 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUpPreallocation(Mat); 120 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegisterAll(const char[]); 121 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat)); 122 123 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetOptionsPrefix(Mat,const char[]); 124 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAppendOptionsPrefix(Mat,const char[]); 125 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOptionsPrefix(Mat,const char*[]); 126 127 /*MC 128 MatRegisterDynamic - Adds a new matrix type 129 130 Synopsis: 131 PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat)) 132 133 Not Collective 134 135 Input Parameters: 136 + name - name of a new user-defined matrix type 137 . path - path (either absolute or relative) the library containing this solver 138 . name_create - name of routine to create method context 139 - routine_create - routine to create method context 140 141 Notes: 142 MatRegisterDynamic() may be called multiple times to add several user-defined solvers. 143 144 If dynamic libraries are used, then the fourth input argument (routine_create) 145 is ignored. 146 147 Sample usage: 148 .vb 149 MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a, 150 "MyMatCreate",MyMatCreate); 151 .ve 152 153 Then, your solver can be chosen with the procedural interface via 154 $ MatSetType(Mat,"my_mat") 155 or at runtime via the option 156 $ -mat_type my_mat 157 158 Level: advanced 159 160 Notes: ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values. 161 If your function is not being put into a shared library then use VecRegister() instead 162 163 .keywords: Mat, register 164 165 .seealso: MatRegisterAll(), MatRegisterDestroy() 166 167 M*/ 168 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 169 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0) 170 #else 171 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d) 172 #endif 173 174 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegisterAll(const char[]); 175 extern PetscTruth MatRegisterAllCalled; 176 extern PetscFList MatList; 177 178 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*); 179 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*); 180 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 181 PetscPolymorphicFunction(MatCreateSeqAIJ,(PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[]),(PETSC_COMM_SELF,m,n,nz,nnz,&A),Mat,A) 182 PetscPolymorphicFunction(MatCreateSeqAIJ,(PetscInt m,PetscInt n,PetscInt nz),(PETSC_COMM_SELF,m,n,nz,PETSC_NULL,&A),Mat,A) 183 PetscPolymorphicFunction(MatCreateSeqAIJ,(PetscInt m,PetscInt n,const PetscInt nnz[]),(PETSC_COMM_SELF,m,n,0,nnz,&A),Mat,A) 184 PetscPolymorphicFunction(MatCreateSeqAIJ,(PetscInt m,PetscInt n),(PETSC_COMM_SELF,m,n,0,PETSC_NULL,&A),Mat,A) 185 PetscPolymorphicSubroutine(MatCreateSeqAIJ,(PetscInt m,PetscInt n,PetscInt nz,Mat *A),(PETSC_COMM_SELF,m,n,nz,PETSC_NULL,A)) 186 PetscPolymorphicSubroutine(MatCreateSeqAIJ,(PetscInt m,PetscInt n,const PetscInt nnz[],Mat *A),(PETSC_COMM_SELF,m,n,0,nnz,A)) 187 PetscPolymorphicSubroutine(MatCreateSeqAIJ,(PetscInt m,PetscInt n,Mat *A),(PETSC_COMM_SELF,m,n,0,PETSC_NULL,A)) 188 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 189 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) 190 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) 191 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) 192 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) 193 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)) 194 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)) 195 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)) 196 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) 197 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) 198 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) 199 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) 200 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)) 201 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)) 202 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)) 203 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat *); 204 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAIJWithSplitArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],PetscInt[],PetscInt[],PetscScalar[],Mat*); 205 206 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 207 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 208 PetscPolymorphicFunction(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[]),(PETSC_COMM_SELF,bs,m,n,nz,nnz,&A),Mat,A) 209 PetscPolymorphicFunction(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz),(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,&A),Mat,A) 210 PetscPolymorphicFunction(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[]),(PETSC_COMM_SELF,bs,m,n,0,nnz,&A),Mat,A) 211 PetscPolymorphicFunction(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n),(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,&A),Mat,A) 212 PetscPolymorphicSubroutine(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,Mat *A),(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,A)) 213 PetscPolymorphicSubroutine(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[],Mat *A),(PETSC_COMM_SELF,bs,m,n,0,nnz,A)) 214 PetscPolymorphicSubroutine(MatCreateSeqBAIJ,(PetscInt bs,PetscInt m,PetscInt n,Mat *A),(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,A)) 215 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 216 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) 217 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) 218 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) 219 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) 220 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)) 221 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)) 222 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)) 223 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) 224 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) 225 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) 226 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) 227 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)) 228 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)) 229 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)) 230 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*); 231 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 232 PetscPolymorphicFunction(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,const PetscInt nnz[]),(PETSC_COMM_SELF,bs,m,n,nz,nnz,&A),Mat,A) 233 PetscPolymorphicFunction(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz),(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,&A),Mat,A) 234 PetscPolymorphicFunction(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[]),(PETSC_COMM_SELF,bs,m,n,0,nnz,&A),Mat,A) 235 PetscPolymorphicFunction(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n),(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,&A),Mat,A) 236 PetscPolymorphicSubroutine(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,PetscInt nz,Mat *A),(PETSC_COMM_SELF,bs,m,n,nz,PETSC_NULL,A)) 237 PetscPolymorphicSubroutine(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,const PetscInt nnz[],Mat *A),(PETSC_COMM_SELF,bs,m,n,0,nnz,A)) 238 PetscPolymorphicSubroutine(MatCreateSeqSBAIJ,(PetscInt bs,PetscInt m,PetscInt n,Mat *A),(PETSC_COMM_SELF,bs,m,n,0,PETSC_NULL,A)) 239 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 240 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) 241 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) 242 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) 243 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) 244 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)) 245 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)) 246 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)) 247 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) 248 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) 249 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) 250 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) 251 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)) 252 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)) 253 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)) 254 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*); 255 PetscPolymorphicFunction(MatCreateShell,(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,void *ctx),(comm,m,n,M,N,ctx,&A),Mat,A) 256 PetscPolymorphicFunction(MatCreateShell,(PetscInt m,PetscInt n,PetscInt M,PetscInt N,void *ctx),(PETSC_COMM_WORLD,m,n,M,N,ctx,&A),Mat,A) 257 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*); 258 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateNormal(Mat,Mat*); 259 PetscPolymorphicFunction(MatCreateNormal,(Mat mat),(mat,&A),Mat,A) 260 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateLRC(Mat,Mat,Mat,Mat*); 261 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateIS(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,ISLocalToGlobalMapping,Mat*); 262 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqCRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 263 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPICRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 264 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateScatter(MPI_Comm,VecScatter,Mat*); 265 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScatterSetVecScatter(Mat,VecScatter); 266 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScatterGetVecScatter(Mat,VecScatter*); 267 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateBlockMat(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,Mat*); 268 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCompositeAddMat(Mat,Mat); 269 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCompositeMerge(Mat); 270 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateComposite(MPI_Comm,PetscInt,const Mat*,Mat*); 271 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqFFTW(MPI_Comm,PetscInt,const PetscInt[],Mat*); 272 273 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUp(Mat); 274 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroy(Mat); 275 276 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConjugate(Mat); 277 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRealPart(Mat); 278 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatImaginaryPart(Mat); 279 280 /* ------------------------------------------------------------*/ 281 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 282 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 283 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesRow(Mat,PetscInt,const PetscScalar[]); 284 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesRowLocal(Mat,PetscInt,const PetscScalar[]); 285 286 /*S 287 MatStencil - Data structure (C struct) for storing information about a single row or 288 column of a matrix as index on an associated grid. 289 290 Level: beginner 291 292 Concepts: matrix; linear operator 293 294 .seealso: MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil() 295 S*/ 296 typedef struct { 297 PetscInt k,j,i,c; 298 } MatStencil; 299 300 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 301 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 302 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt); 303 304 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetColoring(Mat,ISColoring); 305 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesAdic(Mat,void*); 306 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesAdifor(Mat,PetscInt,void*); 307 308 /*E 309 MatAssemblyType - Indicates if the matrix is now to be used, or if you plan 310 to continue to add values to it 311 312 Level: beginner 313 314 .seealso: MatAssemblyBegin(), MatAssemblyEnd() 315 E*/ 316 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 317 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssemblyBegin(Mat,MatAssemblyType); 318 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssemblyEnd(Mat,MatAssemblyType); 319 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssembled(Mat,PetscTruth*); 320 321 322 323 /*E 324 MatOption - Options that may be set for a matrix and its behavior or storage 325 326 Level: beginner 327 328 Any additions/changes here MUST also be made in include/finclude/petscmat.h 329 330 .seealso: MatSetOption() 331 E*/ 332 typedef enum {MAT_ROW_ORIENTED,MAT_NEW_NONZERO_LOCATIONS, 333 MAT_SYMMETRIC, 334 MAT_STRUCTURALLY_SYMMETRIC, 335 MAT_NEW_DIAGONALS,MAT_IGNORE_OFF_PROC_ENTRIES, 336 MAT_NEW_NONZERO_LOCATION_ERR, 337 MAT_NEW_NONZERO_ALLOCATION_ERR,MAT_USE_HASH_TABLE, 338 MAT_KEEP_ZEROED_ROWS,MAT_IGNORE_ZERO_ENTRIES, 339 MAT_USE_INODES, 340 MAT_HERMITIAN, 341 MAT_SYMMETRY_ETERNAL, 342 MAT_USE_COMPRESSEDROW, 343 MAT_IGNORE_LOWER_TRIANGULAR,MAT_ERROR_LOWER_TRIANGULAR, 344 MAT_GETROW_UPPERTRIANGULAR} MatOption; 345 extern const char *MatOptions[]; 346 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetOption(Mat,MatOption,PetscTruth); 347 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetType(Mat,MatType*); 348 PetscPolymorphicFunction(MatGetType,(Mat mat),(mat,&t),MatType,t) 349 350 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]); 351 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 352 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 353 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowUpperTriangular(Mat); 354 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRowUpperTriangular(Mat); 355 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 356 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 357 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumnVector(Mat,Vec,PetscInt); 358 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetArray(Mat,PetscScalar *[]); 359 PetscPolymorphicFunction(MatGetArray,(Mat mat),(mat,&a),PetscScalar*,a) 360 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreArray(Mat,PetscScalar *[]); 361 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBlockSize(Mat,PetscInt *); 362 PetscPolymorphicFunction(MatGetBlockSize,(Mat mat),(mat,&a),PetscInt,a) 363 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetBlockSize(Mat,PetscInt); 364 365 366 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMult(Mat,Vec,Vec); 367 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultAdd(Mat,Vec,Vec,Vec); 368 PetscPolymorphicSubroutine(MatMultAdd,(Mat A,Vec x,Vec y),(A,x,y,y)) 369 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTranspose(Mat,Vec,Vec); 370 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*); 371 PetscPolymorphicFunction(MatIsTranspose,(Mat A,Mat B,PetscReal tol),(A,B,tol,&t),PetscTruth,t) 372 PetscPolymorphicFunction(MatIsTranspose,(Mat A,Mat B),(A,B,0,&t),PetscTruth,t) 373 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitianTranspose(Mat,Mat,PetscReal,PetscTruth*); 374 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeAdd(Mat,Vec,Vec,Vec); 375 PetscPolymorphicSubroutine(MatMultTransposeAdd,(Mat A,Vec x,Vec y),(A,x,y,y)) 376 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultConstrained(Mat,Vec,Vec); 377 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeConstrained(Mat,Vec,Vec); 378 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatSolve(Mat,Mat,Mat); 379 380 /*E 381 MatDuplicateOption - Indicates if a duplicated sparse matrix should have 382 its numerical values copied over or just its nonzero structure. 383 384 Level: beginner 385 386 Any additions/changes here MUST also be made in include/finclude/petscmat.h 387 388 .seealso: MatDuplicate() 389 E*/ 390 typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption; 391 392 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvert(Mat,MatType,MatReuse,Mat*); 393 PetscPolymorphicFunction(MatConvert,(Mat A,MatType t),(A,t,MAT_INITIAL_MATRIX,&a),Mat,a) 394 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDuplicate(Mat,MatDuplicateOption,Mat*); 395 PetscPolymorphicFunction(MatDuplicate,(Mat A,MatDuplicateOption o),(A,o,&a),Mat,a) 396 PetscPolymorphicFunction(MatDuplicate,(Mat A),(A,MAT_COPY_VALUES,&a),Mat,a) 397 398 /*E 399 MatStructure - Indicates if the matrix has the same nonzero structure 400 401 Level: beginner 402 403 Any additions/changes here MUST also be made in include/finclude/petscmat.h 404 405 .seealso: MatCopy(), KSPSetOperators(), PCSetOperators() 406 E*/ 407 typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure; 408 409 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCopy(Mat,Mat,MatStructure); 410 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatView(Mat,PetscViewer); 411 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsSymmetric(Mat,PetscReal,PetscTruth*); 412 PetscPolymorphicFunction(MatIsSymmetric,(Mat A,PetscReal tol),(A,tol,&t),PetscTruth,t) 413 PetscPolymorphicFunction(MatIsSymmetric,(Mat A),(A,0,&t),PetscTruth,t) 414 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsStructurallySymmetric(Mat,PetscTruth*); 415 PetscPolymorphicFunction(MatIsStructurallySymmetric,(Mat A),(A,&t),PetscTruth,t) 416 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitian(Mat,PetscReal,PetscTruth*); 417 PetscPolymorphicFunction(MatIsHermitian,(Mat A),(A,0,&t),PetscTruth,t) 418 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*); 419 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitianKnown(Mat,PetscTruth*,PetscTruth*); 420 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMissingDiagonal(Mat,PetscTruth *,PetscInt *); 421 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLoad(PetscViewer,MatType,Mat*); 422 PetscPolymorphicFunction(MatLoad,(PetscViewer v,MatType t),(v,t,&a),Mat,a) 423 424 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *); 425 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *); 426 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *); 427 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *); 428 429 /*S 430 MatInfo - Context of matrix information, used with MatGetInfo() 431 432 In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE 433 434 Level: intermediate 435 436 Concepts: matrix^nonzero information 437 438 .seealso: MatGetInfo(), MatInfoType 439 S*/ 440 typedef struct { 441 PetscLogDouble rows_global,columns_global; /* number of global rows and columns */ 442 PetscLogDouble rows_local,columns_local; /* number of local rows and columns */ 443 PetscLogDouble block_size; /* block size */ 444 PetscLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 445 PetscLogDouble memory; /* memory allocated */ 446 PetscLogDouble assemblies; /* number of matrix assemblies called */ 447 PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 448 PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 449 PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 450 } MatInfo; 451 452 /*E 453 MatInfoType - Indicates if you want information about the local part of the matrix, 454 the entire parallel matrix or the maximum over all the local parts. 455 456 Level: beginner 457 458 Any additions/changes here MUST also be made in include/finclude/petscmat.h 459 460 .seealso: MatGetInfo(), MatInfo 461 E*/ 462 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 463 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetInfo(Mat,MatInfoType,MatInfo*); 464 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatValid(Mat,PetscTruth*); 465 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetDiagonal(Mat,Vec); 466 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowMax(Mat,Vec,PetscInt[]); 467 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowMin(Mat,Vec,PetscInt[]); 468 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowMaxAbs(Mat,Vec,PetscInt[]); 469 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowSum(Mat,Vec); 470 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatTranspose(Mat,Mat*); 471 PetscPolymorphicFunction(MatTranspose,(Mat A),(A,&t),Mat,t) 472 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPermute(Mat,IS,IS,Mat *); 473 PetscPolymorphicFunction(MatPermute,(Mat A,IS is1,IS is2),(A,is1,is2,&t),Mat,t) 474 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *); 475 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScale(Mat,Vec,Vec); 476 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalSet(Mat,Vec,InsertMode); 477 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatEqual(Mat,Mat,PetscTruth*); 478 PetscPolymorphicFunction(MatEqual,(Mat A,Mat B),(A,B,&t),PetscTruth,t) 479 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultEqual(Mat,Mat,PetscInt,PetscTruth*); 480 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultAddEqual(Mat,Mat,PetscInt,PetscTruth*); 481 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeEqual(Mat,Mat,PetscInt,PetscTruth*); 482 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscTruth*); 483 484 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNorm(Mat,NormType,PetscReal *); 485 PetscPolymorphicFunction(MatNorm,(Mat A,NormType t),(A,t,&n),PetscReal,n) 486 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroEntries(Mat); 487 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRows(Mat,PetscInt,const PetscInt [],PetscScalar); 488 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRowsIS(Mat,IS,PetscScalar); 489 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroColumns(Mat,PetscInt,const PetscInt [],const PetscScalar*); 490 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroColumnsIS(Mat,IS,const PetscScalar*); 491 492 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatUseScaledForm(Mat,PetscTruth); 493 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScaleSystem(Mat,Vec,Vec); 494 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatUnScaleSystem(Mat,Vec,Vec); 495 496 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSize(Mat,PetscInt*,PetscInt*); 497 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalSize(Mat,PetscInt*,PetscInt*); 498 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOwnershipRange(Mat,PetscInt*,PetscInt*); 499 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOwnershipRanges(Mat,const PetscInt**); 500 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOwnershipRangeColumn(Mat,PetscInt*,PetscInt*); 501 502 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 503 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroyMatrices(PetscInt,Mat *[]); 504 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *); 505 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrixRaw(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscInt,MatReuse,Mat *); 506 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSeqNonzeroStructure(Mat,Mat *[]); 507 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroySeqNonzeroStructure(Mat *[]); 508 509 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*); 510 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*); 511 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPISymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*); 512 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPINumeric(Mat,Mat); 513 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroy_MPIAIJ_SeqsToMPI(Mat); 514 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalMat(Mat,MatReuse,Mat*); 515 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*); 516 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*); 517 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBrowsOfAoCols(Mat,Mat,MatReuse,PetscInt**,MatScalar**,Mat*); 518 #if defined (PETSC_USE_CTABLE) 519 #include "petscctable.h" 520 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetCommunicationStructs(Mat, Vec *, PetscTable *, VecScatter *); 521 #else 522 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetCommunicationStructs(Mat, Vec *, PetscInt *[], VecScatter *); 523 #endif 524 525 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt); 526 527 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*); 528 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*); 529 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultNumeric(Mat,Mat,Mat); 530 531 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*); 532 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*); 533 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAPNumeric(Mat,Mat,Mat); 534 535 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*); 536 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*); 537 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTransposeNumeric(Mat,Mat,Mat); 538 539 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAXPY(Mat,PetscScalar,Mat,MatStructure); 540 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAYPX(Mat,PetscScalar,Mat,MatStructure); 541 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCompress(Mat); 542 543 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScale(Mat,PetscScalar); 544 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShift(Mat,PetscScalar); 545 546 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping); 547 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping); 548 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRowsLocal(Mat,PetscInt,const PetscInt [],PetscScalar); 549 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRowsLocalIS(Mat,IS,PetscScalar); 550 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 551 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 552 553 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStashSetInitialSize(Mat,PetscInt,PetscInt); 554 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 555 556 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInterpolate(Mat,Vec,Vec); 557 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInterpolateAdd(Mat,Vec,Vec,Vec); 558 PetscPolymorphicSubroutine(MatInterpolateAdd,(Mat A,Vec x,Vec y),(A,x,y,y)) 559 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestrict(Mat,Vec,Vec); 560 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetVecs(Mat,Vec*,Vec*); 561 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRedundantMatrix(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*); 562 563 /*MC 564 MatSetValue - Set a single entry into a matrix. 565 566 Not collective 567 568 Input Parameters: 569 + m - the matrix 570 . row - the row location of the entry 571 . col - the column location of the entry 572 . value - the value to insert 573 - mode - either INSERT_VALUES or ADD_VALUES 574 575 Notes: 576 For efficiency one should use MatSetValues() and set several or many 577 values simultaneously if possible. 578 579 Level: beginner 580 581 .seealso: MatSetValues(), MatSetValueLocal() 582 M*/ 583 PETSC_STATIC_INLINE PetscErrorCode MatSetValue(Mat v,PetscInt i,PetscInt j,PetscScalar va,InsertMode mode) {return MatSetValues(v,1,&i,1,&j,&va,mode);} 584 585 PETSC_STATIC_INLINE PetscErrorCode MatGetValue(Mat v,PetscInt i,PetscInt j,PetscScalar *va) {return MatGetValues(v,1,&i,1,&j,va);} 586 587 PETSC_STATIC_INLINE PetscErrorCode MatSetValueLocal(Mat v,PetscInt i,PetscInt j,PetscScalar va,InsertMode mode) {return MatSetValuesLocal(v,1,&i,1,&j,&va,mode);} 588 589 /*MC 590 MatPreallocateInitialize - Begins the block of code that will count the number of nonzeros per 591 row in a matrix providing the data that one can use to correctly preallocate the matrix. 592 593 Synopsis: 594 PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 595 596 Collective on MPI_Comm 597 598 Input Parameters: 599 + comm - the communicator that will share the eventually allocated matrix 600 . nrows - the number of LOCAL rows in the matrix 601 - ncols - the number of LOCAL columns in the matrix 602 603 Output Parameters: 604 + dnz - the array that will be passed to the matrix preallocation routines 605 - ozn - the other array passed to the matrix preallocation routines 606 607 608 Level: intermediate 609 610 Notes: 611 See the chapter in the users manual on performance for more details 612 613 Do not malloc or free dnz and onz, that is handled internally by these routines 614 615 Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices) 616 617 This is a MACRO not a function because it has a leading { that is closed by PetscPreallocateFinalize(). 618 619 Concepts: preallocation^Matrix 620 621 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 622 MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal() 623 M*/ 624 #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \ 625 { \ 626 PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 627 _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 628 _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 629 _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\ 630 _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 631 632 /*MC 633 MatPreallocateSymmetricInitialize - Begins the block of code that will count the number of nonzeros per 634 row in a matrix providing the data that one can use to correctly preallocate the matrix. 635 636 Synopsis: 637 PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 638 639 Collective on MPI_Comm 640 641 Input Parameters: 642 + comm - the communicator that will share the eventually allocated matrix 643 . nrows - the number of LOCAL rows in the matrix 644 - ncols - the number of LOCAL columns in the matrix 645 646 Output Parameters: 647 + dnz - the array that will be passed to the matrix preallocation routines 648 - ozn - the other array passed to the matrix preallocation routines 649 650 651 Level: intermediate 652 653 Notes: 654 See the chapter in the users manual on performance for more details 655 656 Do not malloc or free dnz and onz, that is handled internally by these routines 657 658 This is a MACRO not a function because it has a leading { that is closed by PetscPreallocateFinalize(). 659 660 Concepts: preallocation^Matrix 661 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_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 669 _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 670 _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\ 671 _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 672 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 676 677 Synopsis: 678 PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 679 680 Not Collective 681 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 690 691 692 Level: intermediate 693 694 Notes: 695 See the chapter in the users manual on performance for more details 696 697 Do not malloc or free dnz and onz, that is handled internally by these routines 698 699 Concepts: preallocation^Matrix 700 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_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 708 _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 709 for (__l=0;__l<nrows;__l++) {\ 710 _4_ierr = 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 717 718 Synopsis: 719 PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 720 721 Not Collective 722 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 731 732 733 Level: intermediate 734 735 Notes: 736 See the chapter in the users manual on performance for more details 737 738 Do not malloc or free dnz and onz that is handled internally by these routines 739 740 Concepts: preallocation^Matrix 741 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_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 749 _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 750 for (__l=0;__l<nrows;__l++) {\ 751 _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 752 }\ 753 } 754 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 758 759 Synopsis: 760 PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 761 762 Not Collective 763 764 Input Parameters: 765 + row - the row 766 . ncols - the number of columns in the matrix 767 - cols - the columns indicated 768 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 772 773 774 Level: intermediate 775 776 Notes: 777 See the chapter in the users manual on performance for more details 778 779 Do not malloc or free dnz and onz that is handled internally by these routines 780 781 This is a MACRO not a function because it uses variables declared in MatPreallocateInitialize(). 782 783 Concepts: preallocation^Matrix 784 785 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 786 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 787 M*/ 788 #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\ 789 { PetscInt __i; \ 790 if (row < __rstart) SETERRQ2(PETSC_ERR_ARG_OUTOFRANGE,"Trying to set preallocation for row %D less than first local row %D",row,__rstart);\ 791 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);\ 792 for (__i=0; __i<nc; __i++) {\ 793 if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \ 794 else dnz[row - __rstart]++;\ 795 }\ 796 } 797 798 /*MC 799 MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 800 inserted using a local number of the rows and columns 801 802 Synopsis: 803 PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 804 805 Not Collective 806 807 Input Parameters: 808 + nrows - the number of rows indicated 809 . rows - the indices of the rows 810 . ncols - the number of columns in the matrix 811 . cols - the columns indicated 812 . dnz - the array that will be passed to the matrix preallocation routines 813 - ozn - the other array passed to the matrix preallocation routines 814 815 816 Level: intermediate 817 818 Notes: 819 See the chapter in the users manual on performance for more details 820 821 Do not malloc or free dnz and onz that is handled internally by these routines 822 823 This is a MACRO not a function because it uses variables declared in MatPreallocateInitialize(). 824 825 Concepts: preallocation^Matrix 826 827 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 828 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 829 M*/ 830 #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\ 831 { PetscInt __i; \ 832 for (__i=0; __i<nc; __i++) {\ 833 if (cols[__i] >= __end) onz[row - __rstart]++; \ 834 else if (cols[__i] >= row) dnz[row - __rstart]++;\ 835 }\ 836 } 837 838 /*MC 839 MatPreallocateFinalize - Ends the block of code that will count the number of nonzeros per 840 row in a matrix providing the data that one can use to correctly preallocate the matrix. 841 842 Synopsis: 843 PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz) 844 845 Collective on MPI_Comm 846 847 Input Parameters: 848 + dnz - the array that will be passed to the matrix preallocation routines 849 - ozn - the other array passed to the matrix preallocation routines 850 851 852 Level: intermediate 853 854 Notes: 855 See the chapter in the users manual on performance for more details 856 857 Do not malloc or free dnz and onz that is handled internally by these routines 858 859 This is a MACRO not a function because it closes the { started in MatPreallocateInitialize(). 860 861 Concepts: preallocation^Matrix 862 863 .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 864 MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal() 865 M*/ 866 #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);} 867 868 869 870 /* Routines unique to particular data structures */ 871 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellGetContext(Mat,void **); 872 PetscPolymorphicFunction(MatShellGetContext,(Mat A),(A,&t),void*,t) 873 874 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInodeAdjustForInodes(Mat,IS*,IS*); 875 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInodeGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *); 876 877 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetColumnIndices(Mat,PetscInt[]); 878 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJSetColumnIndices(Mat,PetscInt[]); 879 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 880 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 881 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqSBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 882 883 #define MAT_SKIP_ALLOCATION -4 884 885 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 886 PetscPolymorphicSubroutine(MatSeqBAIJSetPreallocation,(Mat A,PetscInt bs,const PetscInt nnz[]),(A,bs,0,nnz)) 887 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 888 PetscPolymorphicSubroutine(MatSeqSBAIJSetPreallocation,(Mat A,PetscInt bs,const PetscInt nnz[]),(A,bs,0,nnz)) 889 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]); 890 PetscPolymorphicSubroutine(MatSeqAIJSetPreallocation,(Mat A,const PetscInt nnz[]),(A,0,nnz)) 891 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDensePreallocation(Mat,PetscScalar[]); 892 893 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 894 PetscPolymorphicSubroutine(MatMPIBAIJSetPreallocation,(Mat A,PetscInt bs,const PetscInt nnz[],const PetscInt onz[]),(A,bs,0,nnz,0,onz)) 895 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 896 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 897 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetPreallocationCSR(Mat,const PetscInt [],const PetscInt [],const PetscScalar []); 898 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]); 899 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]); 900 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]); 901 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIDenseSetPreallocation(Mat,PetscScalar[]); 902 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDenseSetPreallocation(Mat,PetscScalar[]); 903 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]); 904 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]); 905 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]); 906 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAdicSetLocalFunction(Mat,void (*)(void)); 907 908 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDenseSetLDA(Mat,PetscInt); 909 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDenseGetLocalMatrix(Mat,Mat*); 910 911 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStoreValues(Mat); 912 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRetrieveValues(Mat); 913 914 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDAADSetCtx(Mat,void*); 915 916 /* 917 These routines are not usually accessed directly, rather solving is 918 done through the KSP and PC interfaces. 919 */ 920 921 /*E 922 MatOrderingType - String with the name of a PETSc matrix ordering or the creation function 923 with an optional dynamic library name, for example 924 http://www.mcs.anl.gov/petsc/lib.a:orderingcreate() 925 926 Level: beginner 927 928 Cannot use const because the PC objects manipulate the string 929 930 .seealso: MatGetOrdering() 931 E*/ 932 #define MatOrderingType char* 933 #define MATORDERING_NATURAL "natural" 934 #define MATORDERING_ND "nd" 935 #define MATORDERING_1WD "1wd" 936 #define MATORDERING_RCM "rcm" 937 #define MATORDERING_QMD "qmd" 938 #define MATORDERING_ROWLENGTH "rowlength" 939 #define MATORDERING_DSC_ND "dsc_nd" 940 #define MATORDERING_DSC_MMD "dsc_mmd" 941 #define MATORDERING_DSC_MDF "dsc_mdf" 942 #define MATORDERING_CONSTRAINED "constrained" 943 #define MATORDERING_IDENTITY "identity" 944 #define MATORDERING_REVERSE "reverse" 945 946 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOrdering(Mat,const MatOrderingType,IS*,IS*); 947 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOrderingList(PetscFList *list); 948 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*)); 949 950 /*MC 951 MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the 952 matrix package. 953 954 Synopsis: 955 PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering)) 956 957 Not Collective 958 959 Input Parameters: 960 + sname - name of ordering (for example MATORDERING_ND) 961 . path - location of library where creation routine is 962 . name - name of function that creates the ordering type,a string 963 - function - function pointer that creates the ordering 964 965 Level: developer 966 967 If dynamic libraries are used, then the fourth input argument (function) 968 is ignored. 969 970 Sample usage: 971 .vb 972 MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a, 973 "MyOrder",MyOrder); 974 .ve 975 976 Then, your partitioner can be chosen with the procedural interface via 977 $ MatOrderingSetType(part,"my_order) 978 or at runtime via the option 979 $ -pc_factor_mat_ordering_type my_order 980 981 ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values. 982 983 .keywords: matrix, ordering, register 984 985 .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll() 986 M*/ 987 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 988 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 989 #else 990 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 991 #endif 992 993 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegisterDestroy(void); 994 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegisterAll(const char[]); 995 extern PetscTruth MatOrderingRegisterAllCalled; 996 extern PetscFList MatOrderingList; 997 998 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS); 999 1000 /*S 1001 MatFactorInfo - Data passed into the matrix factorization routines 1002 1003 In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE, that is use 1004 $ MatFactorInfo info(MAT_FACTORINFO_SIZE) 1005 1006 Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC. 1007 1008 You can use MatFactorInfoInitialize() to set default values. 1009 1010 Level: developer 1011 1012 .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(), 1013 MatFactorInfoInitialize() 1014 1015 S*/ 1016 typedef struct { 1017 PetscReal shiftnz; /* scaling of identity added to matrix to prevent zero pivots */ 1018 PetscReal shiftpd; /* if true, shift until positive pivots */ 1019 PetscReal shift_fraction; /* record shift fraction taken */ 1020 PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 1021 PetscReal dt; /* drop tolerance */ 1022 PetscReal dtcol; /* tolerance for pivoting */ 1023 PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 1024 PetscReal fill; /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */ 1025 PetscReal levels; /* ICC/ILU(levels) */ 1026 PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 1027 factorization may be faster if do not pivot */ 1028 PetscReal shiftinblocks; /* if block in block factorization has zero pivot then shift diagonal until non-singular */ 1029 PetscReal zeropivot; /* pivot is called zero if less than this */ 1030 } MatFactorInfo; 1031 1032 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFactorInfoInitialize(MatFactorInfo*); 1033 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactor(Mat,IS,MatFactorInfo*); 1034 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 1035 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactorNumeric(Mat,MatFactorInfo*,Mat*); 1036 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactor(Mat,IS,IS,MatFactorInfo*); 1037 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUFactor(Mat,IS,IS,MatFactorInfo*); 1038 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 1039 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 1040 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 1041 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatICCFactor(Mat,IS,MatFactorInfo*); 1042 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactorNumeric(Mat,MatFactorInfo*,Mat*); 1043 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUDTFactor(Mat,IS,IS,MatFactorInfo*,Mat *); 1044 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*); 1045 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolve(Mat,Vec,Vec); 1046 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatForwardSolve(Mat,Vec,Vec); 1047 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatBackwardSolve(Mat,Vec,Vec); 1048 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveAdd(Mat,Vec,Vec,Vec); 1049 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveTranspose(Mat,Vec,Vec); 1050 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 1051 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolves(Mat,Vecs,Vecs); 1052 1053 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUnfactored(Mat); 1054 1055 /*E 1056 MatSORType - What type of (S)SOR to perform 1057 1058 Level: beginner 1059 1060 May be bitwise ORd together 1061 1062 Any additions/changes here MUST also be made in include/finclude/petscmat.h 1063 1064 MatSORType may be bitwise ORd together, so do not change the numbers 1065 1066 .seealso: MatRelax(), MatPBRelax() 1067 E*/ 1068 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 1069 SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 1070 SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 1071 SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 1072 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 1073 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 1074 1075 /* 1076 These routines are for efficiently computing Jacobians via finite differences. 1077 */ 1078 1079 /*E 1080 MatColoringType - String with the name of a PETSc matrix coloring or the creation function 1081 with an optional dynamic library name, for example 1082 http://www.mcs.anl.gov/petsc/lib.a:coloringcreate() 1083 1084 Level: beginner 1085 1086 .seealso: MatGetColoring() 1087 E*/ 1088 #define MatColoringType const char* 1089 #define MATCOLORING_NATURAL "natural" 1090 #define MATCOLORING_SL "sl" 1091 #define MATCOLORING_LF "lf" 1092 #define MATCOLORING_ID "id" 1093 1094 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColoring(Mat,MatColoringType,ISColoring*); 1095 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,MatColoringType,ISColoring *)); 1096 1097 /*MC 1098 MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the 1099 matrix package. 1100 1101 Synopsis: 1102 PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring)) 1103 1104 Not Collective 1105 1106 Input Parameters: 1107 + sname - name of Coloring (for example MATCOLORING_SL) 1108 . path - location of library where creation routine is 1109 . name - name of function that creates the Coloring type, a string 1110 - function - function pointer that creates the coloring 1111 1112 Level: developer 1113 1114 If dynamic libraries are used, then the fourth input argument (function) 1115 is ignored. 1116 1117 Sample usage: 1118 .vb 1119 MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a, 1120 "MyColor",MyColor); 1121 .ve 1122 1123 Then, your partitioner can be chosen with the procedural interface via 1124 $ MatColoringSetType(part,"my_color") 1125 or at runtime via the option 1126 $ -mat_coloring_type my_color 1127 1128 $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 1129 1130 .keywords: matrix, Coloring, register 1131 1132 .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll() 1133 M*/ 1134 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1135 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 1136 #else 1137 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 1138 #endif 1139 1140 extern PetscTruth MatColoringRegisterAllCalled; 1141 1142 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegisterAll(const char[]); 1143 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegisterDestroy(void); 1144 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*); 1145 1146 /*S 1147 MatFDColoring - Object for computing a sparse Jacobian via finite differences 1148 and coloring 1149 1150 Level: beginner 1151 1152 Concepts: coloring, sparse Jacobian, finite differences 1153 1154 .seealso: MatFDColoringCreate() 1155 S*/ 1156 typedef struct _p_MatFDColoring* MatFDColoring; 1157 1158 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 1159 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringDestroy(MatFDColoring); 1160 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringView(MatFDColoring,PetscViewer); 1161 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*); 1162 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetFunction(MatFDColoring,PetscErrorCode (**)(void),void**); 1163 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal); 1164 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFrequency(MatFDColoring,PetscInt); 1165 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetFrequency(MatFDColoring,PetscInt*); 1166 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFromOptions(MatFDColoring); 1167 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 1168 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *); 1169 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetRecompute(MatFDColoring); 1170 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetF(MatFDColoring,Vec); 1171 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]); 1172 /* 1173 These routines are for partitioning matrices: currently used only 1174 for adjacency matrix, MatCreateMPIAdj(). 1175 */ 1176 1177 /*S 1178 MatPartitioning - Object for managing the partitioning of a matrix or graph 1179 1180 Level: beginner 1181 1182 Concepts: partitioning 1183 1184 .seealso: MatPartitioningCreate(), MatPartitioningType 1185 S*/ 1186 typedef struct _p_MatPartitioning* MatPartitioning; 1187 1188 /*E 1189 MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function 1190 with an optional dynamic library name, for example 1191 http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate() 1192 1193 Level: beginner 1194 1195 .seealso: MatPartitioningCreate(), MatPartitioning 1196 E*/ 1197 #define MatPartitioningType const char* 1198 #define MAT_PARTITIONING_CURRENT "current" 1199 #define MAT_PARTITIONING_SQUARE "square" 1200 #define MAT_PARTITIONING_PARMETIS "parmetis" 1201 #define MAT_PARTITIONING_CHACO "chaco" 1202 #define MAT_PARTITIONING_JOSTLE "jostle" 1203 #define MAT_PARTITIONING_PARTY "party" 1204 #define MAT_PARTITIONING_SCOTCH "scotch" 1205 1206 1207 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningCreate(MPI_Comm,MatPartitioning*); 1208 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetType(MatPartitioning,MatPartitioningType); 1209 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetNParts(MatPartitioning,PetscInt); 1210 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetAdjacency(MatPartitioning,Mat); 1211 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]); 1212 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []); 1213 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningApply(MatPartitioning,IS*); 1214 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningDestroy(MatPartitioning); 1215 1216 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning)); 1217 1218 /*MC 1219 MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the 1220 matrix package. 1221 1222 Synopsis: 1223 PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning)) 1224 1225 Not Collective 1226 1227 Input Parameters: 1228 + sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis 1229 . path - location of library where creation routine is 1230 . name - name of function that creates the partitioning type, a string 1231 - function - function pointer that creates the partitioning type 1232 1233 Level: developer 1234 1235 If dynamic libraries are used, then the fourth input argument (function) 1236 is ignored. 1237 1238 Sample usage: 1239 .vb 1240 MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a, 1241 "MyPartCreate",MyPartCreate); 1242 .ve 1243 1244 Then, your partitioner can be chosen with the procedural interface via 1245 $ MatPartitioningSetType(part,"my_part") 1246 or at runtime via the option 1247 $ -mat_partitioning_type my_part 1248 1249 $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 1250 1251 .keywords: matrix, partitioning, register 1252 1253 .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll() 1254 M*/ 1255 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1256 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 1257 #else 1258 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 1259 #endif 1260 1261 extern PetscTruth MatPartitioningRegisterAllCalled; 1262 1263 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegisterAll(const char[]); 1264 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegisterDestroy(void); 1265 1266 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningView(MatPartitioning,PetscViewer); 1267 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetFromOptions(MatPartitioning); 1268 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningGetType(MatPartitioning,MatPartitioningType*); 1269 1270 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 1271 1272 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal); 1273 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningJostleSetCoarseSequential(MatPartitioning); 1274 1275 typedef enum {MP_CHACO_MULTILEVEL_KL,MP_CHACO_SPECTRAL,MP_CHACO_LINEAR,MP_CHACO_RANDOM, MP_CHACO_SCATTERED} MPChacoGlobalType; 1276 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType); 1277 typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType; 1278 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType); 1279 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal); 1280 typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType; 1281 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType); 1282 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal); 1283 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt); 1284 1285 #define MP_PARTY_OPT "opt" 1286 #define MP_PARTY_LIN "lin" 1287 #define MP_PARTY_SCA "sca" 1288 #define MP_PARTY_RAN "ran" 1289 #define MP_PARTY_GBF "gbf" 1290 #define MP_PARTY_GCF "gcf" 1291 #define MP_PARTY_BUB "bub" 1292 #define MP_PARTY_DEF "def" 1293 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetGlobal(MatPartitioning, const char*); 1294 #define MP_PARTY_HELPFUL_SETS "hs" 1295 #define MP_PARTY_KERNIGHAN_LIN "kl" 1296 #define MP_PARTY_NONE "no" 1297 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetLocal(MatPartitioning, const char*); 1298 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal); 1299 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetBipart(MatPartitioning,PetscTruth); 1300 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth); 1301 1302 typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType; 1303 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetArch(MatPartitioning,const char*); 1304 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetMultilevel(MatPartitioning); 1305 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType); 1306 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal); 1307 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetHostList(MatPartitioning,const char*); 1308 typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType; 1309 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType); 1310 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetMapping(MatPartitioning); 1311 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetStrategy(MatPartitioning,char*); 1312 1313 /* 1314 If you add entries here you must also add them to finclude/petscmat.h 1315 */ 1316 typedef enum { MATOP_SET_VALUES=0, 1317 MATOP_GET_ROW=1, 1318 MATOP_RESTORE_ROW=2, 1319 MATOP_MULT=3, 1320 MATOP_MULT_ADD=4, 1321 MATOP_MULT_TRANSPOSE=5, 1322 MATOP_MULT_TRANSPOSE_ADD=6, 1323 MATOP_SOLVE=7, 1324 MATOP_SOLVE_ADD=8, 1325 MATOP_SOLVE_TRANSPOSE=9, 1326 MATOP_SOLVE_TRANSPOSE_ADD=10, 1327 MATOP_LUFACTOR=11, 1328 MATOP_CHOLESKYFACTOR=12, 1329 MATOP_RELAX=13, 1330 MATOP_TRANSPOSE=14, 1331 MATOP_GETINFO=15, 1332 MATOP_EQUAL=16, 1333 MATOP_GET_DIAGONAL=17, 1334 MATOP_DIAGONAL_SCALE=18, 1335 MATOP_NORM=19, 1336 MATOP_ASSEMBLY_BEGIN=20, 1337 MATOP_ASSEMBLY_END=21, 1338 MATOP_COMPRESS=22, 1339 MATOP_SET_OPTION=23, 1340 MATOP_ZERO_ENTRIES=24, 1341 MATOP_ZERO_ROWS=25, 1342 MATOP_LUFACTOR_SYMBOLIC=26, 1343 MATOP_LUFACTOR_NUMERIC=27, 1344 MATOP_CHOLESKY_FACTOR_SYMBOLIC=28, 1345 MATOP_CHOLESKY_FACTOR_NUMERIC=29, 1346 MATOP_SETUP_PREALLOCATION=30, 1347 MATOP_ILUFACTOR_SYMBOLIC=31, 1348 MATOP_ICCFACTOR_SYMBOLIC=32, 1349 MATOP_GET_ARRAY=33, 1350 MATOP_RESTORE_ARRAY=34, 1351 MATOP_DUPLICATE=35, 1352 MATOP_FORWARD_SOLVE=36, 1353 MATOP_BACKWARD_SOLVE=37, 1354 MATOP_ILUFACTOR=38, 1355 MATOP_ICCFACTOR=39, 1356 MATOP_AXPY=40, 1357 MATOP_GET_SUBMATRICES=41, 1358 MATOP_INCREASE_OVERLAP=42, 1359 MATOP_GET_VALUES=43, 1360 MATOP_COPY=44, 1361 MATOP_PRINT_HELP=45, 1362 MATOP_SCALE=46, 1363 MATOP_SHIFT=47, 1364 MATOP_DIAGONAL_SHIFT=48, 1365 MATOP_ILUDT_FACTOR=49, 1366 MATOP_GET_BLOCK_SIZE=50, 1367 MATOP_GET_ROW_IJ=51, 1368 MATOP_RESTORE_ROW_IJ=52, 1369 MATOP_GET_COLUMN_IJ=53, 1370 MATOP_RESTORE_COLUMN_IJ=54, 1371 MATOP_FDCOLORING_CREATE=55, 1372 MATOP_COLORING_PATCH=56, 1373 MATOP_SET_UNFACTORED=57, 1374 MATOP_PERMUTE=58, 1375 MATOP_SET_VALUES_BLOCKED=59, 1376 MATOP_GET_SUBMATRIX=60, 1377 MATOP_DESTROY=61, 1378 MATOP_VIEW=62, 1379 MATOP_GET_MAPS=63, 1380 MATOP_USE_SCALED_FORM=64, 1381 MATOP_SCALE_SYSTEM=65, 1382 MATOP_UNSCALE_SYSTEM=66, 1383 MATOP_SET_LOCAL_TO_GLOBAL_MAP=67, 1384 MATOP_SET_VALUES_LOCAL=68, 1385 MATOP_ZERO_ROWS_LOCAL=69, 1386 MATOP_GET_ROW_MAX=70, 1387 MATOP_CONVERT=71, 1388 MATOP_SET_COLORING=72, 1389 MATOP_SET_VALUES_ADIC=73, 1390 MATOP_SET_VALUES_ADIFOR=74, 1391 MATOP_FD_COLORING_APPLY=75, 1392 MATOP_SET_FROM_OPTIONS=76, 1393 MATOP_MULT_CON=77, 1394 MATOP_MULT_TRANSPOSE_CON=78, 1395 MATOP_ILU_FACTOR_SYMBOLIC_CON=79, 1396 MATOP_PERMUTE_SPARSIFY=80, 1397 MATOP_MULT_MULTIPLE=81, 1398 MATOP_SOLVE_MULTIPLE=82, 1399 MATOP_GET_INERTIA=83, 1400 MATOP_LOAD=84, 1401 MATOP_IS_SYMMETRIC=85, 1402 MATOP_IS_HERMITIAN=86, 1403 MATOP_IS_STRUCTURALLY_SYMMETRIC=87, 1404 MATOP_PB_RELAX=88, 1405 MATOP_GET_VECS=89, 1406 MATOP_MAT_MULT=90, 1407 MATOP_MAT_MULT_SYMBOLIC=91, 1408 MATOP_MAT_MULT_NUMERIC=92, 1409 MATOP_PTAP=93, 1410 MATOP_PTAP_SYMBOLIC=94, 1411 MATOP_PTAP_NUMERIC=95, 1412 MATOP_MAT_MULTTRANSPOSE=96, 1413 MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97, 1414 MATOP_MAT_MULTTRANSPOSE_NUMERIC=98, 1415 MATOP_PTAP_SYMBOLIC_SEQAIJ=99, 1416 MATOP_PTAP_NUMERIC_SEQAIJ=100, 1417 MATOP_PTAP_SYMBOLIC_MPIAIJ=101, 1418 MATOP_PTAP_NUMERIC_MPIAIJ=102, 1419 MATOP_SET_VALUES_ROW = 105, 1420 MATOP_GET_ROW_UTRIANGULAR=108, 1421 MATOP_RESTORE_ROW_UTRIANGULAR=109, 1422 MATOP_MATSOLVE=110, 1423 MATOP_GET_REDUNDANTMATRIX=111, 1424 MATOP_MATGETSEQNONZEROSTRUCTURE=115 1425 } MatOperation; 1426 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatHasOperation(Mat,MatOperation,PetscTruth*); 1427 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellSetOperation(Mat,MatOperation,void(*)(void)); 1428 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellGetOperation(Mat,MatOperation,void(**)(void)); 1429 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellSetContext(Mat,void*); 1430 1431 /* 1432 Codes for matrices stored on disk. By default they are 1433 stored in a universal format. By changing the format with 1434 PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will 1435 be stored in a way natural for the matrix, for example dense matrices 1436 would be stored as dense. Matrices stored this way may only be 1437 read into matrices of the same time. 1438 */ 1439 #define MATRIX_BINARY_FORMAT_DENSE -1 1440 1441 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetHashTableFactor(Mat,PetscReal); 1442 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatISGetLocalMat(Mat,Mat*); 1443 1444 /*S 1445 MatNullSpace - Object that removes a null space from a vector, i.e. 1446 orthogonalizes the vector to a subsapce 1447 1448 Level: advanced 1449 1450 Concepts: matrix; linear operator, null space 1451 1452 Users manual sections: 1453 . sec_singular 1454 1455 .seealso: MatNullSpaceCreate() 1456 S*/ 1457 typedef struct _p_MatNullSpace* MatNullSpace; 1458 1459 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*); 1460 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceSetFunction(MatNullSpace,PetscErrorCode (*)(Vec,void*),void*); 1461 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceDestroy(MatNullSpace); 1462 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceRemove(MatNullSpace,Vec,Vec*); 1463 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceAttach(Mat,MatNullSpace); 1464 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceTest(MatNullSpace,Mat); 1465 1466 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatReorderingSeqSBAIJ(Mat,IS); 1467 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPISBAIJSetHashTableFactor(Mat,PetscReal); 1468 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqSBAIJSetColumnIndices(Mat,PetscInt *); 1469 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJInvertBlockDiagonal(Mat); 1470 1471 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMAIJ(Mat,PetscInt,Mat*); 1472 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMAIJRedimension(Mat,PetscInt,Mat*); 1473 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMAIJGetAIJ(Mat,Mat*); 1474 1475 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatComputeExplicitOperator(Mat,Mat*); 1476 1477 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScaleLocal(Mat,Vec); 1478 1479 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMFFD(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*); 1480 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetBase(Mat,Vec,Vec); 1481 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetFunction(Mat,PetscErrorCode(*)(void*,Vec,Vec),void*); 1482 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetFunctioni(Mat,PetscErrorCode (*)(void*,PetscInt,Vec,PetscScalar*)); 1483 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetFunctioniBase(Mat,PetscErrorCode (*)(void*,Vec)); 1484 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDAddNullSpace(Mat,MatNullSpace); 1485 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetHHistory(Mat,PetscScalar[],PetscInt); 1486 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDResetHHistory(Mat); 1487 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetFunctionError(Mat,PetscReal); 1488 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetPeriod(Mat,PetscInt); 1489 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDGetH(Mat,PetscScalar *); 1490 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetFromOptions(Mat); 1491 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDCheckPositivity(void*,Vec,Vec,PetscScalar*); 1492 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetCheckh(Mat,PetscErrorCode (*)(void*,Vec,Vec,PetscScalar*),void*); 1493 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDDSSetUmin(Mat,PetscReal); 1494 1495 1496 typedef struct _p_MatMFFD* MatMFFD; 1497 1498 /*E 1499 MatMFFDType - algorithm used to compute the h used in computing matrix-vector products via differencing of the function 1500 1501 Level: beginner 1502 1503 .seealso: MatMFFDSetType(), MatMFFDRegister() 1504 E*/ 1505 #define MatMFFDType const char* 1506 #define MATMFFD_DS "ds" 1507 #define MATMFFD_WP "wp" 1508 1509 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDSetType(Mat,MatMFFDType); 1510 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatMFFD)); 1511 1512 /*MC 1513 MatMFFDRegisterDynamic - Adds a method to the MatMFFD registry. 1514 1515 Synopsis: 1516 PetscErrorCode MatMFFDRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(MatMFFD)) 1517 1518 Not Collective 1519 1520 Input Parameters: 1521 + name_solver - name of a new user-defined compute-h module 1522 . path - path (either absolute or relative) the library containing this solver 1523 . name_create - name of routine to create method context 1524 - routine_create - routine to create method context 1525 1526 Level: developer 1527 1528 Notes: 1529 MatMFFDRegisterDynamic() may be called multiple times to add several user-defined solvers. 1530 1531 If dynamic libraries are used, then the fourth input argument (routine_create) 1532 is ignored. 1533 1534 Sample usage: 1535 .vb 1536 MatMFFDRegisterDynamic("my_h",/home/username/my_lib/lib/libO/solaris/mylib.a, 1537 "MyHCreate",MyHCreate); 1538 .ve 1539 1540 Then, your solver can be chosen with the procedural interface via 1541 $ MatMFFDSetType(mfctx,"my_h") 1542 or at runtime via the option 1543 $ -snes_mf_type my_h 1544 1545 .keywords: MatMFFD, register 1546 1547 .seealso: MatMFFDRegisterAll(), MatMFFDRegisterDestroy() 1548 M*/ 1549 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1550 #define MatMFFDRegisterDynamic(a,b,c,d) MatMFFDRegister(a,b,c,0) 1551 #else 1552 #define MatMFFDRegisterDynamic(a,b,c,d) MatMFFDRegister(a,b,c,d) 1553 #endif 1554 1555 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDRegisterAll(const char[]); 1556 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDRegisterDestroy(void); 1557 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDDefaultSetUmin(Mat,PetscReal); 1558 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMFFDWPSetComputeNormU(Mat,PetscTruth); 1559 1560 1561 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 1562 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 1563 1564 PETSC_EXTERN_CXX_END 1565 #endif 1566