Actual source code: petscmat.h
1: /*
2: Include file for the matrix component of PETSc
3: */
4: #pragma once
6: #include <petscvec.h>
8: /* SUBMANSEC = Mat */
10: /*S
11: Mat - Abstract PETSc matrix object used to manage all linear operators in PETSc, even those without
12: an explicit sparse representation (such as matrix-free operators). Also used to hold representations of graphs
13: for graph operations such as coloring, `MatColoringCreate()`
15: Level: beginner
17: Note:
18: See [](doc_matrix), [](ch_matrices) and `MatType` for available matrix types
20: .seealso: [](doc_matrix), [](ch_matrices), `MatCreate()`, `MatType`, `MatSetType()`, `MatDestroy()`
21: S*/
22: typedef struct _p_Mat *Mat;
24: /*S
25: MatState - Snapshot of the state of a `Mat`
27: Level: developer
29: Note:
30: A `MatState` records the object id, state, and nonzero state of a `Mat`.
32: .seealso: [](ch_matrices), `Mat`, `MatGetState()`, `MatStateCompare()`, `MatStateCompareUpdate()`, `MatStateInvalidate()`, `PetscObjectGetId()`
33: S*/
34: typedef struct {
35: PetscObjectId id;
36: PetscObjectState state;
37: PetscObjectState nonzerostate;
38: } MatState;
40: /*J
41: MatType - String with the name of a PETSc matrix type. These are all the matrix formats that PETSc provides.
43: Level: beginner
45: Notes:
46: [](doc_matrix) for a table of available matrix types
48: Use `MatSetType()` or the options database keys `-mat_type` or `-dm_mat_type` to set the matrix format to use for a given `Mat`
50: .seealso: [](doc_matrix), [](ch_matrices), `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()`
51: J*/
52: typedef const char *MatType;
53: #define MATSAME "same"
54: #define MATMAIJ "maij"
55: #define MATSEQMAIJ "seqmaij"
56: #define MATMPIMAIJ "mpimaij"
57: #define MATKAIJ "kaij"
58: #define MATSEQKAIJ "seqkaij"
59: #define MATMPIKAIJ "mpikaij"
60: #define MATIS "is"
61: #define MATAIJ "aij"
62: #define MATSEQAIJ "seqaij"
63: #define MATMPIAIJ "mpiaij"
64: #define MATAIJCRL "aijcrl"
65: #define MATSEQAIJCRL "seqaijcrl"
66: #define MATMPIAIJCRL "mpiaijcrl"
67: #define MATAIJCUSPARSE "aijcusparse"
68: #define MATSEQAIJCUSPARSE "seqaijcusparse"
69: #define MATMPIAIJCUSPARSE "mpiaijcusparse"
70: #define MATAIJHIPSPARSE "aijhipsparse"
71: #define MATSEQAIJHIPSPARSE "seqaijhipsparse"
72: #define MATMPIAIJHIPSPARSE "mpiaijhipsparse"
73: #define MATAIJKOKKOS "aijkokkos"
74: #define MATSEQAIJKOKKOS "seqaijkokkos"
75: #define MATMPIAIJKOKKOS "mpiaijkokkos"
76: #define MATAIJVIENNACL "aijviennacl"
77: #define MATSEQAIJVIENNACL "seqaijviennacl"
78: #define MATMPIAIJVIENNACL "mpiaijviennacl"
79: #define MATAIJPERM "aijperm"
80: #define MATSEQAIJPERM "seqaijperm"
81: #define MATMPIAIJPERM "mpiaijperm"
82: #define MATAIJSELL "aijsell"
83: #define MATSEQAIJSELL "seqaijsell"
84: #define MATMPIAIJSELL "mpiaijsell"
85: #define MATAIJMKL "aijmkl"
86: #define MATSEQAIJMKL "seqaijmkl"
87: #define MATMPIAIJMKL "mpiaijmkl"
88: #define MATBAIJMKL "baijmkl"
89: #define MATSEQBAIJMKL "seqbaijmkl"
90: #define MATMPIBAIJMKL "mpibaijmkl"
91: #define MATSHELL "shell"
92: #define MATCENTERING "centering"
93: #define MATDENSE "dense"
94: #define MATDENSECUDA "densecuda"
95: #define MATDENSEHIP "densehip"
96: #define MATSEQDENSE "seqdense"
97: #define MATSEQDENSECUDA "seqdensecuda"
98: #define MATSEQDENSEHIP "seqdensehip"
99: #define MATMPIDENSE "mpidense"
100: #define MATMPIDENSECUDA "mpidensecuda"
101: #define MATMPIDENSEHIP "mpidensehip"
102: #define MATELEMENTAL "elemental"
103: #define MATSCALAPACK "scalapack"
104: #define MATBAIJ "baij"
105: #define MATSEQBAIJ "seqbaij"
106: #define MATMPIBAIJ "mpibaij"
107: #define MATBAIJLIBXSMM "baijlibxsmm"
108: #define MATSEQBAIJLIBXSMM "seqbaijlibxsmm"
109: #define MATMPIBAIJLIBXSMM "mpibaijlibxsmm"
110: #define MATMPIADJ "mpiadj"
111: #define MATSBAIJ "sbaij"
112: #define MATSEQSBAIJ "seqsbaij"
113: #define MATMPISBAIJ "mpisbaij"
114: #define MATMFFD "mffd"
115: #define MATNORMAL "normal"
116: #define MATNORMALHERMITIAN "normalh"
117: #define MATLRC "lrc"
118: #define MATSCATTER "scatter"
119: #define MATBLOCKMAT "blockmat"
120: #define MATCOMPOSITE "composite"
121: #define MATFFT "fft"
122: #define MATFFTW "fftw"
123: #define MATSEQCUFFT "seqcufft"
124: #define MATSEQHIPFFT "seqhipfft"
125: #define MATTRANSPOSEMAT PETSC_DEPRECATED_MACRO(3, 18, 0, "MATTRANSPOSEVIRTUAL", ) "transpose"
126: #define MATTRANSPOSEVIRTUAL "transpose"
127: #define MATHERMITIANTRANSPOSEVIRTUAL "hermitiantranspose"
128: #define MATSCHURCOMPLEMENT "schurcomplement"
129: #define MATPYTHON "python"
130: #define MATHYPRE "hypre"
131: #define MATHYPRESTRUCT "hyprestruct"
132: #define MATHYPRESSTRUCT "hypresstruct"
133: #define MATSUBMATRIX "submatrix"
134: #define MATLOCALREF "localref"
135: #define MATNEST "nest"
136: #define MATPREALLOCATOR "preallocator"
137: #define MATSELL "sell"
138: #define MATSEQSELL "seqsell"
139: #define MATMPISELL "mpisell"
140: #define MATSELLCUDA "sellcuda"
141: #define MATSEQSELLCUDA "seqsellcuda"
142: #define MATMPISELLCUDA "mpisellcuda"
143: #define MATSELLHIP "sellhip"
144: #define MATSEQSELLHIP "seqsellhip"
145: #define MATMPISELLHIP "mpisellhip"
146: #define MATDUMMY "dummy"
147: #define MATLMVM "lmvm"
148: #define MATLMVMDFP "lmvmdfp"
149: #define MATLMVMDDFP "lmvmddfp"
150: #define MATLMVMBFGS "lmvmbfgs"
151: #define MATLMVMDBFGS "lmvmdbfgs"
152: #define MATLMVMDQN "lmvmdqn"
153: #define MATLMVMSR1 "lmvmsr1"
154: #define MATLMVMBROYDEN "lmvmbroyden"
155: #define MATLMVMBADBROYDEN "lmvmbadbroyden"
156: #define MATLMVMSYMBROYDEN "lmvmsymbroyden"
157: #define MATLMVMSYMBADBROYDEN "lmvmsymbadbroyden"
158: #define MATLMVMDIAGBROYDEN "lmvmdiagbroyden"
159: #define MATCONSTANTDIAGONAL "constantdiagonal"
160: #define MATDIAGONAL "diagonal"
161: #define MATHTOOL "htool"
162: #define MATH2OPUS "h2opus"
164: /*J
165: MatSolverType - String with the name of a PETSc factorization-based matrix solver type.
167: For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc
169: Level: beginner
171: Note:
172: `MATSOLVERUMFPACK`, `MATSOLVERCHOLMOD`, `MATSOLVERKLU`, `MATSOLVERSPQR` form the SuiteSparse package; you can use `--download-suitesparse` as
173: a ./configure option to install them
175: .seealso: [](sec_matfactor), [](ch_matrices), `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()`
176: J*/
177: typedef const char *MatSolverType;
178: #define MATSOLVERSUPERLU "superlu"
179: #define MATSOLVERSUPERLU_DIST "superlu_dist"
180: #define MATSOLVERSTRUMPACK "strumpack"
181: #define MATSOLVERUMFPACK "umfpack"
182: #define MATSOLVERCHOLMOD "cholmod"
183: #define MATSOLVERKLU "klu"
184: #define MATSOLVERELEMENTAL "elemental"
185: #define MATSOLVERSCALAPACK "scalapack"
186: #define MATSOLVERESSL "essl"
187: #define MATSOLVERLUSOL "lusol"
188: #define MATSOLVERMUMPS "mumps"
189: #define MATSOLVERMKL_PARDISO "mkl_pardiso"
190: #define MATSOLVERMKL_CPARDISO "mkl_cpardiso"
191: #define MATSOLVERPASTIX "pastix"
192: #define MATSOLVERMATLAB "matlab"
193: #define MATSOLVERPETSC "petsc"
194: #define MATSOLVERBAS "bas"
195: #define MATSOLVERCUSPARSE "cusparse"
196: #define MATSOLVERCUDA "cuda"
197: #define MATSOLVERHIPSPARSE "hipsparse"
198: #define MATSOLVERHIP "hip"
199: #define MATSOLVERKOKKOS "kokkos"
200: #define MATSOLVERSPQR "spqr"
201: #define MATSOLVERHTOOL "htool"
203: /*E
204: MatFactorType - indicates what type of factorization is requested
206: Values:
207: + `MAT_FACTOR_LU` - LU factorization
208: . `MAT_FACTOR_CHOLESKY` - Cholesky factorization
209: . `MAT_FACTOR_ILU` - ILU factorization
210: . `MAT_FACTOR_ICC` - incomplete Cholesky factorization
211: . `MAT_FACTOR_ILUDT` - ILU factorization with drop tolerance
212: - `MAT_FACTOR_QR` - QR factorization
214: Level: beginner
216: .seealso: [](ch_matrices), `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()`
217: E*/
218: typedef enum {
219: MAT_FACTOR_NONE,
220: MAT_FACTOR_LU,
221: MAT_FACTOR_CHOLESKY,
222: MAT_FACTOR_ILU,
223: MAT_FACTOR_ICC,
224: MAT_FACTOR_ILUDT,
225: MAT_FACTOR_QR,
226: MAT_FACTOR_NUM_TYPES
227: } MatFactorType;
228: PETSC_EXTERN const char *const MatFactorTypes[];
230: PETSC_EXTERN PetscErrorCode MatGetFactor(Mat, MatSolverType, MatFactorType, Mat *);
231: PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat, MatSolverType, MatFactorType, PetscBool *);
232: PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool *);
233: PETSC_DEPRECATED_FUNCTION(3, 15, 0, "MatFactorGetCanUseOrdering()", ) static inline PetscErrorCode MatFactorGetUseOrdering(Mat A, PetscBool *b)
234: {
235: return MatFactorGetCanUseOrdering(A, b);
236: }
237: PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat, MatSolverType *);
238: PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat, MatFactorType *);
239: PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat, MatFactorType);
240: /*S
241: MatSolverFn - Function type for the factor-creation callback registered with `MatSolverTypeRegister()`, used by `MatGetFactor()` to allocate a factored matrix of a particular `MatSolverType` and `MatFactorType`
243: Synopsis:
244: #include <petscmat.h>
245: PetscErrorCode MatSolverFn(Mat A, MatFactorType ftype, Mat *F)
247: Calling Sequence:
248: + A - the matrix to be factored
249: . ftype - the kind of factorization requested (e.g. `MAT_FACTOR_LU`, `MAT_FACTOR_CHOLESKY`)
250: - F - on output, the newly created factor `Mat` of the appropriate `MatType` for the solver
252: Level: developer
254: .seealso: `Mat`, `MatGetFactor()`, `MatSolverType`, `MatFactorType`, `MatSolverTypeRegister()`, `MatSolverTypeGet()`
255: S*/
256: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatSolverFn(Mat, MatFactorType, Mat *);
257: PETSC_EXTERN_TYPEDEF typedef MatSolverFn *MatSolverFunction;
259: PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType, MatType, MatFactorType, MatSolverFn *);
260: PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType, MatType, MatFactorType, PetscBool *, PetscBool *, MatSolverFn **);
261: typedef MatSolverType MatSolverPackage PETSC_DEPRECATED_TYPEDEF(3, 9, 0, "MatSolverType", );
262: PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeRegister()", ) static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype, MatType mtype, MatFactorType ftype, MatSolverFn *f)
263: {
264: return MatSolverTypeRegister(stype, mtype, ftype, f);
265: }
266: PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeGet()", ) static inline PetscErrorCode MatSolverPackageGet(MatSolverType stype, MatType mtype, MatFactorType ftype, PetscBool *foundmtype, PetscBool *foundstype, MatSolverFn **f)
267: {
268: return MatSolverTypeGet(stype, mtype, ftype, foundmtype, foundstype, f);
269: }
271: /*E
272: MatProductType - indicates what type of matrix product to compute
274: Values:
275: + `MATPRODUCT_AB` - product of two matrices
276: . `MATPRODUCT_AtB` - product of the transpose of a given matrix with a matrix
277: . `MATPRODUCT_ABt` - product of a matrix with the transpose of another given matrix
278: . `MATPRODUCT_PtAP` - the triple product of the transpose of a matrix with another matrix and itself
279: . `MATPRODUCT_RARt` - the triple product of a matrix, another matrix and the transpose of the first matrix
280: - `MATPRODUCT_ABC` - the product of three matrices
282: Level: beginner
284: .seealso: [](sec_matmatproduct), [](ch_matrices), `MatProductSetType()`
285: E*/
286: typedef enum {
287: MATPRODUCT_UNSPECIFIED,
288: MATPRODUCT_AB,
289: MATPRODUCT_AtB,
290: MATPRODUCT_ABt,
291: MATPRODUCT_PtAP,
292: MATPRODUCT_RARt,
293: MATPRODUCT_ABC
294: } MatProductType;
295: PETSC_EXTERN const char *const MatProductTypes[];
297: /*J
298: MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation
300: Level: beginner
302: .seealso: [](sec_matmatproduct), [](ch_matrices), `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType`
303: J*/
304: typedef const char *MatProductAlgorithm;
305: #define MATPRODUCTALGORITHMDEFAULT "default"
306: #define MATPRODUCTALGORITHMSORTED "sorted"
307: #define MATPRODUCTALGORITHMSCALABLE "scalable"
308: #define MATPRODUCTALGORITHMSCALABLEFAST "scalable_fast"
309: #define MATPRODUCTALGORITHMHEAP "heap"
310: #define MATPRODUCTALGORITHMBHEAP "btheap"
311: #define MATPRODUCTALGORITHMLLCONDENSED "llcondensed"
312: #define MATPRODUCTALGORITHMROWMERGE "rowmerge"
313: #define MATPRODUCTALGORITHMOUTERPRODUCT "outerproduct"
314: #define MATPRODUCTALGORITHMATB "at*b"
315: #define MATPRODUCTALGORITHMRAP "rap"
316: #define MATPRODUCTALGORITHMNONSCALABLE "nonscalable"
317: #define MATPRODUCTALGORITHMSEQMPI "seqmpi"
318: #define MATPRODUCTALGORITHMBACKEND "backend"
319: #define MATPRODUCTALGORITHMOVERLAPPING "overlapping"
320: #define MATPRODUCTALGORITHMMERGED "merged"
321: #define MATPRODUCTALGORITHMALLATONCE "allatonce"
322: #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged"
323: #define MATPRODUCTALGORITHMALLGATHERV "allgatherv"
324: #define MATPRODUCTALGORITHMCYCLIC "cyclic"
325: #define MATPRODUCTALGORITHMHYPRE "hypre"
327: PETSC_EXTERN PetscErrorCode MatProductCreate(Mat, Mat, Mat, Mat *);
328: PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat, Mat, Mat, Mat);
329: PETSC_EXTERN PetscErrorCode MatProductSetType(Mat, MatProductType);
330: PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat, MatProductAlgorithm);
331: PETSC_EXTERN PetscErrorCode MatProductGetAlgorithm(Mat, MatProductAlgorithm *);
332: PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat, PetscReal);
333: PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat);
334: PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat);
335: PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat);
336: PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat, Mat, Mat, Mat);
337: PETSC_EXTERN PetscErrorCode MatProductClear(Mat);
338: PETSC_EXTERN PetscErrorCode MatProductView(Mat, PetscViewer);
339: PETSC_EXTERN PetscErrorCode MatProductGetType(Mat, MatProductType *);
340: PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat, Mat *, Mat *, Mat *);
342: /* Logging support */
343: #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */
344: PETSC_EXTERN PetscClassId MAT_CLASSID;
345: PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID;
346: PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID;
347: PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID;
348: PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID;
349: PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID;
350: PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID;
351: PETSC_EXTERN PetscClassId MATMFFD_CLASSID;
353: /*E
354: MatReuse - Indicates if matrices obtained from a previous call to `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatConvert()` or several other functions
355: are to be reused to store the new matrix values.
357: Values:
358: + `MAT_INITIAL_MATRIX` - create a new matrix
359: . `MAT_REUSE_MATRIX` - reuse the matrix created with a previous call that used `MAT_INITIAL_MATRIX`
360: . `MAT_INPLACE_MATRIX` - replace the first input matrix with the new matrix (not applicable to all functions)
361: - `MAT_IGNORE_MATRIX` - do not create a new matrix or reuse a given matrix, just ignore that matrix argument (not applicable to all functions)
363: Level: beginner
365: .seealso: [](ch_matrices), `Mat`, `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()`
366: E*/
367: typedef enum {
368: MAT_INITIAL_MATRIX,
369: MAT_REUSE_MATRIX,
370: MAT_IGNORE_MATRIX,
371: MAT_INPLACE_MATRIX
372: } MatReuse;
374: /*E
375: MatCreateSubMatrixOption - Indicates if matrices obtained from a call to `MatCreateSubMatrices()`
376: include the matrix values. Currently it is only used by `MatGetSeqNonzeroStructure()`.
378: Values:
379: + `MAT_DO_NOT_GET_VALUES` - do not copy the matrix values
380: - `MAT_GET_VALUES` - copy the matrix values
382: Level: developer
384: Developer Note:
385: Why is not just a boolean used for this information?
387: .seealso: [](ch_matrices), `Mat`, `MatDuplicateOption`, `PetscCopyMode`, `MatGetSeqNonzeroStructure()`
388: E*/
389: typedef enum {
390: MAT_DO_NOT_GET_VALUES,
391: MAT_GET_VALUES
392: } MatCreateSubMatrixOption;
394: PETSC_EXTERN PetscErrorCode MatInitializePackage(void);
395: PETSC_EXTERN PetscErrorCode MatFinalizePackage(void);
397: PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *);
398: PETSC_EXTERN PetscErrorCode MatCreateFromOptions(MPI_Comm, const char *, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
399: PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt);
400: PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType);
401: PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *);
402: PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType);
403: PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat);
404: PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]);
405: PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat));
406: PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]);
407: PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]);
408: PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]);
409: PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]);
410: PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]);
411: PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]);
412: PETSC_EXTERN PetscErrorCode MatGetState(Mat, MatState *);
413: PETSC_EXTERN PetscErrorCode MatStateCompare(MatState, MatState, PetscBool *);
414: PETSC_EXTERN PetscErrorCode MatStateCompareUpdate(Mat, MatState *, PetscBool *);
415: /*MC
416: MatStateInvalidate - Invalidates a matrix state snapshot
418: Synopsis:
419: #include <petscmat.h>
420: PetscErrorCode MatStateInvalidate(MatState state)
422: Not Collective
424: Input/Output Parameter:
425: . state - the matrix state
427: Level: developer
429: .seealso: [](ch_matrices), `Mat`, `MatState`, `MatGetState()`, `MatStateCompare()`, `MatStateCompareUpdate()`
430: M*/
431: #define MatStateInvalidate(s) ((s).id = 0, (s).state = -1, (s).nonzerostate = -1, PETSC_SUCCESS)
432: PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool);
434: PETSC_EXTERN PetscFunctionList MatList;
435: PETSC_EXTERN PetscFunctionList MatColoringList;
436: PETSC_EXTERN PetscFunctionList MatPartitioningList;
437: PETSC_EXTERN PetscFunctionList MatMeshToCellGraphList;
439: /*E
440: MatStructure - Indicates if two matrices have the same nonzero structure
442: Values:
443: + `SAME_NONZERO_PATTERN` - the two matrices have identical nonzero patterns
444: . `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns
445: . `SUBSET_NONZERO_PATTERN` - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix
446: - `UNKNOWN_NONZERO_PATTERN` - there is no known relationship between the nonzero patterns. In this case the implementations
447: may try to detect a relationship to optimize the operation
449: Level: beginner
451: Note:
452: Certain matrix operations (such as `MatAXPY()`) can run much faster if the sparsity pattern of the matrices are the same. But actually determining if
453: the patterns are the same may be costly. This provides a way for users who know something about the sparsity patterns to provide this information
454: to certain PETSc routines.
456: .seealso: [](ch_matrices), `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()`
457: E*/
458: typedef enum {
459: DIFFERENT_NONZERO_PATTERN,
460: SUBSET_NONZERO_PATTERN,
461: SAME_NONZERO_PATTERN,
462: UNKNOWN_NONZERO_PATTERN
463: } MatStructure;
464: PETSC_EXTERN const char *const MatStructures[];
466: #if PetscDefined(HAVE_MKL_SPARSE)
467: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
468: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
469: PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
470: PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
471: #endif
473: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
474: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
476: PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
477: PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
478: PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]);
479: PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
480: PETSC_EXTERN PetscErrorCode MatSeqSELLGetFillRatio(Mat, PetscReal *);
481: PETSC_EXTERN PetscErrorCode MatSeqSELLGetMaxSliceWidth(Mat, PetscInt *);
482: PETSC_EXTERN PetscErrorCode MatSeqSELLGetAvgSliceWidth(Mat, PetscReal *);
483: PETSC_EXTERN PetscErrorCode MatSeqSELLSetSliceHeight(Mat, PetscInt);
484: PETSC_EXTERN PetscErrorCode MatSeqSELLGetVarSliceSize(Mat, PetscReal *);
486: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
487: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
488: PETSC_EXTERN PetscErrorCode MatMPISELLGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
489: PETSC_EXTERN PetscErrorCode MatMPISELLGetSeqSELL(Mat, Mat *, Mat *, const PetscInt *[]);
491: PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
492: PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
493: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
494: PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
495: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
496: PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
497: PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]);
498: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *);
499: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, PetscInt, PetscInt, Mat, Mat, PetscInt *, Mat *);
501: PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
502: PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
503: PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
505: PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]);
506: PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]);
507: PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode);
509: PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *);
510: PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
512: PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
513: PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
514: PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
515: PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
516: PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]);
518: PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscCtx, Mat *);
519: PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *);
520: PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *);
521: PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *);
522: PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *);
523: PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *);
524: PETSC_EXTERN PetscErrorCode MatLRCSetMats(Mat, Mat, Mat, Vec, Mat);
525: PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *);
526: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
527: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
529: PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *);
530: PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter);
531: PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *);
532: PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *);
533: PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat);
534: PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat);
535: /*E
536: MatCompositeMergeType - Selects the order in which the matrices held by a `MATCOMPOSITE` are combined when `MatCompositeMerge()` is called
538: Values:
539: + `MAT_COMPOSITE_MERGE_RIGHT` - merge into a single matrix starting from the rightmost matrix (multiplicative compositions use this to preserve the natural left-to-right application order)
540: - `MAT_COMPOSITE_MERGE_LEFT` - merge into a single matrix starting from the leftmost matrix
542: Level: advanced
544: .seealso: [](ch_matrices), `Mat`, `MATCOMPOSITE`, `MatCompositeMerge()`, `MatCompositeSetMergeType()`, `MatCompositeType`
545: E*/
546: typedef enum {
547: MAT_COMPOSITE_MERGE_RIGHT,
548: MAT_COMPOSITE_MERGE_LEFT
549: } MatCompositeMergeType;
550: PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType);
551: PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *);
552: /*E
553: MatCompositeType - indicates what type of `MATCOMPOSITE` is used
555: Values:
556: + `MAT_COMPOSITE_ADDITIVE` - sum of matrices (default)
557: - `MAT_COMPOSITE_MULTIPLICATIVE` - product of matrices
559: Level: beginner
561: .seealso: [](ch_matrices), `MATCOMPOSITE`, `MatCompositeSetType()`, `MatCompositeGetType()`
562: E*/
563: typedef enum {
564: MAT_COMPOSITE_ADDITIVE,
565: MAT_COMPOSITE_MULTIPLICATIVE
566: } MatCompositeType;
567: PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType);
568: PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *);
569: PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure);
570: PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *);
571: PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *);
572: PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *);
573: PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *);
575: PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *);
576: PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *);
578: PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *);
579: PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *);
580: PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *);
581: PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *);
582: PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *);
583: PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *);
584: PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *);
585: PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS);
586: PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *);
587: PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *);
588: PETSC_EXTERN PetscErrorCode MatCreateDiagonal(Vec, Mat *);
589: PETSC_EXTERN PetscErrorCode MatDiagonalSetDiagonal(Mat, Vec);
590: PETSC_EXTERN PetscErrorCode MatDiagonalGetDiagonal(Mat, Vec *);
591: PETSC_EXTERN PetscErrorCode MatDiagonalRestoreDiagonal(Mat, Vec *);
592: PETSC_EXTERN PetscErrorCode MatDiagonalGetInverseDiagonal(Mat, Vec *);
593: PETSC_EXTERN PetscErrorCode MatDiagonalRestoreInverseDiagonal(Mat, Vec *);
594: PETSC_EXTERN PetscErrorCode MatConstantDiagonalGetConstant(Mat, PetscScalar *);
595: PETSC_EXTERN PetscErrorCode MatGetCurrentMemType(Mat, PetscMemType *);
597: #if PetscDefined(HAVE_HYPRE)
598: PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
599: #endif
601: PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]);
602: PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]);
603: PETSC_EXTERN PetscErrorCode MatPythonCreate(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const char[], Mat *);
605: PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat);
606: PETSC_EXTERN PetscErrorCode MatResetHash(Mat);
607: PETSC_EXTERN PetscErrorCode MatSetUp(Mat);
608: PETSC_EXTERN PetscErrorCode MatDestroy(Mat *);
609: PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *);
611: PETSC_EXTERN PetscErrorCode MatConjugate(Mat);
612: PETSC_EXTERN PetscErrorCode MatRealPart(Mat);
613: PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat);
614: PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *);
615: PETSC_EXTERN PetscErrorCode MatGetMultPetscSF(Mat, PetscSF *);
616: PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *);
617: PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **);
618: PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *);
619: PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat);
620: PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *);
621: PETSC_EXTERN PetscErrorCode MatComputeVariableBlockEnvelope(Mat);
623: PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
624: PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode);
625: PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
626: PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]);
627: PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]);
628: PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]);
629: PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom);
631: /*S
632: MatStencil - Data structure (C struct) for storing information about rows and
633: columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()`
635: Level: beginner
637: Notes:
638: 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).
639: The c represents the degrees of freedom at each grid point (the dof argument to `DMDASetDOF()`). If dof is 1 then this entry is ignored.
641: For stencil access to vectors see `DMDAVecGetArray()`
643: For staggered grids, see `DMStagStencil`
645: .seealso: [](ch_matrices), `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`,
646: `DMStagStencil`
647: S*/
648: typedef struct {
649: PetscInt k, j, i, c;
650: } MatStencil;
652: PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
653: PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
654: PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt);
656: /*E
657: MatAssemblyType - Indicates if the process of setting values into the matrix is complete, and the matrix is ready for use
659: Values:
660: + `MAT_FLUSH_ASSEMBLY` - you will continue to put values into the matrix
661: - `MAT_FINAL_ASSEMBLY` - you wish to use the matrix with the values currently inserted
663: Level: beginner
665: .seealso: [](ch_matrices), `Mat`, `MatSetValues`, `MatAssemblyBegin()`, `MatAssemblyEnd()`
666: E*/
667: typedef enum {
668: MAT_FLUSH_ASSEMBLY = 1,
669: MAT_FINAL_ASSEMBLY = 0
670: } MatAssemblyType;
672: PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType);
673: PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType);
674: PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *);
676: /*E
677: MatOption - Options that may be set for a matrix that indicate properties of the matrix or affect its behavior or storage
679: Level: beginner
681: Note:
682: See `MatSetOption()` for the use of the options
684: Developer Note:
685: Entries that are negative need not be called collectively by all processes.
687: .seealso: [](ch_matrices), `Mat`, `MatSetOption()`, `VecOption`
688: E*/
689: typedef enum {
690: MAT_OPTION_MIN = -3,
691: MAT_UNUSED_NONZERO_LOCATION_ERR = -2,
692: MAT_ROW_ORIENTED = -1,
693: MAT_SYMMETRIC = 1,
694: MAT_STRUCTURALLY_SYMMETRIC = 2,
695: MAT_FORCE_DIAGONAL_ENTRIES = 3,
696: MAT_IGNORE_OFF_PROC_ENTRIES = 4,
697: MAT_USE_HASH_TABLE = 5,
698: MAT_KEEP_NONZERO_PATTERN = 6,
699: MAT_IGNORE_ZERO_ENTRIES = 7,
700: MAT_USE_INODES = 8,
701: MAT_HERMITIAN = 9,
702: MAT_SYMMETRY_ETERNAL = 10,
703: MAT_NEW_NONZERO_LOCATION_ERR = 11,
704: MAT_IGNORE_LOWER_TRIANGULAR = 12,
705: MAT_ERROR_LOWER_TRIANGULAR = 13,
706: MAT_GETROW_UPPERTRIANGULAR = 14,
707: MAT_SPD = 15,
708: MAT_NO_OFF_PROC_ZERO_ROWS = 16,
709: MAT_NO_OFF_PROC_ENTRIES = 17,
710: MAT_NEW_NONZERO_LOCATIONS = 18,
711: MAT_NEW_NONZERO_ALLOCATION_ERR = 19,
712: MAT_SUBSET_OFF_PROC_ENTRIES = 20,
713: MAT_SUBMAT_SINGLEIS = 21,
714: MAT_STRUCTURE_ONLY = 22,
715: MAT_SORTED_FULL = 23,
716: MAT_FORM_EXPLICIT_TRANSPOSE = 24,
717: MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25,
718: MAT_SPD_ETERNAL = 26,
719: MAT_OPTION_MAX = 27
720: } MatOption;
722: PETSC_EXTERN const char *const *MatOptions;
723: PETSC_EXTERN PetscErrorCode MatSetOption(Mat, MatOption, PetscBool);
724: PETSC_EXTERN PetscErrorCode MatGetOption(Mat, MatOption, PetscBool *);
725: PETSC_EXTERN PetscErrorCode MatPropagateSymmetryOptions(Mat, Mat);
726: PETSC_EXTERN PetscErrorCode MatGetType(Mat, MatType *);
728: PETSC_EXTERN PetscErrorCode MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
729: PETSC_EXTERN PetscErrorCode MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
730: PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
731: PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat);
732: PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat);
733: PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat, Vec, PetscInt);
734: PETSC_EXTERN PetscErrorCode MatSeqAIJGetArray(Mat, PetscScalar *[]);
735: PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]);
736: PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]);
737: PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArray(Mat, PetscScalar *[]);
738: PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]);
739: PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]);
740: PETSC_EXTERN PetscErrorCode MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *);
741: PETSC_EXTERN PetscErrorCode MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
742: PETSC_EXTERN PetscErrorCode MatSeqAIJSetType(Mat, MatType);
743: PETSC_EXTERN PetscErrorCode MatSeqAIJKron(Mat, Mat, MatReuse, Mat *);
744: PETSC_EXTERN PetscErrorCode MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *));
745: PETSC_EXTERN PetscFunctionList MatSeqAIJList;
746: PETSC_EXTERN PetscErrorCode MatSeqBAIJGetArray(Mat, PetscScalar *[]);
747: PETSC_EXTERN PetscErrorCode MatSeqBAIJRestoreArray(Mat, PetscScalar *[]);
748: PETSC_EXTERN PetscErrorCode MatSeqSBAIJGetArray(Mat, PetscScalar *[]);
749: PETSC_EXTERN PetscErrorCode MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]);
750: PETSC_EXTERN PetscErrorCode MatDenseGetArray(Mat, PetscScalar *[]);
751: PETSC_EXTERN PetscErrorCode MatDenseRestoreArray(Mat, PetscScalar *[]);
752: PETSC_EXTERN PetscErrorCode MatDensePlaceArray(Mat, const PetscScalar[]);
753: PETSC_EXTERN PetscErrorCode MatDenseReplaceArray(Mat, const PetscScalar[]);
754: PETSC_EXTERN PetscErrorCode MatDenseReplaceArrayWithMemType(Mat, PetscMemType, const PetscScalar[]);
755: PETSC_EXTERN PetscErrorCode MatDenseResetArray(Mat);
756: PETSC_EXTERN PetscErrorCode MatDenseGetArrayRead(Mat, const PetscScalar *[]);
757: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayRead(Mat, const PetscScalar *[]);
758: PETSC_EXTERN PetscErrorCode MatDenseGetArrayWrite(Mat, PetscScalar *[]);
759: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWrite(Mat, PetscScalar *[]);
760: PETSC_EXTERN PetscErrorCode MatDenseGetArrayAndMemType(Mat, PetscScalar *[], PetscMemType *);
761: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayAndMemType(Mat, PetscScalar *[]);
762: PETSC_EXTERN PetscErrorCode MatDenseGetArrayReadAndMemType(Mat, const PetscScalar *[], PetscMemType *);
763: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayReadAndMemType(Mat, const PetscScalar *[]);
764: PETSC_EXTERN PetscErrorCode MatDenseGetArrayWriteAndMemType(Mat, PetscScalar *[], PetscMemType *);
765: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWriteAndMemType(Mat, PetscScalar *[]);
766: PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat, PetscInt *);
767: PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat, PetscInt);
768: PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat, PetscInt *, PetscInt *);
769: PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat, PetscInt, PetscInt);
770: PETSC_EXTERN PetscErrorCode MatSetBlockSizesFromMats(Mat, Mat, Mat);
771: PETSC_EXTERN PetscErrorCode MatSetVariableBlockSizes(Mat, PetscInt, const PetscInt[]);
772: PETSC_EXTERN PetscErrorCode MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt *[]);
773: PETSC_EXTERN PetscErrorCode MatSelectVariableBlockSizes(Mat, Mat, IS);
775: PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]);
776: PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]);
777: PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *);
778: PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *);
779: PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *);
780: PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *);
781: PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *);
782: PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *);
783: PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
784: PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *);
785: PETSC_EXTERN PetscErrorCode MatDenseUpdateColumnLayout(Mat, PetscLayout);
787: PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec);
788: PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec);
789: PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec);
790: PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec);
791: PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec);
792: PETSC_EXTERN PetscErrorCode MatADot(Mat, Vec, Vec, PetscScalar *);
793: PETSC_EXTERN PetscErrorCode MatANorm(Mat, Vec, PetscReal *);
794: PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *);
795: PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *);
796: PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec);
797: PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec);
798: PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat);
799: PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat);
800: PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat);
801: PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec);
803: /*E
804: MatDuplicateOption - Indicates if a duplicated sparse matrix should have
805: its numerical values copied over or just its nonzero structure.
807: Values:
808: + `MAT_DO_NOT_COPY_VALUES` - Create a matrix using the same nonzero pattern as the original matrix,
809: with zeros for the numerical values
810: . `MAT_COPY_VALUES` - Create a matrix with the same nonzero pattern as the original matrix
811: and with the same numerical values.
812: - `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix
813: and does not copy it, using zeros for the numerical values. The parent and
814: child matrices will share their index (i and j) arrays, and you cannot
815: insert new nonzero entries into either matrix
817: Level: beginner
819: Note:
820: Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in
821: this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified.
823: .seealso: [](ch_matrices), `Mat`, `MatDuplicate()`
824: E*/
825: typedef enum {
826: MAT_DO_NOT_COPY_VALUES,
827: MAT_COPY_VALUES,
828: MAT_SHARE_NONZERO_PATTERN
829: } MatDuplicateOption;
831: PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *);
832: PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *);
834: PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure);
835: PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer);
836: PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *);
837: PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *);
838: PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *);
839: PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *);
840: PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *);
841: PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *);
842: PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *);
843: PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer);
845: PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
846: PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
847: PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
848: PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
850: /*S
851: MatInfo - Context of matrix information, used with `MatGetInfo()`
853: Level: intermediate
855: Fortran Note:
856: `MatInfo` is a derived type, use e.g. `matinfo%nz_allocated` to access its components.
858: .seealso: [](ch_matrices), `Mat`, `MatGetInfo()`, `MatInfoType`
859: S*/
860: typedef struct {
861: PetscLogDouble block_size; /* block size */
862: PetscLogDouble nz_allocated, nz_used, nz_unneeded; /* number of nonzeros */
863: PetscLogDouble memory; /* memory allocated */
864: PetscLogDouble assemblies; /* number of matrix assemblies called */
865: PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */
866: PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */
867: PetscLogDouble factor_mallocs; /* number of mallocs during factorization */
868: } MatInfo;
870: /*E
871: MatInfoType - Indicates if you want information about the local part of the matrix,
872: the entire parallel matrix or the maximum over all the local parts.
874: Values:
875: + `MAT_LOCAL` - values for each MPI process part of the matrix
876: . `MAT_GLOBAL_MAX` - maximum of each value over all MPI processes
877: - `MAT_GLOBAL_SUM` - sum of each value over all MPI processes
879: Level: beginner
881: .seealso: [](ch_matrices), `MatGetInfo()`, `MatInfo`
882: E*/
883: typedef enum {
884: MAT_LOCAL = 1,
885: MAT_GLOBAL_MAX = 2,
886: MAT_GLOBAL_SUM = 3
887: } MatInfoType;
888: PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *);
889: PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec);
890: PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]);
891: PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]);
892: PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]);
893: PETSC_EXTERN PetscErrorCode MatGetRowSumAbs(Mat, Vec);
894: PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]);
895: PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec);
896: PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *);
897: PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *);
898: PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat);
899: PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *);
900: PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *);
901: PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec);
902: PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode);
904: PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *);
905: PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *);
906: PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *);
907: PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
908: PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
909: PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
910: PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
911: PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
912: PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
913: PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
914: PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
915: PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
916: PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *);
918: PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *);
919: PETSC_EXTERN PetscErrorCode MatNormApproximate(Mat, NormType, PetscInt, PetscReal *);
920: PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *);
921: PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *);
922: PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *);
923: PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *);
924: PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *);
925: PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *);
926: PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *);
927: PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *);
928: PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat);
929: PETSC_EXTERN PetscErrorCode MatSetInf(Mat);
930: PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
931: PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec);
932: PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
933: PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
934: PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
935: PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec);
937: PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *);
938: PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *);
939: PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *);
940: PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **);
941: PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *);
942: PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **);
943: PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *);
945: PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
946: 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[])
947: {
948: return MatCreateSubMatrices(mat, n, irow, icol, scall, submat);
949: }
950: PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
951: 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[])
952: {
953: return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat);
954: }
955: PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]);
956: PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]);
957: PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *);
958: PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatrix()", ) static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat)
959: {
960: return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat);
961: }
962: PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *);
963: PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *);
964: PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *);
965: PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *);
967: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *);
968: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *);
969: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat);
970: PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *);
971: PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *);
972: PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
973: PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *);
974: PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *);
975: PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *);
976: PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]);
978: PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt);
979: PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat, PetscInt, IS[], PetscInt);
980: PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool);
982: PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
984: PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
985: PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
987: PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *);
988: PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *);
990: PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
991: PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *);
993: PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure);
994: PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure);
996: PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar);
997: PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar);
999: PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping);
1000: PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
1001: PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *);
1002: PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout);
1003: PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
1004: PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
1005: PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
1006: PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
1007: PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
1008: PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
1009: PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
1011: PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt);
1012: PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
1014: PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec);
1015: PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec);
1016: PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec);
1017: PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *);
1018: PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *);
1019: PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *);
1020: PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *);
1021: PETSC_DEPRECATED_FUNCTION(3, 6, 0, "MatCreateVecs()", ) static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y)
1022: {
1023: return MatCreateVecs(mat, x, y);
1024: }
1025: PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *);
1026: PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *);
1027: PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *);
1028: PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *);
1029: PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *);
1031: PETSC_EXTERN PetscErrorCode MatCopyHashToXAIJ(Mat A, Mat B);
1032: /*@
1033: MatSetValue - Set a single entry into a matrix.
1035: Not Collective
1037: Input Parameters:
1038: + mat - the matrix
1039: . i - the row location of the entry
1040: . j - the column location of the entry
1041: . va - the value to insert
1042: - mode - either `INSERT_VALUES` or `ADD_VALUES`
1044: Level: beginner
1046: Notes:
1047: This value may be cached, so `MatAssemblyBegin()` and `MatAssemblyEnd()`
1048: MUST be called after all calls to `MatSetValue()` have been completed.
1050: For efficiency one should use `MatSetValues()` and set several values simultaneously.
1052: .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `InsertMode`, `MatGetValue()`, `MatSetValues()`,
1053: `MatSetValueLocal()`, `MatSetValuesLocal()`
1054: @*/
1055: static inline PetscErrorCode MatSetValue(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
1056: {
1057: return MatSetValues(mat, 1, &i, 1, &j, &va, mode);
1058: }
1060: /*@
1061: MatGetValue - Gets a single value from a matrix
1063: Not Collective; can only return a value owned by the given process
1065: Input Parameters:
1066: + mat - the matrix
1067: . row - the row location of the entry
1068: - col - the column location of the entry
1070: Output Parameter:
1071: . va - the value
1073: Level: advanced
1075: Notes:
1076: The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd()` before this call
1078: For efficiency one should use `MatGetValues()` and get several values simultaneously.
1080: See notes for `MatGetValues()`.
1082: .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValue()`, `MatGetValuesLocal()`, `MatGetValues()`
1083: @*/
1084: static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va)
1085: {
1086: return MatGetValues(mat, 1, &row, 1, &col, va);
1087: }
1089: /*@
1090: MatSetValueLocal - Inserts or adds a single value into a matrix, using a local numbering of the nodes.
1092: Not Collective
1094: Input Parameters:
1095: + mat - the matrix
1096: . i - the row location of the entry
1097: . j - the column location of the entry
1098: . va - the value to insert
1099: - mode - either `INSERT_VALUES` or `ADD_VALUES`
1101: Level: intermediate
1103: Notes:
1104: For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously.
1106: See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used.
1108: .seealso: [](ch_matrices), `MatSetValue()`, `MatSetValuesLocal()`
1109: @*/
1110: static inline PetscErrorCode MatSetValueLocal(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
1111: {
1112: return MatSetValuesLocal(mat, 1, &i, 1, &j, &va, mode);
1113: }
1115: /*MC
1116: MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per
1117: row in a matrix providing the data that one can use to correctly preallocate the matrix.
1119: Synopsis:
1120: #include <petscmat.h>
1121: PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
1123: Collective
1125: Input Parameters:
1126: + comm - the communicator that will share the eventually allocated matrix
1127: . nrows - the number of LOCAL rows in the matrix
1128: - ncols - the number of LOCAL columns in the matrix
1130: Output Parameters:
1131: + dnz - the array that will be passed to the matrix preallocation routines
1132: - onz - the other array passed to the matrix preallocation routines
1134: Level: deprecated (since v3.19)
1136: Notes:
1137: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1138: the use of this routine
1140: This is a macro that handles its own error checking, it does not return an error code.
1142: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1144: Developer Note:
1145: This is a MACRO, not a function, because it has a leading { that is closed by `PetscPreallocateFinalize()`.
1147: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1148: `MatPreallocateSymmetricSetLocalBlock()`
1149: M*/
1150: #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \
1151: do { \
1152: PetscInt __nrows = (nrows), __ncols = (ncols), __rstart, __end = 0; \
1153: PetscInt PETSC_UNUSED __start; \
1154: PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \
1155: PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \
1156: __start = __end - __ncols; \
1157: (void)__start; \
1158: PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \
1159: __rstart -= __nrows
1161: #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateBegin()", ) MatPreallocateBegin(__VA_ARGS__)
1163: /*MC
1164: MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1165: inserted using a local number of the rows and columns
1167: Synopsis:
1168: #include <petscmat.h>
1169: PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map, PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1171: Not Collective
1173: Input Parameters:
1174: + map - the row mapping from local numbering to global numbering
1175: . nrows - the number of rows indicated
1176: . rows - the indices of the rows
1177: . cmap - the column mapping from local to global numbering
1178: . ncols - the number of columns in the matrix
1179: . cols - the columns indicated
1180: . dnz - the array that will be passed to the matrix preallocation routines
1181: - onz - the other array passed to the matrix preallocation routines
1183: Level: deprecated (since v3.19)
1185: Notes:
1186: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1187: the use of this routine
1189: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1191: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`,
1192: `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()`
1193: M*/
1194: #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
1195: 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));)
1197: /*MC
1198: MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1199: inserted using a local number of the rows and columns. This version removes any duplicate columns in cols
1201: Synopsis:
1202: #include <petscmat.h>
1203: PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map, PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1205: Not Collective
1207: Input Parameters:
1208: + map - the row mapping from local numbering to global numbering
1209: . nrows - the number of rows indicated
1210: . rows - the indices of the rows (these values are mapped to the global values)
1211: . cmap - the column mapping from local to global numbering
1212: . ncols - the number of columns in the matrix (this value will be changed if duplicate columns are found)
1213: . cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed)
1214: . dnz - the array that will be passed to the matrix preallocation routines
1215: - onz - the other array passed to the matrix preallocation routines
1217: Level: deprecated (since v3.19)
1219: Notes:
1220: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1221: the use of this routine
1223: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1225: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`,
1226: `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1227: M*/
1228: #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
1229: 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));)
1231: /*MC
1232: MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1233: inserted using a local number of the rows and columns
1235: Synopsis:
1236: #include <petscmat.h>
1237: PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map, PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1239: Not Collective
1241: Input Parameters:
1242: + map - the row mapping from local numbering to global numbering
1243: . nrows - the number of rows indicated
1244: . rows - the indices of the rows
1245: . cmap - the column mapping from local to global numbering
1246: . ncols - the number of columns in the matrix
1247: . cols - the columns indicated
1248: . dnz - the array that will be passed to the matrix preallocation routines
1249: - onz - the other array passed to the matrix preallocation routines
1251: Level: deprecated (since v3.19)
1253: Notes:
1254: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1255: the use of this routine
1257: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1259: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`,
1260: `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`
1261: M*/
1262: #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
1263: 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));)
1265: /*MC
1266: MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1267: inserted using a local number of the rows and columns
1269: Synopsis:
1270: #include <petscmat.h>
1271: PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map, PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1273: Not Collective
1275: Input Parameters:
1276: + map - the mapping between local numbering and global numbering
1277: . nrows - the number of rows indicated
1278: . rows - the indices of the rows
1279: . ncols - the number of columns in the matrix
1280: . cols - the columns indicated
1281: . dnz - the array that will be passed to the matrix preallocation routines
1282: - onz - the other array passed to the matrix preallocation routines
1284: Level: deprecated (since v3.19)
1286: Notes:
1287: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1288: the use of this routine
1290: Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1292: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`,
1293: `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1294: M*/
1295: #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \
1296: 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));)
1298: /*MC
1299: MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1300: inserted using a local number of the rows and columns
1302: Synopsis:
1303: #include <petscmat.h>
1304: PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1306: Not Collective
1308: Input Parameters:
1309: + row - the row
1310: . ncols - the number of columns in the matrix
1311: - cols - the columns indicated
1313: Output Parameters:
1314: + dnz - the array that will be passed to the matrix preallocation routines
1315: - onz - the other array passed to the matrix preallocation routines
1317: Level: deprecated (since v3.19)
1319: Notes:
1320: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1321: the use of this routine
1323: Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1325: This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin().
1327: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`,
1328: `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1329: M*/
1330: #define MatPreallocateSet(row, nc, cols, dnz, onz) \
1331: 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) { \
1332: if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \
1333: else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \
1334: })
1336: /*MC
1337: MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1338: inserted using a local number of the rows and columns
1340: Synopsis:
1341: #include <petscmat.h>
1342: PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1344: Not Collective
1346: Input Parameters:
1347: + nrows - the number of rows indicated
1348: . rows - the indices of the rows
1349: . ncols - the number of columns in the matrix
1350: . cols - the columns indicated
1351: . dnz - the array that will be passed to the matrix preallocation routines
1352: - onz - the other array passed to the matrix preallocation routines
1354: Level: deprecated (since v3.19)
1356: Notes:
1357: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1358: the use of this routine
1360: Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1362: This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin().
1364: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`,
1365: `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1366: M*/
1367: #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \
1368: PetscMacroReturnStandard(for (PetscInt __i = 0; __i < nc; __i++) { \
1369: if (cols[__i] >= __end) onz[row - __rstart]++; \
1370: else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \
1371: })
1373: /*MC
1374: MatPreallocateLocation - An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists
1376: Synopsis:
1377: #include <petscmat.h>
1378: PetscErrorCode MatPreallocateLocations(Mat A, PetscInt row, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1380: Not Collective
1382: Input Parameters:
1383: + A - matrix
1384: . row - row where values exist (must be local to this process)
1385: . ncols - number of columns
1386: . cols - columns with nonzeros
1387: . dnz - the array that will be passed to the matrix preallocation routines
1388: - onz - the other array passed to the matrix preallocation routines
1390: Level: deprecated (since v3.19)
1392: Notes:
1393: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1394: the use of this routine
1396: Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1398: Developer Note:
1399: This is a MACRO, not a function, because it uses a bunch of variables private to the MatPreallocation.... routines.
1401: .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1402: `MatPreallocateSymmetricSetLocalBlock()`
1403: M*/
1404: #define MatPreallocateLocation(A, row, ncols, cols, dnz, onz) (A ? MatSetValues(A, 1, &row, ncols, cols, NULL, INSERT_VALUES) : MatPreallocateSet(row, ncols, cols, dnz, onz))
1406: /*MC
1407: MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per
1408: row in a matrix providing the data that one can use to correctly preallocate the matrix.
1410: Synopsis:
1411: #include <petscmat.h>
1412: PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz)
1414: Collective
1416: Input Parameters:
1417: + dnz - the array that was be passed to the matrix preallocation routines
1418: - onz - the other array passed to the matrix preallocation routines
1420: Level: deprecated (since v3.19)
1422: Notes:
1423: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1424: the use of this routine
1426: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1428: Developer Note:
1429: This is a MACRO, not a function, because it closes the { started in MatPreallocateBegin().
1431: .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1432: `MatPreallocateSymmetricSetLocalBlock()`
1433: M*/
1434: #define MatPreallocateEnd(dnz, onz) \
1435: PetscCall(PetscFree2(dnz, onz)); \
1436: } \
1437: while (0)
1439: #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateEnd()", ) MatPreallocateEnd(__VA_ARGS__)
1441: /* Routines unique to particular data structures */
1442: PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, PetscCtxRt);
1444: PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *);
1445: PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *);
1447: PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]);
1448: PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]);
1449: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1450: PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1451: PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1452: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscCount, PetscBool);
1454: #define MAT_SKIP_ALLOCATION -4
1456: PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1457: PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1458: PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]);
1459: PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt);
1461: PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1462: PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1463: PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1464: PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1465: PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1466: PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1467: PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1468: PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]);
1469: PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *);
1470: PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *);
1471: PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]);
1472: PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]);
1473: PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
1474: PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
1475: PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *);
1477: PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *);
1478: PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt);
1479: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatDenseSetLDA()", ) static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda)
1480: {
1481: return MatDenseSetLDA(A, lda);
1482: }
1483: PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *);
1485: PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1487: PETSC_EXTERN PetscErrorCode MatStoreValues(Mat);
1488: PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat);
1490: PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *);
1491: PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *);
1492: /*
1493: These routines are not usually accessed directly, rather solving is
1494: done through the KSP and PC interfaces.
1495: */
1497: /*J
1498: MatOrderingType - String with the name of a PETSc matrix ordering. These orderings are most commonly used
1499: to reduce fill in sparse factorizations.
1501: Level: beginner
1503: Notes:
1504: If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and instead the external factorization solver package called utilizes one
1505: of its own.
1507: There is no `MatOrdering` object, the ordering is obtained directly from the matrix with `MatGetOrdering()`
1509: Developer Note:
1510: This API should be converted to an API similar to those for `MatColoring` and `MatPartitioning`
1512: .seealso: [](ch_matrices), [](sec_graph), `MatGetFactor()`, `MatGetOrdering()`, `MatColoringType`, `MatPartitioningType`, `MatCoarsenType`, `PCFactorSetOrderingType()`
1513: J*/
1514: typedef const char *MatOrderingType;
1515: #define MATORDERINGNATURAL "natural"
1516: #define MATORDERINGND "nd"
1517: #define MATORDERING1WD "1wd"
1518: #define MATORDERINGRCM "rcm"
1519: #define MATORDERINGQMD "qmd"
1520: #define MATORDERINGROWLENGTH "rowlength"
1521: #define MATORDERINGWBM "wbm"
1522: #define MATORDERINGSPECTRAL "spectral"
1523: #define MATORDERINGAMD "amd" /* only works if UMFPACK is installed with PETSc */
1524: #define MATORDERINGMETISND "metisnd" /* only works if METIS is installed with PETSc */
1525: #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 */
1526: #define MATORDERINGEXTERNAL "external" /* uses an ordering type internal to the factorization package */
1528: PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat, MatOrderingType, IS *, IS *);
1529: PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFunctionList *);
1530: PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *));
1531: PETSC_EXTERN PetscFunctionList MatOrderingList;
1533: #include "petscmatcoarsen.h"
1535: PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS);
1536: PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *);
1538: PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *);
1540: /*S
1541: MatFactorShiftType - Type of numeric shift used for factorizations
1543: Values:
1544: + `MAT_SHIFT_NONE` - do not shift the matrix diagonal entries
1545: . `MAT_SHIFT_NONZERO` - shift the entries to be non-zero
1546: . `MAT_SHIFT_POSITIVE_DEFINITE` - shift the entries to force the factorization to be positive definite
1547: - `MAT_SHIFT_INBLOCKS` - only shift the factors inside the small dense diagonal blocks of the matrix, for example with `MATBAIJ`
1549: Level: intermediate
1551: .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `PCFactorSetShiftType()`
1552: S*/
1553: typedef enum {
1554: MAT_SHIFT_NONE,
1555: MAT_SHIFT_NONZERO,
1556: MAT_SHIFT_POSITIVE_DEFINITE,
1557: MAT_SHIFT_INBLOCKS
1558: } MatFactorShiftType;
1559: PETSC_EXTERN const char *const MatFactorShiftTypes[];
1560: PETSC_EXTERN const char *const MatFactorShiftTypesDetail[];
1562: /*S
1563: MatFactorError - indicates what type of error was generated in a matrix factorization
1565: Values:
1566: + `MAT_FACTOR_NOERROR` - there was no error during the factorization
1567: . `MAT_FACTOR_STRUCT_ZEROPIVOT` - there was a missing entry in a diagonal location of the matrix
1568: . `MAT_FACTOR_NUMERIC_ZEROPIVOT` - there was a (near) zero pivot during the factorization
1569: . `MAT_FACTOR_OUTMEMORY` - the factorization has run out of memory
1570: - `MAT_FACTOR_OTHER` - some other error has occurred.
1572: Level: intermediate
1574: Note:
1575: When a factorization is done in a preconditioner `PC` the error may be propagated up to a `PCFailedReason` or a `KSPConvergedReason`
1577: .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `MatFactorGetError()`, `MatFactorGetErrorZeroPivot()`, `MatFactorClearError()`,
1578: `PCFailedReason`, `PCGetFailedReason()`, `KSPConvergedReason`
1579: S*/
1580: typedef enum {
1581: MAT_FACTOR_NOERROR,
1582: MAT_FACTOR_STRUCT_ZEROPIVOT,
1583: MAT_FACTOR_NUMERIC_ZEROPIVOT,
1584: MAT_FACTOR_OUTMEMORY,
1585: MAT_FACTOR_OTHER
1586: } MatFactorError;
1588: PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *);
1589: PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat);
1590: PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *);
1592: /*S
1593: MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization
1595: Level: developer
1597: Note:
1598: You can use `MatFactorInfoInitialize()` to set default values.
1600: Fortran Note:
1601: `MatFactorInfo` is a derived type, use e.g. `matfactorinfo%dt` to access its components.
1603: .seealso: [](ch_matrices), `Mat`, `MatInfo`, `MatGetFactor()`, `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`,
1604: `MatICCFactorSymbolic()`, `MatICCFactor()`, `MatFactorInfoInitialize()`
1605: S*/
1606: typedef struct {
1607: PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */
1608: PetscReal usedt;
1609: PetscReal dt; /* drop tolerance */
1610: PetscReal dtcol; /* tolerance for pivoting */
1611: PetscReal dtcount; /* maximum nonzeros to be allowed per row */
1612: PetscReal fill; /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */
1613: PetscReal levels; /* ICC/ILU(levels) */
1614: PetscReal pivotinblocks; /* BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 factorization may be faster if do not pivot */
1615: PetscReal zeropivot; /* pivot is called zero if less than this */
1616: PetscReal shifttype; /* type of shift added to matrix factor to prevent zero pivots */
1617: PetscReal shiftamount; /* how large the shift is */
1618: PetscBool factoronhost; /* do factorization on host instead of device (for device matrix types) */
1619: PetscBool solveonhost; /* do mat solve on host with the factor (for device matrix types) */
1620: } MatFactorInfo;
1622: PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *);
1623: PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *);
1624: PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
1625: PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *);
1626: PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *);
1627: PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *);
1628: PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
1629: PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
1630: PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
1631: PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *);
1632: PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *);
1633: PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *);
1634: PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
1635: PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *);
1636: PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *);
1637: PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec);
1638: PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec);
1639: PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec);
1640: PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec);
1641: PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec);
1642: PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec);
1643: PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs);
1644: PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat);
1646: /*E
1647: MatFactorSchurStatus - Records the current state of the dense Schur complement that is maintained by a factored matrix when a user has requested its formation with `MatFactorSetSchurIS()`
1649: Values:
1650: + `MAT_FACTOR_SCHUR_UNFACTORED` - the Schur complement has been assembled but has not yet been factored or inverted
1651: . `MAT_FACTOR_SCHUR_FACTORED` - the Schur complement has been factored (for example via dense LU) and can be used to solve via `MatFactorSolveSchurComplement()`
1652: - `MAT_FACTOR_SCHUR_INVERTED` - the Schur complement has been explicitly inverted in place; subsequent solves multiply by the dense inverse
1654: Level: advanced
1656: .seealso: [](ch_matrices), `Mat`, `MatFactorSetSchurIS()`, `MatFactorGetSchurComplement()`, `MatFactorRestoreSchurComplement()`,
1657: `MatFactorInvertSchurComplement()`, `MatFactorCreateSchurComplement()`
1658: E*/
1659: typedef enum {
1660: MAT_FACTOR_SCHUR_UNFACTORED,
1661: MAT_FACTOR_SCHUR_FACTORED,
1662: MAT_FACTOR_SCHUR_INVERTED
1663: } MatFactorSchurStatus;
1664: PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS);
1665: PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
1666: PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus);
1667: PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat);
1668: PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
1669: PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec);
1670: PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec);
1671: PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat);
1673: PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat);
1674: /*E
1675: MatSORType - What type of (S)SOR to perform
1677: Values:
1678: + `SOR_FORWARD_SWEEP` - do a sweep from the first row of the matrix to the last
1679: . `SOR_BACKWARD_SWEEP` - do a sweep from the last row to the first
1680: . `SOR_SYMMETRIC_SWEEP` - do a sweep from the first row to the last and then back to the first
1681: . `SOR_LOCAL_FORWARD_SWEEP` - each MPI process does its own forward sweep with no communication
1682: . `SOR_LOCAL_BACKWARD_SWEEP` - each MPI process does its own backward sweep with no communication
1683: . `SOR_LOCAL_SYMMETRIC_SWEEP` - each MPI process does its own symmetric sweep with no communication
1684: . `SOR_ZERO_INITIAL_GUESS` - indicates the initial solution is zero so the sweep can avoid unneeded computation
1685: . `SOR_EISENSTAT` - apply the Eisentat application of SOR, see `PCEISENSTAT`
1686: . `SOR_APPLY_UPPER` - multiply by the upper triangular portion of the matrix
1687: - `SOR_APPLY_LOWER` - multiply by the lower triangular portion of the matrix
1689: Level: beginner
1691: Note:
1692: These may be bitwise ORd together
1694: Developer Note:
1695: Since `MatSORType` may be bitwise ORd together, so do not change the numerical values below
1697: .seealso: [](ch_matrices), `MatSOR()`
1698: E*/
1699: typedef enum {
1700: SOR_FORWARD_SWEEP = 1,
1701: SOR_BACKWARD_SWEEP = 2,
1702: SOR_SYMMETRIC_SWEEP = 3,
1703: SOR_LOCAL_FORWARD_SWEEP = 4,
1704: SOR_LOCAL_BACKWARD_SWEEP = 8,
1705: SOR_LOCAL_SYMMETRIC_SWEEP = 12,
1706: SOR_ZERO_INITIAL_GUESS = 16,
1707: SOR_EISENSTAT = 32,
1708: SOR_APPLY_UPPER = 64,
1709: SOR_APPLY_LOWER = 128
1710: } MatSORType;
1711: PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec);
1713: /*S
1714: MatColoring - Object for managing the coloring of matrices.
1716: Level: beginner
1718: Notes:
1719: Coloring of matrices can be computed directly from the sparse matrix nonzero structure via the `MatColoring` object or from the mesh from which the
1720: matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors).
1722: Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This
1723: same object can also be used to efficiently convert data created by Automatic Differentiation tools to PETSc sparse matrices.
1725: .seealso: [](ch_matrices), [](sec_graph), `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`,
1726: `MatPartitioning`, `MatColoringType`, `MatPartitioningType`, `MatOrderingType`, `MatColoringSetWeightType()`,
1727: `MatColoringSetWeights()`, `MatCoarsenType`, `MatCoarsen`
1728: S*/
1729: typedef struct _p_MatColoring *MatColoring;
1731: /*J
1732: MatColoringType - String with the name of a PETSc matrix coloring
1734: Level: beginner
1736: .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatFDColoringCreate()`, `MatColoringSetType()`, `MatColoring`
1737: J*/
1738: typedef const char *MatColoringType;
1739: #define MATCOLORINGJP "jp"
1740: #define MATCOLORINGPOWER "power"
1741: #define MATCOLORINGNATURAL "natural"
1742: #define MATCOLORINGSL "sl"
1743: #define MATCOLORINGLF "lf"
1744: #define MATCOLORINGID "id"
1745: #define MATCOLORINGGREEDY "greedy"
1747: /*E
1748: MatColoringWeightType - Type of weight scheme used for the coloring algorithm
1750: Values:
1751: + `MAT_COLORING_RANDOM` - Random weights
1752: . `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering.
1753: - `MAT_COLORING_LF` - Last-first weighting.
1755: Level: intermediate
1757: .seealso: [](ch_matrices), `MatColoring`, `MatColoringCreate()`, `MatColoringSetWeightType()`, `MatColoringSetWeights()`
1758: E*/
1759: typedef enum {
1760: MAT_COLORING_WEIGHT_RANDOM,
1761: MAT_COLORING_WEIGHT_LEXICAL,
1762: MAT_COLORING_WEIGHT_LF,
1763: MAT_COLORING_WEIGHT_SL
1764: } MatColoringWeightType;
1766: PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *);
1767: PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *);
1768: PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *);
1769: PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer);
1770: PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType);
1771: PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring);
1772: PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt);
1773: PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *);
1774: PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt);
1775: PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *);
1776: PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *);
1777: PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring));
1778: PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *);
1779: PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType);
1780: PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *);
1781: PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm);
1782: PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring);
1783: PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatColoringTest()", ) static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring)
1784: {
1785: return MatColoringTest(matcoloring, iscoloring);
1786: }
1787: PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring);
1789: /*S
1790: MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring
1792: Level: beginner
1794: Options Database Key:
1795: . -snes_fd_coloring - cause the Jacobian needed by `SNES` to be computed via a use of this object
1797: Note:
1798: This object is created utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()`
1800: .seealso: [](ch_matrices), `Mat`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()`
1801: S*/
1802: typedef struct _p_MatFDColoring *MatFDColoring;
1804: /*S
1805: MatFDColoringFn - Function provided to `MatFDColoringSetFunction()` that computes the function being differenced
1807: Level: advanced
1809: Calling Sequence:
1810: + snes - either a `SNES` object if used within `SNES` otherwise an unused parameter
1811: . in - the location where the Jacobian is to be computed
1812: . out - the location to put the computed function value
1813: - fctx - the function context passed into `MatFDColoringSetFunction()`
1815: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDiFn`, `MatMFFDiBaseFn`
1816: S*/
1817: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatFDColoringFn(void *snes, Vec x, Vec y, void *fctx);
1819: PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *);
1820: PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *);
1821: PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer);
1822: PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, MatFDColoringFn *, void *);
1823: PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, MatFDColoringFn **, void **);
1824: PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal);
1825: PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring);
1826: PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *);
1827: PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec);
1828: PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]);
1829: PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring);
1830: PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt);
1831: PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *);
1833: /*S
1834: MatTransposeColoring - Object for computing a sparse matrix product $C = A*B^T$ via coloring
1836: Level: developer
1838: .seealso: [](ch_matrices), `Mat`, `MatProductType`, `MatTransposeColoringCreate()`
1839: S*/
1840: typedef struct _p_MatTransposeColoring *MatTransposeColoring;
1842: PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *);
1843: PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat);
1844: PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat);
1845: PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *);
1847: /*S
1848: MatPartitioning - Object for managing the partitioning of a matrix or graph
1850: Level: beginner
1852: Note:
1853: There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations
1854: via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`)
1856: Developer Note:
1857: It is an extra maintenance and documentation cost to have two objects with the same functionality. `PetscPartitioner` should be removed
1859: .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`, `MatOrderingType`,
1860: `MatCoarsenType`
1861: S*/
1862: typedef struct _p_MatPartitioning *MatPartitioning;
1864: /*J
1865: MatPartitioningType - String with the name of a PETSc matrix partitioning
1867: Level: beginner
1868: dm
1869: .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`, `MatColoringType`, `MatOrderingType`,
1870: `MatCoarsenType`
1871: J*/
1872: typedef const char *MatPartitioningType;
1873: #define MATPARTITIONINGCURRENT "current"
1874: #define MATPARTITIONINGAVERAGE "average"
1875: #define MATPARTITIONINGSQUARE "square"
1876: #define MATPARTITIONINGPARMETIS "parmetis"
1877: #define MATPARTITIONINGCHACO "chaco"
1878: #define MATPARTITIONINGPARTY "party"
1879: #define MATPARTITIONINGPTSCOTCH "ptscotch"
1880: #define MATPARTITIONINGHIERARCH "hierarch"
1882: PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *);
1883: PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType);
1884: PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt);
1885: PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat);
1886: PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt);
1887: PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]);
1888: PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]);
1889: PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool);
1890: PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *);
1891: PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *);
1892: PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *);
1893: PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS);
1894: PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *);
1895: PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *);
1896: PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning));
1897: PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer);
1898: PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]);
1899: PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning);
1900: PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *);
1902: PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning);
1903: PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
1904: PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *);
1906: /*E
1907: MPChacoGlobalType - Global partitioning method used by `MATPARTITIONINGCHACO` when delegating to the Chaco library
1909: Values:
1910: + `MP_CHACO_MULTILEVEL` - multilevel-Kernighan--Lin style partitioning
1911: . `MP_CHACO_SPECTRAL` - spectral partitioning using Lanczos or RQI eigensolvers
1912: . `MP_CHACO_LINEAR` - linear (rank-order) initial partition
1913: . `MP_CHACO_RANDOM` - random initial partition
1914: - `MP_CHACO_SCATTERED` - scattered (round-robin) initial partition
1916: Level: intermediate
1918: .seealso: [](ch_matrices), `MatPartitioning`, `MATPARTITIONINGCHACO`, `MatPartitioningChacoSetGlobal()`, `MatPartitioningChacoGetGlobal()`,
1919: `MPChacoLocalType`, `MPChacoEigenType`
1920: E*/
1921: typedef enum {
1922: MP_CHACO_MULTILEVEL = 1,
1923: MP_CHACO_SPECTRAL = 2,
1924: MP_CHACO_LINEAR = 4,
1925: MP_CHACO_RANDOM = 5,
1926: MP_CHACO_SCATTERED = 6
1927: } MPChacoGlobalType;
1928: PETSC_EXTERN const char *const MPChacoGlobalTypes[];
1929: /*E
1930: MPChacoLocalType - Local refinement method used by `MATPARTITIONINGCHACO` after the global partition has been chosen
1932: Values:
1933: + `MP_CHACO_KERNIGHAN` - apply Kernighan--Lin local refinement to improve the partition
1934: - `MP_CHACO_NONE` - no local refinement
1936: Level: intermediate
1938: .seealso: [](ch_matrices), `MatPartitioning`, `MATPARTITIONINGCHACO`, `MatPartitioningChacoSetLocal()`, `MatPartitioningChacoGetLocal()`,
1939: `MPChacoGlobalType`
1940: E*/
1941: typedef enum {
1942: MP_CHACO_KERNIGHAN = 1,
1943: MP_CHACO_NONE = 2
1944: } MPChacoLocalType;
1945: PETSC_EXTERN const char *const MPChacoLocalTypes[];
1946: /*E
1947: MPChacoEigenType - Eigensolver used by `MATPARTITIONINGCHACO` when the global partitioning method is `MP_CHACO_SPECTRAL`
1949: Values:
1950: + `MP_CHACO_LANCZOS` - Lanczos algorithm
1951: - `MP_CHACO_RQI` - Rayleigh quotient iteration
1953: Level: intermediate
1955: .seealso: [](ch_matrices), `MatPartitioning`, `MATPARTITIONINGCHACO`, `MatPartitioningChacoSetEigenSolver()`, `MatPartitioningChacoGetEigenSolver()`,
1956: `MPChacoGlobalType`
1957: E*/
1958: typedef enum {
1959: MP_CHACO_LANCZOS = 0,
1960: MP_CHACO_RQI = 1
1961: } MPChacoEigenType;
1962: PETSC_EXTERN const char *const MPChacoEigenTypes[];
1964: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
1965: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *);
1966: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1967: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *);
1968: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal);
1969: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType);
1970: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *);
1971: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1972: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *);
1973: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
1974: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *);
1976: #define MP_PARTY_OPT "opt"
1977: #define MP_PARTY_LIN "lin"
1978: #define MP_PARTY_SCA "sca"
1979: #define MP_PARTY_RAN "ran"
1980: #define MP_PARTY_GBF "gbf"
1981: #define MP_PARTY_GCF "gcf"
1982: #define MP_PARTY_BUB "bub"
1983: #define MP_PARTY_DEF "def"
1984: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *);
1985: #define MP_PARTY_HELPFUL_SETS "hs"
1986: #define MP_PARTY_KERNIGHAN_LIN "kl"
1987: #define MP_PARTY_NONE "no"
1988: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *);
1989: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal);
1990: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool);
1991: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool);
1993: /*E
1994: MPPTScotchStrategyType - Pre-defined strategy used by `MATPARTITIONINGPTSCOTCH` when delegating to the PT-Scotch library
1996: Values:
1997: + `MP_PTSCOTCH_DEFAULT` - the default PT-Scotch strategy
1998: . `MP_PTSCOTCH_QUALITY` - focus on partition quality at the expense of time
1999: . `MP_PTSCOTCH_SPEED` - focus on time to compute the partition
2000: . `MP_PTSCOTCH_BALANCE` - favor load balance
2001: . `MP_PTSCOTCH_SAFETY` - use the most reliable internal heuristics
2002: - `MP_PTSCOTCH_SCALABILITY` - favor scalability at large process counts
2004: Level: intermediate
2006: .seealso: [](ch_matrices), `MatPartitioning`, `MATPARTITIONINGPTSCOTCH`, `MatPartitioningPTScotchSetStrategy()`, `MatPartitioningPTScotchGetStrategy()`
2007: E*/
2008: typedef enum {
2009: MP_PTSCOTCH_DEFAULT,
2010: MP_PTSCOTCH_QUALITY,
2011: MP_PTSCOTCH_SPEED,
2012: MP_PTSCOTCH_BALANCE,
2013: MP_PTSCOTCH_SAFETY,
2014: MP_PTSCOTCH_SCALABILITY
2015: } MPPTScotchStrategyType;
2016: PETSC_EXTERN const char *const MPPTScotchStrategyTypes[];
2018: PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal);
2019: PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *);
2020: PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType);
2021: PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *);
2023: /*
2024: * hierarchical partitioning
2025: */
2026: PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *);
2027: PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *);
2028: PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt);
2029: PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt);
2031: typedef const char *MatMeshToCellGraphType;
2032: #define MATMESHTOCELLGRAPHMETIS "metis"
2033: #define MATMESHTOCELLGRAPHPARMETIS "parmetis"
2035: PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *);
2036: PETSC_EXTERN PetscErrorCode MatMeshToCellGraphRegister(const char[], PetscErrorCode (*)(Mat, PetscInt, Mat *));
2038: /*E
2039: MatOperation - Identifies one of the operations stored in a `Mat`'s function table, for example `MATOP_MULT` or `MATOP_LUFACTOR`
2041: Level: developer
2043: Notes:
2044: Use `MatSetOperation()` to install a custom implementation of a given operation on a `Mat` (typically a `MATSHELL`), `MatGetOperation()` to retrieve the currently installed implementation, and `MatHasOperation()` to test whether one is installed.
2046: The numeric values are part of the binary interface used by the petsc4py bindings; if any of these enum values are changed, the `dMatOps` dictionary in `src/binding/petsc4py/src/petsc4py/PETSc/libpetsc4py.pyx` must be updated to match.
2048: .seealso: [](ch_matrices), `Mat`, `MATSHELL`, `MatSetOperation()`, `MatGetOperation()`, `MatHasOperation()`,
2049: `MatShellSetOperation()`, `MatShellGetOperation()`
2050: E*/
2051: typedef enum {
2052: MATOP_SET_VALUES = 0,
2053: MATOP_GET_ROW = 1,
2054: MATOP_RESTORE_ROW = 2,
2055: MATOP_MULT = 3,
2056: MATOP_MULT_ADD = 4,
2057: MATOP_MULT_TRANSPOSE = 5,
2058: MATOP_MULT_TRANSPOSE_ADD = 6,
2059: MATOP_SOLVE = 7,
2060: MATOP_SOLVE_ADD = 8,
2061: MATOP_SOLVE_TRANSPOSE = 9,
2062: MATOP_SOLVE_TRANSPOSE_ADD = 10,
2063: MATOP_LUFACTOR = 11,
2064: MATOP_CHOLESKYFACTOR = 12,
2065: MATOP_SOR = 13,
2066: MATOP_TRANSPOSE = 14,
2067: MATOP_GETINFO = 15,
2068: MATOP_EQUAL = 16,
2069: MATOP_GET_DIAGONAL = 17,
2070: MATOP_DIAGONAL_SCALE = 18,
2071: MATOP_NORM = 19,
2072: MATOP_ASSEMBLY_BEGIN = 20,
2073: MATOP_ASSEMBLY_END = 21,
2074: MATOP_SET_OPTION = 22,
2075: MATOP_ZERO_ENTRIES = 23,
2076: MATOP_ZERO_ROWS = 24,
2077: MATOP_LUFACTOR_SYMBOLIC = 25,
2078: MATOP_LUFACTOR_NUMERIC = 26,
2079: MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27,
2080: MATOP_CHOLESKY_FACTOR_NUMERIC = 28,
2081: MATOP_SETUP = 29,
2082: MATOP_ILUFACTOR_SYMBOLIC = 30,
2083: MATOP_ICCFACTOR_SYMBOLIC = 31,
2084: MATOP_GET_DIAGONAL_BLOCK = 32,
2085: MATOP_SET_INF = 33,
2086: MATOP_DUPLICATE = 34,
2087: MATOP_FORWARD_SOLVE = 35,
2088: MATOP_BACKWARD_SOLVE = 36,
2089: MATOP_ILUFACTOR = 37,
2090: MATOP_ICCFACTOR = 38,
2091: MATOP_AXPY = 39,
2092: MATOP_CREATE_SUBMATRICES = 40,
2093: MATOP_INCREASE_OVERLAP = 41,
2094: MATOP_GET_VALUES = 42,
2095: MATOP_COPY = 43,
2096: MATOP_GET_ROW_MAX = 44,
2097: MATOP_SCALE = 45,
2098: MATOP_SHIFT = 46,
2099: MATOP_DIAGONAL_SET = 47,
2100: MATOP_ZERO_ROWS_COLUMNS = 48,
2101: MATOP_SET_RANDOM = 49,
2102: MATOP_GET_ROW_IJ = 50,
2103: MATOP_RESTORE_ROW_IJ = 51,
2104: MATOP_GET_COLUMN_IJ = 52,
2105: MATOP_RESTORE_COLUMN_IJ = 53,
2106: MATOP_FDCOLORING_CREATE = 54,
2107: MATOP_COLORING_PATCH = 55,
2108: MATOP_SET_UNFACTORED = 56,
2109: MATOP_PERMUTE = 57,
2110: MATOP_SET_VALUES_BLOCKED = 58,
2111: MATOP_CREATE_SUBMATRIX = 59,
2112: MATOP_DESTROY = 60,
2113: MATOP_VIEW = 61,
2114: MATOP_CONVERT_FROM = 62,
2115: MATOP_MATMAT_MULT_SYMBOLIC = 63,
2116: MATOP_MATMAT_MULT_NUMERIC = 64,
2117: MATOP_SET_LOCAL_TO_GLOBAL_MAP = 65,
2118: MATOP_SET_VALUES_LOCAL = 66,
2119: MATOP_ZERO_ROWS_LOCAL = 67,
2120: MATOP_GET_ROW_MAX_ABS = 68,
2121: MATOP_GET_ROW_MIN_ABS = 69,
2122: MATOP_CONVERT = 70,
2123: MATOP_HAS_OPERATION = 71,
2124: MATOP_FD_COLORING_APPLY = 72,
2125: MATOP_SET_FROM_OPTIONS = 73,
2126: MATOP_FIND_ZERO_DIAGONALS = 74,
2127: MATOP_MULT_MULTIPLE = 75,
2128: MATOP_SOLVE_MULTIPLE = 76,
2129: MATOP_GET_INERTIA = 77,
2130: MATOP_LOAD = 78,
2131: MATOP_IS_SYMMETRIC = 79,
2132: MATOP_IS_HERMITIAN = 80,
2133: MATOP_IS_STRUCTURALLY_SYMMETRIC = 81,
2134: MATOP_SET_VALUES_BLOCKEDLOCAL = 82,
2135: MATOP_CREATE_VECS = 83,
2136: MATOP_MAT_MULT_SYMBOLIC = 84,
2137: MATOP_MAT_MULT_NUMERIC = 85,
2138: MATOP_PTAP_NUMERIC = 86,
2139: MATOP_MAT_TRANSPOSE_MULT_SYMBO = 87,
2140: MATOP_MAT_TRANSPOSE_MULT_NUMER = 88,
2141: MATOP_BIND_TO_CPU = 89,
2142: MATOP_PRODUCTSETFROMOPTIONS = 90,
2143: MATOP_PRODUCTSYMBOLIC = 91,
2144: MATOP_PRODUCTNUMERIC = 92,
2145: MATOP_CONJUGATE = 93,
2146: MATOP_VIEW_NATIVE = 94,
2147: MATOP_SET_VALUES_ROW = 95,
2148: MATOP_REAL_PART = 96,
2149: MATOP_IMAGINARY_PART = 97,
2150: MATOP_GET_ROW_UPPER_TRIANGULAR = 98,
2151: MATOP_RESTORE_ROW_UPPER_TRIANG = 99,
2152: MATOP_MAT_SOLVE = 100,
2153: MATOP_MAT_SOLVE_TRANSPOSE = 101,
2154: MATOP_GET_ROW_MIN = 102,
2155: MATOP_GET_COLUMN_VECTOR = 103,
2156: MATOP_GET_SEQ_NONZERO_STRUCTUR = 104,
2157: MATOP_CREATE = 105,
2158: MATOP_GET_GHOSTS = 106,
2159: MATOP_GET_LOCAL_SUB_MATRIX = 107,
2160: MATOP_RESTORE_LOCALSUB_MATRIX = 108,
2161: MATOP_MULT_DIAGONAL_BLOCK = 109,
2162: MATOP_HERMITIAN_TRANSPOSE = 110,
2163: MATOP_MULT_HERMITIAN_TRANSPOSE = 111,
2164: MATOP_MULT_HERMITIAN_TRANS_ADD = 112,
2165: MATOP_GET_MULTI_PROC_BLOCK = 113,
2166: MATOP_FIND_NONZERO_ROWS = 114,
2167: MATOP_GET_COLUMN_NORMS = 115,
2168: MATOP_INVERT_BLOCK_DIAGONAL = 116,
2169: MATOP_INVERT_VBLOCK_DIAGONAL = 117,
2170: MATOP_CREATE_SUB_MATRICES_MPI = 118,
2171: MATOP_TRANSPOSE_MAT_MULT_SYMBO = 119,
2172: MATOP_TRANSPOSE_MAT_MULT_NUMER = 120,
2173: MATOP_TRANSPOSE_COLORING_CREAT = 121,
2174: MATOP_TRANS_COLORING_APPLY_SPT = 122,
2175: MATOP_TRANS_COLORING_APPLY_DEN = 123,
2176: MATOP_RART_NUMERIC = 124,
2177: MATOP_SET_BLOCK_SIZES = 125,
2178: MATOP_RESIDUAL = 126,
2179: MATOP_FDCOLORING_SETUP = 127,
2180: MATOP_FIND_OFFBLOCK_ENTRIES = 128,
2181: MATOP_MPICONCATENATESEQ = 129,
2182: MATOP_DESTROYSUBMATRICES = 130,
2183: MATOP_MAT_TRANSPOSE_SOLVE = 131,
2184: MATOP_GET_VALUES_LOCAL = 132,
2185: MATOP_CREATE_GRAPH = 133,
2186: MATOP_TRANSPOSE_SYMBOLIC = 134,
2187: MATOP_ELIMINATE_ZEROS = 135,
2188: MATOP_GET_ROW_SUM_ABS = 136,
2189: MATOP_GET_FACTOR = 137,
2190: MATOP_GET_BLOCK_DIAGONAL = 138, /* NOTE: caller of the two op functions owns the returned matrix */
2191: MATOP_GET_VBLOCK_DIAGONAL = 139, /* and need to destroy it after use. */
2192: MATOP_COPY_HASH_TO_XAIJ = 140,
2193: MATOP_GET_CURRENT_MEM_TYPE = 141,
2194: MATOP_ZERO_ROWS_COLUMNS_LOCAL = 142,
2195: MATOP_ADOT = 143,
2196: MATOP_ANORM = 144,
2197: MATOP_ADOT_LOCAL = 145,
2198: MATOP_ANORM_LOCAL = 146,
2199: MATOP_GET_ORDERING = 147
2200: } MatOperation;
2202: PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, PetscErrorCodeFn *);
2203: PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, PetscErrorCodeFn **);
2204: PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *);
2205: PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *);
2206: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatProductClear()", ) static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A)
2207: {
2208: return MatProductClear(A);
2209: }
2210: PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, PetscErrorCodeFn *);
2211: PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, PetscErrorCodeFn **);
2212: PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, PetscCtx);
2213: PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscCtxDestroyFn *);
2214: PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType);
2215: PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
2216: PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
2217: PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat);
2218: PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscCtxDestroyFn *, MatType, MatType);
2219: PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *);
2221: /*
2222: Codes for matrices stored on disk. By default they are
2223: stored in a universal format. By changing the format with
2224: PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will
2225: be stored in a way natural for the matrix, for example dense matrices
2226: would be stored as dense. Matrices stored this way may only be
2227: read into matrices of the same type.
2228: */
2229: #define MATRIX_BINARY_FORMAT_DENSE -1
2231: PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal);
2233: PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType);
2234: PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
2235: PETSC_EXTERN PetscErrorCode MatISSetAllowRepeated(Mat, PetscBool);
2236: PETSC_EXTERN PetscErrorCode MatISGetAllowRepeated(Mat, PetscBool *);
2237: PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool);
2238: PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool);
2239: PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *);
2240: PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *);
2241: PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat);
2242: PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
2244: /*S
2245: MatNullSpace - Object that removes a null space from a vector, i.e.
2246: orthogonalizes the vector to a subspace
2248: Level: advanced
2250: .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
2251: S*/
2252: typedef struct _p_MatNullSpace *MatNullSpace;
2254: /*S
2255: MatNullSpaceRemoveFn - Function provided to `MatNullSpaceSetFunction()` that removes the null space from a vector
2257: Level: advanced
2259: Calling Sequence:
2260: + nsp - the `MatNullSpace` object
2261: . x - the vector from which to remove the null space
2262: - ctx - [optional] user-defined function context provided with `MatNullSpaceSetFunction()`
2264: .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
2265: S*/
2266: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatNullSpaceRemoveFn(MatNullSpace nsp, Vec x, PetscCtx ctx);
2268: PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *);
2269: PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, MatNullSpaceRemoveFn *, void *);
2270: PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *);
2271: PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec);
2272: PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *);
2273: PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *);
2274: PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace);
2275: PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace);
2276: PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace);
2277: PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *);
2278: PETSC_EXTERN PetscErrorCode MatGetNullSpaces(PetscInt, Mat[], MatNullSpace *[]);
2279: PETSC_EXTERN PetscErrorCode MatRestoreNullSpaces(PetscInt, Mat[], MatNullSpace *[]);
2280: PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *);
2281: PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer);
2282: PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **);
2283: PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *);
2285: PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS);
2286: PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *);
2288: PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *);
2289: PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *);
2290: PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *);
2292: PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *);
2293: PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *);
2295: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperator()", ) static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B)
2296: {
2297: return MatComputeOperator(A, PETSC_NULLPTR, B);
2298: }
2299: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperatorTranspose()", ) static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B)
2300: {
2301: return MatComputeOperatorTranspose(A, PETSC_NULLPTR, B);
2302: }
2304: PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *);
2305: PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *);
2306: PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **);
2307: PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2308: PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **);
2309: PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **);
2310: PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **);
2311: PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2312: PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **);
2313: PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **);
2314: PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat);
2315: PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]);
2316: PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]);
2317: PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *);
2319: PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec);
2321: PETSC_EXTERN PetscErrorCode MatMFFDInitializePackage(void);
2322: PETSC_EXTERN PetscErrorCode MatMFFDFinalizePackage(void);
2324: /*S
2325: MatMFFDFn - Function provided to `MatMFFDSetFunction()` that computes the function being differenced
2327: Level: advanced
2329: Calling Sequence:
2330: + ctx - [optional] user-defined function context provided with `MatMFFDSetFunction()`
2331: . x - input vector
2332: - y - output vector
2334: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDiFn`, `MatMFFDiBaseFn`
2335: S*/
2336: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDFn(PetscCtx ctx, Vec x, Vec y);
2338: /*S
2339: MatMFFDiFn - Function provided to `MatMFFDSetFunctioni()` that computes the function being differenced at a single point
2341: Level: advanced
2343: Calling Sequence:
2344: + ctx - [optional] user-defined function context provided with `MatMFFDSetFunction()`
2345: . i - the component of the vector to compute
2346: . x - input vector
2347: - result - the value of the function at that component (output)
2349: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDFn`, `MatMFFDiBaseFn`
2350: S*/
2351: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDiFn(PetscCtx ctx, PetscInt i, Vec x, PetscScalar *result);
2353: /*S
2354: MatMFFDiBaseFn - Function provided to `MatMFFDSetFunctioniBase()` that computes the base of the function evaluations
2355: that will be used for differencing
2357: Level: advanced
2359: Calling Sequence:
2360: + ctx - [optional] user-defined function context provided with `MatMFFDSetFunction()`
2361: - x - input base vector
2363: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDSetFunctioniBase()`, `MatMFFDFn`, `MatMFFDiFn`
2364: S*/
2365: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDiBaseFn(PetscCtx ctx, Vec x);
2367: /*S
2368: MatMFFDCheckhFn - Function provided to `MatMFFDSetCheckh()` that checks and possibly adjusts the value of `h` to ensure some property.
2369: that will be used for differencing
2371: Level: advanced
2373: Calling Sequence:
2374: + ctx - [optional] user-defined function context provided with `MatMFFDSetCheckh()`
2375: . x - input base vector
2376: . y - input step vector that the product is computed with
2377: - h - input tentative step, output possibly adjusted step
2379: Note:
2380: `MatMFFDCheckPositivity()` is one such function
2382: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetCheckh()`, `MatMFFDCheckPositivity()`
2383: S*/
2384: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDCheckhFn(PetscCtx ctx, Vec x, Vec y, PetscScalar *h);
2386: PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2387: PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec);
2388: PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, MatMFFDFn *, void *);
2389: PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, MatMFFDiFn *);
2390: PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, MatMFFDiBaseFn *);
2391: PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt);
2392: PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat);
2393: PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal);
2394: PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt);
2395: PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *);
2396: PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]);
2397: PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *);
2398: PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, MatMFFDCheckhFn *, void *);
2400: /*S
2401: MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free
2402: Jacobian vector products
2404: Level: developer
2406: Notes:
2407: `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure
2409: MatMFFD*() methods actually take the `Mat` as their first argument. Not a `MatMFFD` data structure
2411: This functionality is often obtained using `MatCreateSNESMF()` or with `SNES` solvers using `-snes_mf` or `-snes_mf_operator`
2413: .seealso: [](ch_matrices), `MatMFFDType`, `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`,
2414: `MatCreateSNESMF()`, `SNES`, `-snes_mf`, `-snes_mf_operator`
2415: S*/
2416: typedef struct _p_MatMFFD *MatMFFD;
2418: /*J
2419: MatMFFDType - algorithm used to compute the `h` used in computing matrix-vector products via differencing of a function
2421: Values:
2422: + `MATMFFD_DS` - an algorithm described by Dennis and Schnabel {cite}`dennis:83`
2423: - `MATMFFD_WP` - the Walker-Pernice {cite}`pw98` strategy.
2425: Level: beginner
2427: .seealso: [](ch_matrices), `MatMFFDSetType()`, `MatMFFDRegister()`, `MatMFFDSetFunction()`, `MatCreateMFFD()`
2428: J*/
2429: typedef const char *MatMFFDType;
2430: #define MATMFFD_DS "ds"
2431: #define MATMFFD_WP "wp"
2433: PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType);
2434: PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD));
2436: PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal);
2437: PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool);
2439: PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType);
2441: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
2442: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
2444: #if PetscDefined(HAVE_H2OPUS)
2445: PETSC_EXTERN_TYPEDEF typedef PetscScalar(MatH2OpusKernelFn)(PetscInt, PetscReal[], PetscReal[], void *);
2446: PETSC_EXTERN_TYPEDEF typedef MatH2OpusKernelFn *MatH2OpusKernel;
2448: PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernelFn *, void *, PetscReal, PetscInt, PetscInt, Mat *);
2449: PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *);
2450: PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal);
2451: PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat);
2452: PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal);
2453: PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool);
2454: PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *);
2455: PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *);
2456: PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *);
2457: PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar);
2458: #endif
2460: /*S
2461: MatHtoolKernelFn - Function type for the user-supplied kernel callback used by `MATHTOOL` (`MatCreateHtoolFromKernel()`, `MatHtoolSetKernel()`) to evaluate the dense matrix entries on demand
2463: Synopsis:
2464: #include <petscmat.h>
2465: PetscErrorCode MatHtoolKernelFn(PetscInt sdim, PetscInt M, PetscInt N, const PetscInt *J, const PetscInt *K, PetscScalar *ptr, void *ctx)
2467: Calling Sequence:
2468: + sdim - the spatial dimension of the source/target geometries
2469: . M - the number of target points
2470: . N - the number of source points
2471: . J - array of `M` target point indices into the user's target coordinate array
2472: . K - array of `N` source point indices into the user's source coordinate array
2473: . ptr - column-major output buffer of length `M*N` to fill with kernel values
2474: - ctx - the optional application context passed at registration
2476: Level: intermediate
2478: .seealso: `Mat`, `MATHTOOL`, `MatCreateHtoolFromKernel()`, `MatHtoolSetKernel()`
2479: S*/
2480: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatHtoolKernelFn(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *);
2481: PETSC_EXTERN_TYPEDEF typedef MatHtoolKernelFn *MatHtoolKernel;
2483: PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernelFn *, void *, Mat *);
2484: PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernelFn *, void *);
2485: PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *);
2486: PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *);
2487: PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool);
2488: PETSC_EXTERN PetscErrorCode MatHtoolUseRecompression(Mat, PetscBool);
2489: PETSC_EXTERN PetscErrorCode MatHtoolGetEpsilon(Mat, PetscReal *);
2490: PETSC_EXTERN PetscErrorCode MatHtoolSetEpsilon(Mat, PetscReal);
2491: PETSC_EXTERN PetscErrorCode MatHtoolGetEta(Mat, PetscReal *);
2492: PETSC_EXTERN PetscErrorCode MatHtoolSetEta(Mat, PetscReal);
2493: PETSC_EXTERN PetscErrorCode MatHtoolGetMaxClusterLeafSize(Mat, PetscInt *);
2494: PETSC_EXTERN PetscErrorCode MatHtoolSetMaxClusterLeafSize(Mat, PetscInt);
2495: PETSC_EXTERN PetscErrorCode MatHtoolGetMinTargetDepth(Mat, PetscInt *);
2496: PETSC_EXTERN PetscErrorCode MatHtoolSetMinTargetDepth(Mat, PetscInt);
2497: PETSC_EXTERN PetscErrorCode MatHtoolGetMinSourceDepth(Mat, PetscInt *);
2498: PETSC_EXTERN PetscErrorCode MatHtoolSetMinSourceDepth(Mat, PetscInt);
2499: PETSC_EXTERN PetscErrorCode MatHtoolGetBlockTreeConsistency(Mat, PetscBool *);
2500: PETSC_EXTERN PetscErrorCode MatHtoolSetBlockTreeConsistency(Mat, PetscBool);
2502: /*E
2503: MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL`
2505: Values:
2506: + `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation
2507: . `MAT_HTOOL_COMPRESSOR_FULL_ACA` - full adaptive cross approximation
2508: - `MAT_HTOOL_COMPRESSOR_SVD` - singular value decomposition
2510: Level: intermediate
2512: .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType`, `MatHtoolGetCompressorType()`, `MatHtoolSetCompressorType()`
2513: E*/
2514: typedef enum {
2515: MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA,
2516: MAT_HTOOL_COMPRESSOR_FULL_ACA,
2517: MAT_HTOOL_COMPRESSOR_SVD
2518: } MatHtoolCompressorType;
2520: /*E
2521: MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL`
2523: Values:
2524: + `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default) - axis computed via principle component analysis, split uniformly
2525: . `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC` - axis computed via principle component analysis, split barycentrically
2526: . `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR` - axis along the largest extent of the bounding box, split uniformly
2527: - `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically
2529: Level: intermediate
2531: Note:
2532: Higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types
2534: .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType`, `MatHtoolGetClusteringType()`, `MatHtoolSetClusteringType()`
2535: E*/
2536: typedef enum {
2537: MAT_HTOOL_CLUSTERING_PCA_REGULAR,
2538: MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC,
2539: MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR,
2540: MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC
2541: } MatHtoolClusteringType;
2542: PETSC_EXTERN PetscErrorCode MatHtoolGetCompressorType(Mat, MatHtoolCompressorType *);
2543: PETSC_EXTERN PetscErrorCode MatHtoolSetCompressorType(Mat, MatHtoolCompressorType);
2544: PETSC_EXTERN PetscErrorCode MatHtoolGetClusteringType(Mat, MatHtoolClusteringType *);
2545: PETSC_EXTERN PetscErrorCode MatHtoolSetClusteringType(Mat, MatHtoolClusteringType);
2547: PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt);
2548: PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *);
2549: PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal);
2550: PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *);
2552: PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *);
2553: PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *);
2554: PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *);
2555: PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *);
2556: PETSC_EXTERN PetscErrorCode MatMumpsGetNullPivots(Mat, PetscInt *, PetscInt **);
2557: PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat);
2558: PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat);
2559: PETSC_EXTERN PetscErrorCode MatMumpsSetBlk(Mat, PetscInt, const PetscInt[], const PetscInt[]);
2561: PETSC_EXTERN PetscErrorCode MatMumpsSetOocTmpDir(Mat, const char *);
2562: PETSC_EXTERN PetscErrorCode MatMumpsGetOocTmpDir(Mat, const char *[]);
2564: #if PetscDefined(HAVE_MKL_PARDISO)
2565: PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt);
2566: #endif
2568: #if PetscDefined(HAVE_MKL_CPARDISO)
2569: PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt);
2570: #endif
2572: #if PetscDefined(HAVE_SUPERLU)
2573: PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal);
2574: #endif
2576: #if PetscDefined(HAVE_SUPERLU_DIST)
2577: PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *);
2578: #endif
2580: /*E
2581: MatSTRUMPACKReordering - sparsity reducing ordering to be used in `MATSOLVERSTRUMPACK`
2583: Values:
2584: + `MAT_STRUMPACK_NATURAL` - use the current ordering
2585: . `MAT_STRUMPACK_METIS` - use MeTis to compute an ordering
2586: . `MAT_STRUMPACK_PARMETIS` - use ParMeTis to compute an ordering
2587: . `MAT_STRUMPACK_SCOTCH` - use Scotch to compute an ordering
2588: . `MAT_STRUMPACK_PTSCOTCH` - use parallel Scotch to compute an ordering
2589: . `MAT_STRUMPACK_RCM` - use an RCM ordering
2590: . `MAT_STRUMPACK_GEOMETRIC` - use a geometric ordering (needs mesh info from user)
2591: . `MAT_STRUMPACK_AMD` - approximate minimum degree
2592: . `MAT_STRUMPACK_MMD` - multiple minimum degree
2593: . `MAT_STRUMPACK_AND` - approximate nested dissection
2594: . `MAT_STRUMPACK_MLF` - minimum local fill
2595: - `MAT_STRUMPACK_SPECTRAL` - spectral nested dissection
2597: Level: intermediate
2599: Developer Note:
2600: Should be called `MatSTRUMPACKReorderingType`
2602: .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetReordering()`
2603: E*/
2604: typedef enum {
2605: MAT_STRUMPACK_NATURAL,
2606: MAT_STRUMPACK_METIS,
2607: MAT_STRUMPACK_PARMETIS,
2608: MAT_STRUMPACK_SCOTCH,
2609: MAT_STRUMPACK_PTSCOTCH,
2610: MAT_STRUMPACK_RCM,
2611: MAT_STRUMPACK_GEOMETRIC,
2612: MAT_STRUMPACK_AMD,
2613: MAT_STRUMPACK_MMD,
2614: MAT_STRUMPACK_AND,
2615: MAT_STRUMPACK_MLF,
2616: MAT_STRUMPACK_SPECTRAL
2617: } MatSTRUMPACKReordering;
2618: PETSC_EXTERN const char *const MatSTRUMPACKReorderingTypes[];
2620: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering);
2621: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetReordering(Mat, MatSTRUMPACKReordering *);
2622: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricNxyz(Mat, PetscInt, PetscInt, PetscInt);
2623: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricComponents(Mat, PetscInt);
2624: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricWidth(Mat, PetscInt);
2625: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool);
2626: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetColPerm(Mat, PetscBool *);
2627: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGPU(Mat, PetscBool);
2628: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetGPU(Mat, PetscBool *);
2630: /*E
2631: MatSTRUMPACKCompressionType - Compression used in the approximate sparse factorization solver `MATSOLVERSTRUMPACK`
2633: Values:
2634: + `MAT_STRUMPACK_COMPRESSION_TYPE_NONE` - no compression, direct solver
2635: . `MAT_STRUMPACK_COMPRESSION_TYPE_HSS` - hierarchically semi-separable
2636: . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR` - block low rank
2637: . `MAT_STRUMPACK_COMPRESSION_TYPE_HODLR` - hierarchically off-diagonal low rank (requires ButterflyPACK support, configure with `--download-butterflypack`)
2638: . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR` - hybrid of BLR and HODLR (requires ButterflyPACK support, configure with `--download-butterflypack`)
2639: . `MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR` - hybrid of lossy (ZFP), BLR and HODLR (requires ButterflyPACK and ZFP support, configure with `--download-butterflypack --download-zfp`)
2640: . `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS` - lossless compression (requires ZFP support, configure with `--download-zfp`)
2641: - `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY` - lossy compression (requires ZFP support, configure with `--download-zfp`)
2643: Level: intermediate
2645: .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetCompression()`
2646: E*/
2647: typedef enum {
2648: MAT_STRUMPACK_COMPRESSION_TYPE_NONE,
2649: MAT_STRUMPACK_COMPRESSION_TYPE_HSS,
2650: MAT_STRUMPACK_COMPRESSION_TYPE_BLR,
2651: MAT_STRUMPACK_COMPRESSION_TYPE_HODLR,
2652: MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR,
2653: MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR,
2654: MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS,
2655: MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY
2656: } MatSTRUMPACKCompressionType;
2657: PETSC_EXTERN const char *const MatSTRUMPACKCompressionTypes[];
2659: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompression(Mat, MatSTRUMPACKCompressionType);
2660: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompression(Mat, MatSTRUMPACKCompressionType *);
2661: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompRelTol(Mat, PetscReal);
2662: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompRelTol(Mat, PetscReal *);
2663: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompAbsTol(Mat, PetscReal);
2664: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompAbsTol(Mat, PetscReal *);
2665: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompMinSepSize(Mat, PetscInt);
2666: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompMinSepSize(Mat, PetscInt *);
2667: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLeafSize(Mat, PetscInt);
2668: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLeafSize(Mat, PetscInt *);
2669: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLossyPrecision(Mat, PetscInt);
2670: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLossyPrecision(Mat, PetscInt *);
2671: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompButterflyLevels(Mat, PetscInt);
2672: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompButterflyLevels(Mat, PetscInt *);
2674: PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool);
2675: PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *);
2676: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "MatBindToCPU()", ) static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg)
2677: {
2678: return MatBindToCPU(A, flg);
2679: }
2680: PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool);
2681: PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *);
2683: #if PetscDefined(HAVE_CUDA)
2684: /*E
2685: MatCUSPARSEStorageFormat - indicates the storage format for `MATAIJCUSPARSE` (GPU)
2686: matrices.
2688: Values:
2689: + `MAT_CUSPARSE_CSR` - Compressed Sparse Row
2690: . `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later).
2691: - `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later).
2693: Level: intermediate
2695: .seealso: [](ch_matrices), `MATAIJCUSPARSE`, `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation`
2696: E*/
2698: typedef enum {
2699: MAT_CUSPARSE_CSR,
2700: MAT_CUSPARSE_ELL,
2701: MAT_CUSPARSE_HYB
2702: } MatCUSPARSEStorageFormat;
2704: /* these will be strings associated with enumerated type defined above */
2705: PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[];
2707: /*E
2708: MatCUSPARSEFormatOperation - indicates the operation of `MATAIJCUSPARSE` (GPU)
2709: matrices whose operation should use a particular storage format.
2711: Values:
2712: + `MAT_CUSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()`
2713: . `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()`
2714: . `MAT_CUSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
2715: - `MAT_CUSPARSE_ALL` - sets the storage format for all `MATAIJCUSPARSE` (GPU) matrices
2717: Level: intermediate
2719: .seealso: [](ch_matrices), `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat`
2720: E*/
2721: typedef enum {
2722: MAT_CUSPARSE_MULT_DIAG,
2723: MAT_CUSPARSE_MULT_OFFDIAG,
2724: MAT_CUSPARSE_MULT,
2725: MAT_CUSPARSE_ALL
2726: } MatCUSPARSEFormatOperation;
2728: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2729: PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2730: PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat);
2731: PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool);
2732: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const PetscInt *[], const PetscInt *[]);
2733: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const PetscInt *[], const PetscInt *[]);
2734: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **);
2735: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **);
2736: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **);
2737: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **);
2738: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **);
2739: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **);
2741: PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
2742: PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
2743: PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **);
2744: PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **);
2745: PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **);
2746: PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **);
2747: PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **);
2748: PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **);
2749: PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *);
2750: PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *);
2751: PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat);
2752: PETSC_EXTERN PetscErrorCode MatDenseCUDASetPreallocation(Mat, PetscScalar *);
2754: PETSC_EXTERN PetscErrorCode MatCreateSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2755: #endif
2757: #if PetscDefined(HAVE_HIP)
2758: /*E
2759: MatHIPSPARSEStorageFormat - indicates the storage format for `MATAIJHIPSPARSE` (GPU)
2760: matrices.
2762: Values:
2763: + `MAT_HIPSPARSE_CSR` - Compressed Sparse Row
2764: . `MAT_HIPSPARSE_ELL` - Ellpack
2765: - `MAT_HIPSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format
2767: Level: intermediate
2769: .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEFormatOperation`
2770: E*/
2772: typedef enum {
2773: MAT_HIPSPARSE_CSR,
2774: MAT_HIPSPARSE_ELL,
2775: MAT_HIPSPARSE_HYB
2776: } MatHIPSPARSEStorageFormat;
2778: /* these will be strings associated with enumerated type defined above */
2779: PETSC_EXTERN const char *const MatHIPSPARSEStorageFormats[];
2781: /*E
2782: MatHIPSPARSEFormatOperation - indicates the operation of `MATAIJHIPSPARSE` (GPU)
2783: matrices whose operation should use a particular storage format.
2785: Values:
2786: + `MAT_HIPSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()`
2787: . `MAT_HIPSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()`
2788: . `MAT_HIPSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
2789: - `MAT_HIPSPARSE_ALL` - sets the storage format for all HIPSPARSE (GPU) matrices
2791: Level: intermediate
2793: .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEStorageFormat`
2794: E*/
2795: typedef enum {
2796: MAT_HIPSPARSE_MULT_DIAG,
2797: MAT_HIPSPARSE_MULT_OFFDIAG,
2798: MAT_HIPSPARSE_MULT,
2799: MAT_HIPSPARSE_ALL
2800: } MatHIPSPARSEFormatOperation;
2802: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2803: PETSC_EXTERN PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2804: PETSC_EXTERN PetscErrorCode MatHIPSPARSESetFormat(Mat, MatHIPSPARSEFormatOperation, MatHIPSPARSEStorageFormat);
2805: PETSC_EXTERN PetscErrorCode MatHIPSPARSESetUseCPUSolve(Mat, PetscBool);
2806: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetIJ(Mat, PetscBool, const PetscInt *[], const PetscInt *[]);
2807: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreIJ(Mat, PetscBool, const PetscInt *[], const PetscInt *[]);
2808: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayRead(Mat, const PetscScalar **);
2809: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayRead(Mat, const PetscScalar **);
2810: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayWrite(Mat, PetscScalar **);
2811: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayWrite(Mat, PetscScalar **);
2812: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArray(Mat, PetscScalar **);
2813: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArray(Mat, PetscScalar **);
2815: PETSC_EXTERN PetscErrorCode MatCreateDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
2816: PETSC_EXTERN PetscErrorCode MatCreateSeqDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
2817: PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayWrite(Mat, PetscScalar **);
2818: PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayRead(Mat, const PetscScalar **);
2819: PETSC_EXTERN PetscErrorCode MatDenseHIPGetArray(Mat, PetscScalar **);
2820: PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayWrite(Mat, PetscScalar **);
2821: PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayRead(Mat, const PetscScalar **);
2822: PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArray(Mat, PetscScalar **);
2823: PETSC_EXTERN PetscErrorCode MatDenseHIPPlaceArray(Mat, const PetscScalar *);
2824: PETSC_EXTERN PetscErrorCode MatDenseHIPReplaceArray(Mat, const PetscScalar *);
2825: PETSC_EXTERN PetscErrorCode MatDenseHIPResetArray(Mat);
2826: PETSC_EXTERN PetscErrorCode MatDenseHIPSetPreallocation(Mat, PetscScalar *);
2827: PETSC_EXTERN PetscErrorCode MatCreateSELLHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2828: #endif
2830: #if PetscDefined(HAVE_VIENNACL)
2831: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2832: PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2833: #endif
2835: #if PetscDefined(HAVE_KOKKOS)
2836: PETSC_EXTERN PetscErrorCode MatCreateAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2837: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2838: #endif
2840: #if PetscDefined(HAVE_FFTW)
2841: PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec);
2842: PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec);
2843: PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *);
2844: #endif
2846: #if PetscDefined(HAVE_SCALAPACK) && (PetscDefined(USE_REAL_SINGLE) || PetscDefined(USE_REAL_DOUBLE))
2847: PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2848: PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt);
2849: PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *);
2850: #endif
2852: PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *);
2853: PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *);
2854: PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]);
2855: PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]);
2856: PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***);
2857: PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *);
2858: PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType);
2859: PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]);
2860: PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat);
2862: PETSC_EXTERN PetscErrorCode MatFilter(Mat, PetscReal, PetscBool, PetscBool);
2863: PETSC_DEPRECATED_FUNCTION(3, 20, 0, "MatFilter()", ) static inline PetscErrorCode MatChop(Mat A, PetscReal tol)
2864: {
2865: return MatFilter(A, tol, PETSC_FALSE, PETSC_FALSE);
2866: }
2867: PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *);
2869: PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **);
2871: PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat);
2873: PETSC_EXTERN PetscErrorCode MatHeaderMerge(Mat, Mat *);
2874: PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *);
2876: PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *);
2878: PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, PetscReal, PetscInt, PetscInt[], Mat *);
2879: PETSC_EXTERN PetscErrorCode MatEliminateZeros(Mat, PetscBool);
2881: PETSC_EXTERN PetscErrorCode MatCreateDenseFromVecType(MPI_Comm, VecType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *);
2882: PETSC_EXTERN PetscErrorCode MatCreateDenseWithMemType(MPI_Comm, PetscMemType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *);
2884: PETSC_EXTERN PetscErrorCode MatSetHPL(Mat, int);
2885: #define PETSCBMHPL "hpl"
2887: PETSC_EXTERN PetscErrorCode MatDFischer(Mat, Vec, Vec, Vec, Vec, Vec, Vec, Vec, Vec);