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