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