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 PETSC_DEPRECATED_TYPEDEF(3, 26, 0, "MatSolverFn*", );
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: #define MAT_NULLSPACE_FILE_CLASSID 1211220
351: PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID;
352: PETSC_EXTERN PetscClassId MATMFFD_CLASSID;
354: /*E
355: MatReuse - Indicates if matrices obtained from a previous call to `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatConvert()` or several other functions
356: are to be reused to store the new matrix values.
358: Values:
359: + `MAT_INITIAL_MATRIX` - create a new matrix
360: . `MAT_REUSE_MATRIX` - reuse the matrix created with a previous call that used `MAT_INITIAL_MATRIX`
361: . `MAT_INPLACE_MATRIX` - replace the first input matrix with the new matrix (not applicable to all functions)
362: - `MAT_IGNORE_MATRIX` - do not create a new matrix or reuse a given matrix, just ignore that matrix argument (not applicable to all functions)
364: Level: beginner
366: .seealso: [](ch_matrices), `Mat`, `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()`
367: E*/
368: typedef enum {
369: MAT_INITIAL_MATRIX,
370: MAT_REUSE_MATRIX,
371: MAT_IGNORE_MATRIX,
372: MAT_INPLACE_MATRIX
373: } MatReuse;
375: /*E
376: MatCreateSubMatrixOption - Indicates if matrices obtained from a call to `MatCreateSubMatrices()`
377: include the matrix values. Currently it is only used by `MatGetSeqNonzeroStructure()`.
379: Values:
380: + `MAT_DO_NOT_GET_VALUES` - do not copy the matrix values
381: - `MAT_GET_VALUES` - copy the matrix values
383: Level: developer
385: Developer Note:
386: Why is not just a boolean used for this information?
388: .seealso: [](ch_matrices), `Mat`, `MatDuplicateOption`, `PetscCopyMode`, `MatGetSeqNonzeroStructure()`
389: E*/
390: typedef enum {
391: MAT_DO_NOT_GET_VALUES,
392: MAT_GET_VALUES
393: } MatCreateSubMatrixOption;
395: PETSC_EXTERN PetscErrorCode MatInitializePackage(void);
396: PETSC_EXTERN PetscErrorCode MatFinalizePackage(void);
398: PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *);
399: PETSC_EXTERN PetscErrorCode MatCreateFromOptions(MPI_Comm, const char *, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
400: PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt);
401: PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType);
402: PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *);
403: PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType);
404: PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat);
405: PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]);
406: PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat));
407: PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]);
408: PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]);
409: PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]);
410: PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]);
411: PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]);
412: PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]);
413: PETSC_EXTERN PetscErrorCode MatGetState(Mat, MatState *);
414: PETSC_EXTERN PetscErrorCode MatStateCompare(MatState, MatState, PetscBool *);
415: PETSC_EXTERN PetscErrorCode MatStateCompareUpdate(Mat, MatState *, PetscBool *);
416: /*MC
417: MatStateInvalidate - Invalidates a matrix state snapshot
419: Synopsis:
420: #include <petscmat.h>
421: PetscErrorCode MatStateInvalidate(MatState state)
423: Not Collective
425: Input/Output Parameter:
426: . state - the matrix state
428: Level: developer
430: .seealso: [](ch_matrices), `Mat`, `MatState`, `MatGetState()`, `MatStateCompare()`, `MatStateCompareUpdate()`
431: M*/
432: #define MatStateInvalidate(s) ((s).id = 0, (s).state = -1, (s).nonzerostate = -1, PETSC_SUCCESS)
433: PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool);
435: PETSC_EXTERN PetscFunctionList MatList;
436: PETSC_EXTERN PetscFunctionList MatColoringList;
437: PETSC_EXTERN PetscFunctionList MatPartitioningList;
438: PETSC_EXTERN PetscFunctionList MatMeshToCellGraphList;
440: /*E
441: MatStructure - Indicates if two matrices have the same nonzero structure
443: Values:
444: + `SAME_NONZERO_PATTERN` - the two matrices have identical nonzero patterns
445: . `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns
446: . `SUBSET_NONZERO_PATTERN` - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix
447: - `UNKNOWN_NONZERO_PATTERN` - there is no known relationship between the nonzero patterns. In this case the implementations
448: may try to detect a relationship to optimize the operation
450: Level: beginner
452: Note:
453: Certain matrix operations (such as `MatAXPY()`) can run much faster if the sparsity pattern of the matrices are the same. But actually determining if
454: 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
455: to certain PETSc routines.
457: .seealso: [](ch_matrices), `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()`
458: E*/
459: typedef enum {
460: DIFFERENT_NONZERO_PATTERN,
461: SUBSET_NONZERO_PATTERN,
462: SAME_NONZERO_PATTERN,
463: UNKNOWN_NONZERO_PATTERN
464: } MatStructure;
465: PETSC_EXTERN const char *const MatStructures[];
467: #if PetscDefined(HAVE_MKL_SPARSE)
468: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
469: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
470: PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
471: PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
472: #endif
474: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
475: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
477: PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
478: PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
479: PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]);
480: PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
481: PETSC_EXTERN PetscErrorCode MatSeqSELLGetFillRatio(Mat, PetscReal *);
482: PETSC_EXTERN PetscErrorCode MatSeqSELLGetMaxSliceWidth(Mat, PetscInt *);
483: PETSC_EXTERN PetscErrorCode MatSeqSELLGetAvgSliceWidth(Mat, PetscReal *);
484: PETSC_EXTERN PetscErrorCode MatSeqSELLSetSliceHeight(Mat, PetscInt);
485: PETSC_EXTERN PetscErrorCode MatSeqSELLGetVarSliceSize(Mat, PetscReal *);
487: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
488: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
489: PETSC_EXTERN PetscErrorCode MatMPISELLGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
490: PETSC_EXTERN PetscErrorCode MatMPISELLGetSeqSELL(Mat, Mat *, Mat *, const PetscInt *[]);
492: PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
493: PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
494: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
495: PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
496: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
497: PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
498: PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]);
499: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *);
500: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, PetscInt, PetscInt, Mat, Mat, PetscInt *, Mat *);
502: PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
503: PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
504: PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
506: PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]);
507: PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]);
508: PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode);
510: PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *);
511: PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
513: PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
514: PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
515: PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
516: PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
517: PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]);
519: PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscCtx, Mat *);
520: PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *);
521: PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *);
522: PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *);
523: PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *);
524: PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *);
525: PETSC_EXTERN PetscErrorCode MatLRCSetMats(Mat, Mat, Mat, Vec, Mat);
526: PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *);
527: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
528: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
530: PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *);
531: PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter);
532: PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *);
533: PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *);
534: PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat);
535: PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat);
536: /*E
537: MatCompositeMergeType - Selects the order in which the matrices held by a `MATCOMPOSITE` are combined when `MatCompositeMerge()` is called
539: Values:
540: + `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)
541: - `MAT_COMPOSITE_MERGE_LEFT` - merge into a single matrix starting from the leftmost matrix
543: Level: advanced
545: .seealso: [](ch_matrices), `Mat`, `MATCOMPOSITE`, `MatCompositeMerge()`, `MatCompositeSetMergeType()`, `MatCompositeType`
546: E*/
547: typedef enum {
548: MAT_COMPOSITE_MERGE_RIGHT,
549: MAT_COMPOSITE_MERGE_LEFT
550: } MatCompositeMergeType;
551: PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType);
552: PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *);
553: /*E
554: MatCompositeType - indicates what type of `MATCOMPOSITE` is used
556: Values:
557: + `MAT_COMPOSITE_ADDITIVE` - sum of matrices (default)
558: - `MAT_COMPOSITE_MULTIPLICATIVE` - product of matrices
560: Level: beginner
562: .seealso: [](ch_matrices), `MATCOMPOSITE`, `MatCompositeSetType()`, `MatCompositeGetType()`
563: E*/
564: typedef enum {
565: MAT_COMPOSITE_ADDITIVE,
566: MAT_COMPOSITE_MULTIPLICATIVE
567: } MatCompositeType;
568: PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType);
569: PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *);
570: PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure);
571: PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *);
572: PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *);
573: PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *);
574: PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *);
576: PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *);
577: PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *);
579: PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *);
580: PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *);
581: PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *);
582: PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *);
583: PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *);
584: PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *);
585: PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *);
586: PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS);
587: PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *);
588: PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *);
589: PETSC_EXTERN PetscErrorCode MatCreateDiagonal(Vec, Mat *);
590: PETSC_EXTERN PetscErrorCode MatDiagonalSetDiagonal(Mat, Vec);
591: PETSC_EXTERN PetscErrorCode MatDiagonalGetDiagonal(Mat, Vec *);
592: PETSC_EXTERN PetscErrorCode MatDiagonalRestoreDiagonal(Mat, Vec *);
593: PETSC_EXTERN PetscErrorCode MatDiagonalGetInverseDiagonal(Mat, Vec *);
594: PETSC_EXTERN PetscErrorCode MatDiagonalRestoreInverseDiagonal(Mat, Vec *);
595: PETSC_EXTERN PetscErrorCode MatConstantDiagonalGetConstant(Mat, PetscScalar *);
596: PETSC_EXTERN PetscErrorCode MatGetCurrentMemType(Mat, PetscMemType *);
598: #if PetscDefined(HAVE_HYPRE)
599: PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
600: #endif
602: PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]);
603: PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]);
604: PETSC_EXTERN PetscErrorCode MatPythonCreate(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const char[], Mat *);
606: PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat);
607: PETSC_EXTERN PetscErrorCode MatResetHash(Mat);
608: PETSC_EXTERN PetscErrorCode MatSetUp(Mat);
609: PETSC_EXTERN PetscErrorCode MatDestroy(Mat *);
610: PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *);
612: PETSC_EXTERN PetscErrorCode MatConjugate(Mat);
613: PETSC_EXTERN PetscErrorCode MatRealPart(Mat);
614: PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat);
615: PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *);
616: PETSC_EXTERN PetscErrorCode MatGetMultPetscSF(Mat, PetscSF *);
617: PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *);
618: PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **);
619: PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *);
620: PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat);
621: PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *);
622: PETSC_EXTERN PetscErrorCode MatComputeVariableBlockEnvelope(Mat);
624: PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
625: PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode);
626: PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
627: PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]);
628: PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]);
629: PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]);
630: PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom);
632: /*S
633: MatStencil - Data structure (C struct) for storing information about rows and
634: columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()`
636: Level: beginner
638: Notes:
639: 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).
640: 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.
642: For stencil access to vectors see `DMDAVecGetArray()`
644: For staggered grids, see `DMStagStencil`
646: .seealso: [](ch_matrices), `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`,
647: `DMStagStencil`
648: S*/
649: typedef struct {
650: PetscInt k, j, i, c;
651: } MatStencil;
653: PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
654: PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
655: PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt);
657: /*E
658: MatAssemblyType - Indicates if the process of setting values into the matrix is complete, and the matrix is ready for use
660: Values:
661: + `MAT_FLUSH_ASSEMBLY` - you will continue to put values into the matrix
662: - `MAT_FINAL_ASSEMBLY` - you wish to use the matrix with the values currently inserted
664: Level: beginner
666: .seealso: [](ch_matrices), `Mat`, `MatSetValues`, `MatAssemblyBegin()`, `MatAssemblyEnd()`
667: E*/
668: typedef enum {
669: MAT_FLUSH_ASSEMBLY = 1,
670: MAT_FINAL_ASSEMBLY = 0
671: } MatAssemblyType;
673: PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType);
674: PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType);
675: PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *);
677: /*E
678: MatOption - Options that may be set for a matrix that indicate properties of the matrix or affect its behavior or storage
680: Level: beginner
682: Note:
683: See `MatSetOption()` for the use of the options
685: Developer Note:
686: Entries that are negative need not be called collectively by all processes.
688: .seealso: [](ch_matrices), `Mat`, `MatSetOption()`, `VecOption`
689: E*/
690: typedef enum {
691: MAT_OPTION_MIN = -3,
692: MAT_UNUSED_NONZERO_LOCATION_ERR = -2,
693: MAT_ROW_ORIENTED = -1,
694: MAT_SYMMETRIC = 1,
695: MAT_STRUCTURALLY_SYMMETRIC = 2,
696: MAT_FORCE_DIAGONAL_ENTRIES = 3,
697: MAT_IGNORE_OFF_PROC_ENTRIES = 4,
698: MAT_USE_HASH_TABLE = 5,
699: MAT_KEEP_NONZERO_PATTERN = 6,
700: MAT_IGNORE_ZERO_ENTRIES = 7,
701: MAT_USE_INODES = 8,
702: MAT_HERMITIAN = 9,
703: MAT_SYMMETRY_ETERNAL = 10,
704: MAT_NEW_NONZERO_LOCATION_ERR = 11,
705: MAT_IGNORE_LOWER_TRIANGULAR = 12,
706: MAT_ERROR_LOWER_TRIANGULAR = 13,
707: MAT_GETROW_UPPERTRIANGULAR = 14,
708: MAT_SPD = 15,
709: MAT_NO_OFF_PROC_ZERO_ROWS = 16,
710: MAT_NO_OFF_PROC_ENTRIES = 17,
711: MAT_NEW_NONZERO_LOCATIONS = 18,
712: MAT_NEW_NONZERO_ALLOCATION_ERR = 19,
713: MAT_SUBSET_OFF_PROC_ENTRIES = 20,
714: MAT_SUBMAT_SINGLEIS = 21,
715: MAT_STRUCTURE_ONLY = 22,
716: MAT_SORTED_FULL = 23,
717: MAT_FORM_EXPLICIT_TRANSPOSE = 24,
718: MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25,
719: MAT_SPD_ETERNAL = 26,
720: MAT_OPTION_MAX = 27
721: } MatOption;
723: PETSC_EXTERN const char *const *MatOptions;
724: PETSC_EXTERN PetscErrorCode MatSetOption(Mat, MatOption, PetscBool);
725: PETSC_EXTERN PetscErrorCode MatGetOption(Mat, MatOption, PetscBool *);
726: PETSC_EXTERN PetscErrorCode MatPropagateSymmetryOptions(Mat, Mat);
727: PETSC_EXTERN PetscErrorCode MatGetType(Mat, MatType *);
729: PETSC_EXTERN PetscErrorCode MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
730: PETSC_EXTERN PetscErrorCode MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
731: PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
732: PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat);
733: PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat);
734: PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat, Vec, PetscInt);
735: PETSC_EXTERN PetscErrorCode MatSeqAIJGetArray(Mat, PetscScalar *[]);
736: PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]);
737: PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]);
738: PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArray(Mat, PetscScalar *[]);
739: PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]);
740: PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]);
741: PETSC_EXTERN PetscErrorCode MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *);
742: PETSC_EXTERN PetscErrorCode MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
743: PETSC_EXTERN PetscErrorCode MatSeqAIJSetType(Mat, MatType);
744: PETSC_EXTERN PetscErrorCode MatSeqAIJKron(Mat, Mat, MatReuse, Mat *);
745: PETSC_EXTERN PetscErrorCode MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *));
746: PETSC_EXTERN PetscFunctionList MatSeqAIJList;
747: PETSC_EXTERN PetscErrorCode MatSeqBAIJGetArray(Mat, PetscScalar *[]);
748: PETSC_EXTERN PetscErrorCode MatSeqBAIJRestoreArray(Mat, PetscScalar *[]);
749: PETSC_EXTERN PetscErrorCode MatSeqSBAIJGetArray(Mat, PetscScalar *[]);
750: PETSC_EXTERN PetscErrorCode MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]);
751: PETSC_EXTERN PetscErrorCode MatDenseGetArray(Mat, PetscScalar *[]);
752: PETSC_EXTERN PetscErrorCode MatDenseRestoreArray(Mat, PetscScalar *[]);
753: PETSC_EXTERN PetscErrorCode MatDensePlaceArray(Mat, const PetscScalar[]);
754: PETSC_EXTERN PetscErrorCode MatDenseReplaceArray(Mat, const PetscScalar[]);
755: PETSC_EXTERN PetscErrorCode MatDenseReplaceArrayWithMemType(Mat, PetscMemType, const PetscScalar[]);
756: PETSC_EXTERN PetscErrorCode MatDenseResetArray(Mat);
757: PETSC_EXTERN PetscErrorCode MatDenseGetArrayRead(Mat, const PetscScalar *[]);
758: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayRead(Mat, const PetscScalar *[]);
759: PETSC_EXTERN PetscErrorCode MatDenseGetArrayWrite(Mat, PetscScalar *[]);
760: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWrite(Mat, PetscScalar *[]);
761: PETSC_EXTERN PetscErrorCode MatDenseGetArrayAndMemType(Mat, PetscScalar *[], PetscMemType *);
762: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayAndMemType(Mat, PetscScalar *[]);
763: PETSC_EXTERN PetscErrorCode MatDenseGetArrayReadAndMemType(Mat, const PetscScalar *[], PetscMemType *);
764: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayReadAndMemType(Mat, const PetscScalar *[]);
765: PETSC_EXTERN PetscErrorCode MatDenseGetArrayWriteAndMemType(Mat, PetscScalar *[], PetscMemType *);
766: PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWriteAndMemType(Mat, PetscScalar *[]);
767: PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat, PetscInt *);
768: PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat, PetscInt);
769: PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat, PetscInt *, PetscInt *);
770: PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat, PetscInt, PetscInt);
771: PETSC_EXTERN PetscErrorCode MatSetBlockSizesFromMats(Mat, Mat, Mat);
772: PETSC_EXTERN PetscErrorCode MatSetVariableBlockSizes(Mat, PetscInt, const PetscInt[]);
773: PETSC_EXTERN PetscErrorCode MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt *[]);
774: PETSC_EXTERN PetscErrorCode MatSelectVariableBlockSizes(Mat, Mat, IS);
776: PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]);
777: PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]);
778: PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *);
779: PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *);
780: PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *);
781: PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *);
782: PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *);
783: PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *);
784: PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
785: PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *);
786: PETSC_EXTERN PetscErrorCode MatDenseUpdateColumnLayout(Mat, PetscLayout);
788: PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec);
789: PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec);
790: PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec);
791: PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec);
792: PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec);
793: PETSC_EXTERN PetscErrorCode MatADot(Mat, Vec, Vec, PetscScalar *);
794: PETSC_EXTERN PetscErrorCode MatANorm(Mat, Vec, PetscReal *);
795: PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *);
796: PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *);
797: PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec);
798: PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec);
799: PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat);
800: PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat);
801: PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat);
802: PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec);
804: /*E
805: MatDuplicateOption - Indicates if a duplicated sparse matrix should have
806: its numerical values copied over or just its nonzero structure.
808: Values:
809: + `MAT_DO_NOT_COPY_VALUES` - Create a matrix using the same nonzero pattern as the original matrix,
810: with zeros for the numerical values
811: . `MAT_COPY_VALUES` - Create a matrix with the same nonzero pattern as the original matrix
812: and with the same numerical values.
813: - `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix
814: and does not copy it, using zeros for the numerical values. The parent and
815: child matrices will share their index (i and j) arrays, and you cannot
816: insert new nonzero entries into either matrix
818: Level: beginner
820: Note:
821: Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in
822: this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified.
824: .seealso: [](ch_matrices), `Mat`, `MatDuplicate()`
825: E*/
826: typedef enum {
827: MAT_DO_NOT_COPY_VALUES,
828: MAT_COPY_VALUES,
829: MAT_SHARE_NONZERO_PATTERN
830: } MatDuplicateOption;
832: PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *);
833: PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *);
835: PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure);
836: PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer);
837: PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *);
838: PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *);
839: PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *);
840: PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *);
841: PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *);
842: PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *);
843: PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *);
844: PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer);
846: PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
847: PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
848: PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
849: PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
851: /*S
852: MatInfo - Context of matrix information, used with `MatGetInfo()`
854: Level: intermediate
856: Fortran Note:
857: `MatInfo` is a derived type, use e.g. `matinfo%nz_allocated` to access its components.
859: .seealso: [](ch_matrices), `Mat`, `MatGetInfo()`, `MatInfoType`
860: S*/
861: typedef struct {
862: PetscLogDouble block_size; /* block size */
863: PetscLogDouble nz_allocated, nz_used, nz_unneeded; /* number of nonzeros */
864: PetscLogDouble memory; /* memory allocated */
865: PetscLogDouble assemblies; /* number of matrix assemblies called */
866: PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */
867: PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */
868: PetscLogDouble factor_mallocs; /* number of mallocs during factorization */
869: } MatInfo;
871: /*E
872: MatInfoType - Indicates if you want information about the local part of the matrix,
873: the entire parallel matrix or the maximum over all the local parts.
875: Values:
876: + `MAT_LOCAL` - values for each MPI process part of the matrix
877: . `MAT_GLOBAL_MAX` - maximum of each value over all MPI processes
878: - `MAT_GLOBAL_SUM` - sum of each value over all MPI processes
880: Level: beginner
882: .seealso: [](ch_matrices), `MatGetInfo()`, `MatInfo`
883: E*/
884: typedef enum {
885: MAT_LOCAL = 1,
886: MAT_GLOBAL_MAX = 2,
887: MAT_GLOBAL_SUM = 3
888: } MatInfoType;
889: PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *);
890: PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec);
891: PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]);
892: PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]);
893: PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]);
894: PETSC_EXTERN PetscErrorCode MatGetRowSumAbs(Mat, Vec);
895: PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]);
896: PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec);
897: PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *);
898: PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *);
899: PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat);
900: PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *);
901: PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *);
902: PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec);
903: PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode);
905: PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *);
906: PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *);
907: PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *);
908: PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
909: PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
910: PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
911: PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
912: PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
913: PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
914: PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
915: PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
916: PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
917: PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *);
919: PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *);
920: PETSC_EXTERN PetscErrorCode MatNormApproximate(Mat, NormType, PetscInt, PetscReal *);
921: PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *);
922: PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *);
923: PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *);
924: PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *);
925: PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *);
926: PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *);
927: PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *);
928: PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *);
929: PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat);
930: PETSC_EXTERN PetscErrorCode MatFlag(Mat, PetscInt);
931: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "MatFlag()", ) static inline PetscErrorCode MatSetInf(Mat A)
932: {
933: return MatFlag(A, 1);
934: }
935: PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
936: PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec);
937: PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
938: PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
939: PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
940: PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec);
942: PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *);
943: PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *);
944: PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *);
945: PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **);
946: PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *);
947: PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **);
948: PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *);
950: PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
951: 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[])
952: {
953: return MatCreateSubMatrices(mat, n, irow, icol, scall, submat);
954: }
955: PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
956: 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[])
957: {
958: return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat);
959: }
960: PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]);
961: PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]);
962: PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *);
963: PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatrix()", ) static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat)
964: {
965: return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat);
966: }
967: PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *);
968: PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *);
969: PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *);
970: PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *);
972: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *);
973: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *);
974: PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat);
975: PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *);
976: PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *);
977: PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
978: PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *);
979: PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *);
980: PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *);
981: PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]);
983: PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt);
984: PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat, PetscInt, IS[], PetscInt);
985: PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool);
987: PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
989: PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
990: PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
992: PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *);
993: PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *);
995: PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
996: PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *);
998: PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure);
999: PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure);
1001: PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar);
1002: PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar);
1004: PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping);
1005: PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
1006: PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *);
1007: PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout);
1008: PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
1009: PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
1010: PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
1011: PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
1012: PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
1013: PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
1014: PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
1016: PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt);
1017: PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
1019: PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec);
1020: PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec);
1021: PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec);
1022: PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *);
1023: PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *);
1024: PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *);
1025: PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *);
1026: PETSC_DEPRECATED_FUNCTION(3, 6, 0, "MatCreateVecs()", ) static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y)
1027: {
1028: return MatCreateVecs(mat, x, y);
1029: }
1030: PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *);
1031: PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *);
1032: PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *);
1033: PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *);
1034: PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *);
1036: PETSC_EXTERN PetscErrorCode MatCopyHashToXAIJ(Mat A, Mat B);
1037: /*@
1038: MatSetValue - Set a single entry into a matrix.
1040: Not Collective
1042: Input Parameters:
1043: + mat - the matrix
1044: . i - the row location of the entry
1045: . j - the column location of the entry
1046: . va - the value to insert
1047: - mode - either `INSERT_VALUES` or `ADD_VALUES`
1049: Level: beginner
1051: Notes:
1052: This value may be cached, so `MatAssemblyBegin()` and `MatAssemblyEnd()`
1053: MUST be called after all calls to `MatSetValue()` have been completed.
1055: For efficiency one should use `MatSetValues()` and set several values simultaneously.
1057: .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `InsertMode`, `MatGetValue()`, `MatSetValues()`,
1058: `MatSetValueLocal()`, `MatSetValuesLocal()`
1059: @*/
1060: static inline PetscErrorCode MatSetValue(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
1061: {
1062: return MatSetValues(mat, 1, &i, 1, &j, &va, mode);
1063: }
1065: /*@
1066: MatGetValue - Gets a single value from a matrix
1068: Not Collective; can only return a value owned by the given process
1070: Input Parameters:
1071: + mat - the matrix
1072: . row - the row location of the entry
1073: - col - the column location of the entry
1075: Output Parameter:
1076: . va - the value
1078: Level: advanced
1080: Notes:
1081: The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd()` before this call
1083: For efficiency one should use `MatGetValues()` and get several values simultaneously.
1085: See notes for `MatGetValues()`.
1087: .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValue()`, `MatGetValuesLocal()`, `MatGetValues()`
1088: @*/
1089: static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va)
1090: {
1091: return MatGetValues(mat, 1, &row, 1, &col, va);
1092: }
1094: /*@
1095: MatSetValueLocal - Inserts or adds a single value into a matrix, using a local numbering of the nodes.
1097: Not Collective
1099: Input Parameters:
1100: + mat - the matrix
1101: . i - the row location of the entry
1102: . j - the column location of the entry
1103: . va - the value to insert
1104: - mode - either `INSERT_VALUES` or `ADD_VALUES`
1106: Level: intermediate
1108: Notes:
1109: For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously.
1111: See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used.
1113: .seealso: [](ch_matrices), `MatSetValue()`, `MatSetValuesLocal()`
1114: @*/
1115: static inline PetscErrorCode MatSetValueLocal(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
1116: {
1117: return MatSetValuesLocal(mat, 1, &i, 1, &j, &va, mode);
1118: }
1120: /*MC
1121: MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per
1122: row in a matrix providing the data that one can use to correctly preallocate the matrix.
1124: Synopsis:
1125: #include <petscmat.h>
1126: PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
1128: Collective
1130: Input Parameters:
1131: + comm - the communicator that will share the eventually allocated matrix
1132: . nrows - the number of LOCAL rows in the matrix
1133: - ncols - the number of LOCAL columns in the matrix
1135: Output Parameters:
1136: + dnz - the array that will be passed to the matrix preallocation routines
1137: - onz - the other array passed to the matrix preallocation routines
1139: Level: deprecated (since v3.19)
1141: Notes:
1142: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1143: the use of this routine
1145: This is a macro that handles its own error checking, it does not return an error code.
1147: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1149: Developer Note:
1150: This is a MACRO, not a function, because it has a leading { that is closed by `PetscPreallocateFinalize()`.
1152: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1153: `MatPreallocateSymmetricSetLocalBlock()`
1154: M*/
1155: #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \
1156: do { \
1157: PetscInt __nrows = (nrows), __ncols = (ncols), __rstart, __end = 0; \
1158: PetscInt PETSC_UNUSED __start; \
1159: PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \
1160: PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \
1161: __start = __end - __ncols; \
1162: (void)__start; \
1163: PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \
1164: __rstart -= __nrows
1166: #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateBegin()", ) MatPreallocateBegin(__VA_ARGS__)
1168: /*MC
1169: MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1170: inserted using a local number of the rows and columns
1172: Synopsis:
1173: #include <petscmat.h>
1174: PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map, PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1176: Not Collective
1178: Input Parameters:
1179: + map - the row mapping from local numbering to global numbering
1180: . nrows - the number of rows indicated
1181: . rows - the indices of the rows
1182: . cmap - the column mapping from local to global numbering
1183: . ncols - the number of columns in the matrix
1184: . cols - the columns indicated
1185: . dnz - the array that will be passed to the matrix preallocation routines
1186: - onz - the other array passed to the matrix preallocation routines
1188: Level: deprecated (since v3.19)
1190: Notes:
1191: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1192: the use of this routine
1194: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1196: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`,
1197: `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()`
1198: M*/
1199: #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
1200: 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));)
1202: /*MC
1203: MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1204: inserted using a local number of the rows and columns. This version removes any duplicate columns in cols
1206: Synopsis:
1207: #include <petscmat.h>
1208: PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map, PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1210: Not Collective
1212: Input Parameters:
1213: + map - the row mapping from local numbering to global numbering
1214: . nrows - the number of rows indicated
1215: . rows - the indices of the rows (these values are mapped to the global values)
1216: . cmap - the column mapping from local to global numbering
1217: . ncols - the number of columns in the matrix (this value will be changed if duplicate columns are found)
1218: . cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed)
1219: . dnz - the array that will be passed to the matrix preallocation routines
1220: - onz - the other array passed to the matrix preallocation routines
1222: Level: deprecated (since v3.19)
1224: Notes:
1225: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1226: the use of this routine
1228: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1230: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`,
1231: `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1232: M*/
1233: #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
1234: 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));)
1236: /*MC
1237: MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1238: inserted using a local number of the rows and columns
1240: Synopsis:
1241: #include <petscmat.h>
1242: PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map, PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1244: Not Collective
1246: Input Parameters:
1247: + map - the row mapping from local numbering to global numbering
1248: . nrows - the number of rows indicated
1249: . rows - the indices of the rows
1250: . cmap - the column mapping from local to global numbering
1251: . ncols - the number of columns in the matrix
1252: . cols - the columns indicated
1253: . dnz - the array that will be passed to the matrix preallocation routines
1254: - onz - the other array passed to the matrix preallocation routines
1256: Level: deprecated (since v3.19)
1258: Notes:
1259: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1260: the use of this routine
1262: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1264: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`,
1265: `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`
1266: M*/
1267: #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
1268: 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));)
1270: /*MC
1271: MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1272: inserted using a local number of the rows and columns
1274: Synopsis:
1275: #include <petscmat.h>
1276: PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map, PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1278: Not Collective
1280: Input Parameters:
1281: + map - the mapping between local numbering and global numbering
1282: . nrows - the number of rows indicated
1283: . rows - the indices of the rows
1284: . ncols - the number of columns in the matrix
1285: . cols - the columns indicated
1286: . dnz - the array that will be passed to the matrix preallocation routines
1287: - onz - the other array passed to the matrix preallocation routines
1289: Level: deprecated (since v3.19)
1291: Notes:
1292: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1293: the use of this routine
1295: Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1297: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`,
1298: `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1299: M*/
1300: #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \
1301: 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));)
1303: /*MC
1304: MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1305: inserted using a local number of the rows and columns
1307: Synopsis:
1308: #include <petscmat.h>
1309: PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1311: Not Collective
1313: Input Parameters:
1314: + row - the row
1315: . ncols - the number of columns in the matrix
1316: - cols - the columns indicated
1318: Output Parameters:
1319: + dnz - the array that will be passed to the matrix preallocation routines
1320: - onz - the other array passed to the matrix preallocation routines
1322: Level: deprecated (since v3.19)
1324: Notes:
1325: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1326: the use of this routine
1328: Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1330: This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin().
1332: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`,
1333: `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1334: M*/
1335: #define MatPreallocateSet(row, nc, cols, dnz, onz) \
1336: 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) { \
1337: if ((cols)[__i] < __start || (cols)[__i] >= __end) (onz)[(row) - __rstart]++; \
1338: else if ((dnz)[(row) - __rstart] < __ncols) (dnz)[(row) - __rstart]++; \
1339: })
1341: /*MC
1342: MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1343: inserted using a local number of the rows and columns
1345: Synopsis:
1346: #include <petscmat.h>
1347: PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1349: Not Collective
1351: Input Parameters:
1352: + nrows - the number of rows indicated
1353: . rows - the indices of the rows
1354: . ncols - the number of columns in the matrix
1355: . cols - the columns indicated
1356: . dnz - the array that will be passed to the matrix preallocation routines
1357: - onz - the other array passed to the matrix preallocation routines
1359: Level: deprecated (since v3.19)
1361: Notes:
1362: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1363: the use of this routine
1365: Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1367: This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin().
1369: .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`,
1370: `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1371: M*/
1372: #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \
1373: PetscMacroReturnStandard(for (PetscInt __i = 0; __i < (nc); __i++) { \
1374: if ((cols)[__i] >= __end) (onz)[(row) - __rstart]++; \
1375: else if ((cols)[__i] >= (row) && (dnz)[(row) - __rstart] < __ncols) (dnz)[(row) - __rstart]++; \
1376: })
1378: /*MC
1379: MatPreallocateLocation - An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists
1381: Synopsis:
1382: #include <petscmat.h>
1383: PetscErrorCode MatPreallocateLocations(Mat A, PetscInt row, PetscInt ncols, PetscInt *cols, PetscInt *dnz, PetscInt *onz)
1385: Not Collective
1387: Input Parameters:
1388: + A - matrix
1389: . row - row where values exist (must be local to this process)
1390: . ncols - number of columns
1391: . cols - columns with nonzeros
1392: . dnz - the array that will be passed to the matrix preallocation routines
1393: - onz - the other array passed to the matrix preallocation routines
1395: Level: deprecated (since v3.19)
1397: Notes:
1398: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1399: the use of this routine
1401: Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1403: Developer Note:
1404: This is a MACRO, not a function, because it uses a bunch of variables private to the MatPreallocation.... routines.
1406: .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1407: `MatPreallocateSymmetricSetLocalBlock()`
1408: M*/
1409: #define MatPreallocateLocation(A, row, ncols, cols, dnz, onz) ((A) ? MatSetValues(A, 1, &(row), ncols, cols, NULL, INSERT_VALUES) : MatPreallocateSet(row, ncols, cols, dnz, onz))
1411: /*MC
1412: MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per
1413: row in a matrix providing the data that one can use to correctly preallocate the matrix.
1415: Synopsis:
1416: #include <petscmat.h>
1417: PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz)
1419: Collective
1421: Input Parameters:
1422: + dnz - the array that was be passed to the matrix preallocation routines
1423: - onz - the other array passed to the matrix preallocation routines
1425: Level: deprecated (since v3.19)
1427: Notes:
1428: This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
1429: the use of this routine
1431: Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1433: Developer Note:
1434: This is a MACRO, not a function, because it closes the { started in MatPreallocateBegin().
1436: .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1437: `MatPreallocateSymmetricSetLocalBlock()`
1438: M*/
1439: #define MatPreallocateEnd(dnz, onz) \
1440: PetscCall(PetscFree2(dnz, onz)); \
1441: } \
1442: while (0)
1444: #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateEnd()", ) MatPreallocateEnd(__VA_ARGS__)
1446: /* Routines unique to particular data structures */
1447: PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, PetscCtxRt);
1449: PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *);
1450: PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *);
1452: PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]);
1453: PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]);
1454: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1455: PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1456: PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1457: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscCount, PetscBool);
1459: #define MAT_SKIP_ALLOCATION -4
1461: PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1462: PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1463: PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]);
1464: PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt);
1466: PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1467: PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1468: PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1469: PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1470: PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1471: PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1472: PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1473: PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]);
1474: PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *);
1475: PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *);
1476: PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]);
1477: PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]);
1478: PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
1479: PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
1480: PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *);
1482: PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *);
1483: PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt);
1484: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatDenseSetLDA()", ) static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda)
1485: {
1486: return MatDenseSetLDA(A, lda);
1487: }
1488: PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *);
1490: PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1492: PETSC_EXTERN PetscErrorCode MatStoreValues(Mat);
1493: PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat);
1495: PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *);
1496: PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *);
1497: /*
1498: These routines are not usually accessed directly, rather solving is
1499: done through the KSP and PC interfaces.
1500: */
1502: /*J
1503: MatOrderingType - String with the name of a PETSc matrix ordering. These orderings are most commonly used
1504: to reduce fill in sparse factorizations.
1506: Level: beginner
1508: Notes:
1509: If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and instead the external factorization solver package called utilizes one
1510: of its own.
1512: There is no `MatOrdering` object, the ordering is obtained directly from the matrix with `MatGetOrdering()`
1514: Developer Note:
1515: This API should be converted to an API similar to those for `MatColoring` and `MatPartitioning`
1517: .seealso: [](ch_matrices), [](sec_graph), `MatGetFactor()`, `MatGetOrdering()`, `MatColoringType`, `MatPartitioningType`, `MatCoarsenType`, `PCFactorSetOrderingType()`
1518: J*/
1519: typedef const char *MatOrderingType;
1520: #define MATORDERINGNATURAL "natural"
1521: #define MATORDERINGND "nd"
1522: #define MATORDERING1WD "1wd"
1523: #define MATORDERINGRCM "rcm"
1524: #define MATORDERINGQMD "qmd"
1525: #define MATORDERINGROWLENGTH "rowlength"
1526: #define MATORDERINGWBM "wbm"
1527: #define MATORDERINGSPECTRAL "spectral"
1528: #define MATORDERINGAMD "amd" /* only works if UMFPACK is installed with PETSc */
1529: #define MATORDERINGMETISND "metisnd" /* only works if METIS is installed with PETSc */
1530: #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 */
1531: #define MATORDERINGEXTERNAL "external" /* uses an ordering type internal to the factorization package */
1533: PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat, MatOrderingType, IS *, IS *);
1534: PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFunctionList *);
1535: PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *));
1536: PETSC_EXTERN PetscFunctionList MatOrderingList;
1538: #include "petscmatcoarsen.h"
1540: PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS);
1541: PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *);
1543: PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *);
1545: /*S
1546: MatFactorShiftType - Type of numeric shift used for factorizations
1548: Values:
1549: + `MAT_SHIFT_NONE` - do not shift the matrix diagonal entries
1550: . `MAT_SHIFT_NONZERO` - shift the entries to be non-zero
1551: . `MAT_SHIFT_POSITIVE_DEFINITE` - shift the entries to force the factorization to be positive definite
1552: - `MAT_SHIFT_INBLOCKS` - only shift the factors inside the small dense diagonal blocks of the matrix, for example with `MATBAIJ`
1554: Level: intermediate
1556: .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `PCFactorSetShiftType()`
1557: S*/
1558: typedef enum {
1559: MAT_SHIFT_NONE,
1560: MAT_SHIFT_NONZERO,
1561: MAT_SHIFT_POSITIVE_DEFINITE,
1562: MAT_SHIFT_INBLOCKS
1563: } MatFactorShiftType;
1564: PETSC_EXTERN const char *const MatFactorShiftTypes[];
1565: PETSC_EXTERN const char *const MatFactorShiftTypesDetail[];
1567: /*S
1568: MatFactorError - indicates what type of error was generated in a matrix factorization
1570: Values:
1571: + `MAT_FACTOR_NOERROR` - there was no error during the factorization
1572: . `MAT_FACTOR_STRUCT_ZEROPIVOT` - there was a missing entry in a diagonal location of the matrix
1573: . `MAT_FACTOR_NUMERIC_ZEROPIVOT` - there was a (near) zero pivot during the factorization
1574: . `MAT_FACTOR_OUTMEMORY` - the factorization has run out of memory
1575: - `MAT_FACTOR_OTHER` - some other error has occurred.
1577: Level: intermediate
1579: Note:
1580: When a factorization is done in a preconditioner `PC` the error may be propagated up to a `PCFailedReason` or a `KSPConvergedReason`
1582: .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `MatFactorGetError()`, `MatFactorGetErrorZeroPivot()`, `MatFactorClearError()`,
1583: `PCFailedReason`, `PCGetFailedReason()`, `KSPConvergedReason`
1584: S*/
1585: typedef enum {
1586: MAT_FACTOR_NOERROR,
1587: MAT_FACTOR_STRUCT_ZEROPIVOT,
1588: MAT_FACTOR_NUMERIC_ZEROPIVOT,
1589: MAT_FACTOR_OUTMEMORY,
1590: MAT_FACTOR_OTHER
1591: } MatFactorError;
1593: PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *);
1594: PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat);
1595: PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *);
1597: /*S
1598: MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization
1600: Level: developer
1602: Note:
1603: You can use `MatFactorInfoInitialize()` to set default values.
1605: Fortran Note:
1606: `MatFactorInfo` is a derived type, use e.g. `matfactorinfo%dt` to access its components.
1608: .seealso: [](ch_matrices), `Mat`, `MatInfo`, `MatGetFactor()`, `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`,
1609: `MatICCFactorSymbolic()`, `MatICCFactor()`, `MatFactorInfoInitialize()`
1610: S*/
1611: typedef struct {
1612: PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */
1613: PetscReal usedt;
1614: PetscReal dt; /* drop tolerance */
1615: PetscReal dtcol; /* tolerance for pivoting */
1616: PetscReal dtcount; /* maximum nonzeros to be allowed per row */
1617: PetscReal fill; /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */
1618: PetscReal levels; /* ICC/ILU(levels) */
1619: PetscReal pivotinblocks; /* BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 factorization may be faster if do not pivot */
1620: PetscReal zeropivot; /* pivot is called zero if less than this */
1621: PetscReal shifttype; /* type of shift added to matrix factor to prevent zero pivots */
1622: PetscReal shiftamount; /* how large the shift is */
1623: PetscBool factoronhost; /* do factorization on host instead of device (for device matrix types) */
1624: PetscBool solveonhost; /* do mat solve on host with the factor (for device matrix types) */
1625: } MatFactorInfo;
1627: PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *);
1628: PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *);
1629: PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
1630: PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *);
1631: PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *);
1632: PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *);
1633: PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
1634: PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
1635: PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
1636: PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *);
1637: PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *);
1638: PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *);
1639: PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
1640: PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *);
1641: PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *);
1642: PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec);
1643: PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec);
1644: PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec);
1645: PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec);
1646: PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec);
1647: PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec);
1648: PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs);
1649: PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat);
1651: /*E
1652: 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()`
1654: Values:
1655: + `MAT_FACTOR_SCHUR_UNFACTORED` - the Schur complement has been assembled but has not yet been factored or inverted
1656: . `MAT_FACTOR_SCHUR_FACTORED` - the Schur complement has been factored (for example via dense LU) and can be used to solve via `MatFactorSolveSchurComplement()`
1657: - `MAT_FACTOR_SCHUR_INVERTED` - the Schur complement has been explicitly inverted in place; subsequent solves multiply by the dense inverse
1659: Level: advanced
1661: .seealso: [](ch_matrices), `Mat`, `MatFactorSetSchurIS()`, `MatFactorGetSchurComplement()`, `MatFactorRestoreSchurComplement()`,
1662: `MatFactorInvertSchurComplement()`, `MatFactorCreateSchurComplement()`
1663: E*/
1664: typedef enum {
1665: MAT_FACTOR_SCHUR_UNFACTORED,
1666: MAT_FACTOR_SCHUR_FACTORED,
1667: MAT_FACTOR_SCHUR_INVERTED
1668: } MatFactorSchurStatus;
1669: PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS);
1670: PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
1671: PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus);
1672: PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat);
1673: PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
1674: PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec);
1675: PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec);
1676: PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat);
1678: PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat);
1679: /*E
1680: MatSORType - What type of (S)SOR to perform
1682: Values:
1683: + `SOR_FORWARD_SWEEP` - do a sweep from the first row of the matrix to the last
1684: . `SOR_BACKWARD_SWEEP` - do a sweep from the last row to the first
1685: . `SOR_SYMMETRIC_SWEEP` - do a sweep from the first row to the last and then back to the first
1686: . `SOR_LOCAL_FORWARD_SWEEP` - each MPI process does its own forward sweep with no communication
1687: . `SOR_LOCAL_BACKWARD_SWEEP` - each MPI process does its own backward sweep with no communication
1688: . `SOR_LOCAL_SYMMETRIC_SWEEP` - each MPI process does its own symmetric sweep with no communication
1689: . `SOR_ZERO_INITIAL_GUESS` - indicates the initial solution is zero so the sweep can avoid unneeded computation
1690: . `SOR_EISENSTAT` - apply the Eisentat application of SOR, see `PCEISENSTAT`
1691: . `SOR_APPLY_UPPER` - multiply by the upper triangular portion of the matrix
1692: - `SOR_APPLY_LOWER` - multiply by the lower triangular portion of the matrix
1694: Level: beginner
1696: Note:
1697: These may be bitwise ORd together
1699: Developer Note:
1700: Since `MatSORType` may be bitwise ORd together, so do not change the numerical values below
1702: .seealso: [](ch_matrices), `MatSOR()`
1703: E*/
1704: typedef enum {
1705: SOR_FORWARD_SWEEP = 1,
1706: SOR_BACKWARD_SWEEP = 2,
1707: SOR_SYMMETRIC_SWEEP = 3,
1708: SOR_LOCAL_FORWARD_SWEEP = 4,
1709: SOR_LOCAL_BACKWARD_SWEEP = 8,
1710: SOR_LOCAL_SYMMETRIC_SWEEP = 12,
1711: SOR_ZERO_INITIAL_GUESS = 16,
1712: SOR_EISENSTAT = 32,
1713: SOR_APPLY_UPPER = 64,
1714: SOR_APPLY_LOWER = 128
1715: } MatSORType;
1716: PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec);
1718: /*S
1719: MatColoring - Object for managing the coloring of matrices.
1721: Level: beginner
1723: Notes:
1724: Coloring of matrices can be computed directly from the sparse matrix nonzero structure via the `MatColoring` object or from the mesh from which the
1725: matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors).
1727: Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This
1728: same object can also be used to efficiently convert data created by Automatic Differentiation tools to PETSc sparse matrices.
1730: .seealso: [](ch_matrices), [](sec_graph), `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`,
1731: `MatPartitioning`, `MatColoringType`, `MatPartitioningType`, `MatOrderingType`, `MatColoringSetWeightType()`,
1732: `MatColoringSetWeights()`, `MatCoarsenType`, `MatCoarsen`
1733: S*/
1734: typedef struct _p_MatColoring *MatColoring;
1736: /*J
1737: MatColoringType - String with the name of a PETSc matrix coloring
1739: Level: beginner
1741: .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatFDColoringCreate()`, `MatColoringSetType()`, `MatColoring`
1742: J*/
1743: typedef const char *MatColoringType;
1744: #define MATCOLORINGJP "jp"
1745: #define MATCOLORINGPOWER "power"
1746: #define MATCOLORINGNATURAL "natural"
1747: #define MATCOLORINGSL "sl"
1748: #define MATCOLORINGLF "lf"
1749: #define MATCOLORINGID "id"
1750: #define MATCOLORINGGREEDY "greedy"
1752: /*E
1753: MatColoringWeightType - Type of weight scheme used for the coloring algorithm
1755: Values:
1756: + `MAT_COLORING_RANDOM` - Random weights
1757: . `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering.
1758: - `MAT_COLORING_LF` - Last-first weighting.
1760: Level: intermediate
1762: .seealso: [](ch_matrices), `MatColoring`, `MatColoringCreate()`, `MatColoringSetWeightType()`, `MatColoringSetWeights()`
1763: E*/
1764: typedef enum {
1765: MAT_COLORING_WEIGHT_RANDOM,
1766: MAT_COLORING_WEIGHT_LEXICAL,
1767: MAT_COLORING_WEIGHT_LF,
1768: MAT_COLORING_WEIGHT_SL
1769: } MatColoringWeightType;
1771: PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *);
1772: PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *);
1773: PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *);
1774: PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer);
1775: PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType);
1776: PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring);
1777: PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt);
1778: PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *);
1779: PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt);
1780: PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *);
1781: PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *);
1782: PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring));
1783: PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *);
1784: PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType);
1785: PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *);
1786: PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm);
1787: PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring);
1788: PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatColoringTest()", ) static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring)
1789: {
1790: return MatColoringTest(matcoloring, iscoloring);
1791: }
1792: PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring);
1794: /*S
1795: MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring
1797: Level: beginner
1799: Options Database Key:
1800: . -snes_fd_coloring - cause the Jacobian needed by `SNES` to be computed via a use of this object
1802: Note:
1803: This object is created utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()`
1805: .seealso: [](ch_matrices), `Mat`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()`
1806: S*/
1807: typedef struct _p_MatFDColoring *MatFDColoring;
1809: /*S
1810: MatFDColoringFn - Function provided to `MatFDColoringSetFunction()` that computes the function being differenced
1812: Level: advanced
1814: Calling Sequence:
1815: + snes - either a `SNES` object if used within `SNES` otherwise an unused parameter
1816: . in - the location where the Jacobian is to be computed
1817: . out - the location to put the computed function value
1818: - fctx - the function context passed into `MatFDColoringSetFunction()`
1820: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDiFn`, `MatMFFDiBaseFn`
1821: S*/
1822: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatFDColoringFn(void *snes, Vec x, Vec y, void *fctx);
1824: PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *);
1825: PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *);
1826: PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer);
1827: PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, MatFDColoringFn *, void *);
1828: PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, MatFDColoringFn **, void **);
1829: PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal);
1830: PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring);
1831: PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *);
1832: PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec);
1833: PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]);
1834: PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring);
1835: PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt);
1836: PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *);
1838: /*S
1839: MatTransposeColoring - Object for computing a sparse matrix product $C = A*B^T$ via coloring
1841: Level: developer
1843: .seealso: [](ch_matrices), `Mat`, `MatProductType`, `MatTransposeColoringCreate()`
1844: S*/
1845: typedef struct _p_MatTransposeColoring *MatTransposeColoring;
1847: PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *);
1848: PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat);
1849: PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat);
1850: PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *);
1852: /*S
1853: MatPartitioning - Object for managing the partitioning of a matrix or graph
1855: Level: beginner
1857: Note:
1858: There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations
1859: via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`)
1861: Developer Note:
1862: It is an extra maintenance and documentation cost to have two objects with the same functionality. `PetscPartitioner` should be removed
1864: .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`, `MatOrderingType`,
1865: `MatCoarsenType`
1866: S*/
1867: typedef struct _p_MatPartitioning *MatPartitioning;
1869: /*J
1870: MatPartitioningType - String with the name of a PETSc matrix partitioning
1872: Level: beginner
1873: dm
1874: .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`, `MatColoringType`, `MatOrderingType`,
1875: `MatCoarsenType`
1876: J*/
1877: typedef const char *MatPartitioningType;
1878: #define MATPARTITIONINGCURRENT "current"
1879: #define MATPARTITIONINGAVERAGE "average"
1880: #define MATPARTITIONINGSQUARE "square"
1881: #define MATPARTITIONINGPARMETIS "parmetis"
1882: #define MATPARTITIONINGCHACO "chaco"
1883: #define MATPARTITIONINGPARTY "party"
1884: #define MATPARTITIONINGPTSCOTCH "ptscotch"
1885: #define MATPARTITIONINGHIERARCH "hierarch"
1887: PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *);
1888: PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType);
1889: PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt);
1890: PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat);
1891: PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt);
1892: PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]);
1893: PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]);
1894: PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool);
1895: PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *);
1896: PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *);
1897: PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *);
1898: PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS);
1899: PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *);
1900: PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *);
1901: PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning));
1902: PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer);
1903: PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]);
1904: PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning);
1905: PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *);
1907: PETSC_EXTERN PetscErrorCode MatPartitioningParMETISSetRepartition(MatPartitioning);
1908: PETSC_EXTERN PetscErrorCode MatPartitioningParMETISSetCoarseSequential(MatPartitioning);
1909: PETSC_EXTERN PetscErrorCode MatPartitioningParMETISGetEdgeCut(MatPartitioning, PetscInt *);
1911: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "MatPartitioningParMETISSetRepartition()", ) static inline PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part)
1912: {
1913: return MatPartitioningParMETISSetRepartition(part);
1914: }
1915: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "MatPartitioningParMETISSetCoarseSequential()", ) static inline PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning part)
1916: {
1917: return MatPartitioningParMETISSetCoarseSequential(part);
1918: }
1919: PETSC_DEPRECATED_FUNCTION(3, 26, 0, "MatPartitioningParMETISGetEdgeCut()", ) static inline PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning part, PetscInt *cut)
1920: {
1921: return MatPartitioningParMETISGetEdgeCut(part, cut);
1922: }
1924: /*E
1925: MPChacoGlobalType - Global partitioning method used by `MATPARTITIONINGCHACO` when delegating to the Chaco library
1927: Values:
1928: + `MP_CHACO_MULTILEVEL` - multilevel-Kernighan--Lin style partitioning
1929: . `MP_CHACO_SPECTRAL` - spectral partitioning using Lanczos or RQI eigensolvers
1930: . `MP_CHACO_LINEAR` - linear (rank-order) initial partition
1931: . `MP_CHACO_RANDOM` - random initial partition
1932: - `MP_CHACO_SCATTERED` - scattered (round-robin) initial partition
1934: Level: intermediate
1936: .seealso: [](ch_matrices), `MatPartitioning`, `MATPARTITIONINGCHACO`, `MatPartitioningChacoSetGlobal()`, `MatPartitioningChacoGetGlobal()`,
1937: `MPChacoLocalType`, `MPChacoEigenType`
1938: E*/
1939: typedef enum {
1940: MP_CHACO_MULTILEVEL = 1,
1941: MP_CHACO_SPECTRAL = 2,
1942: MP_CHACO_LINEAR = 4,
1943: MP_CHACO_RANDOM = 5,
1944: MP_CHACO_SCATTERED = 6
1945: } MPChacoGlobalType;
1946: PETSC_EXTERN const char *const MPChacoGlobalTypes[];
1947: /*E
1948: MPChacoLocalType - Local refinement method used by `MATPARTITIONINGCHACO` after the global partition has been chosen
1950: Values:
1951: + `MP_CHACO_KERNIGHAN` - apply Kernighan--Lin local refinement to improve the partition
1952: - `MP_CHACO_NONE` - no local refinement
1954: Level: intermediate
1956: .seealso: [](ch_matrices), `MatPartitioning`, `MATPARTITIONINGCHACO`, `MatPartitioningChacoSetLocal()`, `MatPartitioningChacoGetLocal()`,
1957: `MPChacoGlobalType`
1958: E*/
1959: typedef enum {
1960: MP_CHACO_KERNIGHAN = 1,
1961: MP_CHACO_NONE = 2
1962: } MPChacoLocalType;
1963: PETSC_EXTERN const char *const MPChacoLocalTypes[];
1964: /*E
1965: MPChacoEigenType - Eigensolver used by `MATPARTITIONINGCHACO` when the global partitioning method is `MP_CHACO_SPECTRAL`
1967: Values:
1968: + `MP_CHACO_LANCZOS` - Lanczos algorithm
1969: - `MP_CHACO_RQI` - Rayleigh quotient iteration
1971: Level: intermediate
1973: .seealso: [](ch_matrices), `MatPartitioning`, `MATPARTITIONINGCHACO`, `MatPartitioningChacoSetEigenSolver()`, `MatPartitioningChacoGetEigenSolver()`,
1974: `MPChacoGlobalType`
1975: E*/
1976: typedef enum {
1977: MP_CHACO_LANCZOS = 0,
1978: MP_CHACO_RQI = 1
1979: } MPChacoEigenType;
1980: PETSC_EXTERN const char *const MPChacoEigenTypes[];
1982: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
1983: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *);
1984: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1985: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *);
1986: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal);
1987: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType);
1988: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *);
1989: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1990: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *);
1991: PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
1992: PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *);
1994: #define MP_PARTY_OPT "opt"
1995: #define MP_PARTY_LIN "lin"
1996: #define MP_PARTY_SCA "sca"
1997: #define MP_PARTY_RAN "ran"
1998: #define MP_PARTY_GBF "gbf"
1999: #define MP_PARTY_GCF "gcf"
2000: #define MP_PARTY_BUB "bub"
2001: #define MP_PARTY_DEF "def"
2002: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *);
2003: #define MP_PARTY_HELPFUL_SETS "hs"
2004: #define MP_PARTY_KERNIGHAN_LIN "kl"
2005: #define MP_PARTY_NONE "no"
2006: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *);
2007: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal);
2008: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool);
2009: PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool);
2011: /*E
2012: MPPTScotchStrategyType - Pre-defined strategy used by `MATPARTITIONINGPTSCOTCH` when delegating to the PT-Scotch library
2014: Values:
2015: + `MP_PTSCOTCH_DEFAULT` - the default PT-Scotch strategy
2016: . `MP_PTSCOTCH_QUALITY` - focus on partition quality at the expense of time
2017: . `MP_PTSCOTCH_SPEED` - focus on time to compute the partition
2018: . `MP_PTSCOTCH_BALANCE` - favor load balance
2019: . `MP_PTSCOTCH_SAFETY` - use the most reliable internal heuristics
2020: - `MP_PTSCOTCH_SCALABILITY` - favor scalability at large process counts
2022: Level: intermediate
2024: .seealso: [](ch_matrices), `MatPartitioning`, `MATPARTITIONINGPTSCOTCH`, `MatPartitioningPTScotchSetStrategy()`, `MatPartitioningPTScotchGetStrategy()`
2025: E*/
2026: typedef enum {
2027: MP_PTSCOTCH_DEFAULT,
2028: MP_PTSCOTCH_QUALITY,
2029: MP_PTSCOTCH_SPEED,
2030: MP_PTSCOTCH_BALANCE,
2031: MP_PTSCOTCH_SAFETY,
2032: MP_PTSCOTCH_SCALABILITY
2033: } MPPTScotchStrategyType;
2034: PETSC_EXTERN const char *const MPPTScotchStrategyTypes[];
2036: PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal);
2037: PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *);
2038: PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType);
2039: PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *);
2041: /*
2042: * hierarchical partitioning
2043: */
2044: PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *);
2045: PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *);
2046: PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt);
2047: PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt);
2049: /*J
2050: MatMeshToCellGraphType - String with the name of registered algorithm that computes a cell graph from a mesh (graph containing
2051: the coupling of vertices) representation.
2053: Options Database Key:
2054: . -mat_mesh_to_cell_graph_type (parmetis|metis) - the conversion package to use; default is ParMETIS if available, otherwise METIS
2056: Level: beginner
2058: .seealso: `Mat`, `MatMeshToCellGraph()`, `MatMeshToCellGraphRegister()`
2059: J*/
2060: typedef const char *MatMeshToCellGraphType;
2061: #define MATMESHTOCELLGRAPHMETIS "metis"
2062: #define MATMESHTOCELLGRAPHPARMETIS "parmetis"
2064: PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *);
2065: PETSC_EXTERN PetscErrorCode MatMeshToCellGraphRegister(const char[], PetscErrorCode (*)(Mat, PetscInt, Mat *));
2067: /*E
2068: MatOperation - Identifies one of the operations stored in a `Mat`'s function table, for example `MATOP_MULT` or `MATOP_LUFACTOR`
2070: Level: developer
2072: Notes:
2073: 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.
2075: 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.
2077: .seealso: [](ch_matrices), `Mat`, `MATSHELL`, `MatSetOperation()`, `MatGetOperation()`, `MatHasOperation()`,
2078: `MatShellSetOperation()`, `MatShellGetOperation()`
2079: E*/
2080: typedef enum {
2081: MATOP_SET_VALUES = 0,
2082: MATOP_GET_ROW = 1,
2083: MATOP_RESTORE_ROW = 2,
2084: MATOP_MULT = 3,
2085: MATOP_MULT_ADD = 4,
2086: MATOP_MULT_TRANSPOSE = 5,
2087: MATOP_MULT_TRANSPOSE_ADD = 6,
2088: MATOP_SOLVE = 7,
2089: MATOP_SOLVE_ADD = 8,
2090: MATOP_SOLVE_TRANSPOSE = 9,
2091: MATOP_SOLVE_TRANSPOSE_ADD = 10,
2092: MATOP_LUFACTOR = 11,
2093: MATOP_CHOLESKYFACTOR = 12,
2094: MATOP_SOR = 13,
2095: MATOP_TRANSPOSE = 14,
2096: MATOP_GETINFO = 15,
2097: MATOP_EQUAL = 16,
2098: MATOP_GET_DIAGONAL = 17,
2099: MATOP_DIAGONAL_SCALE = 18,
2100: MATOP_NORM = 19,
2101: MATOP_ASSEMBLY_BEGIN = 20,
2102: MATOP_ASSEMBLY_END = 21,
2103: MATOP_SET_OPTION = 22,
2104: MATOP_ZERO_ENTRIES = 23,
2105: MATOP_ZERO_ROWS = 24,
2106: MATOP_LUFACTOR_SYMBOLIC = 25,
2107: MATOP_LUFACTOR_NUMERIC = 26,
2108: MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27,
2109: MATOP_CHOLESKY_FACTOR_NUMERIC = 28,
2110: MATOP_SETUP = 29,
2111: MATOP_ILUFACTOR_SYMBOLIC = 30,
2112: MATOP_ICCFACTOR_SYMBOLIC = 31,
2113: MATOP_GET_DIAGONAL_BLOCK = 32,
2114: MATOP_SET_INF = 33,
2115: MATOP_DUPLICATE = 34,
2116: MATOP_FORWARD_SOLVE = 35,
2117: MATOP_BACKWARD_SOLVE = 36,
2118: MATOP_ILUFACTOR = 37,
2119: MATOP_ICCFACTOR = 38,
2120: MATOP_AXPY = 39,
2121: MATOP_CREATE_SUBMATRICES = 40,
2122: MATOP_INCREASE_OVERLAP = 41,
2123: MATOP_GET_VALUES = 42,
2124: MATOP_COPY = 43,
2125: MATOP_GET_ROW_MAX = 44,
2126: MATOP_SCALE = 45,
2127: MATOP_SHIFT = 46,
2128: MATOP_DIAGONAL_SET = 47,
2129: MATOP_ZERO_ROWS_COLUMNS = 48,
2130: MATOP_SET_RANDOM = 49,
2131: MATOP_GET_ROW_IJ = 50,
2132: MATOP_RESTORE_ROW_IJ = 51,
2133: MATOP_GET_COLUMN_IJ = 52,
2134: MATOP_RESTORE_COLUMN_IJ = 53,
2135: MATOP_FDCOLORING_CREATE = 54,
2136: MATOP_COLORING_PATCH = 55,
2137: MATOP_SET_UNFACTORED = 56,
2138: MATOP_PERMUTE = 57,
2139: MATOP_SET_VALUES_BLOCKED = 58,
2140: MATOP_CREATE_SUBMATRIX = 59,
2141: MATOP_DESTROY = 60,
2142: MATOP_VIEW = 61,
2143: MATOP_CONVERT_FROM = 62,
2144: MATOP_MATMAT_MULT_SYMBOLIC = 63,
2145: MATOP_MATMAT_MULT_NUMERIC = 64,
2146: MATOP_SET_LOCAL_TO_GLOBAL_MAP = 65,
2147: MATOP_SET_VALUES_LOCAL = 66,
2148: MATOP_ZERO_ROWS_LOCAL = 67,
2149: MATOP_GET_ROW_MAX_ABS = 68,
2150: MATOP_GET_ROW_MIN_ABS = 69,
2151: MATOP_CONVERT = 70,
2152: MATOP_HAS_OPERATION = 71,
2153: MATOP_FD_COLORING_APPLY = 72,
2154: MATOP_SET_FROM_OPTIONS = 73,
2155: MATOP_FIND_ZERO_DIAGONALS = 74,
2156: MATOP_MULT_MULTIPLE = 75,
2157: MATOP_SOLVE_MULTIPLE = 76,
2158: MATOP_GET_INERTIA = 77,
2159: MATOP_LOAD = 78,
2160: MATOP_IS_SYMMETRIC = 79,
2161: MATOP_IS_HERMITIAN = 80,
2162: MATOP_IS_STRUCTURALLY_SYMMETRIC = 81,
2163: MATOP_SET_VALUES_BLOCKEDLOCAL = 82,
2164: MATOP_CREATE_VECS = 83,
2165: MATOP_MAT_MULT_SYMBOLIC = 84,
2166: MATOP_MAT_MULT_NUMERIC = 85,
2167: MATOP_PTAP_NUMERIC = 86,
2168: MATOP_MAT_TRANSPOSE_MULT_SYMBO = 87,
2169: MATOP_MAT_TRANSPOSE_MULT_NUMER = 88,
2170: MATOP_BIND_TO_CPU = 89,
2171: MATOP_PRODUCTSETFROMOPTIONS = 90,
2172: MATOP_PRODUCTSYMBOLIC = 91,
2173: MATOP_PRODUCTNUMERIC = 92,
2174: MATOP_CONJUGATE = 93,
2175: MATOP_VIEW_NATIVE = 94,
2176: MATOP_SET_VALUES_ROW = 95,
2177: MATOP_REAL_PART = 96,
2178: MATOP_IMAGINARY_PART = 97,
2179: MATOP_GET_ROW_UPPER_TRIANGULAR = 98,
2180: MATOP_RESTORE_ROW_UPPER_TRIANG = 99,
2181: MATOP_MAT_SOLVE = 100,
2182: MATOP_MAT_SOLVE_TRANSPOSE = 101,
2183: MATOP_GET_ROW_MIN = 102,
2184: MATOP_GET_COLUMN_VECTOR = 103,
2185: MATOP_GET_SEQ_NONZERO_STRUCTUR = 104,
2186: MATOP_CREATE = 105,
2187: MATOP_GET_GHOSTS = 106,
2188: MATOP_GET_LOCAL_SUB_MATRIX = 107,
2189: MATOP_RESTORE_LOCALSUB_MATRIX = 108,
2190: MATOP_MULT_DIAGONAL_BLOCK = 109,
2191: MATOP_HERMITIAN_TRANSPOSE = 110,
2192: MATOP_MULT_HERMITIAN_TRANSPOSE = 111,
2193: MATOP_MULT_HERMITIAN_TRANS_ADD = 112,
2194: MATOP_GET_MULTI_PROC_BLOCK = 113,
2195: MATOP_FIND_NONZERO_ROWS = 114,
2196: MATOP_GET_COLUMN_NORMS = 115,
2197: MATOP_INVERT_BLOCK_DIAGONAL = 116,
2198: MATOP_INVERT_VBLOCK_DIAGONAL = 117,
2199: MATOP_CREATE_SUB_MATRICES_MPI = 118,
2200: MATOP_TRANSPOSE_MAT_MULT_SYMBO = 119,
2201: MATOP_TRANSPOSE_MAT_MULT_NUMER = 120,
2202: MATOP_TRANSPOSE_COLORING_CREAT = 121,
2203: MATOP_TRANS_COLORING_APPLY_SPT = 122,
2204: MATOP_TRANS_COLORING_APPLY_DEN = 123,
2205: MATOP_RART_NUMERIC = 124,
2206: MATOP_SET_BLOCK_SIZES = 125,
2207: MATOP_RESIDUAL = 126,
2208: MATOP_FDCOLORING_SETUP = 127,
2209: MATOP_FIND_OFFBLOCK_ENTRIES = 128,
2210: MATOP_MPICONCATENATESEQ = 129,
2211: MATOP_DESTROYSUBMATRICES = 130,
2212: MATOP_MAT_TRANSPOSE_SOLVE = 131,
2213: MATOP_GET_VALUES_LOCAL = 132,
2214: MATOP_CREATE_GRAPH = 133,
2215: MATOP_TRANSPOSE_SYMBOLIC = 134,
2216: MATOP_ELIMINATE_ZEROS = 135,
2217: MATOP_GET_ROW_SUM_ABS = 136,
2218: MATOP_GET_FACTOR = 137,
2219: MATOP_GET_BLOCK_DIAGONAL = 138, /* NOTE: caller of the two op functions owns the returned matrix */
2220: MATOP_GET_VBLOCK_DIAGONAL = 139, /* and need to destroy it after use. */
2221: MATOP_COPY_HASH_TO_XAIJ = 140,
2222: MATOP_GET_CURRENT_MEM_TYPE = 141,
2223: MATOP_ZERO_ROWS_COLUMNS_LOCAL = 142,
2224: MATOP_ADOT = 143,
2225: MATOP_ANORM = 144,
2226: MATOP_ADOT_LOCAL = 145,
2227: MATOP_ANORM_LOCAL = 146,
2228: MATOP_GET_ORDERING = 147
2229: } MatOperation;
2231: PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, PetscErrorCodeFn *);
2232: PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, PetscErrorCodeFn **);
2233: PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *);
2234: PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *);
2235: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatProductClear()", ) static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A)
2236: {
2237: return MatProductClear(A);
2238: }
2239: PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, PetscErrorCodeFn *);
2240: PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, PetscErrorCodeFn **);
2241: PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, PetscCtx);
2242: PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscCtxDestroyFn *);
2243: PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType);
2244: PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
2245: PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
2246: PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat);
2247: PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscCtxDestroyFn *, MatType, MatType);
2248: PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *);
2250: /*
2251: Codes for matrices stored on disk. By default they are
2252: stored in a universal format. By changing the format with
2253: PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will
2254: be stored in a way natural for the matrix, for example dense matrices
2255: would be stored as dense. Matrices stored this way may only be
2256: read into matrices of the same type.
2257: */
2258: #define MATRIX_BINARY_FORMAT_DENSE -1
2260: PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal);
2262: PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType);
2263: PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
2264: PETSC_EXTERN PetscErrorCode MatISSetAllowRepeated(Mat, PetscBool);
2265: PETSC_EXTERN PetscErrorCode MatISGetAllowRepeated(Mat, PetscBool *);
2266: PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool);
2267: PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool);
2268: PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *);
2269: PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *);
2270: PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat);
2271: PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
2273: /*S
2274: MatNullSpace - Object that removes a null space from a vector, i.e.
2275: orthogonalizes the vector to a subspace
2277: Level: advanced
2279: .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
2280: S*/
2281: typedef struct _p_MatNullSpace *MatNullSpace;
2283: /*S
2284: MatNullSpaceRemoveFn - Function provided to `MatNullSpaceSetFunction()` that removes the null space from a vector
2286: Level: advanced
2288: Calling Sequence:
2289: + nsp - the `MatNullSpace` object
2290: . x - the vector from which to remove the null space
2291: - ctx - [optional] user-defined function context provided with `MatNullSpaceSetFunction()`
2293: .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
2294: S*/
2295: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatNullSpaceRemoveFn(MatNullSpace nsp, Vec x, PetscCtx ctx);
2297: PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *);
2298: PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, MatNullSpaceRemoveFn *, void *);
2299: PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *);
2300: PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec);
2301: PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *);
2302: PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *);
2303: PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace);
2304: PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace);
2305: PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace);
2306: PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *);
2307: PETSC_EXTERN PetscErrorCode MatGetNullSpaces(PetscInt, Mat[], MatNullSpace *[]);
2308: PETSC_EXTERN PetscErrorCode MatRestoreNullSpaces(PetscInt, Mat[], MatNullSpace *[]);
2309: PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *);
2310: PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer);
2311: PETSC_EXTERN PetscErrorCode MatNullSpaceLoad(PetscViewer, MatNullSpace *);
2312: PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **);
2313: PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *);
2315: PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS);
2316: PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *);
2318: PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *);
2319: PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *);
2320: PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *);
2322: PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *);
2323: PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *);
2325: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperator()", ) static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B)
2326: {
2327: return MatComputeOperator(A, PETSC_NULLPTR, B);
2328: }
2329: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperatorTranspose()", ) static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B)
2330: {
2331: return MatComputeOperatorTranspose(A, PETSC_NULLPTR, B);
2332: }
2334: PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *);
2335: PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *);
2336: PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **);
2337: PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2338: PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **);
2339: PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **);
2340: PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **);
2341: PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2342: PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **);
2343: PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **);
2344: PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat);
2345: PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]);
2346: PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]);
2347: PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *);
2349: PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec);
2351: PETSC_EXTERN PetscErrorCode MatMFFDInitializePackage(void);
2352: PETSC_EXTERN PetscErrorCode MatMFFDFinalizePackage(void);
2354: /*S
2355: MatMFFDFn - Function provided to `MatMFFDSetFunction()` that computes the function being differenced
2357: Level: advanced
2359: Calling Sequence:
2360: + ctx - [optional] user-defined function context provided with `MatMFFDSetFunction()`
2361: . x - input vector
2362: - y - output vector
2364: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDiFn`, `MatMFFDiBaseFn`
2365: S*/
2366: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDFn(PetscCtx ctx, Vec x, Vec y);
2368: /*S
2369: MatMFFDiFn - Function provided to `MatMFFDSetFunctioni()` that computes the function being differenced at a single point
2371: Level: advanced
2373: Calling Sequence:
2374: + ctx - [optional] user-defined function context provided with `MatMFFDSetFunction()`
2375: . i - the component of the vector to compute
2376: . x - input vector
2377: - result - the value of the function at that component (output)
2379: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDFn`, `MatMFFDiBaseFn`
2380: S*/
2381: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDiFn(PetscCtx ctx, PetscInt i, Vec x, PetscScalar *result);
2383: /*S
2384: MatMFFDiBaseFn - Function provided to `MatMFFDSetFunctioniBase()` that computes the base of the function evaluations
2385: that will be used for differencing
2387: Level: advanced
2389: Calling Sequence:
2390: + ctx - [optional] user-defined function context provided with `MatMFFDSetFunction()`
2391: - x - input base vector
2393: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDSetFunctioniBase()`, `MatMFFDFn`, `MatMFFDiFn`
2394: S*/
2395: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDiBaseFn(PetscCtx ctx, Vec x);
2397: /*S
2398: MatMFFDCheckhFn - Function provided to `MatMFFDSetCheckh()` that checks and possibly adjusts the value of `h` to ensure some property.
2399: that will be used for differencing
2401: Level: advanced
2403: Calling Sequence:
2404: + ctx - [optional] user-defined function context provided with `MatMFFDSetCheckh()`
2405: . x - input base vector
2406: . y - input step vector that the product is computed with
2407: - h - input tentative step, output possibly adjusted step
2409: Note:
2410: `MatMFFDCheckPositivity()` is one such function
2412: .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetCheckh()`, `MatMFFDCheckPositivity()`
2413: S*/
2414: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDCheckhFn(PetscCtx ctx, Vec x, Vec y, PetscScalar *h);
2416: PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2417: PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec);
2418: PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, MatMFFDFn *, void *);
2419: PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, MatMFFDiFn *);
2420: PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, MatMFFDiBaseFn *);
2421: PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt);
2422: PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat);
2423: PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal);
2424: PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt);
2425: PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *);
2426: PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]);
2427: PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *);
2428: PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, MatMFFDCheckhFn *, void *);
2430: /*S
2431: MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free
2432: Jacobian vector products
2434: Level: developer
2436: Notes:
2437: `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure
2439: MatMFFD*() methods actually take the `Mat` as their first argument. Not a `MatMFFD` data structure
2441: This functionality is often obtained using `MatCreateSNESMF()` or with `SNES` solvers using `-snes_mf` or `-snes_mf_operator`
2443: .seealso: [](ch_matrices), `MatMFFDType`, `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`,
2444: `MatCreateSNESMF()`, `SNES`, `-snes_mf`, `-snes_mf_operator`
2445: S*/
2446: typedef struct _p_MatMFFD *MatMFFD;
2448: /*J
2449: MatMFFDType - algorithm used to compute the `h` used in computing matrix-vector products via differencing of a function
2451: Values:
2452: + `MATMFFD_DS` - an algorithm described by Dennis and Schnabel {cite}`dennis:83`
2453: - `MATMFFD_WP` - the Walker-Pernice {cite}`pw98` strategy.
2455: Level: beginner
2457: .seealso: [](ch_matrices), `MatMFFDSetType()`, `MatMFFDRegister()`, `MatMFFDSetFunction()`, `MatCreateMFFD()`
2458: J*/
2459: typedef const char *MatMFFDType;
2460: #define MATMFFD_DS "ds"
2461: #define MATMFFD_WP "wp"
2463: PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType);
2464: PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD));
2466: PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal);
2467: PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool);
2469: PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType);
2471: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
2472: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
2474: #if PetscDefined(HAVE_H2OPUS)
2475: /*S
2476: MatH2OpusKernelFn - Function type for the user-supplied kernel callback used by `MATH2OPUS` (see `MatCreateH2OpusFromKernel()`)
2477: to evaluate the dense matrix entries on demand
2479: Synopsis:
2480: #include <petscmat.h>
2481: PetscScalar MatH2OpusKernelFn(PetscInt spacedim, PetscReal target[], PetscReal source[], PetscCtx ctx)
2483: Calling Sequence:
2484: + spacedim - spatial dimension, either 1, 2, or 3
2485: . target - spatial coordinate of the target point, its length is `spacedim`
2486: . source - spatial coordinate of the source point, its length is `spacedim`
2487: - ctx - the optional application context passed with `MatCreateH2OpusFromKernel()`
2489: Level: intermediate
2491: Note:
2492: Returns the matrix entry coupling the target and source points
2494: .seealso: `Mat`, `MATH2OPUS`, `MATHTOOL`, `MatCreateH2OpusFromKernel()`
2495: S*/
2496: PETSC_EXTERN_TYPEDEF typedef PetscScalar MatH2OpusKernelFn(PetscInt spacedim, PetscReal target[], PetscReal source[], PetscCtx ctx);
2498: PETSC_EXTERN_TYPEDEF typedef MatH2OpusKernelFn *MatH2OpusKernel PETSC_DEPRECATED_TYPEDEF(3, 26, 0, "MatH2OpusKernelFn*", );
2500: PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernelFn *, PetscCtx, PetscReal, PetscInt, PetscInt, Mat *);
2501: PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *);
2502: PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal);
2503: PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat);
2504: PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal);
2505: PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool);
2506: PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *);
2507: PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *);
2508: PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *);
2509: PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar);
2510: #endif
2512: /*S
2513: MatHtoolKernelFn - Function type for the user-supplied kernel callback used by `MATHTOOL` (`MatCreateHtoolFromKernel()`, `MatHtoolSetKernel()`) to evaluate the dense matrix entries on demand
2515: Synopsis:
2516: #include <petscmat.h>
2517: PetscErrorCode MatHtoolKernelFn(PetscInt sdim, PetscInt M, PetscInt N, const PetscInt *J, const PetscInt *K, PetscScalar *ptr, void *ctx)
2519: Calling Sequence:
2520: + sdim - the spatial dimension of the source/target geometries
2521: . M - the number of target points
2522: . N - the number of source points
2523: . J - array of `M` target point indices into the user's target coordinate array
2524: . K - array of `N` source point indices into the user's source coordinate array
2525: . ptr - column-major output buffer of length `M*N` to fill with kernel values
2526: - ctx - the optional application context passed at registration
2528: Level: intermediate
2530: .seealso: `Mat`, `MATHTOOL`, `MatCreateHtoolFromKernel()`, `MatHtoolSetKernel()`
2531: S*/
2532: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatHtoolKernelFn(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *);
2533: PETSC_EXTERN_TYPEDEF typedef MatHtoolKernelFn *MatHtoolKernel PETSC_DEPRECATED_TYPEDEF(3, 26, 0, "MatHtoolKernelFn*", );
2535: PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernelFn *, void *, Mat *);
2536: PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernelFn *, void *);
2537: PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *);
2538: PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *);
2539: PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool);
2540: PETSC_EXTERN PetscErrorCode MatHtoolUseRecompression(Mat, PetscBool);
2541: PETSC_EXTERN PetscErrorCode MatHtoolGetEpsilon(Mat, PetscReal *);
2542: PETSC_EXTERN PetscErrorCode MatHtoolSetEpsilon(Mat, PetscReal);
2543: PETSC_EXTERN PetscErrorCode MatHtoolGetEta(Mat, PetscReal *);
2544: PETSC_EXTERN PetscErrorCode MatHtoolSetEta(Mat, PetscReal);
2545: PETSC_EXTERN PetscErrorCode MatHtoolGetMaxClusterLeafSize(Mat, PetscInt *);
2546: PETSC_EXTERN PetscErrorCode MatHtoolSetMaxClusterLeafSize(Mat, PetscInt);
2547: PETSC_EXTERN PetscErrorCode MatHtoolGetMinTargetDepth(Mat, PetscInt *);
2548: PETSC_EXTERN PetscErrorCode MatHtoolSetMinTargetDepth(Mat, PetscInt);
2549: PETSC_EXTERN PetscErrorCode MatHtoolGetMinSourceDepth(Mat, PetscInt *);
2550: PETSC_EXTERN PetscErrorCode MatHtoolSetMinSourceDepth(Mat, PetscInt);
2551: PETSC_EXTERN PetscErrorCode MatHtoolGetBlockTreeConsistency(Mat, PetscBool *);
2552: PETSC_EXTERN PetscErrorCode MatHtoolSetBlockTreeConsistency(Mat, PetscBool);
2554: /*E
2555: MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL`
2557: Values:
2558: + `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation
2559: . `MAT_HTOOL_COMPRESSOR_FULL_ACA` - full adaptive cross approximation
2560: - `MAT_HTOOL_COMPRESSOR_SVD` - singular value decomposition
2562: Level: intermediate
2564: .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType`, `MatHtoolGetCompressorType()`, `MatHtoolSetCompressorType()`
2565: E*/
2566: typedef enum {
2567: MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA,
2568: MAT_HTOOL_COMPRESSOR_FULL_ACA,
2569: MAT_HTOOL_COMPRESSOR_SVD
2570: } MatHtoolCompressorType;
2572: /*E
2573: MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL`
2575: Values:
2576: + `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default) - axis computed via principle component analysis, split uniformly
2577: . `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC` - axis computed via principle component analysis, split barycentrically
2578: . `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR` - axis along the largest extent of the bounding box, split uniformly
2579: - `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically
2581: Level: intermediate
2583: Note:
2584: Higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types
2586: .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType`, `MatHtoolGetClusteringType()`, `MatHtoolSetClusteringType()`
2587: E*/
2588: typedef enum {
2589: MAT_HTOOL_CLUSTERING_PCA_REGULAR,
2590: MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC,
2591: MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR,
2592: MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC
2593: } MatHtoolClusteringType;
2594: PETSC_EXTERN PetscErrorCode MatHtoolGetCompressorType(Mat, MatHtoolCompressorType *);
2595: PETSC_EXTERN PetscErrorCode MatHtoolSetCompressorType(Mat, MatHtoolCompressorType);
2596: PETSC_EXTERN PetscErrorCode MatHtoolGetClusteringType(Mat, MatHtoolClusteringType *);
2597: PETSC_EXTERN PetscErrorCode MatHtoolSetClusteringType(Mat, MatHtoolClusteringType);
2599: PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt);
2600: PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *);
2601: PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal);
2602: PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *);
2604: PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *);
2605: PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *);
2606: PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *);
2607: PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *);
2608: PETSC_EXTERN PetscErrorCode MatMumpsGetNullPivots(Mat, PetscInt *, PetscInt **);
2609: PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat);
2610: PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat);
2611: PETSC_EXTERN PetscErrorCode MatMumpsSetBlk(Mat, PetscInt, const PetscInt[], const PetscInt[]);
2613: PETSC_EXTERN PetscErrorCode MatMumpsSetOocTmpDir(Mat, const char *);
2614: PETSC_EXTERN PetscErrorCode MatMumpsGetOocTmpDir(Mat, const char *[]);
2616: #if PetscDefined(HAVE_MKL_PARDISO)
2617: PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt);
2618: #endif
2620: #if PetscDefined(HAVE_MKL_CPARDISO)
2621: PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt);
2622: #endif
2624: #if PetscDefined(HAVE_SUPERLU)
2625: PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal);
2626: #endif
2628: #if PetscDefined(HAVE_SUPERLU_DIST)
2629: PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *);
2630: #endif
2632: /*E
2633: MatSTRUMPACKReordering - sparsity reducing ordering to be used in `MATSOLVERSTRUMPACK`
2635: Values:
2636: + `MAT_STRUMPACK_NATURAL` - use the current ordering
2637: . `MAT_STRUMPACK_METIS` - use MeTis to compute an ordering
2638: . `MAT_STRUMPACK_PARMETIS` - use ParMeTis to compute an ordering
2639: . `MAT_STRUMPACK_SCOTCH` - use Scotch to compute an ordering
2640: . `MAT_STRUMPACK_PTSCOTCH` - use parallel Scotch to compute an ordering
2641: . `MAT_STRUMPACK_RCM` - use an RCM ordering
2642: . `MAT_STRUMPACK_GEOMETRIC` - use a geometric ordering (needs mesh info from user)
2643: . `MAT_STRUMPACK_AMD` - approximate minimum degree
2644: . `MAT_STRUMPACK_MMD` - multiple minimum degree
2645: . `MAT_STRUMPACK_AND` - approximate nested dissection
2646: . `MAT_STRUMPACK_MLF` - minimum local fill
2647: - `MAT_STRUMPACK_SPECTRAL` - spectral nested dissection
2649: Level: intermediate
2651: Developer Note:
2652: Should be called `MatSTRUMPACKReorderingType`
2654: .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetReordering()`
2655: E*/
2656: typedef enum {
2657: MAT_STRUMPACK_NATURAL,
2658: MAT_STRUMPACK_METIS,
2659: MAT_STRUMPACK_PARMETIS,
2660: MAT_STRUMPACK_SCOTCH,
2661: MAT_STRUMPACK_PTSCOTCH,
2662: MAT_STRUMPACK_RCM,
2663: MAT_STRUMPACK_GEOMETRIC,
2664: MAT_STRUMPACK_AMD,
2665: MAT_STRUMPACK_MMD,
2666: MAT_STRUMPACK_AND,
2667: MAT_STRUMPACK_MLF,
2668: MAT_STRUMPACK_SPECTRAL
2669: } MatSTRUMPACKReordering;
2670: PETSC_EXTERN const char *const MatSTRUMPACKReorderingTypes[];
2672: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering);
2673: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetReordering(Mat, MatSTRUMPACKReordering *);
2674: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricNxyz(Mat, PetscInt, PetscInt, PetscInt);
2675: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricComponents(Mat, PetscInt);
2676: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricWidth(Mat, PetscInt);
2677: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool);
2678: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetColPerm(Mat, PetscBool *);
2679: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGPU(Mat, PetscBool);
2680: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetGPU(Mat, PetscBool *);
2682: /*E
2683: MatSTRUMPACKCompressionType - Compression used in the approximate sparse factorization solver `MATSOLVERSTRUMPACK`
2685: Values:
2686: + `MAT_STRUMPACK_COMPRESSION_TYPE_NONE` - no compression, direct solver
2687: . `MAT_STRUMPACK_COMPRESSION_TYPE_HSS` - hierarchically semi-separable
2688: . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR` - block low rank
2689: . `MAT_STRUMPACK_COMPRESSION_TYPE_HODLR` - hierarchically off-diagonal low rank (requires ButterflyPACK support, configure with `--download-butterflypack`)
2690: . `MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR` - hybrid of BLR and HODLR (requires ButterflyPACK support, configure with `--download-butterflypack`)
2691: . `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`)
2692: . `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS` - lossless compression (requires ZFP support, configure with `--download-zfp`)
2693: - `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY` - lossy compression (requires ZFP support, configure with `--download-zfp`)
2695: Level: intermediate
2697: .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetCompression()`
2698: E*/
2699: typedef enum {
2700: MAT_STRUMPACK_COMPRESSION_TYPE_NONE,
2701: MAT_STRUMPACK_COMPRESSION_TYPE_HSS,
2702: MAT_STRUMPACK_COMPRESSION_TYPE_BLR,
2703: MAT_STRUMPACK_COMPRESSION_TYPE_HODLR,
2704: MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR,
2705: MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR,
2706: MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS,
2707: MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY
2708: } MatSTRUMPACKCompressionType;
2709: PETSC_EXTERN const char *const MatSTRUMPACKCompressionTypes[];
2711: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompression(Mat, MatSTRUMPACKCompressionType);
2712: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompression(Mat, MatSTRUMPACKCompressionType *);
2713: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompRelTol(Mat, PetscReal);
2714: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompRelTol(Mat, PetscReal *);
2715: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompAbsTol(Mat, PetscReal);
2716: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompAbsTol(Mat, PetscReal *);
2717: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompMinSepSize(Mat, PetscInt);
2718: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompMinSepSize(Mat, PetscInt *);
2719: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLeafSize(Mat, PetscInt);
2720: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLeafSize(Mat, PetscInt *);
2721: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLossyPrecision(Mat, PetscInt);
2722: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLossyPrecision(Mat, PetscInt *);
2723: PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompButterflyLevels(Mat, PetscInt);
2724: PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompButterflyLevels(Mat, PetscInt *);
2726: PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool);
2727: PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *);
2728: PETSC_DEPRECATED_FUNCTION(3, 13, 0, "MatBindToCPU()", ) static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg)
2729: {
2730: return MatBindToCPU(A, flg);
2731: }
2732: PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool);
2733: PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *);
2735: #if PetscDefined(HAVE_CUDA)
2736: /*E
2737: MatCUSPARSEStorageFormat - indicates the storage format for `MATAIJCUSPARSE` (GPU)
2738: matrices.
2740: Values:
2741: + `MAT_CUSPARSE_CSR` - Compressed Sparse Row
2742: . `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later).
2743: - `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later).
2745: Level: intermediate
2747: .seealso: [](ch_matrices), `MATAIJCUSPARSE`, `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation`
2748: E*/
2750: typedef enum {
2751: MAT_CUSPARSE_CSR,
2752: MAT_CUSPARSE_ELL,
2753: MAT_CUSPARSE_HYB
2754: } MatCUSPARSEStorageFormat;
2756: /* these will be strings associated with enumerated type defined above */
2757: PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[];
2759: /*E
2760: MatCUSPARSEFormatOperation - indicates the operation of `MATAIJCUSPARSE` (GPU)
2761: matrices whose operation should use a particular storage format.
2763: Values:
2764: + `MAT_CUSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()`
2765: . `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()`
2766: . `MAT_CUSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
2767: - `MAT_CUSPARSE_ALL` - sets the storage format for all `MATAIJCUSPARSE` (GPU) matrices
2769: Level: intermediate
2771: .seealso: [](ch_matrices), `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat`
2772: E*/
2773: typedef enum {
2774: MAT_CUSPARSE_MULT_DIAG,
2775: MAT_CUSPARSE_MULT_OFFDIAG,
2776: MAT_CUSPARSE_MULT,
2777: MAT_CUSPARSE_ALL
2778: } MatCUSPARSEFormatOperation;
2780: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2781: PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2782: PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat);
2783: PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool);
2784: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const PetscInt *[], const PetscInt *[]);
2785: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const PetscInt *[], const PetscInt *[]);
2786: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **);
2787: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **);
2788: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **);
2789: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **);
2790: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **);
2791: PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **);
2793: PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
2794: PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
2795: PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **);
2796: PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **);
2797: PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **);
2798: PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **);
2799: PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **);
2800: PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **);
2801: PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *);
2802: PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *);
2803: PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat);
2804: PETSC_EXTERN PetscErrorCode MatDenseCUDASetPreallocation(Mat, PetscScalar *);
2806: PETSC_EXTERN PetscErrorCode MatCreateSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2807: #endif
2809: #if PetscDefined(HAVE_HIP)
2810: /*E
2811: MatHIPSPARSEStorageFormat - indicates the storage format for `MATAIJHIPSPARSE` (GPU)
2812: matrices.
2814: Values:
2815: + `MAT_HIPSPARSE_CSR` - Compressed Sparse Row
2816: . `MAT_HIPSPARSE_ELL` - Ellpack
2817: - `MAT_HIPSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format
2819: Level: intermediate
2821: .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEFormatOperation`
2822: E*/
2824: typedef enum {
2825: MAT_HIPSPARSE_CSR,
2826: MAT_HIPSPARSE_ELL,
2827: MAT_HIPSPARSE_HYB
2828: } MatHIPSPARSEStorageFormat;
2830: /* these will be strings associated with enumerated type defined above */
2831: PETSC_EXTERN const char *const MatHIPSPARSEStorageFormats[];
2833: /*E
2834: MatHIPSPARSEFormatOperation - indicates the operation of `MATAIJHIPSPARSE` (GPU)
2835: matrices whose operation should use a particular storage format.
2837: Values:
2838: + `MAT_HIPSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()`
2839: . `MAT_HIPSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()`
2840: . `MAT_HIPSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
2841: - `MAT_HIPSPARSE_ALL` - sets the storage format for all HIPSPARSE (GPU) matrices
2843: Level: intermediate
2845: .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEStorageFormat`
2846: E*/
2847: typedef enum {
2848: MAT_HIPSPARSE_MULT_DIAG,
2849: MAT_HIPSPARSE_MULT_OFFDIAG,
2850: MAT_HIPSPARSE_MULT,
2851: MAT_HIPSPARSE_ALL
2852: } MatHIPSPARSEFormatOperation;
2854: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2855: PETSC_EXTERN PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2856: PETSC_EXTERN PetscErrorCode MatHIPSPARSESetFormat(Mat, MatHIPSPARSEFormatOperation, MatHIPSPARSEStorageFormat);
2857: PETSC_EXTERN PetscErrorCode MatHIPSPARSESetUseCPUSolve(Mat, PetscBool);
2858: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetIJ(Mat, PetscBool, const PetscInt *[], const PetscInt *[]);
2859: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreIJ(Mat, PetscBool, const PetscInt *[], const PetscInt *[]);
2860: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayRead(Mat, const PetscScalar **);
2861: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayRead(Mat, const PetscScalar **);
2862: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayWrite(Mat, PetscScalar **);
2863: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayWrite(Mat, PetscScalar **);
2864: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArray(Mat, PetscScalar **);
2865: PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArray(Mat, PetscScalar **);
2867: PETSC_EXTERN PetscErrorCode MatCreateDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
2868: PETSC_EXTERN PetscErrorCode MatCreateSeqDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
2869: PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayWrite(Mat, PetscScalar **);
2870: PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayRead(Mat, const PetscScalar **);
2871: PETSC_EXTERN PetscErrorCode MatDenseHIPGetArray(Mat, PetscScalar **);
2872: PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayWrite(Mat, PetscScalar **);
2873: PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayRead(Mat, const PetscScalar **);
2874: PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArray(Mat, PetscScalar **);
2875: PETSC_EXTERN PetscErrorCode MatDenseHIPPlaceArray(Mat, const PetscScalar *);
2876: PETSC_EXTERN PetscErrorCode MatDenseHIPReplaceArray(Mat, const PetscScalar *);
2877: PETSC_EXTERN PetscErrorCode MatDenseHIPResetArray(Mat);
2878: PETSC_EXTERN PetscErrorCode MatDenseHIPSetPreallocation(Mat, PetscScalar *);
2879: PETSC_EXTERN PetscErrorCode MatCreateSELLHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2880: #endif
2882: #if PetscDefined(HAVE_VIENNACL)
2883: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2884: PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2885: #endif
2887: #if PetscDefined(HAVE_KOKKOS)
2888: PETSC_EXTERN PetscErrorCode MatCreateAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2889: PETSC_EXTERN PetscErrorCode MatCreateSeqAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2890: #endif
2892: #if PetscDefined(HAVE_FFTW)
2893: PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec);
2894: PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec);
2895: PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *);
2896: #endif
2898: #if PetscDefined(HAVE_SCALAPACK) && (PetscDefined(USE_REAL_SINGLE) || PetscDefined(USE_REAL_DOUBLE))
2899: PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2900: PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt);
2901: PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *);
2902: #endif
2904: PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *);
2905: PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *);
2906: PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]);
2907: PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]);
2908: PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***);
2909: PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *);
2910: PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType);
2911: PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]);
2912: PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat);
2914: PETSC_EXTERN PetscErrorCode MatCreateNestFromMultipleShifts(Mat, PetscInt, const PetscScalar[], const PetscScalar[], Mat, PetscBool, MatStructure, Mat *);
2915: PETSC_EXTERN PetscErrorCode MatCreateVecNestFromMultipleShifts(Mat, Vec, Vec *);
2917: PETSC_EXTERN PetscErrorCode MatFilter(Mat, PetscReal, PetscBool, PetscBool);
2918: PETSC_DEPRECATED_FUNCTION(3, 20, 0, "MatFilter()", ) static inline PetscErrorCode MatChop(Mat A, PetscReal tol)
2919: {
2920: return MatFilter(A, tol, PETSC_FALSE, PETSC_FALSE);
2921: }
2922: PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *);
2924: PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **);
2926: PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat);
2928: PETSC_EXTERN PetscErrorCode MatHeaderMerge(Mat, Mat *);
2929: PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *);
2931: PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *);
2933: PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, PetscReal, PetscInt, PetscInt[], Mat *);
2934: PETSC_EXTERN PetscErrorCode MatEliminateZeros(Mat, PetscBool);
2936: PETSC_EXTERN PetscErrorCode MatCreateDenseFromVecType(MPI_Comm, VecType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *);
2937: PETSC_EXTERN PetscErrorCode MatCreateDenseWithMemType(MPI_Comm, PetscMemType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *);
2939: PETSC_EXTERN PetscErrorCode MatSetHPL(Mat, int);
2940: #define PETSCBMHPL "hpl"
2942: PETSC_EXTERN PetscErrorCode MatDFischer(Mat, Vec, Vec, Vec, Vec, Vec, Vec, Vec, Vec);