1 /* 2 Include file for the matrix component of PETSc 3 */ 4 #ifndef PETSCMAT_H 5 #define PETSCMAT_H 6 7 #include <petscvec.h> 8 9 /* SUBMANSEC = Mat */ 10 11 /*S 12 Mat - Abstract PETSc matrix object used to manage all linear operators in PETSc, even those without 13 an explicit sparse representation (such as matrix-free operators) 14 15 Level: beginner 16 17 .seealso: `MatCreate()`, `MatType`, `MatSetType()`, `MatDestroy()` 18 S*/ 19 typedef struct _p_Mat *Mat; 20 21 /*J 22 MatType - String with the name of a PETSc matrix type 23 24 Level: beginner 25 26 .seealso: `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()` 27 J*/ 28 typedef const char *MatType; 29 #define MATSAME "same" 30 #define MATMAIJ "maij" 31 #define MATSEQMAIJ "seqmaij" 32 #define MATMPIMAIJ "mpimaij" 33 #define MATKAIJ "kaij" 34 #define MATSEQKAIJ "seqkaij" 35 #define MATMPIKAIJ "mpikaij" 36 #define MATIS "is" 37 #define MATAIJ "aij" 38 #define MATSEQAIJ "seqaij" 39 #define MATMPIAIJ "mpiaij" 40 #define MATAIJCRL "aijcrl" 41 #define MATSEQAIJCRL "seqaijcrl" 42 #define MATMPIAIJCRL "mpiaijcrl" 43 #define MATAIJCUSPARSE "aijcusparse" 44 #define MATSEQAIJCUSPARSE "seqaijcusparse" 45 #define MATMPIAIJCUSPARSE "mpiaijcusparse" 46 #define MATAIJKOKKOS "aijkokkos" 47 #define MATSEQAIJKOKKOS "seqaijkokkos" 48 #define MATMPIAIJKOKKOS "mpiaijkokkos" 49 #define MATAIJVIENNACL "aijviennacl" 50 #define MATSEQAIJVIENNACL "seqaijviennacl" 51 #define MATMPIAIJVIENNACL "mpiaijviennacl" 52 #define MATAIJPERM "aijperm" 53 #define MATSEQAIJPERM "seqaijperm" 54 #define MATMPIAIJPERM "mpiaijperm" 55 #define MATAIJSELL "aijsell" 56 #define MATSEQAIJSELL "seqaijsell" 57 #define MATMPIAIJSELL "mpiaijsell" 58 #define MATAIJMKL "aijmkl" 59 #define MATSEQAIJMKL "seqaijmkl" 60 #define MATMPIAIJMKL "mpiaijmkl" 61 #define MATBAIJMKL "baijmkl" 62 #define MATSEQBAIJMKL "seqbaijmkl" 63 #define MATMPIBAIJMKL "mpibaijmkl" 64 #define MATSHELL "shell" 65 #define MATCENTERING "centering" 66 #define MATDENSE "dense" 67 #define MATDENSECUDA "densecuda" 68 #define MATSEQDENSE "seqdense" 69 #define MATSEQDENSECUDA "seqdensecuda" 70 #define MATMPIDENSE "mpidense" 71 #define MATMPIDENSECUDA "mpidensecuda" 72 #define MATELEMENTAL "elemental" 73 #define MATSCALAPACK "scalapack" 74 #define MATBAIJ "baij" 75 #define MATSEQBAIJ "seqbaij" 76 #define MATMPIBAIJ "mpibaij" 77 #define MATMPIADJ "mpiadj" 78 #define MATSBAIJ "sbaij" 79 #define MATSEQSBAIJ "seqsbaij" 80 #define MATMPISBAIJ "mpisbaij" 81 #define MATMFFD "mffd" 82 #define MATNORMAL "normal" 83 #define MATNORMALHERMITIAN "normalh" 84 #define MATLRC "lrc" 85 #define MATSCATTER "scatter" 86 #define MATBLOCKMAT "blockmat" 87 #define MATCOMPOSITE "composite" 88 #define MATFFT "fft" 89 #define MATFFTW "fftw" 90 #define MATSEQCUFFT "seqcufft" 91 #define MATTRANSPOSEMAT "transpose" 92 #define MATSCHURCOMPLEMENT "schurcomplement" 93 #define MATPYTHON "python" 94 #define MATHYPRE "hypre" 95 #define MATHYPRESTRUCT "hyprestruct" 96 #define MATHYPRESSTRUCT "hypresstruct" 97 #define MATSUBMATRIX "submatrix" 98 #define MATLOCALREF "localref" 99 #define MATNEST "nest" 100 #define MATPREALLOCATOR "preallocator" 101 #define MATSELL "sell" 102 #define MATSEQSELL "seqsell" 103 #define MATMPISELL "mpisell" 104 #define MATDUMMY "dummy" 105 #define MATLMVM "lmvm" 106 #define MATLMVMDFP "lmvmdfp" 107 #define MATLMVMBFGS "lmvmbfgs" 108 #define MATLMVMSR1 "lmvmsr1" 109 #define MATLMVMBROYDEN "lmvmbroyden" 110 #define MATLMVMBADBROYDEN "lmvmbadbroyden" 111 #define MATLMVMSYMBROYDEN "lmvmsymbroyden" 112 #define MATLMVMSYMBADBROYDEN "lmvmsymbadbroyden" 113 #define MATLMVMDIAGBROYDEN "lmvmdiagbroyden" 114 #define MATCONSTANTDIAGONAL "constantdiagonal" 115 #define MATHTOOL "htool" 116 #define MATH2OPUS "h2opus" 117 118 /*J 119 MatSolverType - String with the name of a PETSc matrix solver type. 120 121 For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc 122 123 Level: beginner 124 125 Notes: MATSOLVERUMFPACK, MATSOLVERCHOLMOD, MATSOLVERKLU, MATSOLVERSPQR form the SuiteSparse package for which you can use --download-suitesparse 126 127 .seealso: `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()` 128 J*/ 129 typedef const char *MatSolverType; 130 #define MATSOLVERSUPERLU "superlu" 131 #define MATSOLVERSUPERLU_DIST "superlu_dist" 132 #define MATSOLVERSTRUMPACK "strumpack" 133 #define MATSOLVERUMFPACK "umfpack" 134 #define MATSOLVERCHOLMOD "cholmod" 135 #define MATSOLVERKLU "klu" 136 #define MATSOLVERSPARSEELEMENTAL "sparseelemental" 137 #define MATSOLVERELEMENTAL "elemental" 138 #define MATSOLVERSCALAPACK "scalapack" 139 #define MATSOLVERESSL "essl" 140 #define MATSOLVERLUSOL "lusol" 141 #define MATSOLVERMUMPS "mumps" 142 #define MATSOLVERMKL_PARDISO "mkl_pardiso" 143 #define MATSOLVERMKL_CPARDISO "mkl_cpardiso" 144 #define MATSOLVERPASTIX "pastix" 145 #define MATSOLVERMATLAB "matlab" 146 #define MATSOLVERPETSC "petsc" 147 #define MATSOLVERBAS "bas" 148 #define MATSOLVERCUSPARSE "cusparse" 149 #define MATSOLVERCUSPARSEBAND "cusparseband" 150 #define MATSOLVERCUDA "cuda" 151 #define MATSOLVERKOKKOS "kokkos" 152 #define MATSOLVERKOKKOSDEVICE "kokkosdevice" 153 #define MATSOLVERSPQR "spqr" 154 155 /*E 156 MatFactorType - indicates what type of factorization is requested 157 158 Level: beginner 159 160 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 161 162 .seealso: `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()` 163 E*/ 164 typedef enum { 165 MAT_FACTOR_NONE, 166 MAT_FACTOR_LU, 167 MAT_FACTOR_CHOLESKY, 168 MAT_FACTOR_ILU, 169 MAT_FACTOR_ICC, 170 MAT_FACTOR_ILUDT, 171 MAT_FACTOR_QR, 172 MAT_FACTOR_NUM_TYPES 173 } MatFactorType; 174 PETSC_EXTERN const char *const MatFactorTypes[]; 175 176 PETSC_EXTERN PetscErrorCode MatGetFactor(Mat, MatSolverType, MatFactorType, Mat *); 177 PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat, MatSolverType, MatFactorType, PetscBool *); 178 PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool *); 179 PETSC_DEPRECATED_FUNCTION("Use MatFactorGetCanUseOrdering() (since version 3.15)") static inline PetscErrorCode MatFactorGetUseOrdering(Mat A, PetscBool *b) { 180 return MatFactorGetCanUseOrdering(A, b); 181 } 182 PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat, MatSolverType *); 183 PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat, MatFactorType *); 184 PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat, MatFactorType); 185 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatSolverFunction)(Mat, MatFactorType, Mat *); 186 PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType, MatType, MatFactorType, MatSolverFunction); 187 PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType, MatType, MatFactorType, PetscBool *, PetscBool *, MatSolverFunction *); 188 typedef MatSolverType MatSolverPackage PETSC_DEPRECATED_TYPEDEF("Use MatSolverType (since version 3.9)"); 189 PETSC_DEPRECATED_FUNCTION("Use MatSolverTypeRegister() (since version 3.9)") static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype, MatType mtype, MatFactorType ftype, MatSolverFunction f) { 190 return MatSolverTypeRegister(stype, mtype, ftype, f); 191 } 192 PETSC_DEPRECATED_FUNCTION("Use MatSolverTypeGet() (since version 3.9)") static inline PetscErrorCode MatSolverPackageGet(MatSolverType stype, MatType mtype, MatFactorType ftype, PetscBool *foundmtype, PetscBool *foundstype, MatSolverFunction *f) { 193 return MatSolverTypeGet(stype, mtype, ftype, foundmtype, foundstype, f); 194 } 195 196 /*E 197 MatProductType - indicates what type of matrix product is requested 198 199 Level: beginner 200 201 .seealso: `MatProductSetType()` 202 E*/ 203 typedef enum { 204 MATPRODUCT_UNSPECIFIED = 0, 205 MATPRODUCT_AB, 206 MATPRODUCT_AtB, 207 MATPRODUCT_ABt, 208 MATPRODUCT_PtAP, 209 MATPRODUCT_RARt, 210 MATPRODUCT_ABC 211 } MatProductType; 212 PETSC_EXTERN const char *const MatProductTypes[]; 213 214 /*J 215 MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation 216 217 Level: beginner 218 219 .seealso: `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType` 220 J*/ 221 typedef const char *MatProductAlgorithm; 222 #define MATPRODUCTALGORITHMDEFAULT "default" 223 #define MATPRODUCTALGORITHMSORTED "sorted" 224 #define MATPRODUCTALGORITHMSCALABLE "scalable" 225 #define MATPRODUCTALGORITHMSCALABLEFAST "scalable_fast" 226 #define MATPRODUCTALGORITHMHEAP "heap" 227 #define MATPRODUCTALGORITHMBHEAP "btheap" 228 #define MATPRODUCTALGORITHMLLCONDENSED "llcondensed" 229 #define MATPRODUCTALGORITHMROWMERGE "rowmerge" 230 #define MATPRODUCTALGORITHMOUTERPRODUCT "outerproduct" 231 #define MATPRODUCTALGORITHMATB "at*b" 232 #define MATPRODUCTALGORITHMRAP "rap" 233 #define MATPRODUCTALGORITHMNONSCALABLE "nonscalable" 234 #define MATPRODUCTALGORITHMSEQMPI "seqmpi" 235 #define MATPRODUCTALGORITHMBACKEND "backend" 236 #define MATPRODUCTALGORITHMOVERLAPPING "overlapping" 237 #define MATPRODUCTALGORITHMMERGED "merged" 238 #define MATPRODUCTALGORITHMALLATONCE "allatonce" 239 #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged" 240 #define MATPRODUCTALGORITHMALLGATHERV "allgatherv" 241 #define MATPRODUCTALGORITHMCYCLIC "cyclic" 242 #if defined(PETSC_HAVE_HYPRE) 243 #define MATPRODUCTALGORITHMHYPRE "hypre" 244 #endif 245 246 PETSC_EXTERN PetscErrorCode MatProductCreate(Mat, Mat, Mat, Mat *); 247 PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat, Mat, Mat, Mat); 248 PETSC_EXTERN PetscErrorCode MatProductSetType(Mat, MatProductType); 249 PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat, MatProductAlgorithm); 250 PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat, PetscReal); 251 PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat); 252 PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat); 253 PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat); 254 PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat, Mat, Mat, Mat); 255 PETSC_EXTERN PetscErrorCode MatProductClear(Mat); 256 PETSC_EXTERN PetscErrorCode MatProductView(Mat, PetscViewer); 257 PETSC_EXTERN PetscErrorCode MatProductGetType(Mat, MatProductType *); 258 PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat, Mat *, Mat *, Mat *); 259 260 /* Logging support */ 261 #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */ 262 PETSC_EXTERN PetscClassId MAT_CLASSID; 263 PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID; 264 PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID; 265 PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID; 266 PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID; 267 PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID; 268 PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID; 269 PETSC_EXTERN PetscClassId MATMFFD_CLASSID; 270 271 /*E 272 MatReuse - Indicates if matrices obtained from a previous call to MatCreateSubMatrices(), MatCreateSubMatrix(), MatConvert() or several other functions 273 are to be reused to store the new matrix values. 274 275 $ MAT_INITIAL_MATRIX - create a new matrix 276 $ MAT_REUSE_MATRIX - reuse the matrix created with a previous call that used MAT_INITIAL_MATRIX 277 $ MAT_INPLACE_MATRIX - replace the first input matrix with the new matrix (not applicable to all functions) 278 $ MAT_IGNORE_MATRIX - do not create a new matrix or reuse a give matrix, just ignore that matrix argument (not applicable to all functions) 279 280 Level: beginner 281 282 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 283 284 .seealso: `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()` 285 E*/ 286 typedef enum { 287 MAT_INITIAL_MATRIX, 288 MAT_REUSE_MATRIX, 289 MAT_IGNORE_MATRIX, 290 MAT_INPLACE_MATRIX 291 } MatReuse; 292 293 /*E 294 MatCreateSubMatrixOption - Indicates if matrices obtained from a call to MatCreateSubMatrices() 295 include the matrix values. Currently it is only used by MatGetSeqNonzeroStructure(). 296 297 Level: beginner 298 299 .seealso: `MatGetSeqNonzeroStructure()` 300 E*/ 301 typedef enum { 302 MAT_DO_NOT_GET_VALUES, 303 MAT_GET_VALUES 304 } MatCreateSubMatrixOption; 305 306 PETSC_EXTERN PetscErrorCode MatInitializePackage(void); 307 308 PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *); 309 PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt); 310 PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType); 311 PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *); 312 PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType); 313 PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat); 314 PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]); 315 PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat)); 316 PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]); 317 PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]); 318 PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]); 319 PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]); 320 PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]); 321 PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]); 322 PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool); 323 324 PETSC_EXTERN PetscFunctionList MatList; 325 PETSC_EXTERN PetscFunctionList MatColoringList; 326 PETSC_EXTERN PetscFunctionList MatPartitioningList; 327 328 /*E 329 MatStructure - Indicates if two matrices have the same nonzero structure 330 331 Level: beginner 332 333 $ SAME_NONZERO_PATTERN - the two matrices have identical nonzero patterns 334 $ DIFFERENT_NONZERO_PATTERN - the two matrices may have different nonzero patterns 335 $ SUBSET_NONZERO_PATTERN - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix 336 $ UNKNOWN_NONZERO_PATTERN - there is no known relationship between the nonzero patterns. In this case the implementations may try to detect a relationship to optimize the operation 337 338 Developer Notes: 339 Any additions/changes here MUST also be made in src/mat/f90-mod/petscmat.h 340 341 .seealso: `MatCopy()`, `MatAXPY()`, `MatAYPX()` 342 E*/ 343 typedef enum { 344 DIFFERENT_NONZERO_PATTERN, 345 SUBSET_NONZERO_PATTERN, 346 SAME_NONZERO_PATTERN, 347 UNKNOWN_NONZERO_PATTERN 348 } MatStructure; 349 PETSC_EXTERN const char *const MatStructures[]; 350 351 #if defined PETSC_HAVE_MKL_SPARSE 352 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 353 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 354 PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 355 PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 356 #endif 357 358 PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 359 PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 360 PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]); 361 PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 362 363 PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 364 PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 365 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 366 PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 367 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 368 PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 369 PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]); 370 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *); 371 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, Mat, Mat, const PetscInt[], Mat *); 372 373 PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 374 PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 375 PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 376 377 PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]); 378 PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]); 379 PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode); 380 381 PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *); 382 PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 383 384 PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 385 PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *); 386 PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 387 PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 388 PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]); 389 390 PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, void *, Mat *); 391 PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *); 392 PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *); 393 PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *); 394 PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *); 395 PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *); 396 PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *); 397 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 398 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 399 400 PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *); 401 PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter); 402 PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *); 403 PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *); 404 PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat); 405 PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat); 406 typedef enum { 407 MAT_COMPOSITE_MERGE_RIGHT, 408 MAT_COMPOSITE_MERGE_LEFT 409 } MatCompositeMergeType; 410 PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType); 411 PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *); 412 typedef enum { 413 MAT_COMPOSITE_ADDITIVE, 414 MAT_COMPOSITE_MULTIPLICATIVE 415 } MatCompositeType; 416 PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType); 417 PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *); 418 PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure); 419 PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *); 420 PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *); 421 PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *); 422 PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *); 423 424 PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *); 425 PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *); 426 427 PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *); 428 PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *); 429 PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *); 430 PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *); 431 PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *); 432 PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *); 433 PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *); 434 PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS); 435 PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *); 436 PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *); 437 438 #if defined(PETSC_HAVE_HYPRE) 439 PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 440 #endif 441 442 PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]); 443 PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]); 444 445 PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat); 446 PETSC_EXTERN PetscErrorCode MatSetUp(Mat); 447 PETSC_EXTERN PetscErrorCode MatDestroy(Mat *); 448 PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *); 449 450 PETSC_EXTERN PetscErrorCode MatConjugate(Mat); 451 PETSC_EXTERN PetscErrorCode MatRealPart(Mat); 452 PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat); 453 PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *); 454 PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *); 455 PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **); 456 PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *); 457 PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat); 458 PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *); 459 460 /* ------------------------------------------------------------*/ 461 PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 462 PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode); 463 PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 464 PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]); 465 PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]); 466 PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]); 467 PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom); 468 469 /*S 470 MatStencil - Data structure (C struct) for storing information about a single row or 471 column of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()` 472 473 The i,j, and k represent the logical coordinates over the entire grid (for 2 and 1 dimensional problems the k and j entries are ignored). 474 The c represents the the degrees of freedom at each grid point (the dof argument to `DMDASetDOF()`). If dof is 1 then this entry is ignored. 475 476 For stencil access to vectors see `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`. 477 478 Fortran usage is different, see `MatSetValuesStencil()` for details. 479 480 Level: beginner 481 482 .seealso: `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`, `DMDAVecGetArrayF90()` 483 S*/ 484 typedef struct { 485 PetscInt k, j, i, c; 486 } MatStencil; 487 488 PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode); 489 PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode); 490 PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt); 491 492 /*E 493 MatAssemblyType - Indicates if the matrix is now to be used, for example in a solver, or if you plan 494 to continue to add or insert values to it 495 496 Level: beginner 497 498 .seealso: `MatAssemblyBegin()`, `MatAssemblyEnd()` 499 E*/ 500 typedef enum { 501 MAT_FLUSH_ASSEMBLY = 1, 502 MAT_FINAL_ASSEMBLY = 0 503 } MatAssemblyType; 504 PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType); 505 PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType); 506 PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *); 507 508 /*E 509 MatOption - Options that may be set for a matrix and its behavior or storage 510 511 Level: beginner 512 513 Developer Notes: 514 Entries that are negative need not be called collectively by all processes. 515 516 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 517 518 Any additions/changes here must also be made in src/mat/interface/dlregismat.c in MatOptions[] 519 520 .seealso: `MatSetOption()` 521 E*/ 522 typedef enum { 523 MAT_OPTION_MIN = -3, 524 MAT_UNUSED_NONZERO_LOCATION_ERR = -2, 525 MAT_ROW_ORIENTED = -1, 526 MAT_SYMMETRIC = 1, 527 MAT_STRUCTURALLY_SYMMETRIC = 2, 528 MAT_FORCE_DIAGONAL_ENTRIES = 3, 529 MAT_IGNORE_OFF_PROC_ENTRIES = 4, 530 MAT_USE_HASH_TABLE = 5, 531 MAT_KEEP_NONZERO_PATTERN = 6, 532 MAT_IGNORE_ZERO_ENTRIES = 7, 533 MAT_USE_INODES = 8, 534 MAT_HERMITIAN = 9, 535 MAT_SYMMETRY_ETERNAL = 10, 536 MAT_NEW_NONZERO_LOCATION_ERR = 11, 537 MAT_IGNORE_LOWER_TRIANGULAR = 12, 538 MAT_ERROR_LOWER_TRIANGULAR = 13, 539 MAT_GETROW_UPPERTRIANGULAR = 14, 540 MAT_SPD = 15, 541 MAT_NO_OFF_PROC_ZERO_ROWS = 16, 542 MAT_NO_OFF_PROC_ENTRIES = 17, 543 MAT_NEW_NONZERO_LOCATIONS = 18, 544 MAT_NEW_NONZERO_ALLOCATION_ERR = 19, 545 MAT_SUBSET_OFF_PROC_ENTRIES = 20, 546 MAT_SUBMAT_SINGLEIS = 21, 547 MAT_STRUCTURE_ONLY = 22, 548 MAT_SORTED_FULL = 23, 549 MAT_FORM_EXPLICIT_TRANSPOSE = 24, 550 MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25, 551 MAT_SPD_ETERNAL = 26, 552 MAT_OPTION_MAX = 27 553 } MatOption; 554 555 PETSC_EXTERN const char *const *MatOptions; 556 PETSC_EXTERN PetscErrorCode MatSetOption(Mat, MatOption, PetscBool); 557 PETSC_EXTERN PetscErrorCode MatGetOption(Mat, MatOption, PetscBool *); 558 PETSC_EXTERN PetscErrorCode MatPropagateSymmetryOptions(Mat, Mat); 559 PETSC_EXTERN PetscErrorCode MatGetType(Mat, MatType *); 560 561 PETSC_EXTERN PetscErrorCode MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]); 562 PETSC_EXTERN PetscErrorCode MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]); 563 PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]); 564 PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat); 565 PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat); 566 PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat, Vec, PetscInt); 567 PETSC_EXTERN PetscErrorCode MatSeqAIJGetArray(Mat, PetscScalar *[]); 568 PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]); 569 PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]); 570 PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArray(Mat, PetscScalar *[]); 571 PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]); 572 PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]); 573 PETSC_EXTERN PetscErrorCode MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *); 574 PETSC_EXTERN PetscErrorCode MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 575 PETSC_EXTERN PetscErrorCode MatSeqAIJSetType(Mat, MatType); 576 PETSC_EXTERN PetscErrorCode MatSeqAIJKron(Mat, Mat, MatReuse, Mat *); 577 PETSC_EXTERN PetscErrorCode MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *)); 578 PETSC_EXTERN PetscFunctionList MatSeqAIJList; 579 PETSC_EXTERN PetscErrorCode MatSeqBAIJGetArray(Mat, PetscScalar *[]); 580 PETSC_EXTERN PetscErrorCode MatSeqBAIJRestoreArray(Mat, PetscScalar *[]); 581 PETSC_EXTERN PetscErrorCode MatSeqSBAIJGetArray(Mat, PetscScalar *[]); 582 PETSC_EXTERN PetscErrorCode MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]); 583 PETSC_EXTERN PetscErrorCode MatDenseGetArray(Mat, PetscScalar *[]); 584 PETSC_EXTERN PetscErrorCode MatDenseRestoreArray(Mat, PetscScalar *[]); 585 PETSC_EXTERN PetscErrorCode MatDensePlaceArray(Mat, const PetscScalar[]); 586 PETSC_EXTERN PetscErrorCode MatDenseReplaceArray(Mat, const PetscScalar[]); 587 PETSC_EXTERN PetscErrorCode MatDenseResetArray(Mat); 588 PETSC_EXTERN PetscErrorCode MatDenseGetArrayRead(Mat, const PetscScalar *[]); 589 PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayRead(Mat, const PetscScalar *[]); 590 PETSC_EXTERN PetscErrorCode MatDenseGetArrayWrite(Mat, PetscScalar *[]); 591 PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWrite(Mat, PetscScalar *[]); 592 PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat, PetscInt *); 593 PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat, PetscInt); 594 PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat, PetscInt *, PetscInt *); 595 PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat, PetscInt, PetscInt); 596 PETSC_EXTERN PetscErrorCode MatSetBlockSizesFromMats(Mat, Mat, Mat); 597 PETSC_EXTERN PetscErrorCode MatSetVariableBlockSizes(Mat, PetscInt, PetscInt *); 598 PETSC_EXTERN PetscErrorCode MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt **); 599 600 PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]); 601 PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]); 602 PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *); 603 PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *); 604 PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *); 605 PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *); 606 PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *); 607 PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *); 608 PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 609 PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *); 610 611 PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec); 612 PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec); 613 PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec); 614 PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec); 615 PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec); 616 PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *); 617 PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *); 618 PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec); 619 PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec); 620 PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat); 621 PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat); 622 PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat); 623 PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec); 624 625 /*E 626 MatDuplicateOption - Indicates if a duplicated sparse matrix should have 627 its numerical values copied over or just its nonzero structure. 628 629 Level: beginner 630 631 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 632 633 $ `MAT_DO_NOT_COPY_VALUES` - Create a matrix using the same nonzero pattern as the original matrix, 634 $ with zeros for the numerical values. 635 $ `MAT_COPY_VALUES` - Create a matrix with the same nonzero pattern as the original matrix 636 $ and with the same numerical values. 637 $ `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix 638 $ and does not copy it, using zeros for the numerical values. The parent and 639 $ child matrices will share their index (i and j) arrays, and you cannot 640 $ insert new nonzero entries into either matrix. 641 642 Note: 643 Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in 644 this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified. 645 646 .seealso: `MatDuplicate()` 647 E*/ 648 typedef enum { 649 MAT_DO_NOT_COPY_VALUES, 650 MAT_COPY_VALUES, 651 MAT_SHARE_NONZERO_PATTERN 652 } MatDuplicateOption; 653 654 PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *); 655 PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *); 656 657 PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure); 658 PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer); 659 PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *); 660 PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *); 661 PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *); 662 PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *); 663 PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *); 664 PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *); 665 PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *); 666 PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat, PetscBool *, PetscInt *); 667 PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer); 668 669 PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 670 PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 671 PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 672 PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *); 673 674 /*S 675 MatInfo - Context of matrix information, used with `MatGetInfo()` 676 677 In Fortran this is simply a double precision array of dimension `MAT_INFO_SIZE` 678 679 Level: intermediate 680 681 .seealso: `MatGetInfo()`, `MatInfoType` 682 S*/ 683 typedef struct { 684 PetscLogDouble block_size; /* block size */ 685 PetscLogDouble nz_allocated, nz_used, nz_unneeded; /* number of nonzeros */ 686 PetscLogDouble memory; /* memory allocated */ 687 PetscLogDouble assemblies; /* number of matrix assemblies called */ 688 PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 689 PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */ 690 PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 691 } MatInfo; 692 693 /*E 694 MatInfoType - Indicates if you want information about the local part of the matrix, 695 the entire parallel matrix or the maximum over all the local parts. 696 697 Level: beginner 698 699 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 700 701 .seealso: `MatGetInfo()`, `MatInfo` 702 E*/ 703 typedef enum { 704 MAT_LOCAL = 1, 705 MAT_GLOBAL_MAX = 2, 706 MAT_GLOBAL_SUM = 3 707 } MatInfoType; 708 PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *); 709 PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec); 710 PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]); 711 PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]); 712 PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]); 713 PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]); 714 PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec); 715 PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *); 716 PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *); 717 PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat); 718 PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *); 719 PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *); 720 PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec); 721 PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode); 722 723 PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *); 724 PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *); 725 PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *); 726 PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *); 727 PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *); 728 PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *); 729 PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *); 730 PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 731 PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 732 PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 733 PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 734 PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *); 735 PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *); 736 737 PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *); 738 PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *); 739 PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *); 740 PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *); 741 PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *); 742 PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *); 743 PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *); 744 PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *); 745 PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *); 746 PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat); 747 PETSC_EXTERN PetscErrorCode MatSetInf(Mat); 748 PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 749 PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec); 750 PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec); 751 PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec); 752 PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 753 PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec); 754 755 PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *); 756 PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *); 757 PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *); 758 PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **); 759 PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *); 760 PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **); 761 PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *); 762 763 PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]); 764 PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatrices() (since version 3.8)") static inline PetscErrorCode MatGetSubMatrices(Mat mat, PetscInt n, const IS irow[], const IS icol[], MatReuse scall, Mat *submat[]) { 765 return MatCreateSubMatrices(mat, n, irow, icol, scall, submat); 766 } 767 PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]); 768 PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatricesMPI() (since version 3.8)") static inline PetscErrorCode MatGetSubMatricesMPI(Mat mat, PetscInt n, const IS irow[], const IS icol[], MatReuse scall, Mat *submat[]) { 769 return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat); 770 } 771 PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]); 772 PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]); 773 PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *); 774 PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatrix() (since version 3.8)") static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat) { 775 return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat); 776 } 777 PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *); 778 PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *); 779 PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *); 780 PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *); 781 782 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *); 783 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *); 784 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat); 785 PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *); 786 PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *); 787 PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *); 788 PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *); 789 PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *); 790 PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *); 791 PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]); 792 793 PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt); 794 PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat mat, PetscInt n, IS is[], PetscInt ov); 795 PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool); 796 797 PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *); 798 799 PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *); 800 PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *); 801 802 PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *); 803 PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *); 804 805 PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *); 806 PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *); 807 808 PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure); 809 PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure); 810 811 PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar); 812 PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar); 813 814 PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping); 815 PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *); 816 PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *); 817 PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout); 818 PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 819 PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec); 820 PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec); 821 PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec); 822 PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]); 823 PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 824 PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode); 825 826 PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt); 827 PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *); 828 829 PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec); 830 PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec); 831 PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec); 832 PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *); 833 PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *); 834 PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *); 835 PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *); 836 PETSC_DEPRECATED_FUNCTION("Use MatCreateVecs() (since version 3.6)") static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y) { 837 return MatCreateVecs(mat, x, y); 838 } 839 PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *); 840 PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *); 841 PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *); 842 PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *); 843 PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *); 844 845 /*MC 846 MatSetValue - Set a single entry into a matrix. 847 848 Not collective 849 850 Synopsis: 851 #include <petscmat.h> 852 PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode) 853 854 Input Parameters: 855 + m - the matrix 856 . row - the row location of the entry 857 . col - the column location of the entry 858 . value - the value to insert 859 - mode - either `INSERT_VALUES` or `ADD_VALUES` 860 861 Notes: 862 For efficiency one should use `MatSetValues()` and set several values simultaneously. 863 864 Level: beginner 865 866 .seealso: `MatGetValue()`, `MatSetValues()`, `MatSetValueLocal()`, `MatSetValuesLocal()` 867 M*/ 868 static inline PetscErrorCode MatSetValue(Mat v, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode) { 869 return MatSetValues(v, 1, &i, 1, &j, &va, mode); 870 } 871 872 /*@C 873 MatGetValue - Gets a single value from a matrix 874 875 Not Collective; can only return a value owned by the given process 876 877 Input Parameters: 878 + mat - the matrix 879 . row - the row location of the entry 880 - col - the column location of the entry 881 882 Output Parameter: 883 . va - the value 884 885 Notes: 886 For efficiency one should use `MatGetValues()` and get several values simultaneously. 887 888 See notes for `MatGetValues()`. 889 890 Level: advanced 891 892 .seealso: `MatSetValue()`, `MatGetValueLocal()`, `MatGetValues()` 893 @*/ 894 static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va) { 895 return MatGetValues(mat, 1, &row, 1, &col, va); 896 } 897 898 /*MC 899 MatSetValueLocal - Inserts or adds a single value into a matrix, 900 using a local numbering of the nodes. 901 902 Not Collective 903 904 Input Parameters: 905 + m - the matrix 906 . row - the row location of the entry 907 . col - the column location of the entry 908 . value - the value to insert 909 - mode - either `INSERT_VALUES` or `ADD_VALUES` 910 911 Notes: 912 For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously. 913 914 See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used. 915 916 Level: intermediate 917 918 .seealso: `MatSetValue()`, `MatSetValuesLocal()` 919 M*/ 920 static inline PetscErrorCode MatSetValueLocal(Mat v, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode) { 921 return MatSetValuesLocal(v, 1, &i, 1, &j, &va, mode); 922 } 923 924 /*MC 925 MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per 926 row in a matrix providing the data that one can use to correctly preallocate the matrix. 927 928 Synopsis: 929 #include <petscmat.h> 930 PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 931 932 Collective 933 934 Input Parameters: 935 + comm - the communicator that will share the eventually allocated matrix 936 . nrows - the number of LOCAL rows in the matrix 937 - ncols - the number of LOCAL columns in the matrix 938 939 Output Parameters: 940 + dnz - the array that will be passed to the matrix preallocation routines 941 - onz - the other array passed to the matrix preallocation routines 942 943 Level: intermediate 944 945 Notes: 946 This is a macro that handles its own error checking, it does not return an error code. 947 948 See Users-Manual: ch_performance for more details. 949 950 Do not malloc or free dnz and onz, that is handled internally by these routines 951 952 Developer Notes: 953 This is a MACRO not a function because it has a leading { that is closed by PetscPreallocateFinalize(). 954 955 .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 956 `MatPreallocateSymmetricSetLocalBlock()` 957 M*/ 958 #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \ 959 do { \ 960 PetscInt __nrows = (nrows), __ncols = (ncols), __rstart, __start, __end = 0; \ 961 PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \ 962 PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \ 963 __start = __end - __ncols; \ 964 (void)__start; \ 965 PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \ 966 __rstart -= __nrows 967 968 #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO("GCC warning \"Use MatPreallocateBegin() (since version 3.18)\"") MatPreallocateBegin(__VA_ARGS__) 969 970 /*MC 971 MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 972 inserted using a local number of the rows and columns 973 974 Synopsis: 975 #include <petscmat.h> 976 PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 977 978 Not Collective 979 980 Input Parameters: 981 + map - the row mapping from local numbering to global numbering 982 . nrows - the number of rows indicated 983 . rows - the indices of the rows 984 . cmap - the column mapping from local to global numbering 985 . ncols - the number of columns in the matrix 986 . cols - the columns indicated 987 . dnz - the array that will be passed to the matrix preallocation routines 988 - onz - the other array passed to the matrix preallocation routines 989 990 Level: intermediate 991 992 Notes: 993 See Users-Manual: ch_performance for more details. 994 995 Do not malloc or free dnz and onz, that is handled internally by these routines 996 997 .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 998 `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()` 999 M*/ 1000 #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 1001 PetscMacroReturnStandard(PetscCall(ISLocalToGlobalMappingApply(rmap, nrows, rows, rows)); PetscCall(ISLocalToGlobalMappingApply(cmap, ncols, cols, cols)); for (PetscInt __l = 0; __l < nrows; __l++) PetscCall(MatPreallocateSet((rows)[__l], ncols, cols, dnz, onz));) 1002 1003 /*MC 1004 MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1005 inserted using a local number of the rows and columns. This version removes any duplicate columns in cols 1006 1007 Synopsis: 1008 #include <petscmat.h> 1009 PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1010 1011 Not Collective 1012 1013 Input Parameters: 1014 + map - the row mapping from local numbering to global numbering 1015 . nrows - the number of rows indicated 1016 . rows - the indices of the rows (these values are mapped to the global values) 1017 . cmap - the column mapping from local to global numbering 1018 . ncols - the number of columns in the matrix (this value will be changed if duplicate columns are found) 1019 . cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed) 1020 . dnz - the array that will be passed to the matrix preallocation routines 1021 - onz - the other array passed to the matrix preallocation routines 1022 1023 Level: intermediate 1024 1025 Notes: 1026 See Users-Manual: ch_performance for more details. 1027 1028 Do not malloc or free dnz and onz, that is handled internally by these routines 1029 1030 .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1031 `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()` 1032 M*/ 1033 #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 1034 PetscMacroReturnStandard(PetscCall(ISLocalToGlobalMappingApply(rmap, nrows, rows, rows)); PetscCall(ISLocalToGlobalMappingApply(cmap, ncols, cols, cols)); PetscCall(PetscSortRemoveDupsInt(&ncols, cols)); for (PetscInt __l = 0; __l < nrows; __l++) PetscCall(MatPreallocateSet((rows)[__l], ncols, cols, dnz, onz));) 1035 1036 /*MC 1037 MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1038 inserted using a local number of the rows and columns 1039 1040 Synopsis: 1041 #include <petscmat.h> 1042 PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1043 1044 Not Collective 1045 1046 Input Parameters: 1047 + map - the row mapping from local numbering to global numbering 1048 . nrows - the number of rows indicated 1049 . rows - the indices of the rows 1050 . cmap - the column mapping from local to global numbering 1051 . ncols - the number of columns in the matrix 1052 . cols - the columns indicated 1053 . dnz - the array that will be passed to the matrix preallocation routines 1054 - onz - the other array passed to the matrix preallocation routines 1055 1056 Level: intermediate 1057 1058 Notes: 1059 See Users-Manual: ch_performance for more details. 1060 1061 Do not malloc or free dnz and onz, that is handled internally by these routines 1062 1063 .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1064 `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()` 1065 M*/ 1066 #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \ 1067 PetscMacroReturnStandard(PetscCall(ISLocalToGlobalMappingApplyBlock(rmap, nrows, rows, rows)); PetscCall(ISLocalToGlobalMappingApplyBlock(cmap, ncols, cols, cols)); for (PetscInt __l = 0; __l < nrows; __l++) PetscCall(MatPreallocateSet((rows)[__l], ncols, cols, dnz, onz));) 1068 1069 /*MC 1070 MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1071 inserted using a local number of the rows and columns 1072 1073 Synopsis: 1074 #include <petscmat.h> 1075 PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1076 1077 Not Collective 1078 1079 Input Parameters: 1080 + map - the mapping between local numbering and global numbering 1081 . nrows - the number of rows indicated 1082 . rows - the indices of the rows 1083 . ncols - the number of columns in the matrix 1084 . cols - the columns indicated 1085 . dnz - the array that will be passed to the matrix preallocation routines 1086 - onz - the other array passed to the matrix preallocation routines 1087 1088 Level: intermediate 1089 1090 Notes: 1091 See Users-Manual: ch_performance for more details. 1092 1093 Do not malloc or free dnz and onz that is handled internally by these routines 1094 1095 .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()` 1096 `MatPreallocateBegin()`, `MatPreallocateSetLocal()` 1097 M*/ 1098 #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \ 1099 PetscMacroReturnStandard(PetscCall(ISLocalToGlobalMappingApplyBlock(map, nrows, rows, rows)); PetscCall(ISLocalToGlobalMappingApplyBlock(map, ncols, cols, cols)); for (PetscInt __l = 0; __l < nrows; __l++) PetscCall(MatPreallocateSymmetricSetBlock((rows)[__l], ncols, cols, dnz, onz));) 1100 1101 /*MC 1102 MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1103 inserted using a local number of the rows and columns 1104 1105 Synopsis: 1106 #include <petscmat.h> 1107 PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1108 1109 Not Collective 1110 1111 Input Parameters: 1112 + row - the row 1113 . ncols - the number of columns in the matrix 1114 - cols - the columns indicated 1115 1116 Output Parameters: 1117 + dnz - the array that will be passed to the matrix preallocation routines 1118 - onz - the other array passed to the matrix preallocation routines 1119 1120 Level: intermediate 1121 1122 Notes: 1123 See Users-Manual: ch_performance for more details. 1124 1125 Do not malloc or free dnz and onz that is handled internally by these routines 1126 1127 This is a MACRO not a function because it uses variables declared in MatPreallocateBegin(). 1128 1129 .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()` 1130 `MatPreallocateBegin()`, `MatPreallocateSetLocal()` 1131 M*/ 1132 #define MatPreallocateSet(row, nc, cols, dnz, onz) \ 1133 PetscMacroReturnStandard(PetscCheck(row >= __rstart, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Trying to set preallocation for row %" PetscInt_FMT " less than first local row %" PetscInt_FMT, row, __rstart); PetscCheck(row < __rstart + __nrows, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Trying to set preallocation for row %" PetscInt_FMT " greater than last local row %" PetscInt_FMT, row, __rstart + __nrows - 1); for (PetscInt __i = 0; __i < nc; ++__i) { \ 1134 if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \ 1135 else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \ 1136 }) 1137 1138 /*MC 1139 MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be 1140 inserted using a local number of the rows and columns 1141 1142 Synopsis: 1143 #include <petscmat.h> 1144 PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 1145 1146 Not Collective 1147 1148 Input Parameters: 1149 + nrows - the number of rows indicated 1150 . rows - the indices of the rows 1151 . ncols - the number of columns in the matrix 1152 . cols - the columns indicated 1153 . dnz - the array that will be passed to the matrix preallocation routines 1154 - onz - the other array passed to the matrix preallocation routines 1155 1156 Level: intermediate 1157 1158 Notes: 1159 See Users-Manual: ch_performance for more details. 1160 1161 Do not malloc or free dnz and onz that is handled internally by these routines 1162 1163 This is a MACRO not a function because it uses variables declared in MatPreallocateBegin(). 1164 1165 .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`, 1166 `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()` 1167 M*/ 1168 #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \ 1169 PetscMacroReturnStandard(for (PetscInt __i = 0; __i < nc; __i++) { \ 1170 if (cols[__i] >= __end) onz[row - __rstart]++; \ 1171 else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \ 1172 }) 1173 1174 /*MC 1175 MatPreallocateLocation - An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists 1176 1177 Synopsis: 1178 #include <petscmat.h> 1179 PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz) 1180 1181 Not Collective 1182 1183 Input Parameters: 1184 + A - matrix 1185 . row - row where values exist (must be local to this process) 1186 . ncols - number of columns 1187 . cols - columns with nonzeros 1188 . dnz - the array that will be passed to the matrix preallocation routines 1189 - onz - the other array passed to the matrix preallocation routines 1190 1191 Level: intermediate 1192 1193 Notes: 1194 See Users-Manual: ch_performance for more details. 1195 1196 Do not malloc or free dnz and onz that is handled internally by these routines 1197 1198 This is a MACRO not a function because it uses a bunch of variables private to the MatPreallocation.... routines. 1199 1200 .seealso: `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1201 `MatPreallocateSymmetricSetLocalBlock()` 1202 M*/ 1203 #define MatPreallocateLocation(A, row, ncols, cols, dnz, onz) (A ? MatSetValues(A, 1, &row, ncols, cols, NULL, INSERT_VALUES) : MatPreallocateSet(row, ncols, cols, dnz, onz)) 1204 1205 /*MC 1206 MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per 1207 row in a matrix providing the data that one can use to correctly preallocate the matrix. 1208 1209 Synopsis: 1210 #include <petscmat.h> 1211 PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz) 1212 1213 Collective 1214 1215 Input Parameters: 1216 + dnz - the array that was be passed to the matrix preallocation routines 1217 - onz - the other array passed to the matrix preallocation routines 1218 1219 Level: intermediate 1220 1221 Notes: 1222 This is a macro that handles its own error checking, it does not return an error code. 1223 1224 See Users-Manual: ch_performance for more details. 1225 1226 Do not malloc or free dnz and onz, that is handled internally by these routines 1227 1228 Developer Notes: 1229 This is a MACRO not a function because it closes the { started in MatPreallocateBegin(). 1230 1231 .seealso: `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`, 1232 `MatPreallocateSymmetricSetLocalBlock()` 1233 M*/ 1234 #define MatPreallocateEnd(dnz, onz) \ 1235 PetscCall(PetscFree2(dnz, onz)); \ 1236 } \ 1237 while (0) 1238 1239 #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO("GCC warning \"Use MatPreallocateEnd() (since version 3.18)\"") MatPreallocateEnd(__VA_ARGS__) 1240 1241 /* Routines unique to particular data structures */ 1242 PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, void *); 1243 1244 PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *); 1245 PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *); 1246 1247 PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]); 1248 PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]); 1249 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1250 PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1251 PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *); 1252 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscInt, PetscBool); 1253 1254 #define MAT_SKIP_ALLOCATION -4 1255 1256 PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1257 PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1258 PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]); 1259 PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt); 1260 1261 PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1262 PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1263 PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1264 PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]); 1265 PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 1266 PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]); 1267 PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]); 1268 PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]); 1269 PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *); 1270 PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *); 1271 PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]); 1272 PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]); 1273 PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]); 1274 PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]); 1275 PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *); 1276 1277 PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *); 1278 PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt); 1279 PETSC_DEPRECATED_FUNCTION("Use MatDenseSetLDA() (since version 3.14)") static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda) { 1280 return MatDenseSetLDA(A, lda); 1281 } 1282 PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *); 1283 1284 PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]); 1285 1286 PETSC_EXTERN PetscErrorCode MatStoreValues(Mat); 1287 PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat); 1288 1289 PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *); 1290 PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *); 1291 /* 1292 These routines are not usually accessed directly, rather solving is 1293 done through the KSP and PC interfaces. 1294 */ 1295 1296 /*J 1297 MatOrderingType - String with the name of a PETSc matrix ordering 1298 1299 Level: beginner 1300 1301 Notes: 1302 If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and utilizes one built into the factorization package 1303 1304 .seealso: `MatGetOrdering()` 1305 J*/ 1306 typedef const char *MatOrderingType; 1307 #define MATORDERINGNATURAL "natural" 1308 #define MATORDERINGND "nd" 1309 #define MATORDERING1WD "1wd" 1310 #define MATORDERINGRCM "rcm" 1311 #define MATORDERINGQMD "qmd" 1312 #define MATORDERINGROWLENGTH "rowlength" 1313 #define MATORDERINGWBM "wbm" 1314 #define MATORDERINGSPECTRAL "spectral" 1315 #define MATORDERINGAMD "amd" /* only works if UMFPACK is installed with PETSc */ 1316 #define MATORDERINGMETISND "metisnd" /* only works if METIS is installed with PETSc */ 1317 #define MATORDERINGNATURAL_OR_ND "natural_or_nd" /* special coase used for Cholesky and ICC, allows ND when AIJ matrix is used but Natural when SBAIJ is used */ 1318 #define MATORDERINGEXTERNAL "external" /* uses an ordering type internal to the factorization package */ 1319 1320 PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat, MatOrderingType, IS *, IS *); 1321 PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFunctionList *); 1322 PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *)); 1323 PETSC_EXTERN PetscFunctionList MatOrderingList; 1324 1325 PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS); 1326 PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *); 1327 1328 PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *); 1329 1330 /*S 1331 MatFactorShiftType - Numeric Shift for factorizations 1332 1333 Level: beginner 1334 1335 .seealso: `MatGetFactor()` 1336 S*/ 1337 typedef enum { 1338 MAT_SHIFT_NONE, 1339 MAT_SHIFT_NONZERO, 1340 MAT_SHIFT_POSITIVE_DEFINITE, 1341 MAT_SHIFT_INBLOCKS 1342 } MatFactorShiftType; 1343 PETSC_EXTERN const char *const MatFactorShiftTypes[]; 1344 PETSC_EXTERN const char *const MatFactorShiftTypesDetail[]; 1345 1346 /*S 1347 MatFactorError - indicates what type of error was generated in a matrix factorization 1348 1349 Level: beginner 1350 1351 Developer Note: 1352 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 1353 1354 .seealso: `MatGetFactor()` 1355 S*/ 1356 typedef enum { 1357 MAT_FACTOR_NOERROR, 1358 MAT_FACTOR_STRUCT_ZEROPIVOT, 1359 MAT_FACTOR_NUMERIC_ZEROPIVOT, 1360 MAT_FACTOR_OUTMEMORY, 1361 MAT_FACTOR_OTHER 1362 } MatFactorError; 1363 1364 PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *); 1365 PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat); 1366 PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *); 1367 1368 /*S 1369 MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization 1370 1371 In Fortran these are simply double precision arrays of size `MAT_FACTORINFO_SIZE`, that is use 1372 $ MatFactorInfo info(MAT_FACTORINFO_SIZE) 1373 1374 Notes: 1375 These are not usually directly used by users, instead use `PC` type of `PCLU`, `PCILU`, `PCCHOLESKY` or `PCICC`. 1376 1377 You can use `MatFactorInfoInitialize()` to set default values. 1378 1379 Level: developer 1380 1381 .seealso: `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`, `MatICCFactorSymbolic()`, `MatICCFactor()`, 1382 `MatFactorInfoInitialize()` 1383 1384 S*/ 1385 typedef struct { 1386 PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 1387 PetscReal usedt; 1388 PetscReal dt; /* drop tolerance */ 1389 PetscReal dtcol; /* tolerance for pivoting */ 1390 PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 1391 PetscReal fill; /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */ 1392 PetscReal levels; /* ICC/ILU(levels) */ 1393 PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 1394 factorization may be faster if do not pivot */ 1395 PetscReal zeropivot; /* pivot is called zero if less than this */ 1396 PetscReal shifttype; /* type of shift added to matrix factor to prevent zero pivots */ 1397 PetscReal shiftamount; /* how large the shift is */ 1398 } MatFactorInfo; 1399 1400 PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *); 1401 PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *); 1402 PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 1403 PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *); 1404 PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *); 1405 PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *); 1406 PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *); 1407 PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *); 1408 PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 1409 PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *); 1410 PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *); 1411 PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *); 1412 PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *); 1413 PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *); 1414 PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *); 1415 PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec); 1416 PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec); 1417 PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec); 1418 PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec); 1419 PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec); 1420 PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec); 1421 PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs); 1422 PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat); 1423 1424 typedef enum { 1425 MAT_FACTOR_SCHUR_UNFACTORED, 1426 MAT_FACTOR_SCHUR_FACTORED, 1427 MAT_FACTOR_SCHUR_INVERTED 1428 } MatFactorSchurStatus; 1429 PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS); 1430 PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *); 1431 PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus); 1432 PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat); 1433 PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *); 1434 PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec); 1435 PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec); 1436 PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat); 1437 1438 PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat); 1439 /*E 1440 MatSORType - What type of (S)SOR to perform 1441 1442 Level: beginner 1443 1444 May be bitwise ORd together 1445 1446 Developer Notes: 1447 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 1448 1449 `MatSORType` may be bitwise ORd together, so do not change the numerical values 1450 1451 .seealso: `MatSOR()` 1452 E*/ 1453 typedef enum { 1454 SOR_FORWARD_SWEEP = 1, 1455 SOR_BACKWARD_SWEEP = 2, 1456 SOR_SYMMETRIC_SWEEP = 3, 1457 SOR_LOCAL_FORWARD_SWEEP = 4, 1458 SOR_LOCAL_BACKWARD_SWEEP = 8, 1459 SOR_LOCAL_SYMMETRIC_SWEEP = 12, 1460 SOR_ZERO_INITIAL_GUESS = 16, 1461 SOR_EISENSTAT = 32, 1462 SOR_APPLY_UPPER = 64, 1463 SOR_APPLY_LOWER = 128 1464 } MatSORType; 1465 PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec); 1466 1467 /*S 1468 MatColoring - Object for managing the coloring of matrices. 1469 1470 Level: beginner 1471 1472 Notes: 1473 Coloring of matrices can be computed directly from the sparse matrix nonzero structure via the `MatColoring` object or from the mesh from which the 1474 matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors). 1475 1476 Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This 1477 same object can also be used to efficiently convert data created by Automatic Differentation tools to PETSc sparse matrices. 1478 1479 .seealso: `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`, `MatOrdering`, `MatPartitioning`, `MatColoringType` 1480 S*/ 1481 typedef struct _p_MatColoring *MatColoring; 1482 1483 /*J 1484 MatColoringType - String with the name of a PETSc matrix coloring 1485 1486 Level: beginner 1487 1488 .seealso: `MatColoringSetType()`, `MatColoring` 1489 J*/ 1490 typedef const char *MatColoringType; 1491 #define MATCOLORINGJP "jp" 1492 #define MATCOLORINGPOWER "power" 1493 #define MATCOLORINGNATURAL "natural" 1494 #define MATCOLORINGSL "sl" 1495 #define MATCOLORINGLF "lf" 1496 #define MATCOLORINGID "id" 1497 #define MATCOLORINGGREEDY "greedy" 1498 1499 /*E 1500 MatColoringWeightType - Type of weight scheme 1501 1502 Not Collective 1503 1504 + `MAT_COLORING_RANDOM` - Random weights 1505 . `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering. 1506 - `MAT_COLORING_LF` - Last-first weighting. 1507 1508 Level: intermediate 1509 1510 Developer Note: 1511 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 1512 1513 .seealso: `MatColoring`, `MatColoringCreate()` 1514 E*/ 1515 typedef enum { 1516 MAT_COLORING_WEIGHT_RANDOM, 1517 MAT_COLORING_WEIGHT_LEXICAL, 1518 MAT_COLORING_WEIGHT_LF, 1519 MAT_COLORING_WEIGHT_SL 1520 } MatColoringWeightType; 1521 1522 PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *); 1523 PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *); 1524 PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *); 1525 PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer); 1526 PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType); 1527 PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring); 1528 PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt); 1529 PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *); 1530 PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt); 1531 PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *); 1532 PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *); 1533 PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring)); 1534 PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *); 1535 PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType); 1536 PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *); 1537 PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm); 1538 PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring); 1539 PETSC_DEPRECATED_FUNCTION("Use MatColoringTest() (since version 3.10)") static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring) { 1540 return MatColoringTest(matcoloring, iscoloring); 1541 } 1542 PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring); 1543 1544 /*S 1545 MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring 1546 1547 Level: beginner 1548 1549 Notes: 1550 This object is creating utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()` 1551 1552 .seealso: `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()` 1553 S*/ 1554 typedef struct _p_MatFDColoring *MatFDColoring; 1555 1556 PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *); 1557 PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *); 1558 PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer); 1559 PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, PetscErrorCode (*)(void), void *); 1560 PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, PetscErrorCode (**)(void), void **); 1561 PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal); 1562 PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring); 1563 PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *); 1564 PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec); 1565 PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]); 1566 PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring); 1567 PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt); 1568 PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *); 1569 1570 /*S 1571 MatTransposeColoring - Object for computing a sparse matrix product C=A*B^T via coloring 1572 1573 Level: beginner 1574 1575 .seealso: `MatTransposeColoringCreate()` 1576 S*/ 1577 typedef struct _p_MatTransposeColoring *MatTransposeColoring; 1578 1579 PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *); 1580 PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat); 1581 PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat); 1582 PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *); 1583 1584 /*S 1585 MatPartitioning - Object for managing the partitioning of a matrix or graph 1586 1587 Level: beginner 1588 1589 Note: 1590 There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations 1591 via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`) 1592 1593 Developers Note: 1594 It is an extra maintainance and documentation cost to have two objects with the same functionality. 1595 1596 .seealso: `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()` 1597 S*/ 1598 typedef struct _p_MatPartitioning *MatPartitioning; 1599 1600 /*J 1601 MatPartitioningType - String with the name of a PETSc matrix partitioning 1602 1603 Level: beginner 1604 dm 1605 .seealso: `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()` 1606 J*/ 1607 typedef const char *MatPartitioningType; 1608 #define MATPARTITIONINGCURRENT "current" 1609 #define MATPARTITIONINGAVERAGE "average" 1610 #define MATPARTITIONINGSQUARE "square" 1611 #define MATPARTITIONINGPARMETIS "parmetis" 1612 #define MATPARTITIONINGCHACO "chaco" 1613 #define MATPARTITIONINGPARTY "party" 1614 #define MATPARTITIONINGPTSCOTCH "ptscotch" 1615 #define MATPARTITIONINGHIERARCH "hierarch" 1616 1617 PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *); 1618 PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType); 1619 PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt); 1620 PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat); 1621 PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt); 1622 PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]); 1623 PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]); 1624 PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool); 1625 PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *); 1626 PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *); 1627 PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *); 1628 PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS); 1629 PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *); 1630 PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *); 1631 PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning)); 1632 PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer); 1633 PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]); 1634 PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning); 1635 PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *); 1636 1637 PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part); 1638 PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 1639 PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *); 1640 1641 typedef enum { 1642 MP_CHACO_MULTILEVEL = 1, 1643 MP_CHACO_SPECTRAL = 2, 1644 MP_CHACO_LINEAR = 4, 1645 MP_CHACO_RANDOM = 5, 1646 MP_CHACO_SCATTERED = 6 1647 } MPChacoGlobalType; 1648 PETSC_EXTERN const char *const MPChacoGlobalTypes[]; 1649 typedef enum { 1650 MP_CHACO_KERNIGHAN = 1, 1651 MP_CHACO_NONE = 2 1652 } MPChacoLocalType; 1653 PETSC_EXTERN const char *const MPChacoLocalTypes[]; 1654 typedef enum { 1655 MP_CHACO_LANCZOS = 0, 1656 MP_CHACO_RQI = 1 1657 } MPChacoEigenType; 1658 PETSC_EXTERN const char *const MPChacoEigenTypes[]; 1659 1660 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType); 1661 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *); 1662 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType); 1663 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *); 1664 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal); 1665 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType); 1666 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *); 1667 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal); 1668 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *); 1669 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt); 1670 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *); 1671 1672 #define MP_PARTY_OPT "opt" 1673 #define MP_PARTY_LIN "lin" 1674 #define MP_PARTY_SCA "sca" 1675 #define MP_PARTY_RAN "ran" 1676 #define MP_PARTY_GBF "gbf" 1677 #define MP_PARTY_GCF "gcf" 1678 #define MP_PARTY_BUB "bub" 1679 #define MP_PARTY_DEF "def" 1680 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *); 1681 #define MP_PARTY_HELPFUL_SETS "hs" 1682 #define MP_PARTY_KERNIGHAN_LIN "kl" 1683 #define MP_PARTY_NONE "no" 1684 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *); 1685 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal); 1686 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool); 1687 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool); 1688 1689 typedef enum { 1690 MP_PTSCOTCH_DEFAULT, 1691 MP_PTSCOTCH_QUALITY, 1692 MP_PTSCOTCH_SPEED, 1693 MP_PTSCOTCH_BALANCE, 1694 MP_PTSCOTCH_SAFETY, 1695 MP_PTSCOTCH_SCALABILITY 1696 } MPPTScotchStrategyType; 1697 PETSC_EXTERN const char *const MPPTScotchStrategyTypes[]; 1698 1699 PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal); 1700 PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *); 1701 PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType); 1702 PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *); 1703 1704 /* 1705 * hierarchical partitioning 1706 */ 1707 PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *); 1708 PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *); 1709 PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt); 1710 PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt); 1711 1712 PETSC_EXTERN PetscErrorCode MatMeshToVertexGraph(Mat, PetscInt, Mat *); 1713 PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *); 1714 1715 /* 1716 If you add entries here you must also add them to src/mat/f90-mod/petscmat.h 1717 If any of the enum values are changed, also update dMatOps dict at src/binding/petsc4py/src/libpetsc4py/libpetsc4py.pyx 1718 */ 1719 typedef enum { 1720 MATOP_SET_VALUES = 0, 1721 MATOP_GET_ROW = 1, 1722 MATOP_RESTORE_ROW = 2, 1723 MATOP_MULT = 3, 1724 MATOP_MULT_ADD = 4, 1725 MATOP_MULT_TRANSPOSE = 5, 1726 MATOP_MULT_TRANSPOSE_ADD = 6, 1727 MATOP_SOLVE = 7, 1728 MATOP_SOLVE_ADD = 8, 1729 MATOP_SOLVE_TRANSPOSE = 9, 1730 MATOP_SOLVE_TRANSPOSE_ADD = 10, 1731 MATOP_LUFACTOR = 11, 1732 MATOP_CHOLESKYFACTOR = 12, 1733 MATOP_SOR = 13, 1734 MATOP_TRANSPOSE = 14, 1735 MATOP_GETINFO = 15, 1736 MATOP_EQUAL = 16, 1737 MATOP_GET_DIAGONAL = 17, 1738 MATOP_DIAGONAL_SCALE = 18, 1739 MATOP_NORM = 19, 1740 MATOP_ASSEMBLY_BEGIN = 20, 1741 MATOP_ASSEMBLY_END = 21, 1742 MATOP_SET_OPTION = 22, 1743 MATOP_ZERO_ENTRIES = 23, 1744 MATOP_ZERO_ROWS = 24, 1745 MATOP_LUFACTOR_SYMBOLIC = 25, 1746 MATOP_LUFACTOR_NUMERIC = 26, 1747 MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27, 1748 MATOP_CHOLESKY_FACTOR_NUMERIC = 28, 1749 MATOP_SETUP = 29, 1750 MATOP_ILUFACTOR_SYMBOLIC = 30, 1751 MATOP_ICCFACTOR_SYMBOLIC = 31, 1752 MATOP_GET_DIAGONAL_BLOCK = 32, 1753 MATOP_SET_INF = 33, 1754 MATOP_DUPLICATE = 34, 1755 MATOP_FORWARD_SOLVE = 35, 1756 MATOP_BACKWARD_SOLVE = 36, 1757 MATOP_ILUFACTOR = 37, 1758 MATOP_ICCFACTOR = 38, 1759 MATOP_AXPY = 39, 1760 MATOP_CREATE_SUBMATRICES = 40, 1761 MATOP_INCREASE_OVERLAP = 41, 1762 MATOP_GET_VALUES = 42, 1763 MATOP_COPY = 43, 1764 MATOP_GET_ROW_MAX = 44, 1765 MATOP_SCALE = 45, 1766 MATOP_SHIFT = 46, 1767 MATOP_DIAGONAL_SET = 47, 1768 MATOP_ZERO_ROWS_COLUMNS = 48, 1769 MATOP_SET_RANDOM = 49, 1770 MATOP_GET_ROW_IJ = 50, 1771 MATOP_RESTORE_ROW_IJ = 51, 1772 MATOP_GET_COLUMN_IJ = 52, 1773 MATOP_RESTORE_COLUMN_IJ = 53, 1774 MATOP_FDCOLORING_CREATE = 54, 1775 MATOP_COLORING_PATCH = 55, 1776 MATOP_SET_UNFACTORED = 56, 1777 MATOP_PERMUTE = 57, 1778 MATOP_SET_VALUES_BLOCKED = 58, 1779 MATOP_CREATE_SUBMATRIX = 59, 1780 MATOP_DESTROY = 60, 1781 MATOP_VIEW = 61, 1782 MATOP_CONVERT_FROM = 62, 1783 /* MATOP_PLACEHOLDER_63=63 */ 1784 MATOP_MATMAT_MULT_SYMBOLIC = 64, 1785 MATOP_MATMAT_MULT_NUMERIC = 65, 1786 MATOP_SET_LOCAL_TO_GLOBAL_MAP = 66, 1787 MATOP_SET_VALUES_LOCAL = 67, 1788 MATOP_ZERO_ROWS_LOCAL = 68, 1789 MATOP_GET_ROW_MAX_ABS = 69, 1790 MATOP_GET_ROW_MIN_ABS = 70, 1791 MATOP_CONVERT = 71, 1792 MATOP_HAS_OPERATION = 72, 1793 /* MATOP_PLACEHOLDER_73=73, */ 1794 MATOP_SET_VALUES_ADIFOR = 74, 1795 MATOP_FD_COLORING_APPLY = 75, 1796 MATOP_SET_FROM_OPTIONS = 76, 1797 /* MATOP_PLACEHOLDER_77=77, */ 1798 /* MATOP_PLACEHOLDER_78=78, */ 1799 MATOP_FIND_ZERO_DIAGONALS = 79, 1800 MATOP_MULT_MULTIPLE = 80, 1801 MATOP_SOLVE_MULTIPLE = 81, 1802 MATOP_GET_INERTIA = 82, 1803 MATOP_LOAD = 83, 1804 MATOP_IS_SYMMETRIC = 84, 1805 MATOP_IS_HERMITIAN = 85, 1806 MATOP_IS_STRUCTURALLY_SYMMETRIC = 86, 1807 MATOP_SET_VALUES_BLOCKEDLOCAL = 87, 1808 MATOP_CREATE_VECS = 88, 1809 /* MATOP_PLACEHOLDER_89=89, */ 1810 MATOP_MAT_MULT_SYMBOLIC = 90, 1811 MATOP_MAT_MULT_NUMERIC = 91, 1812 /* MATOP_PLACEHOLDER_92=92, */ 1813 MATOP_PTAP_SYMBOLIC = 93, 1814 MATOP_PTAP_NUMERIC = 94, 1815 /* MATOP_PLACEHOLDER_95=95, */ 1816 MATOP_MAT_TRANSPOSE_MULT_SYMBO = 96, 1817 MATOP_MAT_TRANSPOSE_MULT_NUMER = 97, 1818 MATOP_BIND_TO_CPU = 98, 1819 MATOP_PRODUCTSETFROMOPTIONS = 99, 1820 MATOP_PRODUCTSYMBOLIC = 100, 1821 MATOP_PRODUCTNUMERIC = 101, 1822 MATOP_CONJUGATE = 102, 1823 MATOP_VIEW_NATIVE = 103, 1824 MATOP_SET_VALUES_ROW = 104, 1825 MATOP_REAL_PART = 105, 1826 MATOP_IMAGINARY_PART = 106, 1827 MATOP_GET_ROW_UPPER_TRIANGULAR = 107, 1828 MATOP_RESTORE_ROW_UPPER_TRIANG = 108, 1829 MATOP_MAT_SOLVE = 109, 1830 MATOP_MAT_SOLVE_TRANSPOSE = 110, 1831 MATOP_GET_ROW_MIN = 111, 1832 MATOP_GET_COLUMN_VECTOR = 112, 1833 MATOP_MISSING_DIAGONAL = 113, 1834 MATOP_GET_SEQ_NONZERO_STRUCTUR = 114, 1835 MATOP_CREATE = 115, 1836 MATOP_GET_GHOSTS = 116, 1837 MATOP_GET_LOCAL_SUB_MATRIX = 117, 1838 MATOP_RESTORE_LOCALSUB_MATRIX = 118, 1839 MATOP_MULT_DIAGONAL_BLOCK = 119, 1840 MATOP_HERMITIAN_TRANSPOSE = 120, 1841 MATOP_MULT_HERMITIAN_TRANSPOSE = 121, 1842 MATOP_MULT_HERMITIAN_TRANS_ADD = 122, 1843 MATOP_GET_MULTI_PROC_BLOCK = 123, 1844 MATOP_FIND_NONZERO_ROWS = 124, 1845 MATOP_GET_COLUMN_NORMS = 125, 1846 MATOP_INVERT_BLOCK_DIAGONAL = 126, 1847 MATOP_INVERT_VBLOCK_DIAGONAL = 127, 1848 MATOP_CREATE_SUB_MATRICES_MPI = 128, 1849 MATOP_SET_VALUES_BATCH = 129, 1850 /* MATOP_PLACEHOLDER_130=130, */ 1851 MATOP_TRANSPOSE_MAT_MULT_SYMBO = 131, 1852 MATOP_TRANSPOSE_MAT_MULT_NUMER = 132, 1853 MATOP_TRANSPOSE_COLORING_CREAT = 133, 1854 MATOP_TRANS_COLORING_APPLY_SPT = 134, 1855 MATOP_TRANS_COLORING_APPLY_DEN = 135, 1856 /* MATOP_PLACEHOLDER_136=136, */ 1857 MATOP_RART_SYMBOLIC = 137, 1858 MATOP_RART_NUMERIC = 138, 1859 MATOP_SET_BLOCK_SIZES = 139, 1860 MATOP_AYPX = 140, 1861 MATOP_RESIDUAL = 141, 1862 MATOP_FDCOLORING_SETUP = 142, 1863 MATOP_FIND_OFFBLOCK_ENTRIES = 143, 1864 MATOP_MPICONCATENATESEQ = 144, 1865 MATOP_DESTROYSUBMATRICES = 145, 1866 MATOP_TRANSPOSE_SOLVE = 146, 1867 MATOP_GET_VALUES_LOCAL = 147 1868 } MatOperation; 1869 PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, void (*)(void)); 1870 PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, void (**)(void)); 1871 PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *); 1872 PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *); 1873 PETSC_DEPRECATED_FUNCTION("Use MatProductClear() (since version 3.14)") static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A) { 1874 return MatProductClear(A); 1875 } 1876 PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, void (*)(void)); 1877 PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, void (**)(void)); 1878 PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, void *); 1879 PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscErrorCode (*)(void *)); 1880 PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType); 1881 PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *); 1882 PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *); 1883 PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat); 1884 PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscErrorCode (*)(void *), MatType, MatType); 1885 PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *); 1886 1887 /* 1888 Codes for matrices stored on disk. By default they are 1889 stored in a universal format. By changing the format with 1890 PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will 1891 be stored in a way natural for the matrix, for example dense matrices 1892 would be stored as dense. Matrices stored this way may only be 1893 read into matrices of the same type. 1894 */ 1895 #define MATRIX_BINARY_FORMAT_DENSE -1 1896 1897 PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal); 1898 1899 PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType); 1900 PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]); 1901 PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool); 1902 PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool); 1903 PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *); 1904 PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *); 1905 PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat); 1906 PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *); 1907 PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use the MatConvert() interface (since version 3.10)") PetscErrorCode MatISGetMPIXAIJ(Mat, MatReuse, Mat *); 1908 1909 /*S 1910 MatNullSpace - Object that removes a null space from a vector, i.e. 1911 orthogonalizes the vector to a subspace 1912 1913 Level: advanced 1914 1915 .seealso: `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()` 1916 S*/ 1917 typedef struct _p_MatNullSpace *MatNullSpace; 1918 1919 PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *); 1920 PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, PetscErrorCode (*)(MatNullSpace, Vec, void *), void *); 1921 PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *); 1922 PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec); 1923 PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *); 1924 PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *); 1925 PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace); 1926 PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace); 1927 PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace); 1928 PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *); 1929 PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *); 1930 PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer); 1931 PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **); 1932 PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *); 1933 1934 PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS); 1935 PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat, PetscReal); 1936 PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *); 1937 1938 PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *); 1939 PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *); 1940 PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *); 1941 1942 PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *); 1943 PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *); 1944 1945 PETSC_DEPRECATED_FUNCTION("Use MatComputeOperator() (since version 3.12)") static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B) { 1946 return MatComputeOperator(A, NULL, B); 1947 } 1948 PETSC_DEPRECATED_FUNCTION("Use MatComputeOperatorTranspose() (since version 3.12)") static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B) { 1949 return MatComputeOperatorTranspose(A, NULL, B); 1950 } 1951 1952 PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *); 1953 PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *); 1954 PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **); 1955 PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **); 1956 PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **); 1957 PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **); 1958 PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **); 1959 PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **); 1960 PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **); 1961 PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **); 1962 PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat); 1963 PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]); 1964 PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]); 1965 PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *); 1966 1967 PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec); 1968 1969 PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 1970 PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec); 1971 PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, PetscErrorCode (*)(void *, Vec, Vec), void *); 1972 PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, PetscErrorCode (*)(void *, PetscInt, Vec, PetscScalar *)); 1973 PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, PetscErrorCode (*)(void *, Vec)); 1974 PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt); 1975 PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat); 1976 PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal); 1977 PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt); 1978 PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *); 1979 PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]); 1980 PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *); 1981 PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, PetscErrorCode (*)(void *, Vec, Vec, PetscScalar *), void *); 1982 1983 /*S 1984 MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free 1985 Jacobian vector products 1986 1987 Notes: 1988 `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure 1989 1990 MatMFFD*() methods actually take the Mat as their first argument. Not a `MatMFFD` data structure 1991 1992 Level: developer 1993 1994 .seealso: `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()` 1995 S*/ 1996 typedef struct _p_MatMFFD *MatMFFD; 1997 1998 /*J 1999 MatMFFDType - algorithm used to compute the h used in computing matrix-vector products via differencing of the function 2000 2001 Level: beginner 2002 2003 .seealso: `MatMFFDSetType()`, `MatMFFDRegister()` 2004 J*/ 2005 typedef const char *MatMFFDType; 2006 #define MATMFFD_DS "ds" 2007 #define MATMFFD_WP "wp" 2008 2009 PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType); 2010 PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD)); 2011 2012 PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal); 2013 PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool); 2014 2015 PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType); 2016 2017 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 2018 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 2019 2020 #ifdef PETSC_HAVE_H2OPUS 2021 PETSC_EXTERN_TYPEDEF typedef PetscScalar (*MatH2OpusKernel)(PetscInt, PetscReal[], PetscReal[], void *); 2022 PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernel, void *, PetscReal, PetscInt, PetscInt, Mat *); 2023 PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *); 2024 PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal); 2025 PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat); 2026 PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal); 2027 PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool); 2028 PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *); 2029 PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *); 2030 PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *); 2031 PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar); 2032 #endif 2033 2034 #ifdef PETSC_HAVE_HTOOL 2035 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatHtoolKernel)(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *); 2036 PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernel, void *, Mat *); 2037 PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernel, void *); 2038 PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *); 2039 PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *); 2040 PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool); 2041 /*E 2042 MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL` 2043 2044 Level: beginner 2045 2046 Values: 2047 + `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation 2048 . `MAT_HTOOL_COMPRESSOR_FULL_ACA` - full adaptive cross approximation 2049 - `MAT_HTOOL_COMPRESSOR_SVD` - singular value decomposition 2050 2051 .seealso: `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType` 2052 E*/ 2053 typedef enum { 2054 MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA, 2055 MAT_HTOOL_COMPRESSOR_FULL_ACA, 2056 MAT_HTOOL_COMPRESSOR_SVD 2057 } MatHtoolCompressorType; 2058 /*E 2059 MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL` 2060 2061 Level: beginner 2062 2063 Values: 2064 + `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default) - axis computed via principle component analysis, split uniformly 2065 . `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC` - axis computed via principle component analysis, split barycentrically 2066 . `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR` - axis along the largest extent of the bounding box, split uniformly 2067 - `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically 2068 2069 Notes: higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types 2070 2071 .seealso: `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType` 2072 E*/ 2073 typedef enum { 2074 MAT_HTOOL_CLUSTERING_PCA_REGULAR, 2075 MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC, 2076 MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR, 2077 MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC 2078 } MatHtoolClusteringType; 2079 #endif 2080 2081 #ifdef PETSC_HAVE_MUMPS 2082 PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt); 2083 PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *); 2084 PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal); 2085 PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *); 2086 2087 PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *); 2088 PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *); 2089 PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *); 2090 PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *); 2091 PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat); 2092 PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat); 2093 #endif 2094 2095 #ifdef PETSC_HAVE_MKL_PARDISO 2096 PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt); 2097 #endif 2098 2099 #ifdef PETSC_HAVE_MKL_CPARDISO 2100 PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt); 2101 #endif 2102 2103 #ifdef PETSC_HAVE_SUPERLU 2104 PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal); 2105 #endif 2106 2107 #ifdef PETSC_HAVE_SUPERLU_DIST 2108 PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *); 2109 #endif 2110 2111 #ifdef PETSC_HAVE_STRUMPACK 2112 /*E 2113 MatSTRUMPACKReordering - sparsity reducing ordering to be used in `STRUMPACK` 2114 2115 Level: intermediate 2116 E*/ 2117 typedef enum { 2118 MAT_STRUMPACK_NATURAL = 0, 2119 MAT_STRUMPACK_METIS = 1, 2120 MAT_STRUMPACK_PARMETIS = 2, 2121 MAT_STRUMPACK_SCOTCH = 3, 2122 MAT_STRUMPACK_PTSCOTCH = 4, 2123 MAT_STRUMPACK_RCM = 5 2124 } MatSTRUMPACKReordering; 2125 PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering); 2126 PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool); 2127 PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSRelTol(Mat, PetscReal); 2128 PETSC_DEPRECATED_FUNCTION("Use MatSTRUMPACKSetHSSRelTol() (since version 3.9)") static inline PetscErrorCode MatSTRUMPACKSetHSSRelCompTol(Mat mat, PetscReal rtol) { 2129 return MatSTRUMPACKSetHSSRelTol(mat, rtol); 2130 } 2131 PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSAbsTol(Mat, PetscReal); 2132 PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSMinSepSize(Mat, PetscInt); 2133 PETSC_DEPRECATED_FUNCTION("Use MatSTRUMPACKSetHSSMinSepSize() (since version 3.9)") static inline PetscErrorCode MatSTRUMPACKSetHSSMinSize(Mat mat, PetscInt hssminsize) { 2134 return MatSTRUMPACKSetHSSMinSepSize(mat, hssminsize); 2135 } 2136 PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSMaxRank(Mat, PetscInt); 2137 PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSLeafSize(Mat, PetscInt); 2138 #endif 2139 2140 PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool); 2141 PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *); 2142 PETSC_DEPRECATED_FUNCTION("Use MatBindToCPU (since v3.13)") static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg) { 2143 return MatBindToCPU(A, flg); 2144 } 2145 PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool); 2146 PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *); 2147 2148 typedef struct _n_SplitCSRMat *PetscSplitCSRDataStructure; 2149 PETSC_EXTERN PetscErrorCode MatCUSPARSEGetDeviceMatWrite(Mat, PetscSplitCSRDataStructure *); 2150 2151 #ifdef PETSC_HAVE_KOKKOS_KERNELS 2152 PETSC_EXTERN PetscErrorCode MatKokkosGetDeviceMatWrite(Mat, PetscSplitCSRDataStructure *); 2153 PETSC_EXTERN PetscErrorCode MatSeqAIJKokkosSetDeviceMat(Mat, PetscSplitCSRDataStructure); 2154 PETSC_EXTERN PetscErrorCode MatSeqAIJKokkosGetDeviceMat(Mat, PetscSplitCSRDataStructure *); 2155 #endif 2156 2157 #ifdef PETSC_HAVE_CUDA 2158 /*E 2159 MatCUSPARSEStorageFormat - indicates the storage format for CUSPARSE (GPU) 2160 matrices. 2161 2162 Not Collective 2163 2164 + `MAT_CUSPARSE_CSR` - Compressed Sparse Row 2165 . `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later). 2166 - `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later). 2167 2168 Level: intermediate 2169 2170 Developer Note: 2171 Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h 2172 2173 .seealso: `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation` 2174 E*/ 2175 2176 typedef enum { 2177 MAT_CUSPARSE_CSR, 2178 MAT_CUSPARSE_ELL, 2179 MAT_CUSPARSE_HYB 2180 } MatCUSPARSEStorageFormat; 2181 2182 /* these will be strings associated with enumerated type defined above */ 2183 PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[]; 2184 2185 /*E 2186 MatCUSPARSEFormatOperation - indicates the operation of CUSPARSE (GPU) 2187 matrices whose operation should use a particular storage format. 2188 2189 Not Collective 2190 2191 + `MAT_CUSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel MatMult 2192 . `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the offdiagonal matrix in the parallel MatMult 2193 . `MAT_CUSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) MatMult 2194 - `MAT_CUSPARSE_ALL` - sets the storage format for all CUSPARSE (GPU) matrices 2195 2196 Level: intermediate 2197 2198 .seealso: `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat` 2199 E*/ 2200 typedef enum { 2201 MAT_CUSPARSE_MULT_DIAG, 2202 MAT_CUSPARSE_MULT_OFFDIAG, 2203 MAT_CUSPARSE_MULT, 2204 MAT_CUSPARSE_ALL 2205 } MatCUSPARSEFormatOperation; 2206 2207 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 2208 PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 2209 PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat); 2210 PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool); 2211 typedef struct Mat_SeqAIJCUSPARSETriFactors *Mat_SeqAIJCUSPARSETriFactors_p; 2212 PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const int **, const int **); 2213 PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const int **, const int **); 2214 PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **); 2215 PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **); 2216 PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **); 2217 PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **); 2218 PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **); 2219 PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **); 2220 2221 PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *); 2222 PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *); 2223 PETSC_EXTERN PetscErrorCode MatMPIDenseCUDASetPreallocation(Mat, PetscScalar[]); 2224 PETSC_EXTERN PetscErrorCode MatSeqDenseCUDASetPreallocation(Mat, PetscScalar[]); 2225 PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **); 2226 PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **); 2227 PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **); 2228 PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **); 2229 PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **); 2230 PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **); 2231 PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *); 2232 PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *); 2233 PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat); 2234 2235 #endif 2236 2237 #if defined(PETSC_HAVE_VIENNACL) 2238 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *); 2239 PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *); 2240 #endif 2241 2242 #if defined(PETSC_HAVE_FFTW) 2243 PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec); 2244 PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec); 2245 PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *); 2246 #endif 2247 2248 #if defined(PETSC_HAVE_SCALAPACK) 2249 PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *); 2250 PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt); 2251 PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *); 2252 #endif 2253 2254 PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *); 2255 PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *); 2256 PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]); 2257 PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]); 2258 PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***); 2259 PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *); 2260 PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType); 2261 PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]); 2262 PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat); 2263 2264 PETSC_EXTERN PetscErrorCode MatChop(Mat, PetscReal); 2265 PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *); 2266 2267 PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **); 2268 2269 PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat); 2270 2271 PETSC_INTERN PetscErrorCode MatHeaderMerge(Mat, Mat *); 2272 PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *); 2273 2274 PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *); 2275 2276 PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, Mat *); 2277 PETSC_EXTERN PetscErrorCode MatFilter(Mat, PetscReal, Mat *); 2278 2279 #endif 2280