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