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