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