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 MATSAME "same" 30 #define MATSEQMAIJ "seqmaij" 31 #define MATMPIMAIJ "mpimaij" 32 #define MATMAIJ "maij" 33 #define MATIS "is" 34 #define MATMPIROWBS "mpirowbs" 35 #define MATSEQAIJ "seqaij" 36 #define MATMPIAIJ "mpiaij" 37 #define MATAIJ "aij" 38 #define MATSHELL "shell" 39 #define MATSEQBDIAG "seqbdiag" 40 #define MATMPIBDIAG "mpibdiag" 41 #define MATBDIAG "bdiag" 42 #define MATSEQDENSE "seqdense" 43 #define MATMPIDENSE "mpidense" 44 #define MATDENSE "dense" 45 #define MATSEQBAIJ "seqbaij" 46 #define MATMPIBAIJ "mpibaij" 47 #define MATBAIJ "baij" 48 #define MATMPIADJ "mpiadj" 49 #define MATSEQSBAIJ "seqsbaij" 50 #define MATMPISBAIJ "mpisbaij" 51 #define MATSBAIJ "sbaij" 52 #define MATDAAD "daad" 53 #define MATMFFD "mffd" 54 #define MATNORMAL "normal" 55 #define MATSEQAIJSPOOLES "seqaijspooles" 56 #define MATMPIAIJSPOOLES "mpiaijspooles" 57 #define MATSEQSBAIJSPOOLES "seqsbaijspooles" 58 #define MATMPISBAIJSPOOLES "mpisbaijspooles" 59 #define MATAIJSPOOLES "aijspooles" 60 #define MATSBAIJSPOOLES "sbaijspooles" 61 #define MATSUPERLU "superlu" 62 #define MATSUPERLU_DIST "superlu_dist" 63 #define MATUMFPACK "umfpack" 64 #define MATESSL "essl" 65 #define MATLUSOL "lusol" 66 #define MATAIJMUMPS "aijmumps" 67 #define MATSBAIJMUMPS "sbaijmumps" 68 #define MATDSCPACK "dscpack" 69 #define MATMATLAB "matlab" 70 #define MatType char* 71 72 /* Logging support */ 73 #define MAT_FILE_COOKIE 1211216 /* used to indicate matrices in binary files */ 74 extern PetscCookie MAT_COOKIE, MATSNESMFCTX_COOKIE, MAT_FDCOLORING_COOKIE, MAT_PARTITIONING_COOKIE, MAT_NULLSPACE_COOKIE; 75 extern PetscEvent MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose; 76 extern PetscEvent MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose; 77 extern PetscEvent MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic; 78 extern PetscEvent MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor; 79 extern PetscEvent MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin; 80 extern PetscEvent MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering; 81 extern PetscEvent MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate; 82 extern PetscEvent MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction; 83 extern PetscEvent MAT_MatMult, MAT_MatMultSymbolic, MAT_MatMultNumeric; 84 extern PetscEvent MAT_PtAP, MAT_PtAPSymbolic, MAT_PtAPNumeric; 85 extern PetscEvent MAT_MatMultTranspose, MAT_MatMultTransposeSymbolic, MAT_MatMultTransposeNumeric; 86 87 /*E 88 MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices() 89 or MatGetSubMatrix() are to be reused to store the new matrix values. 90 91 Level: beginner 92 93 Any additions/changes here MUST also be made in include/finclude/petscmat.h 94 95 .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices() 96 E*/ 97 typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse; 98 99 EXTERN PetscErrorCode MatInitializePackage(char *); 100 101 EXTERN PetscErrorCode MatCreate(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*); 102 EXTERN PetscErrorCode MatSetType(Mat,const MatType); 103 EXTERN PetscErrorCode MatSetFromOptions(Mat); 104 EXTERN PetscErrorCode MatSetUpPreallocation(Mat); 105 EXTERN PetscErrorCode MatRegisterAll(const char[]); 106 EXTERN PetscErrorCode MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat)); 107 108 /*MC 109 MatRegisterDynamic - Adds a new matrix type 110 111 Synopsis: 112 PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat)) 113 114 Not Collective 115 116 Input Parameters: 117 + name - name of a new user-defined matrix type 118 . path - path (either absolute or relative) the library containing this solver 119 . name_create - name of routine to create method context 120 - routine_create - routine to create method context 121 122 Notes: 123 MatRegisterDynamic() may be called multiple times to add several user-defined solvers. 124 125 If dynamic libraries are used, then the fourth input argument (routine_create) 126 is ignored. 127 128 Sample usage: 129 .vb 130 MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a, 131 "MyMatCreate",MyMatCreate); 132 .ve 133 134 Then, your solver can be chosen with the procedural interface via 135 $ MatSetType(Mat,"my_mat") 136 or at runtime via the option 137 $ -mat_type my_mat 138 139 Level: advanced 140 141 Notes: ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values. 142 If your function is not being put into a shared library then use VecRegister() instead 143 144 .keywords: Mat, register 145 146 .seealso: MatRegisterAll(), MatRegisterDestroy() 147 148 M*/ 149 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 150 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0) 151 #else 152 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d) 153 #endif 154 155 extern PetscTruth MatRegisterAllCalled; 156 extern PetscFList MatList; 157 158 EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*); 159 EXTERN PetscErrorCode MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*); 160 EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 161 EXTERN PetscErrorCode MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 162 EXTERN PetscErrorCode MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 163 EXTERN PetscErrorCode MatCreateSeqBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*); 164 EXTERN PetscErrorCode MatCreateMPIBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*); 165 EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 166 EXTERN PetscErrorCode MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 167 EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*); 168 EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 169 EXTERN PetscErrorCode MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 170 EXTERN PetscErrorCode MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*); 171 EXTERN PetscErrorCode MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*); 172 EXTERN PetscErrorCode MatCreateNormal(Mat,Mat*); 173 EXTERN PetscErrorCode MatDestroy(Mat); 174 175 EXTERN PetscErrorCode MatPrintHelp(Mat); 176 EXTERN PetscErrorCode MatGetPetscMaps(Mat,PetscMap*,PetscMap*); 177 178 /* ------------------------------------------------------------*/ 179 EXTERN PetscErrorCode MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 180 EXTERN PetscErrorCode MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 181 182 /*S 183 MatStencil - Data structure (C struct) for storing information about a single row or 184 column of a matrix as index on an associated grid. 185 186 Level: beginner 187 188 Concepts: matrix; linear operator 189 190 .seealso: MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil() 191 S*/ 192 typedef struct { 193 PetscInt k,j,i,c; 194 } MatStencil; 195 196 EXTERN PetscErrorCode MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 197 EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 198 EXTERN PetscErrorCode MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt); 199 200 EXTERN PetscErrorCode MatSetColoring(Mat,ISColoring); 201 EXTERN PetscErrorCode MatSetValuesAdic(Mat,void*); 202 EXTERN PetscErrorCode MatSetValuesAdifor(Mat,PetscInt,void*); 203 204 /*E 205 MatAssemblyType - Indicates if the matrix is now to be used, or if you plan 206 to continue to add values to it 207 208 Level: beginner 209 210 .seealso: MatAssemblyBegin(), MatAssemblyEnd() 211 E*/ 212 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 213 EXTERN PetscErrorCode MatAssemblyBegin(Mat,MatAssemblyType); 214 EXTERN PetscErrorCode MatAssemblyEnd(Mat,MatAssemblyType); 215 EXTERN PetscErrorCode MatAssembled(Mat,PetscTruth*); 216 217 extern PetscInt MatSetValue_Row, MatSetValue_Column; 218 extern PetscScalar MatSetValue_Value; 219 220 /*MC 221 MatSetValue - Set a single entry into a matrix. 222 223 Synopsis: 224 PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode); 225 226 Not collective 227 228 Input Parameters: 229 + m - the matrix 230 . row - the row location of the entry 231 . col - the column location of the entry 232 . value - the value to insert 233 - mode - either INSERT_VALUES or ADD_VALUES 234 235 Notes: 236 For efficiency one should use MatSetValues() and set several or many 237 values simultaneously if possible. 238 239 Level: beginner 240 241 .seealso: MatSetValues(), MatSetValueLocal() 242 M*/ 243 #define MatSetValue(v,i,j,va,mode) \ 244 ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \ 245 MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode)) 246 247 #define MatGetValue(v,i,j,va) \ 248 ((MatSetValue_Row = i,MatSetValue_Column = j,0) || \ 249 MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va)) 250 251 #define MatSetValueLocal(v,i,j,va,mode) \ 252 ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \ 253 MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode)) 254 255 /*E 256 MatOption - Options that may be set for a matrix and its behavior or storage 257 258 Level: beginner 259 260 Any additions/changes here MUST also be made in include/finclude/petscmat.h 261 262 .seealso: MatSetOption() 263 E*/ 264 typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4, 265 MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16, 266 MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64, 267 MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66, 268 MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69, 269 MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72, 270 MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74, 271 MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76, 272 MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78, 273 MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81, 274 MAT_DO_NOT_USE_INODES=82,MAT_NOT_SYMMETRIC=83,MAT_HERMITIAN=84, 275 MAT_NOT_STRUCTURALLY_SYMMETRIC=85,MAT_NOT_HERMITIAN=86, 276 MAT_SYMMETRY_ETERNAL=87,MAT_NOT_SYMMETRY_ETERNAL=88, 277 MAT_USE_COMPRESSEDROW=89,MAT_DO_NOT_USE_COMPRESSEDROW=90, 278 MAT_IGNORE_LOWER_TRIANGULAR=91,MAT_ERROR_LOWER_TRIANGULAR=92} MatOption; 279 EXTERN PetscErrorCode MatSetOption(Mat,MatOption); 280 EXTERN PetscErrorCode MatGetType(Mat,MatType*); 281 282 EXTERN PetscErrorCode MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]); 283 EXTERN PetscErrorCode MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 284 EXTERN PetscErrorCode MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 285 EXTERN PetscErrorCode MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 286 EXTERN PetscErrorCode MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 287 EXTERN PetscErrorCode MatGetColumnVector(Mat,Vec,PetscInt); 288 EXTERN PetscErrorCode MatGetArray(Mat,PetscScalar *[]); 289 EXTERN PetscErrorCode MatRestoreArray(Mat,PetscScalar *[]); 290 EXTERN PetscErrorCode MatGetBlockSize(Mat,PetscInt *); 291 EXTERN PetscErrorCode MatSetBlockSize(Mat,PetscInt); 292 293 EXTERN PetscErrorCode MatMult(Mat,Vec,Vec); 294 EXTERN PetscErrorCode MatMultAdd(Mat,Vec,Vec,Vec); 295 EXTERN PetscErrorCode MatMultTranspose(Mat,Vec,Vec); 296 EXTERN PetscErrorCode MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*); 297 EXTERN PetscErrorCode MatMultTransposeAdd(Mat,Vec,Vec,Vec); 298 EXTERN PetscErrorCode MatMultConstrained(Mat,Vec,Vec); 299 EXTERN PetscErrorCode MatMultTransposeConstrained(Mat,Vec,Vec); 300 301 /*E 302 MatDuplicateOption - Indicates if a duplicated sparse matrix should have 303 its numerical values copied over or just its nonzero structure. 304 305 Level: beginner 306 307 Any additions/changes here MUST also be made in include/finclude/petscmat.h 308 309 .seealso: MatDuplicate() 310 E*/ 311 typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption; 312 313 EXTERN PetscErrorCode MatConvertRegister(const char[],const char[],const char[],PetscErrorCode (*)(Mat,MatType,MatReuse,Mat*)); 314 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 315 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0) 316 #else 317 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d) 318 #endif 319 EXTERN PetscErrorCode MatConvertRegisterAll(const char[]); 320 EXTERN PetscErrorCode MatConvertRegisterDestroy(void); 321 extern PetscTruth MatConvertRegisterAllCalled; 322 extern PetscFList MatConvertList; 323 EXTERN PetscErrorCode MatConvert(Mat,const MatType,MatReuse,Mat*); 324 EXTERN PetscErrorCode MatDuplicate(Mat,MatDuplicateOption,Mat*); 325 326 /*E 327 MatStructure - Indicates if the matrix has the same nonzero structure 328 329 Level: beginner 330 331 Any additions/changes here MUST also be made in include/finclude/petscmat.h 332 333 .seealso: MatCopy(), KSPSetOperators(), PCSetOperators() 334 E*/ 335 typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure; 336 337 EXTERN PetscErrorCode MatCopy(Mat,Mat,MatStructure); 338 EXTERN PetscErrorCode MatView(Mat,PetscViewer); 339 EXTERN PetscErrorCode MatIsSymmetric(Mat,PetscReal,PetscTruth*); 340 EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat,PetscTruth*); 341 EXTERN PetscErrorCode MatIsHermitian(Mat,PetscTruth*); 342 EXTERN PetscErrorCode MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*); 343 EXTERN PetscErrorCode MatIsHermitianKnown(Mat,PetscTruth*,PetscTruth*); 344 EXTERN PetscErrorCode MatLoad(PetscViewer,const MatType,Mat*); 345 346 EXTERN PetscErrorCode MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *); 347 EXTERN PetscErrorCode MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *); 348 EXTERN PetscErrorCode MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *); 349 EXTERN PetscErrorCode MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *); 350 351 /*S 352 MatInfo - Context of matrix information, used with MatGetInfo() 353 354 In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE 355 356 Level: intermediate 357 358 Concepts: matrix^nonzero information 359 360 .seealso: MatGetInfo(), MatInfoType 361 S*/ 362 typedef struct { 363 PetscLogDouble rows_global,columns_global; /* number of global rows and columns */ 364 PetscLogDouble rows_local,columns_local; /* number of local rows and columns */ 365 PetscLogDouble block_size; /* block size */ 366 PetscLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 367 PetscLogDouble memory; /* memory allocated */ 368 PetscLogDouble assemblies; /* number of matrix assemblies called */ 369 PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 370 PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 371 PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 372 } MatInfo; 373 374 /*E 375 MatInfoType - Indicates if you want information about the local part of the matrix, 376 the entire parallel matrix or the maximum over all the local parts. 377 378 Level: beginner 379 380 Any additions/changes here MUST also be made in include/finclude/petscmat.h 381 382 .seealso: MatGetInfo(), MatInfo 383 E*/ 384 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 385 EXTERN PetscErrorCode MatGetInfo(Mat,MatInfoType,MatInfo*); 386 EXTERN PetscErrorCode MatValid(Mat,PetscTruth*); 387 EXTERN PetscErrorCode MatGetDiagonal(Mat,Vec); 388 EXTERN PetscErrorCode MatGetRowMax(Mat,Vec); 389 EXTERN PetscErrorCode MatTranspose(Mat,Mat*); 390 EXTERN PetscErrorCode MatPermute(Mat,IS,IS,Mat *); 391 EXTERN PetscErrorCode MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *); 392 EXTERN PetscErrorCode MatDiagonalScale(Mat,Vec,Vec); 393 EXTERN PetscErrorCode MatDiagonalSet(Mat,Vec,InsertMode); 394 EXTERN PetscErrorCode MatEqual(Mat,Mat,PetscTruth*); 395 EXTERN PetscErrorCode MatMultEqual(Mat,Mat,PetscInt,PetscTruth*); 396 EXTERN PetscErrorCode MatMultAddEqual(Mat,Mat,PetscInt,PetscTruth*); 397 EXTERN PetscErrorCode MatMultTransposeEqual(Mat,Mat,PetscInt,PetscTruth*); 398 EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscTruth*); 399 400 EXTERN PetscErrorCode MatNorm(Mat,NormType,PetscReal *); 401 EXTERN PetscErrorCode MatZeroEntries(Mat); 402 EXTERN PetscErrorCode MatZeroRows(Mat,IS,const PetscScalar*); 403 EXTERN PetscErrorCode MatZeroColumns(Mat,IS,const PetscScalar*); 404 405 EXTERN PetscErrorCode MatUseScaledForm(Mat,PetscTruth); 406 EXTERN PetscErrorCode MatScaleSystem(Mat,Vec,Vec); 407 EXTERN PetscErrorCode MatUnScaleSystem(Mat,Vec,Vec); 408 409 EXTERN PetscErrorCode MatGetSize(Mat,PetscInt*,PetscInt*); 410 EXTERN PetscErrorCode MatGetLocalSize(Mat,PetscInt*,PetscInt*); 411 EXTERN PetscErrorCode MatGetOwnershipRange(Mat,PetscInt*,PetscInt*); 412 413 EXTERN PetscErrorCode MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 414 EXTERN PetscErrorCode MatDestroyMatrices(PetscInt,Mat *[]); 415 EXTERN PetscErrorCode MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *); 416 EXTERN PetscErrorCode MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*); 417 EXTERN PetscErrorCode MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*); 418 EXTERN PetscErrorCode MatMerge_SeqsToMPISymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*); 419 EXTERN PetscErrorCode MatMerge_SeqsToMPINumeric(Mat,Mat); 420 EXTERN PetscErrorCode MatDestroy_MPIAIJ_SeqsToMPI(Mat); 421 EXTERN PetscErrorCode MatGetLocalMat(Mat,MatReuse,Mat*); 422 EXTERN PetscErrorCode MatGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*); 423 EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*); 424 EXTERN PetscErrorCode MatGetBrowsOfAoCols(Mat,Mat,MatReuse,PetscInt**,PetscScalar**,Mat*); 425 426 EXTERN PetscErrorCode MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt); 427 428 EXTERN PetscErrorCode MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*); 429 EXTERN PetscErrorCode MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*); 430 EXTERN PetscErrorCode MatMatMultNumeric(Mat,Mat,Mat); 431 432 EXTERN PetscErrorCode MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*); 433 EXTERN PetscErrorCode MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*); 434 EXTERN PetscErrorCode MatPtAPNumeric(Mat,Mat,Mat); 435 436 EXTERN PetscErrorCode MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*); 437 EXTERN PetscErrorCode MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*); 438 EXTERN PetscErrorCode MatMatMultTransposeNumeric(Mat,Mat,Mat); 439 440 EXTERN PetscErrorCode MatAXPY(const PetscScalar *,Mat,Mat,MatStructure); 441 EXTERN PetscErrorCode MatAYPX(const PetscScalar *,Mat,Mat); 442 EXTERN PetscErrorCode MatCompress(Mat); 443 444 EXTERN PetscErrorCode MatScale(const PetscScalar *,Mat); 445 EXTERN PetscErrorCode MatShift(const PetscScalar *,Mat); 446 447 EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping); 448 EXTERN PetscErrorCode MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping); 449 EXTERN PetscErrorCode MatZeroRowsLocal(Mat,IS,const PetscScalar*); 450 EXTERN PetscErrorCode MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 451 EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 452 453 EXTERN PetscErrorCode MatStashSetInitialSize(Mat,PetscInt,PetscInt); 454 EXTERN PetscErrorCode MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 455 456 EXTERN PetscErrorCode MatInterpolateAdd(Mat,Vec,Vec,Vec); 457 EXTERN PetscErrorCode MatInterpolate(Mat,Vec,Vec); 458 EXTERN PetscErrorCode MatRestrict(Mat,Vec,Vec); 459 EXTERN PetscErrorCode MatGetVecs(Mat,Vec*,Vec*); 460 461 /*MC 462 MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per 463 row in a matrix providing the data that one can use to correctly preallocate the matrix. 464 465 Synopsis: 466 PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 467 468 Collective on MPI_Comm 469 470 Input Parameters: 471 + comm - the communicator that will share the eventually allocated matrix 472 . nrows - the number of LOCAL rows in the matrix 473 - ncols - the number of LOCAL columns in the matrix 474 475 Output Parameters: 476 + dnz - the array that will be passed to the matrix preallocation routines 477 - ozn - the other array passed to the matrix preallocation routines 478 479 480 Level: intermediate 481 482 Notes: 483 See the chapter in the users manual on performance for more details 484 485 Do not malloc or free dnz and onz, that is handled internally by these routines 486 487 Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices) 488 489 Concepts: preallocation^Matrix 490 491 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 492 MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal() 493 M*/ 494 #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \ 495 { \ 496 PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 497 _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 498 _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 499 _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\ 500 _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 501 502 /*MC 503 MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per 504 row in a matrix providing the data that one can use to correctly preallocate the matrix. 505 506 Synopsis: 507 PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 508 509 Collective on MPI_Comm 510 511 Input Parameters: 512 + comm - the communicator that will share the eventually allocated matrix 513 . nrows - the number of LOCAL rows in the matrix 514 - ncols - the number of LOCAL columns in the matrix 515 516 Output Parameters: 517 + dnz - the array that will be passed to the matrix preallocation routines 518 - ozn - the other array passed to the matrix preallocation routines 519 520 521 Level: intermediate 522 523 Notes: 524 See the chapter in the users manual on performance for more details 525 526 Do not malloc or free dnz and onz, that is handled internally by these routines 527 528 Concepts: preallocation^Matrix 529 530 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 531 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 532 M*/ 533 #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \ 534 { \ 535 PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__end; \ 536 _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 537 _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 538 _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\ 539 _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 540 541 /*MC 542 MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 543 inserted using a local number of the rows and columns 544 545 Synopsis: 546 PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 547 548 Not Collective 549 550 Input Parameters: 551 + map - the mapping between local numbering and global numbering 552 . nrows - the number of rows indicated 553 . rows - the indices of the rows 554 . ncols - the number of columns in the matrix 555 . cols - the columns indicated 556 . dnz - the array that will be passed to the matrix preallocation routines 557 - ozn - the other array passed to the matrix preallocation routines 558 559 560 Level: intermediate 561 562 Notes: 563 See the chapter in the users manual on performance for more details 564 565 Do not malloc or free dnz and onz, that is handled internally by these routines 566 567 Concepts: preallocation^Matrix 568 569 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 570 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 571 M*/ 572 #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 573 {\ 574 PetscInt __l;\ 575 _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 576 _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 577 for (__l=0;__l<nrows;__l++) {\ 578 _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 579 }\ 580 } 581 582 /*MC 583 MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 584 inserted using a local number of the rows and columns 585 586 Synopsis: 587 PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 588 589 Not Collective 590 591 Input Parameters: 592 + map - the mapping between local numbering and global numbering 593 . nrows - the number of rows indicated 594 . rows - the indices of the rows 595 . ncols - the number of columns in the matrix 596 . cols - the columns indicated 597 . dnz - the array that will be passed to the matrix preallocation routines 598 - ozn - the other array passed to the matrix preallocation routines 599 600 601 Level: intermediate 602 603 Notes: 604 See the chapter in the users manual on performance for more details 605 606 Do not malloc or free dnz and onz that is handled internally by these routines 607 608 Concepts: preallocation^Matrix 609 610 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 611 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 612 M*/ 613 #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 614 {\ 615 PetscInt __l;\ 616 _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 617 _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 618 for (__l=0;__l<nrows;__l++) {\ 619 _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 620 }\ 621 } 622 623 /*MC 624 MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 625 inserted using a local number of the rows and columns 626 627 Synopsis: 628 PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 629 630 Not Collective 631 632 Input Parameters: 633 + nrows - the number of rows indicated 634 . rows - the indices of the rows 635 . ncols - the number of columns in the matrix 636 - cols - the columns indicated 637 638 Output Parameters: 639 + dnz - the array that will be passed to the matrix preallocation routines 640 - ozn - the other array passed to the matrix preallocation routines 641 642 643 Level: intermediate 644 645 Notes: 646 See the chapter in the users manual on performance for more details 647 648 Do not malloc or free dnz and onz that is handled internally by these routines 649 650 Concepts: preallocation^Matrix 651 652 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 653 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 654 M*/ 655 #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\ 656 { PetscInt __i; \ 657 for (__i=0; __i<nc; __i++) {\ 658 if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \ 659 }\ 660 dnz[row - __rstart] = nc - onz[row - __rstart];\ 661 } 662 663 /*MC 664 MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 665 inserted using a local number of the rows and columns 666 667 Synopsis: 668 PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 669 670 Not Collective 671 672 Input Parameters: 673 + nrows - the number of rows indicated 674 . rows - the indices of the rows 675 . ncols - the number of columns in the matrix 676 . cols - the columns indicated 677 . dnz - the array that will be passed to the matrix preallocation routines 678 - ozn - the other array passed to the matrix preallocation routines 679 680 681 Level: intermediate 682 683 Notes: 684 See the chapter in the users manual on performance for more details 685 686 Do not malloc or free dnz and onz that is handled internally by these routines 687 688 Concepts: preallocation^Matrix 689 690 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 691 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 692 M*/ 693 #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\ 694 { PetscInt __i; \ 695 for (__i=0; __i<nc; __i++) {\ 696 if (cols[__i] >= __end) onz[row - __rstart]++; \ 697 else if (cols[__i] >= row) dnz[row - __rstart]++;\ 698 }\ 699 } 700 701 /*MC 702 MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per 703 row in a matrix providing the data that one can use to correctly preallocate the matrix. 704 705 Synopsis: 706 PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz) 707 708 Collective on MPI_Comm 709 710 Input Parameters: 711 + dnz - the array that will be passed to the matrix preallocation routines 712 - ozn - the other array passed to the matrix preallocation routines 713 714 715 Level: intermediate 716 717 Notes: 718 See the chapter in the users manual on performance for more details 719 720 Do not malloc or free dnz and onz that is handled internally by these routines 721 722 Concepts: preallocation^Matrix 723 724 .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 725 MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal() 726 M*/ 727 #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);} 728 729 730 731 /* Routines unique to particular data structures */ 732 EXTERN PetscErrorCode MatShellGetContext(Mat,void **); 733 734 EXTERN PetscErrorCode MatBDiagGetData(Mat,PetscInt*,PetscInt*,PetscInt*[],PetscInt*[],PetscScalar***); 735 EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat,PetscInt[]); 736 EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat,PetscInt[]); 737 EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 738 739 EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 740 EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 741 EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]); 742 EXTERN PetscErrorCode MatSeqDensePreallocation(Mat,PetscScalar[]); 743 EXTERN PetscErrorCode MatSeqBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]); 744 EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat,PetscScalar[]); 745 746 EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 747 EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 748 EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 749 EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]); 750 EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]); 751 EXTERN PetscErrorCode MatMPIDensePreallocation(Mat,PetscScalar[]); 752 EXTERN PetscErrorCode MatMPIBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]); 753 EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]); 754 EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat,PetscScalar[]); 755 EXTERN PetscErrorCode MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]); 756 EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]); 757 EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]); 758 EXTERN PetscErrorCode MatAdicSetLocalFunction(Mat,void (*)(void)); 759 760 EXTERN PetscErrorCode MatSeqDenseSetLDA(Mat,PetscInt); 761 762 EXTERN PetscErrorCode MatStoreValues(Mat); 763 EXTERN PetscErrorCode MatRetrieveValues(Mat); 764 765 EXTERN PetscErrorCode MatDAADSetCtx(Mat,void*); 766 767 /* 768 These routines are not usually accessed directly, rather solving is 769 done through the KSP and PC interfaces. 770 */ 771 772 /*E 773 MatOrderingType - String with the name of a PETSc matrix ordering or the creation function 774 with an optional dynamic library name, for example 775 http://www.mcs.anl.gov/petsc/lib.a:orderingcreate() 776 777 Level: beginner 778 779 .seealso: MatGetOrdering() 780 E*/ 781 #define MatOrderingType char* 782 #define MATORDERING_NATURAL "natural" 783 #define MATORDERING_ND "nd" 784 #define MATORDERING_1WD "1wd" 785 #define MATORDERING_RCM "rcm" 786 #define MATORDERING_QMD "qmd" 787 #define MATORDERING_ROWLENGTH "rowlength" 788 #define MATORDERING_DSC_ND "dsc_nd" 789 #define MATORDERING_DSC_MMD "dsc_mmd" 790 #define MATORDERING_DSC_MDF "dsc_mdf" 791 #define MATORDERING_CONSTRAINED "constrained" 792 #define MATORDERING_IDENTITY "identity" 793 #define MATORDERING_REVERSE "reverse" 794 795 EXTERN PetscErrorCode MatGetOrdering(Mat,const MatOrderingType,IS*,IS*); 796 EXTERN PetscErrorCode MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*)); 797 798 /*MC 799 MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the 800 matrix package. 801 802 Synopsis: 803 PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering)) 804 805 Not Collective 806 807 Input Parameters: 808 + sname - name of ordering (for example MATORDERING_ND) 809 . path - location of library where creation routine is 810 . name - name of function that creates the ordering type,a string 811 - function - function pointer that creates the ordering 812 813 Level: developer 814 815 If dynamic libraries are used, then the fourth input argument (function) 816 is ignored. 817 818 Sample usage: 819 .vb 820 MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a, 821 "MyOrder",MyOrder); 822 .ve 823 824 Then, your partitioner can be chosen with the procedural interface via 825 $ MatOrderingSetType(part,"my_order) 826 or at runtime via the option 827 $ -pc_ilu_mat_ordering_type my_order 828 $ -pc_lu_mat_ordering_type my_order 829 830 ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values. 831 832 .keywords: matrix, ordering, register 833 834 .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll() 835 M*/ 836 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 837 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 838 #else 839 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 840 #endif 841 842 EXTERN PetscErrorCode MatOrderingRegisterDestroy(void); 843 EXTERN PetscErrorCode MatOrderingRegisterAll(const char[]); 844 extern PetscTruth MatOrderingRegisterAllCalled; 845 extern PetscFList MatOrderingList; 846 847 EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS); 848 849 /*S 850 MatFactorInfo - Data based into the matrix factorization routines 851 852 In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE 853 854 Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC. 855 856 Level: developer 857 858 .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(), 859 MatFactorInfoInitialize() 860 861 S*/ 862 typedef struct { 863 PetscReal shiftnz; /* scaling of identity added to matrix to prevent zero pivots */ 864 PetscTruth shiftpd; /* if true, shift until positive pivots */ 865 PetscReal shift_fraction; /* record shift fraction taken */ 866 PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 867 PetscReal dt; /* drop tolerance */ 868 PetscReal dtcol; /* tolerance for pivoting */ 869 PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 870 PetscReal fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/ 871 PetscReal levels; /* ICC/ILU(levels) */ 872 PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 873 factorization may be faster if do not pivot */ 874 PetscReal zeropivot; /* pivot is called zero if less than this */ 875 } MatFactorInfo; 876 877 EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo*); 878 EXTERN PetscErrorCode MatCholeskyFactor(Mat,IS,MatFactorInfo*); 879 EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 880 EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat,MatFactorInfo*,Mat*); 881 EXTERN PetscErrorCode MatLUFactor(Mat,IS,IS,MatFactorInfo*); 882 EXTERN PetscErrorCode MatILUFactor(Mat,IS,IS,MatFactorInfo*); 883 EXTERN PetscErrorCode MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 884 EXTERN PetscErrorCode MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 885 EXTERN PetscErrorCode MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 886 EXTERN PetscErrorCode MatICCFactor(Mat,IS,MatFactorInfo*); 887 EXTERN PetscErrorCode MatLUFactorNumeric(Mat,MatFactorInfo*,Mat*); 888 EXTERN PetscErrorCode MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *); 889 EXTERN PetscErrorCode MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*); 890 EXTERN PetscErrorCode MatSolve(Mat,Vec,Vec); 891 EXTERN PetscErrorCode MatForwardSolve(Mat,Vec,Vec); 892 EXTERN PetscErrorCode MatBackwardSolve(Mat,Vec,Vec); 893 EXTERN PetscErrorCode MatSolveAdd(Mat,Vec,Vec,Vec); 894 EXTERN PetscErrorCode MatSolveTranspose(Mat,Vec,Vec); 895 EXTERN PetscErrorCode MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 896 EXTERN PetscErrorCode MatSolves(Mat,Vecs,Vecs); 897 898 EXTERN PetscErrorCode MatSetUnfactored(Mat); 899 900 /*E 901 MatSORType - What type of (S)SOR to perform 902 903 Level: beginner 904 905 May be bitwise ORd together 906 907 Any additions/changes here MUST also be made in include/finclude/petscmat.h 908 909 MatSORType may be bitwise ORd together, so do not change the numbers 910 911 .seealso: MatRelax(), MatPBRelax() 912 E*/ 913 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 914 SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 915 SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 916 SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 917 EXTERN PetscErrorCode MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 918 EXTERN PetscErrorCode MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 919 920 /* 921 These routines are for efficiently computing Jacobians via finite differences. 922 */ 923 924 /*E 925 MatColoringType - String with the name of a PETSc matrix coloring or the creation function 926 with an optional dynamic library name, for example 927 http://www.mcs.anl.gov/petsc/lib.a:coloringcreate() 928 929 Level: beginner 930 931 .seealso: MatGetColoring() 932 E*/ 933 #define MatColoringType char* 934 #define MATCOLORING_NATURAL "natural" 935 #define MATCOLORING_SL "sl" 936 #define MATCOLORING_LF "lf" 937 #define MATCOLORING_ID "id" 938 939 EXTERN PetscErrorCode MatGetColoring(Mat,const MatColoringType,ISColoring*); 940 EXTERN PetscErrorCode MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatColoringType,ISColoring *)); 941 942 /*MC 943 MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the 944 matrix package. 945 946 Synopsis: 947 PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring)) 948 949 Not Collective 950 951 Input Parameters: 952 + sname - name of Coloring (for example MATCOLORING_SL) 953 . path - location of library where creation routine is 954 . name - name of function that creates the Coloring type, a string 955 - function - function pointer that creates the coloring 956 957 Level: developer 958 959 If dynamic libraries are used, then the fourth input argument (function) 960 is ignored. 961 962 Sample usage: 963 .vb 964 MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a, 965 "MyColor",MyColor); 966 .ve 967 968 Then, your partitioner can be chosen with the procedural interface via 969 $ MatColoringSetType(part,"my_color") 970 or at runtime via the option 971 $ -mat_coloring_type my_color 972 973 $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 974 975 .keywords: matrix, Coloring, register 976 977 .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll() 978 M*/ 979 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 980 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 981 #else 982 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 983 #endif 984 985 extern PetscTruth MatColoringRegisterAllCalled; 986 987 EXTERN PetscErrorCode MatColoringRegisterAll(const char[]); 988 EXTERN PetscErrorCode MatColoringRegisterDestroy(void); 989 EXTERN PetscErrorCode MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*); 990 991 /*S 992 MatFDColoring - Object for computing a sparse Jacobian via finite differences 993 and coloring 994 995 Level: beginner 996 997 Concepts: coloring, sparse Jacobian, finite differences 998 999 .seealso: MatFDColoringCreate() 1000 S*/ 1001 typedef struct _p_MatFDColoring *MatFDColoring; 1002 1003 EXTERN PetscErrorCode MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 1004 EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring); 1005 EXTERN PetscErrorCode MatFDColoringView(MatFDColoring,PetscViewer); 1006 EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*); 1007 EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal); 1008 EXTERN PetscErrorCode MatFDColoringSetFrequency(MatFDColoring,PetscInt); 1009 EXTERN PetscErrorCode MatFDColoringGetFrequency(MatFDColoring,PetscInt*); 1010 EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring); 1011 EXTERN PetscErrorCode MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 1012 EXTERN PetscErrorCode MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *); 1013 EXTERN PetscErrorCode MatFDColoringSetRecompute(MatFDColoring); 1014 EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring,Vec); 1015 EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]); 1016 /* 1017 These routines are for partitioning matrices: currently used only 1018 for adjacency matrix, MatCreateMPIAdj(). 1019 */ 1020 1021 /*S 1022 MatPartitioning - Object for managing the partitioning of a matrix or graph 1023 1024 Level: beginner 1025 1026 Concepts: partitioning 1027 1028 .seealso: MatPartitioningCreate(), MatPartitioningType 1029 S*/ 1030 typedef struct _p_MatPartitioning *MatPartitioning; 1031 1032 /*E 1033 MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function 1034 with an optional dynamic library name, for example 1035 http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate() 1036 1037 Level: beginner 1038 1039 .seealso: MatPartitioningCreate(), MatPartitioning 1040 E*/ 1041 #define MatPartitioningType char* 1042 #define MAT_PARTITIONING_CURRENT "current" 1043 #define MAT_PARTITIONING_SQUARE "square" 1044 #define MAT_PARTITIONING_PARMETIS "parmetis" 1045 #define MAT_PARTITIONING_CHACO "chaco" 1046 #define MAT_PARTITIONING_JOSTLE "jostle" 1047 #define MAT_PARTITIONING_PARTY "party" 1048 #define MAT_PARTITIONING_SCOTCH "scotch" 1049 1050 1051 EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm,MatPartitioning*); 1052 EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning,const MatPartitioningType); 1053 EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning,PetscInt); 1054 EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning,Mat); 1055 EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]); 1056 EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []); 1057 EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning,IS*); 1058 EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning); 1059 1060 EXTERN PetscErrorCode MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning)); 1061 1062 /*MC 1063 MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the 1064 matrix package. 1065 1066 Synopsis: 1067 PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning)) 1068 1069 Not Collective 1070 1071 Input Parameters: 1072 + sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis 1073 . path - location of library where creation routine is 1074 . name - name of function that creates the partitioning type, a string 1075 - function - function pointer that creates the partitioning type 1076 1077 Level: developer 1078 1079 If dynamic libraries are used, then the fourth input argument (function) 1080 is ignored. 1081 1082 Sample usage: 1083 .vb 1084 MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a, 1085 "MyPartCreate",MyPartCreate); 1086 .ve 1087 1088 Then, your partitioner can be chosen with the procedural interface via 1089 $ MatPartitioningSetType(part,"my_part") 1090 or at runtime via the option 1091 $ -mat_partitioning_type my_part 1092 1093 $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 1094 1095 .keywords: matrix, partitioning, register 1096 1097 .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll() 1098 M*/ 1099 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1100 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 1101 #else 1102 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 1103 #endif 1104 1105 extern PetscTruth MatPartitioningRegisterAllCalled; 1106 1107 EXTERN PetscErrorCode MatPartitioningRegisterAll(const char[]); 1108 EXTERN PetscErrorCode MatPartitioningRegisterDestroy(void); 1109 1110 EXTERN PetscErrorCode MatPartitioningView(MatPartitioning,PetscViewer); 1111 EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning); 1112 EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning,MatPartitioningType*); 1113 1114 EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 1115 1116 EXTERN PetscErrorCode MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal); 1117 EXTERN PetscErrorCode MatPartitioningJostleSetCoarseSequential(MatPartitioning); 1118 1119 typedef enum { MP_CHACO_MULTILEVEL_KL, MP_CHACO_SPECTRAL, MP_CHACO_LINEAR, 1120 MP_CHACO_RANDOM, MP_CHACO_SCATTERED } MPChacoGlobalType; 1121 EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType); 1122 typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType; 1123 EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType); 1124 EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal); 1125 typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType; 1126 EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType); 1127 EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal); 1128 EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt); 1129 1130 #define MP_PARTY_OPT "opt" 1131 #define MP_PARTY_LIN "lin" 1132 #define MP_PARTY_SCA "sca" 1133 #define MP_PARTY_RAN "ran" 1134 #define MP_PARTY_GBF "gbf" 1135 #define MP_PARTY_GCF "gcf" 1136 #define MP_PARTY_BUB "bub" 1137 #define MP_PARTY_DEF "def" 1138 EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char*); 1139 #define MP_PARTY_HELPFUL_SETS "hs" 1140 #define MP_PARTY_KERNIGHAN_LIN "kl" 1141 #define MP_PARTY_NONE "no" 1142 EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char*); 1143 EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal); 1144 EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning,PetscTruth); 1145 EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth); 1146 1147 typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType; 1148 EXTERN PetscErrorCode MatPartitioningScotchSetArch(MatPartitioning,const char*); 1149 EXTERN PetscErrorCode MatPartitioningScotchSetMultilevel(MatPartitioning); 1150 EXTERN PetscErrorCode MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType); 1151 EXTERN PetscErrorCode MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal); 1152 EXTERN PetscErrorCode MatPartitioningScotchSetHostList(MatPartitioning,const char*); 1153 typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType; 1154 EXTERN PetscErrorCode MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType); 1155 EXTERN PetscErrorCode MatPartitioningScotchSetMapping(MatPartitioning); 1156 EXTERN PetscErrorCode MatPartitioningScotchSetStrategy(MatPartitioning,char*); 1157 1158 /* 1159 If you add entries here you must also add them to finclude/petscmat.h 1160 */ 1161 typedef enum { MATOP_SET_VALUES=0, 1162 MATOP_GET_ROW=1, 1163 MATOP_RESTORE_ROW=2, 1164 MATOP_MULT=3, 1165 MATOP_MULT_ADD=4, 1166 MATOP_MULT_TRANSPOSE=5, 1167 MATOP_MULT_TRANSPOSE_ADD=6, 1168 MATOP_SOLVE=7, 1169 MATOP_SOLVE_ADD=8, 1170 MATOP_SOLVE_TRANSPOSE=9, 1171 MATOP_SOLVE_TRANSPOSE_ADD=10, 1172 MATOP_LUFACTOR=11, 1173 MATOP_CHOLESKYFACTOR=12, 1174 MATOP_RELAX=13, 1175 MATOP_TRANSPOSE=14, 1176 MATOP_GETINFO=15, 1177 MATOP_EQUAL=16, 1178 MATOP_GET_DIAGONAL=17, 1179 MATOP_DIAGONAL_SCALE=18, 1180 MATOP_NORM=19, 1181 MATOP_ASSEMBLY_BEGIN=20, 1182 MATOP_ASSEMBLY_END=21, 1183 MATOP_COMPRESS=22, 1184 MATOP_SET_OPTION=23, 1185 MATOP_ZERO_ENTRIES=24, 1186 MATOP_ZERO_ROWS=25, 1187 MATOP_LUFACTOR_SYMBOLIC=26, 1188 MATOP_LUFACTOR_NUMERIC=27, 1189 MATOP_CHOLESKY_FACTOR_SYMBOLIC=28, 1190 MATOP_CHOLESKY_FACTOR_NUMERIC=29, 1191 MATOP_SETUP_PREALLOCATION=30, 1192 MATOP_ILUFACTOR_SYMBOLIC=31, 1193 MATOP_ICCFACTOR_SYMBOLIC=32, 1194 MATOP_GET_ARRAY=33, 1195 MATOP_RESTORE_ARRAY=34, 1196 MATOP_DUPLCIATE=35, 1197 MATOP_FORWARD_SOLVE=36, 1198 MATOP_BACKWARD_SOLVE=37, 1199 MATOP_ILUFACTOR=38, 1200 MATOP_ICCFACTOR=39, 1201 MATOP_AXPY=40, 1202 MATOP_GET_SUBMATRICES=41, 1203 MATOP_INCREASE_OVERLAP=42, 1204 MATOP_GET_VALUES=43, 1205 MATOP_COPY=44, 1206 MATOP_PRINT_HELP=45, 1207 MATOP_SCALE=46, 1208 MATOP_SHIFT=47, 1209 MATOP_DIAGONAL_SHIFT=48, 1210 MATOP_ILUDT_FACTOR=49, 1211 MATOP_GET_BLOCK_SIZE=50, 1212 MATOP_GET_ROW_IJ=51, 1213 MATOP_RESTORE_ROW_IJ=52, 1214 MATOP_GET_COLUMN_IJ=53, 1215 MATOP_RESTORE_COLUMN_IJ=54, 1216 MATOP_FDCOLORING_CREATE=55, 1217 MATOP_COLORING_PATCH=56, 1218 MATOP_SET_UNFACTORED=57, 1219 MATOP_PERMUTE=58, 1220 MATOP_SET_VALUES_BLOCKED=59, 1221 MATOP_GET_SUBMATRIX=60, 1222 MATOP_DESTROY=61, 1223 MATOP_VIEW=62, 1224 MATOP_GET_MAPS=63, 1225 MATOP_USE_SCALED_FORM=64, 1226 MATOP_SCALE_SYSTEM=65, 1227 MATOP_UNSCALE_SYSTEM=66, 1228 MATOP_SET_LOCAL_TO_GLOBAL_MAP=67, 1229 MATOP_SET_VALUES_LOCAL=68, 1230 MATOP_ZERO_ROWS_LOCAL=69, 1231 MATOP_GET_ROW_MAX=70, 1232 MATOP_CONVERT=71, 1233 MATOP_SET_COLORING=72, 1234 MATOP_SET_VALUES_ADIC=73, 1235 MATOP_SET_VALUES_ADIFOR=74, 1236 MATOP_FD_COLORING_APPLY=75, 1237 MATOP_SET_FROM_OPTIONS=76, 1238 MATOP_MULT_CON=77, 1239 MATOP_MULT_TRANSPOSE_CON=78, 1240 MATOP_ILU_FACTOR_SYMBOLIC_CON=79, 1241 MATOP_PERMUTE_SPARSIFY=80, 1242 MATOP_MULT_MULTIPLE=81, 1243 MATOP_SOLVE_MULTIPLE=82, 1244 MATOP_GET_INERTIA=83, 1245 MATOP_LOAD=84, 1246 MATOP_IS_SYMMETRIC=85, 1247 MATOP_IS_HERMITIAN=86, 1248 MATOP_IS_STRUCTURALLY_SYMMETRIC=87, 1249 MATOP_PB_RELAX=88, 1250 MATOP_GET_VECS=89, 1251 MATOP_MAT_MULT=90, 1252 MATOP_MAT_MULT_SYMBOLIC=91, 1253 MATOP_MAT_MULT_NUMERIC=92, 1254 MATOP_PTAP=93, 1255 MATOP_PTAP_SYMBOLIC=94, 1256 MATOP_PTAP_NUMERIC=95, 1257 MATOP_MAT_MULTTRANSPOSE=96, 1258 MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97, 1259 MATOP_MAT_MULTTRANSPOSE_NUMERIC=98, 1260 MATOP_PTAP_SYMBOLIC_SEQAIJ=99, 1261 MATOP_PTAP_NUMERIC_SEQAIJ=100, 1262 MATOP_PTAP_SYMBOLIC_MPIAIJ=101, 1263 MATOP_PTAP_NUMERIC_MPIAIJ=102 1264 } MatOperation; 1265 EXTERN PetscErrorCode MatHasOperation(Mat,MatOperation,PetscTruth*); 1266 EXTERN PetscErrorCode MatShellSetOperation(Mat,MatOperation,void(*)(void)); 1267 EXTERN PetscErrorCode MatShellGetOperation(Mat,MatOperation,void(**)(void)); 1268 EXTERN PetscErrorCode MatShellSetContext(Mat,void*); 1269 1270 /* 1271 Codes for matrices stored on disk. By default they are 1272 stored in a universal format. By changing the format with 1273 PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will 1274 be stored in a way natural for the matrix, for example dense matrices 1275 would be stored as dense. Matrices stored this way may only be 1276 read into matrices of the same time. 1277 */ 1278 #define MATRIX_BINARY_FORMAT_DENSE -1 1279 1280 EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat,PetscReal); 1281 EXTERN PetscErrorCode MatSeqAIJGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *); 1282 EXTERN PetscErrorCode MatMPIRowbsGetColor(Mat,ISColoring *); 1283 1284 EXTERN PetscErrorCode MatISGetLocalMat(Mat,Mat*); 1285 1286 /*S 1287 MatNullSpace - Object that removes a null space from a vector, i.e. 1288 orthogonalizes the vector to a subsapce 1289 1290 Level: advanced 1291 1292 Concepts: matrix; linear operator, null space 1293 1294 Users manual sections: 1295 . sec_singular 1296 1297 .seealso: MatNullSpaceCreate() 1298 S*/ 1299 typedef struct _p_MatNullSpace* MatNullSpace; 1300 1301 EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*); 1302 EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace); 1303 EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace,Vec,Vec*); 1304 EXTERN PetscErrorCode MatNullSpaceAttach(Mat,MatNullSpace); 1305 EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace,Mat); 1306 1307 EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat,IS); 1308 EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat,PetscReal); 1309 EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat,PetscInt *); 1310 1311 1312 EXTERN PetscErrorCode MatCreateMAIJ(Mat,PetscInt,Mat*); 1313 EXTERN PetscErrorCode MatMAIJRedimension(Mat,PetscInt,Mat*); 1314 EXTERN PetscErrorCode MatMAIJGetAIJ(Mat,Mat*); 1315 1316 EXTERN PetscErrorCode MatComputeExplicitOperator(Mat,Mat*); 1317 1318 EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat,Vec); 1319 1320 EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 1321 EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 1322 1323 PETSC_EXTERN_CXX_END 1324 #endif 1325