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