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