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