xref: /petsc/include/petscmat.h (revision 0da935d541a7182c5ecf339615946e1daca8be12)
12eac72dbSBarry Smith /*
22eac72dbSBarry Smith      Include file for the matrix component of PETSc
32eac72dbSBarry Smith */
4a4963045SJacob Faibussowitsch #pragma once
5ac09b921SBarry Smith 
62c8e378dSBarry Smith #include <petscvec.h>
72eac72dbSBarry Smith 
8ac09b921SBarry Smith /* SUBMANSEC = Mat */
9ac09b921SBarry Smith 
10d9274352SBarry Smith /*S
118f6c3df8SBarry Smith    Mat - Abstract PETSc matrix object used to manage all linear operators in PETSc, even those without
12af27ebaaSBarry Smith          an explicit sparse representation (such as matrix-free operators). Also used to hold representations of graphs
13af27ebaaSBarry Smith          for graph operations such as coloring, `MatColoringCreate()`
142eac72dbSBarry Smith 
15d91e6319SBarry Smith    Level: beginner
16d91e6319SBarry Smith 
172ef1f0ffSBarry Smith    Note:
181cc06b55SBarry Smith    See [](doc_matrix), [](ch_matrices) and `MatType` for available matrix types
192ef1f0ffSBarry Smith 
201cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatCreate()`, `MatType`, `MatSetType()`, `MatDestroy()`
21d9274352SBarry Smith S*/
22d9274352SBarry Smith typedef struct _p_Mat *Mat;
23d9274352SBarry Smith 
2476bdecfbSBarry Smith /*J
258f6c3df8SBarry Smith    MatType - String with the name of a PETSc matrix type
26d9274352SBarry Smith 
27d9274352SBarry Smith    Level: beginner
28d9274352SBarry Smith 
292ef1f0ffSBarry Smith    Note:
302ef1f0ffSBarry Smith    [](doc_matrix) for a table of available matrix types
312ef1f0ffSBarry Smith 
321cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()`
3376bdecfbSBarry Smith J*/
3419fd82e9SBarry Smith typedef const char *MatType;
35273d9f13SBarry Smith #define MATSAME                      "same"
365a11e1b2SBarry Smith #define MATMAIJ                      "maij"
37273d9f13SBarry Smith #define MATSEQMAIJ                   "seqmaij"
38273d9f13SBarry Smith #define MATMPIMAIJ                   "mpimaij"
3949bd79ccSDebojyoti Ghosh #define MATKAIJ                      "kaij"
4049bd79ccSDebojyoti Ghosh #define MATSEQKAIJ                   "seqkaij"
4149bd79ccSDebojyoti Ghosh #define MATMPIKAIJ                   "mpikaij"
42273d9f13SBarry Smith #define MATIS                        "is"
435a11e1b2SBarry Smith #define MATAIJ                       "aij"
44273d9f13SBarry Smith #define MATSEQAIJ                    "seqaij"
45273d9f13SBarry Smith #define MATMPIAIJ                    "mpiaij"
465a11e1b2SBarry Smith #define MATAIJCRL                    "aijcrl"
475a11e1b2SBarry Smith #define MATSEQAIJCRL                 "seqaijcrl"
485a11e1b2SBarry Smith #define MATMPIAIJCRL                 "mpiaijcrl"
499ae82921SPaul Mullowney #define MATAIJCUSPARSE               "aijcusparse"
509ae82921SPaul Mullowney #define MATSEQAIJCUSPARSE            "seqaijcusparse"
519ae82921SPaul Mullowney #define MATMPIAIJCUSPARSE            "mpiaijcusparse"
5247d993e7Ssuyashtn #define MATAIJHIPSPARSE              "aijhipsparse"
5347d993e7Ssuyashtn #define MATSEQAIJHIPSPARSE           "seqaijhipsparse"
5447d993e7Ssuyashtn #define MATMPIAIJHIPSPARSE           "mpiaijhipsparse"
558c3ff71bSJunchao Zhang #define MATAIJKOKKOS                 "aijkokkos"
568c3ff71bSJunchao Zhang #define MATSEQAIJKOKKOS              "seqaijkokkos"
578c3ff71bSJunchao Zhang #define MATMPIAIJKOKKOS              "mpiaijkokkos"
58d67ff14aSKarl Rupp #define MATAIJVIENNACL               "aijviennacl"
59d67ff14aSKarl Rupp #define MATSEQAIJVIENNACL            "seqaijviennacl"
60d67ff14aSKarl Rupp #define MATMPIAIJVIENNACL            "mpiaijviennacl"
615a11e1b2SBarry Smith #define MATAIJPERM                   "aijperm"
625a11e1b2SBarry Smith #define MATSEQAIJPERM                "seqaijperm"
635a11e1b2SBarry Smith #define MATMPIAIJPERM                "mpiaijperm"
644dfdc2d9SRichard Tran Mills #define MATAIJSELL                   "aijsell"
654dfdc2d9SRichard Tran Mills #define MATSEQAIJSELL                "seqaijsell"
664dfdc2d9SRichard Tran Mills #define MATMPIAIJSELL                "mpiaijsell"
674a2a386eSRichard Tran Mills #define MATAIJMKL                    "aijmkl"
684a2a386eSRichard Tran Mills #define MATSEQAIJMKL                 "seqaijmkl"
694a2a386eSRichard Tran Mills #define MATMPIAIJMKL                 "mpiaijmkl"
70b5b72c8aSIrina Sokolova #define MATBAIJMKL                   "baijmkl"
71b5b72c8aSIrina Sokolova #define MATSEQBAIJMKL                "seqbaijmkl"
72b5b72c8aSIrina Sokolova #define MATMPIBAIJMKL                "mpibaijmkl"
73273d9f13SBarry Smith #define MATSHELL                     "shell"
74c1fff1c6SRichard Tran Mills #define MATCENTERING                 "centering"
755a11e1b2SBarry Smith #define MATDENSE                     "dense"
76637a0070SStefano Zampini #define MATDENSECUDA                 "densecuda"
7747d993e7Ssuyashtn #define MATDENSEHIP                  "densehip"
78209238afSKris Buschelman #define MATSEQDENSE                  "seqdense"
79bfc799aaSStefano Zampini #define MATSEQDENSECUDA              "seqdensecuda"
8047d993e7Ssuyashtn #define MATSEQDENSEHIP               "seqdensehip"
81273d9f13SBarry Smith #define MATMPIDENSE                  "mpidense"
82637a0070SStefano Zampini #define MATMPIDENSECUDA              "mpidensecuda"
8347d993e7Ssuyashtn #define MATMPIDENSEHIP               "mpidensehip"
84db31f6deSJed Brown #define MATELEMENTAL                 "elemental"
85d24d4204SJose E. Roman #define MATSCALAPACK                 "scalapack"
865a11e1b2SBarry Smith #define MATBAIJ                      "baij"
87273d9f13SBarry Smith #define MATSEQBAIJ                   "seqbaij"
88273d9f13SBarry Smith #define MATMPIBAIJ                   "mpibaij"
89273d9f13SBarry Smith #define MATMPIADJ                    "mpiadj"
905a11e1b2SBarry Smith #define MATSBAIJ                     "sbaij"
91273d9f13SBarry Smith #define MATSEQSBAIJ                  "seqsbaij"
92273d9f13SBarry Smith #define MATMPISBAIJ                  "mpisbaij"
93cebc7f6cSBarry Smith #define MATMFFD                      "mffd"
94c8a8475eSBarry Smith #define MATNORMAL                    "normal"
95c5e4d11fSDmitry Karpeev #define MATNORMALHERMITIAN           "normalh"
96ab92ecdeSBarry Smith #define MATLRC                       "lrc"
972a6744ebSBarry Smith #define MATSCATTER                   "scatter"
98421e10b8SBarry Smith #define MATBLOCKMAT                  "blockmat"
99793850ffSBarry Smith #define MATCOMPOSITE                 "composite"
1001f8c7532SHong Zhang #define MATFFT                       "fft"
1011f8c7532SHong Zhang #define MATFFTW                      "fftw"
102e133240eSMatthew G Knepley #define MATSEQCUFFT                  "seqcufft"
10347d993e7Ssuyashtn #define MATSEQHIPFFT                 "seqhipfft"
104edd03b47SJacob Faibussowitsch #define MATTRANSPOSEMAT              PETSC_DEPRECATED_MACRO(3, 18, 0, "MATTRANSPOSEVIRTUAL", ) "transpose"
105013e2dc7SBarry Smith #define MATTRANSPOSEVIRTUAL          "transpose"
106013e2dc7SBarry Smith #define MATHERMITIANTRANSPOSEVIRTUAL "hermitiantranspose"
10772ca8751SBarry Smith #define MATSCHURCOMPLEMENT           "schurcomplement"
1081d6018f0SLisandro Dalcin #define MATPYTHON                    "python"
10963c07aadSStefano Zampini #define MATHYPRE                     "hypre"
110f91d8e95SBarry Smith #define MATHYPRESTRUCT               "hyprestruct"
111a9e6138eSGlenn Hammond #define MATHYPRESSTRUCT              "hypresstruct"
112ee1cef2cSJed Brown #define MATSUBMATRIX                 "submatrix"
1132c0dbf93SJed Brown #define MATLOCALREF                  "localref"
114d8588912SDave May #define MATNEST                      "nest"
115c094ef40SMatthew G. Knepley #define MATPREALLOCATOR              "preallocator"
116d4002b98SHong Zhang #define MATSELL                      "sell"
117d4002b98SHong Zhang #define MATSEQSELL                   "seqsell"
118d4002b98SHong Zhang #define MATMPISELL                   "mpisell"
1192d1451d4SHong Zhang #define MATSELLCUDA                  "sellcuda"
1202d1451d4SHong Zhang #define MATSEQSELLCUDA               "seqsellcuda"
1212d1451d4SHong Zhang #define MATMPISELLCUDA               "mpisellcuda"
122a3b2e22bSHong Zhang #define MATDUMMY                     "dummy"
123cd929ea3SAlp Dener #define MATLMVM                      "lmvm"
12478e4361aSAlp Dener #define MATLMVMDFP                   "lmvmdfp"
12578e4361aSAlp Dener #define MATLMVMBFGS                  "lmvmbfgs"
12678e4361aSAlp Dener #define MATLMVMSR1                   "lmvmsr1"
127864588a7SAlp Dener #define MATLMVMBROYDEN               "lmvmbroyden"
128864588a7SAlp Dener #define MATLMVMBADBROYDEN            "lmvmbadbroyden"
129864588a7SAlp Dener #define MATLMVMSYMBROYDEN            "lmvmsymbroyden"
130864588a7SAlp Dener #define MATLMVMSYMBADBROYDEN         "lmvmsymbadbroyden"
131864588a7SAlp Dener #define MATLMVMDIAGBROYDEN           "lmvmdiagbroyden"
1323423f386SBarry Smith #define MATCONSTANTDIAGONAL          "constantdiagonal"
133345a4b08SToby Isaac #define MATDIAGONAL                  "diagonal"
134c7a4214aSPierre Jolivet #define MATHTOOL                     "htool"
13553022affSStefano Zampini #define MATH2OPUS                    "h2opus"
136773941d6SBarry Smith 
13776bdecfbSBarry Smith /*J
138af27ebaaSBarry Smith    MatSolverType - String with the name of a PETSc factorization-based matrix solver type.
1399989ab13SBarry Smith 
140c2b89b5dSBarry Smith    For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc
1419989ab13SBarry Smith 
1429989ab13SBarry Smith    Level: beginner
1439989ab13SBarry Smith 
1442ef1f0ffSBarry Smith    Note:
14516a05f60SBarry Smith    `MATSOLVERUMFPACK`, `MATSOLVERCHOLMOD`, `MATSOLVERKLU`, `MATSOLVERSPQR` form the SuiteSparse package; you can use `--download-suitesparse` as
14616a05f60SBarry Smith    a ./configure option to install them
147c7ccbb75SBarry Smith 
1481cc06b55SBarry Smith .seealso: [](sec_matfactor), [](ch_matrices), `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()`
14976bdecfbSBarry Smith J*/
150ea799195SBarry Smith typedef const char *MatSolverType;
1512692d6eeSBarry Smith #define MATSOLVERSUPERLU      "superlu"
1522692d6eeSBarry Smith #define MATSOLVERSUPERLU_DIST "superlu_dist"
15308f5efcfSPieter Ghysels #define MATSOLVERSTRUMPACK    "strumpack"
1542692d6eeSBarry Smith #define MATSOLVERUMFPACK      "umfpack"
15520db9a53SJed Brown #define MATSOLVERCHOLMOD      "cholmod"
156d89f5e7aSBarry Smith #define MATSOLVERKLU          "klu"
157d89f5e7aSBarry Smith #define MATSOLVERELEMENTAL    "elemental"
158d24d4204SJose E. Roman #define MATSOLVERSCALAPACK    "scalapack"
1592692d6eeSBarry Smith #define MATSOLVERESSL         "essl"
1602692d6eeSBarry Smith #define MATSOLVERLUSOL        "lusol"
1612692d6eeSBarry Smith #define MATSOLVERMUMPS        "mumps"
162d615f992SSatish Balay #define MATSOLVERMKL_PARDISO  "mkl_pardiso"
163d305a81bSVasiliy Kozyrev #define MATSOLVERMKL_CPARDISO "mkl_cpardiso"
1642692d6eeSBarry Smith #define MATSOLVERPASTIX       "pastix"
1652692d6eeSBarry Smith #define MATSOLVERMATLAB       "matlab"
1662692d6eeSBarry Smith #define MATSOLVERPETSC        "petsc"
1672692d6eeSBarry Smith #define MATSOLVERBAS          "bas"
1689ae82921SPaul Mullowney #define MATSOLVERCUSPARSE     "cusparse"
169bfc799aaSStefano Zampini #define MATSOLVERCUDA         "cuda"
17047d993e7Ssuyashtn #define MATSOLVERHIPSPARSE    "hipsparse"
17147d993e7Ssuyashtn #define MATSOLVERHIP          "hip"
172930e68a5SMark Adams #define MATSOLVERKOKKOS       "kokkos"
173a2fc1e05SToby Isaac #define MATSOLVERSPQR         "spqr"
174c0cdd4a1SDahai Guo 
175b24902e0SBarry Smith /*E
176b24902e0SBarry Smith     MatFactorType - indicates what type of factorization is requested
177b24902e0SBarry Smith 
1782ef1f0ffSBarry Smith     Values:
1792ef1f0ffSBarry Smith +  `MAT_FACTOR_LU`       - LU factorization
1802ef1f0ffSBarry Smith .  `MAT_FACTOR_CHOLESKY` - Cholesky factorization
1812ef1f0ffSBarry Smith .  `MAT_FACTOR_ILU`      - ILU factorization
1822ef1f0ffSBarry Smith .  `MAT_FACTOR_ICC`      - incomplete Cholesky factorization
1832ef1f0ffSBarry Smith .  `MAT_FACTOR_ILUDT`    - ILU factorization with drop tolerance
1842ef1f0ffSBarry Smith -  `MAT_FACTOR_QR`       - QR factorization
185b24902e0SBarry Smith 
18616a05f60SBarry Smith     Level: beginner
18716a05f60SBarry Smith 
1881cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()`
189b24902e0SBarry Smith E*/
1909371c9d4SSatish Balay typedef enum {
1919371c9d4SSatish Balay   MAT_FACTOR_NONE,
1929371c9d4SSatish Balay   MAT_FACTOR_LU,
1939371c9d4SSatish Balay   MAT_FACTOR_CHOLESKY,
1949371c9d4SSatish Balay   MAT_FACTOR_ILU,
1959371c9d4SSatish Balay   MAT_FACTOR_ICC,
1969371c9d4SSatish Balay   MAT_FACTOR_ILUDT,
1979371c9d4SSatish Balay   MAT_FACTOR_QR,
1989371c9d4SSatish Balay   MAT_FACTOR_NUM_TYPES
1999371c9d4SSatish Balay } MatFactorType;
200014dd563SJed Brown PETSC_EXTERN const char *const MatFactorTypes[];
201e92e720dSBarry Smith 
202ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactor(Mat, MatSolverType, MatFactorType, Mat *);
203ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat, MatSolverType, MatFactorType, PetscBool *);
204f73b0415SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool *);
205edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 15, 0, "MatFactorGetCanUseOrdering()", ) static inline PetscErrorCode MatFactorGetUseOrdering(Mat A, PetscBool *b)
206d71ae5a4SJacob Faibussowitsch {
2079371c9d4SSatish Balay   return MatFactorGetCanUseOrdering(A, b);
2089371c9d4SSatish Balay }
209ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat, MatSolverType *);
210014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat, MatFactorType *);
2117abd51d3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat, MatFactorType);
2122430ea28SJose E. Roman PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatSolverFunction)(Mat, MatFactorType, Mat *);
2132430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType, MatType, MatFactorType, MatSolverFunction);
2142430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType, MatType, MatFactorType, PetscBool *, PetscBool *, MatSolverFunction *);
215edd03b47SJacob Faibussowitsch typedef MatSolverType       MatSolverPackage PETSC_DEPRECATED_TYPEDEF(3, 9, 0, "MatSolverType", );
216edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeRegister()", ) static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype, MatType mtype, MatFactorType ftype, MatSolverFunction f)
217d71ae5a4SJacob Faibussowitsch {
2189371c9d4SSatish Balay   return MatSolverTypeRegister(stype, mtype, ftype, f);
2199371c9d4SSatish Balay }
220edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeGet()", ) static inline PetscErrorCode MatSolverPackageGet(MatSolverType stype, MatType mtype, MatFactorType ftype, PetscBool *foundmtype, PetscBool *foundstype, MatSolverFunction *f)
221d71ae5a4SJacob Faibussowitsch {
2229371c9d4SSatish Balay   return MatSolverTypeGet(stype, mtype, ftype, foundmtype, foundstype, f);
2239371c9d4SSatish Balay }
2249989ab13SBarry Smith 
2254222ddf1SHong Zhang /*E
22695bd0b28SBarry Smith     MatProductType - indicates what type of matrix product to compute
2274222ddf1SHong Zhang 
2282ef1f0ffSBarry Smith     Values:
2292ef1f0ffSBarry Smith +  `MATPRODUCT_AB`   - product of two matrices
2302ef1f0ffSBarry Smith .  `MATPRODUCT_AtB`  - product of the transpose of a given matrix with a matrix
2312ef1f0ffSBarry Smith .  `MATPRODUCT_ABt`  - product of a matrix with the transpose of another given matrix
2322ef1f0ffSBarry Smith .  `MATPRODUCT_PtAP` - the triple product of the transpose of a matrix with another matrix and itself
2332ef1f0ffSBarry Smith .  `MATPRODUCT_RARt` - the triple product of a matrix, another matrix and the transpose of the first matrix
2342ef1f0ffSBarry Smith -  `MATPRODUCT_ABC`  - the product of three matrices
2352ef1f0ffSBarry Smith 
23616a05f60SBarry Smith     Level: beginner
23716a05f60SBarry Smith 
2381cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatProductSetType()`
2394222ddf1SHong Zhang E*/
2409371c9d4SSatish Balay typedef enum {
2419371c9d4SSatish Balay   MATPRODUCT_UNSPECIFIED = 0,
2429371c9d4SSatish Balay   MATPRODUCT_AB,
2439371c9d4SSatish Balay   MATPRODUCT_AtB,
2449371c9d4SSatish Balay   MATPRODUCT_ABt,
2459371c9d4SSatish Balay   MATPRODUCT_PtAP,
2469371c9d4SSatish Balay   MATPRODUCT_RARt,
2479371c9d4SSatish Balay   MATPRODUCT_ABC
2489371c9d4SSatish Balay } MatProductType;
249544a5e07SHong Zhang PETSC_EXTERN const char *const MatProductTypes[];
2504222ddf1SHong Zhang 
2514222ddf1SHong Zhang /*J
2524222ddf1SHong Zhang     MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation
2534222ddf1SHong Zhang 
2544222ddf1SHong Zhang    Level: beginner
2554222ddf1SHong Zhang 
2561cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType`
2574222ddf1SHong Zhang J*/
2584222ddf1SHong Zhang typedef const char *MatProductAlgorithm;
2593e662e0bSHong Zhang #define MATPRODUCTALGORITHMDEFAULT         "default"
2603e662e0bSHong Zhang #define MATPRODUCTALGORITHMSORTED          "sorted"
2613e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLE        "scalable"
2623e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLEFAST    "scalable_fast"
2633e662e0bSHong Zhang #define MATPRODUCTALGORITHMHEAP            "heap"
2643e662e0bSHong Zhang #define MATPRODUCTALGORITHMBHEAP           "btheap"
2653e662e0bSHong Zhang #define MATPRODUCTALGORITHMLLCONDENSED     "llcondensed"
2663e662e0bSHong Zhang #define MATPRODUCTALGORITHMROWMERGE        "rowmerge"
2673e662e0bSHong Zhang #define MATPRODUCTALGORITHMOUTERPRODUCT    "outerproduct"
2683e662e0bSHong Zhang #define MATPRODUCTALGORITHMATB             "at*b"
2693e662e0bSHong Zhang #define MATPRODUCTALGORITHMRAP             "rap"
2703e662e0bSHong Zhang #define MATPRODUCTALGORITHMNONSCALABLE     "nonscalable"
2713e662e0bSHong Zhang #define MATPRODUCTALGORITHMSEQMPI          "seqmpi"
2723e662e0bSHong Zhang #define MATPRODUCTALGORITHMBACKEND         "backend"
2733e662e0bSHong Zhang #define MATPRODUCTALGORITHMOVERLAPPING     "overlapping"
2743e662e0bSHong Zhang #define MATPRODUCTALGORITHMMERGED          "merged"
2753e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCE       "allatonce"
2763e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged"
2773e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLGATHERV      "allgatherv"
2783e662e0bSHong Zhang #define MATPRODUCTALGORITHMCYCLIC          "cyclic"
2793e662e0bSHong Zhang #if defined(PETSC_HAVE_HYPRE)
2803e662e0bSHong Zhang   #define MATPRODUCTALGORITHMHYPRE "hypre"
2813e662e0bSHong Zhang #endif
2824222ddf1SHong Zhang 
2834222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreate(Mat, Mat, Mat, Mat *);
2844222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat, Mat, Mat, Mat);
2854222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetType(Mat, MatProductType);
2864222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat, MatProductAlgorithm);
2878fcac130SJose E. Roman PETSC_EXTERN PetscErrorCode MatProductGetAlgorithm(Mat, MatProductAlgorithm *);
2884222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat, PetscReal);
2894222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat);
2904222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat);
2914222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat);
2924222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat, Mat, Mat, Mat);
2934417c5e8SHong Zhang PETSC_EXTERN PetscErrorCode MatProductClear(Mat);
2946718818eSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductView(Mat, PetscViewer);
295c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetType(Mat, MatProductType *);
296c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat, Mat *, Mat *, Mat *);
2974222ddf1SHong Zhang 
298c06d978dSMatthew Knepley /* Logging support */
2990700a824SBarry Smith #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */
300014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_CLASSID;
301335efc43SPeter Brune PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID;
302014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID;
303014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID;
304014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID;
305014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID;
306014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID;
307014dd563SJed Brown PETSC_EXTERN PetscClassId MATMFFD_CLASSID;
308c06d978dSMatthew Knepley 
309ceb03754SKris Buschelman /*E
3102ef1f0ffSBarry Smith    MatReuse - Indicates if matrices obtained from a previous call to `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatConvert()` or several other functions
311cf37664fSBarry Smith    are to be reused to store the new matrix values.
312cf37664fSBarry Smith 
3132ef1f0ffSBarry Smith    Values:
3142ef1f0ffSBarry Smith +  `MAT_INITIAL_MATRIX` - create a new matrix
3152ef1f0ffSBarry Smith .  `MAT_REUSE_MATRIX`   - reuse the matrix created with a previous call that used `MAT_INITIAL_MATRIX`
3162ef1f0ffSBarry Smith .  `MAT_INPLACE_MATRIX` - replace the first input matrix with the new matrix (not applicable to all functions)
3172ef1f0ffSBarry Smith -  `MAT_IGNORE_MATRIX`  - do not create a new matrix or reuse a give matrix, just ignore that matrix argument (not applicable to all functions)
318ceb03754SKris Buschelman 
319ceb03754SKris Buschelman     Level: beginner
320ceb03754SKris Buschelman 
3211cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()`
322ceb03754SKris Buschelman E*/
3239371c9d4SSatish Balay typedef enum {
3249371c9d4SSatish Balay   MAT_INITIAL_MATRIX,
3259371c9d4SSatish Balay   MAT_REUSE_MATRIX,
3269371c9d4SSatish Balay   MAT_IGNORE_MATRIX,
3279371c9d4SSatish Balay   MAT_INPLACE_MATRIX
3289371c9d4SSatish Balay } MatReuse;
329ceb03754SKris Buschelman 
3305494a064SHong Zhang /*E
3312ef1f0ffSBarry Smith     MatCreateSubMatrixOption - Indicates if matrices obtained from a call to `MatCreateSubMatrices()`
3322ef1f0ffSBarry Smith     include the matrix values. Currently it is only used by `MatGetSeqNonzeroStructure()`.
3335494a064SHong Zhang 
3342ef1f0ffSBarry Smith     Values:
3352ef1f0ffSBarry Smith +  `MAT_DO_NOT_GET_VALUES` - do not copy the matrix values
3362ef1f0ffSBarry Smith -  `MAT_GET_VALUES`        - copy the matrix values
3372ef1f0ffSBarry Smith 
33895bd0b28SBarry Smith     Level: developer
33995bd0b28SBarry Smith 
3402ef1f0ffSBarry Smith     Developer Note:
3412ef1f0ffSBarry Smith     Why is not just a boolean used for this information?
3422ef1f0ffSBarry Smith 
3431cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicateOption`, `PetscCopyMode`, `MatGetSeqNonzeroStructure()`
3445494a064SHong Zhang E*/
3459371c9d4SSatish Balay typedef enum {
3469371c9d4SSatish Balay   MAT_DO_NOT_GET_VALUES,
3479371c9d4SSatish Balay   MAT_GET_VALUES
3489371c9d4SSatish Balay } MatCreateSubMatrixOption;
3495494a064SHong Zhang 
350607a6623SBarry Smith PETSC_EXTERN PetscErrorCode MatInitializePackage(void);
3514bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatFinalizePackage(void);
352c06d978dSMatthew Knepley 
353014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *);
35477433607SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFromOptions(MPI_Comm, const char *, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
355014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt);
35619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType);
3570d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *);
3580d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType);
359014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat);
360fe2efc57SMark PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]);
361bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat));
36223bebc0bSBarry Smith PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]);
363014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]);
36426cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]);
36526cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]);
366014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]);
367014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]);
36884d44b13SHong Zhang PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool);
369f69a0ea3SMatthew Knepley 
370140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatList;
371140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatColoringList;
372140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatPartitioningList;
37328988994SBarry Smith 
3743b224e63SBarry Smith /*E
375aa6c7ce3SBarry Smith    MatStructure - Indicates if two matrices have the same nonzero structure
3763b224e63SBarry Smith 
3772ef1f0ffSBarry Smith    Values:
3782ef1f0ffSBarry Smith +  `SAME_NONZERO_PATTERN`      - the two matrices have identical nonzero patterns
3792ef1f0ffSBarry Smith .  `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns
3802ef1f0ffSBarry Smith .  `SUBSET_NONZERO_PATTERN`    - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix
3812ef1f0ffSBarry Smith -  `UNKNOWN_NONZERO_PATTERN`   - there is no known relationship between the nonzero patterns. In this case the implementations
3822ef1f0ffSBarry Smith                                  may try to detect a relationship to optimize the operation
383531d0c6aSBarry Smith 
38416a05f60SBarry Smith    Level: beginner
38516a05f60SBarry Smith 
386af27ebaaSBarry Smith    Note:
387af27ebaaSBarry Smith    Certain matrix operations (such as `MatAXPY()`) can run much faster if the sparsity pattern of the matrices are the same. But actually determining if
388af27ebaaSBarry Smith    the patterns are the same may be costly. This provides a way for users who know something about the sparsity patterns to provide this information
389af27ebaaSBarry Smith    to certain PETSc routines.
390af27ebaaSBarry Smith 
3911cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()`
3923b224e63SBarry Smith E*/
3939371c9d4SSatish Balay typedef enum {
3949371c9d4SSatish Balay   DIFFERENT_NONZERO_PATTERN,
3959371c9d4SSatish Balay   SUBSET_NONZERO_PATTERN,
3969371c9d4SSatish Balay   SAME_NONZERO_PATTERN,
3979371c9d4SSatish Balay   UNKNOWN_NONZERO_PATTERN
3989371c9d4SSatish Balay } MatStructure;
399d60b7d5cSBarry Smith PETSC_EXTERN const char *const MatStructures[];
4003b224e63SBarry Smith 
4019779e05dSSatish Balay #if defined                 PETSC_HAVE_MKL_SPARSE
402ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
403ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
40480095d54SIrina Sokolova PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
405ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
40680095d54SIrina Sokolova #endif
407cd929ea3SAlp Dener 
4084bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
4094bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
4104bf303faSJacob Faibussowitsch 
411d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
412d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
413d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]);
414d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
41507e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetFillRatio(Mat, PetscReal *);
41607e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetMaxSliceWidth(Mat, PetscInt *);
41707e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetAvgSliceWidth(Mat, PetscReal *);
41807e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetSliceHeight(Mat, PetscInt);
419b921024eSHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetVarSliceSize(Mat, PetscReal *);
42080095d54SIrina Sokolova 
4214bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
4224bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
423fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
424fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetSeqSELL(Mat, Mat *, Mat *, const PetscInt *[]);
4254bf303faSJacob Faibussowitsch 
426014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
427014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
428014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
429014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
430014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
4318f8f2f0dSBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
4326a3d2595SBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]);
433014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *);
4343b00a383SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, Mat, Mat, const PetscInt[], Mat *);
4353b00a383SHong Zhang 
436014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
437014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
438014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
4397e8381f9SStefano Zampini 
440e8729f6fSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]);
44182a78a4eSJed Brown PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]);
4427e8381f9SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode);
443d21a29f3SJed Brown 
444014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *);
445014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
446d21a29f3SJed Brown 
447014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
448014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
44938f409ebSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
450014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
4514cce697cSJed Brown PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]);
452dfb205c3SBarry Smith 
453014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, void *, Mat *);
454c1fff1c6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *);
455014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *);
456c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *);
457986c4d72SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *);
458267ca84cSJose E. Roman PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *);
459bcf2175cSMatthew Knepley PETSC_EXTERN PetscErrorCode MatLRCSetMats(Mat, Mat, Mat, Vec, Mat);
460c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *);
461014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
462014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
463c0cdd4a1SDahai Guo 
464014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *);
465014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter);
466014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *);
467014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *);
468014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat);
469014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat);
4709371c9d4SSatish Balay typedef enum {
4719371c9d4SSatish Balay   MAT_COMPOSITE_MERGE_RIGHT,
4729371c9d4SSatish Balay   MAT_COMPOSITE_MERGE_LEFT
4739371c9d4SSatish Balay } MatCompositeMergeType;
4748c8613bfSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType);
475014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *);
476*0da935d5SPierre Jolivet /*E
477*0da935d5SPierre Jolivet     MatCompositeType - indicates what type of `MATCOMPOSITE` is used
478*0da935d5SPierre Jolivet 
479*0da935d5SPierre Jolivet     Values:
480*0da935d5SPierre Jolivet +  `MAT_COMPOSITE_ADDITIVE`       - sum of matrices (default)
481*0da935d5SPierre Jolivet -  `MAT_COMPOSITE_MULTIPLICATIVE` - product of matrices
482*0da935d5SPierre Jolivet 
483*0da935d5SPierre Jolivet     Level: beginner
484*0da935d5SPierre Jolivet 
485*0da935d5SPierre Jolivet .seealso: [](ch_matrices), `MATCOMPOSITE`, `MatCompositeSetType()`, `MatCompositeGetType()`
486*0da935d5SPierre Jolivet E*/
4879371c9d4SSatish Balay typedef enum {
4889371c9d4SSatish Balay   MAT_COMPOSITE_ADDITIVE,
4899371c9d4SSatish Balay   MAT_COMPOSITE_MULTIPLICATIVE
4909371c9d4SSatish Balay } MatCompositeType;
491014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType);
4926dbc55e5SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *);
4933b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure);
4943b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *);
4956d0add67SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *);
4968b5c3584SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *);
49703049c21SJunchao Zhang PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *);
4986d7c1e57SBarry Smith 
49919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *);
500014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *);
501dedccee8SHong Zhang 
502014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *);
5038060fb66Sstefano_zampini PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *);
504d0de2241SAndrew Spott PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *);
50506511a5cSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *);
506fa80d070SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *);
50765f45395SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *);
50854e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *);
50954e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS);
510014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *);
5113423f386SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *);
512345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatCreateDiagonal(Vec, Mat *);
513345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetDiagonal(Mat, Vec *);
514345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreDiagonal(Mat, Vec *);
515345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetInverseDiagonal(Mat, Vec *);
516345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreInverseDiagonal(Mat, Vec *);
5171472f72bSBarry Smith 
518978814f1SStefano Zampini #if defined(PETSC_HAVE_HYPRE)
519d975228cSstefano_zampini PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
520978814f1SStefano Zampini #endif
521978814f1SStefano Zampini 
522014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]);
523ebead697SStefano Zampini PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]);
5241d6018f0SLisandro Dalcin 
525846b4da1SFande Kong PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat);
526014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetUp(Mat);
527014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroy(Mat *);
528e56f5c9eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *);
52921c89e3eSBarry Smith 
530014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatConjugate(Mat);
531014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRealPart(Mat);
532014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat);
533014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *);
534014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *);
535713ccfa9SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **);
5360da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *);
537479a70c0SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat);
5388a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *);
53920c04d79SPierre Jolivet PETSC_EXTERN PetscErrorCode MatComputeVariableBlockEnvelope(Mat);
54099cafbc1SBarry Smith 
541014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
5428a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode);
543014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
544014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]);
545014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]);
546014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]);
54773a71a0fSBarry Smith PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom);
54884cb2905SBarry Smith 
5492ef4de8bSBarry Smith /*S
5502ef1f0ffSBarry Smith    MatStencil - Data structure (C struct) for storing information about rows and
5512ef1f0ffSBarry Smith    columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()`
55262ef0227SBarry Smith 
5532ef1f0ffSBarry Smith    Level: beginner
5542ef1f0ffSBarry Smith 
5552ef1f0ffSBarry Smith    Notes:
55662ef0227SBarry Smith    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).
55787497f52SBarry Smith    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.
55862ef0227SBarry Smith 
55987497f52SBarry Smith    For stencil access to vectors see `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`.
560be479b30SJed Brown 
5612ef1f0ffSBarry Smith    For staggered grids, see `DMStagStencil`
5622ef4de8bSBarry Smith 
5632ef1f0ffSBarry Smith    Fortran Note:
5642ef1f0ffSBarry Smith    See `MatSetValuesStencil()` for details.
5652ef4de8bSBarry Smith 
5661cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`,
5672ef1f0ffSBarry Smith           `DMStagStencil`
5682ef4de8bSBarry Smith S*/
569435da068SBarry Smith typedef struct {
570c1ac3661SBarry Smith   PetscInt k, j, i, c;
571435da068SBarry Smith } MatStencil;
5722ef4de8bSBarry Smith 
573014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
574014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
575014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt);
576435da068SBarry Smith 
577d91e6319SBarry Smith /*E
5782ef1f0ffSBarry Smith     MatAssemblyType - Indicates if the process of setting values into the matrix is complete, and the matrix is ready for use
579d91e6319SBarry Smith 
5802ef1f0ffSBarry Smith     Values:
5812ef1f0ffSBarry Smith +   `MAT_FLUSH_ASSEMBLY` - you will continue to put values into the matrix
5822ef1f0ffSBarry Smith -   `MAT_FINAL_ASSEMBLY` - you wish to use the matrix with the values currently inserted
5832ef1f0ffSBarry Smith 
58416a05f60SBarry Smith     Level: beginner
58516a05f60SBarry Smith 
5861cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValues`, `MatAssemblyBegin()`, `MatAssemblyEnd()`
587d91e6319SBarry Smith E*/
5889371c9d4SSatish Balay typedef enum {
5899371c9d4SSatish Balay   MAT_FLUSH_ASSEMBLY = 1,
5909371c9d4SSatish Balay   MAT_FINAL_ASSEMBLY = 0
5919371c9d4SSatish Balay } MatAssemblyType;
592014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType);
593014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType);
594014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *);
5954f9c727eSBarry Smith 
596d91e6319SBarry Smith /*E
5972ef1f0ffSBarry Smith    MatOption - Options that may be set for a matrix that indicate properties of the matrix or affect its behavior or storage
598d91e6319SBarry Smith 
599d91e6319SBarry Smith    Level: beginner
600d91e6319SBarry Smith 
6012ef1f0ffSBarry Smith    Note:
6022ef1f0ffSBarry Smith    See `MatSetOption()` for the use of the options
6032ef1f0ffSBarry Smith 
6042ef1f0ffSBarry Smith    Developer Note:
60595452b02SPatrick Sanan    Entries that are negative need not be called collectively by all processes.
606382164b0SBarry Smith 
6071cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetOption()`
608d91e6319SBarry Smith E*/
6099371c9d4SSatish Balay typedef enum {
6109371c9d4SSatish Balay   MAT_OPTION_MIN                  = -3,
611c5e4d11fSDmitry Karpeev   MAT_UNUSED_NONZERO_LOCATION_ERR = -2,
61292d4d306SBarry Smith   MAT_ROW_ORIENTED                = -1,
613382164b0SBarry Smith   MAT_SYMMETRIC                   = 1,
614382164b0SBarry Smith   MAT_STRUCTURALLY_SYMMETRIC      = 2,
6158c78258cSHong Zhang   MAT_FORCE_DIAGONAL_ENTRIES      = 3,
616382164b0SBarry Smith   MAT_IGNORE_OFF_PROC_ENTRIES     = 4,
617382164b0SBarry Smith   MAT_USE_HASH_TABLE              = 5,
618382164b0SBarry Smith   MAT_KEEP_NONZERO_PATTERN        = 6,
619382164b0SBarry Smith   MAT_IGNORE_ZERO_ENTRIES         = 7,
620382164b0SBarry Smith   MAT_USE_INODES                  = 8,
621382164b0SBarry Smith   MAT_HERMITIAN                   = 9,
622382164b0SBarry Smith   MAT_SYMMETRY_ETERNAL            = 10,
623c5e4d11fSDmitry Karpeev   MAT_NEW_NONZERO_LOCATION_ERR    = 11,
624382164b0SBarry Smith   MAT_IGNORE_LOWER_TRIANGULAR     = 12,
625382164b0SBarry Smith   MAT_ERROR_LOWER_TRIANGULAR      = 13,
626382164b0SBarry Smith   MAT_GETROW_UPPERTRIANGULAR      = 14,
627382164b0SBarry Smith   MAT_SPD                         = 15,
62892d4d306SBarry Smith   MAT_NO_OFF_PROC_ZERO_ROWS       = 16,
62992d4d306SBarry Smith   MAT_NO_OFF_PROC_ENTRIES         = 17,
63092d4d306SBarry Smith   MAT_NEW_NONZERO_LOCATIONS       = 18,
631c5e4d11fSDmitry Karpeev   MAT_NEW_NONZERO_ALLOCATION_ERR  = 19,
632c5e4d11fSDmitry Karpeev   MAT_SUBSET_OFF_PROC_ENTRIES     = 20,
633c10200c1SHong Zhang   MAT_SUBMAT_SINGLEIS             = 21,
634957cac9fSHong Zhang   MAT_STRUCTURE_ONLY              = 22,
635071fcb05SBarry Smith   MAT_SORTED_FULL                 = 23,
6361a2c6b5cSJunchao Zhang   MAT_FORM_EXPLICIT_TRANSPOSE     = 24,
637b94d7dedSBarry Smith   MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25,
638b94d7dedSBarry Smith   MAT_SPD_ETERNAL                 = 26,
6399371c9d4SSatish Balay   MAT_OPTION_MAX                  = 27
6409371c9d4SSatish Balay } MatOption;
641e057df02SPaul Mullowney 
6420f8fb01aSBarry Smith PETSC_EXTERN const char *const *MatOptions;
643014dd563SJed Brown PETSC_EXTERN PetscErrorCode     MatSetOption(Mat, MatOption, PetscBool);
6447d68702bSBarry Smith PETSC_EXTERN PetscErrorCode     MatGetOption(Mat, MatOption, PetscBool *);
645856afa8bSStefano Zampini PETSC_EXTERN PetscErrorCode     MatPropagateSymmetryOptions(Mat, Mat);
64619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode     MatGetType(Mat, MatType *);
64784cb2905SBarry Smith 
648014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
649014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
650014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
651014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetRowUpperTriangular(Mat);
652014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatRestoreRowUpperTriangular(Mat);
653014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetColumnVector(Mat, Vec, PetscInt);
6548c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArray(Mat, PetscScalar *[]);
6558f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]);
656d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]);
6578c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArray(Mat, PetscScalar *[]);
6588f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]);
659d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]);
66021e72a00SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *);
661bd04181cSBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
6624099cc6bSBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJSetType(Mat, MatType);
663ad7e164aSPierre Jolivet PETSC_EXTERN PetscErrorCode    MatSeqAIJKron(Mat, Mat, MatReuse, Mat *);
664388d47a6SSatish Balay PETSC_EXTERN PetscErrorCode    MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *));
6654099cc6bSBarry Smith PETSC_EXTERN PetscFunctionList MatSeqAIJList;
666cda14afcSprj- PETSC_EXTERN PetscErrorCode    MatSeqBAIJGetArray(Mat, PetscScalar *[]);
667cda14afcSprj- PETSC_EXTERN PetscErrorCode    MatSeqBAIJRestoreArray(Mat, PetscScalar *[]);
6688397e458SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqSBAIJGetArray(Mat, PetscScalar *[]);
6698397e458SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]);
6708c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseGetArray(Mat, PetscScalar *[]);
6718c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseRestoreArray(Mat, PetscScalar *[]);
672d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode    MatDensePlaceArray(Mat, const PetscScalar[]);
673d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseReplaceArray(Mat, const PetscScalar[]);
674d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseResetArray(Mat);
6758572280aSBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseGetArrayRead(Mat, const PetscScalar *[]);
6768572280aSBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayRead(Mat, const PetscScalar *[]);
6776947451fSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseGetArrayWrite(Mat, PetscScalar *[]);
6786947451fSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayWrite(Mat, PetscScalar *[]);
679cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayAndMemType(Mat, PetscScalar *[], PetscMemType *);
680cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayAndMemType(Mat, PetscScalar *[]);
681cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayReadAndMemType(Mat, const PetscScalar *[], PetscMemType *);
682cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayReadAndMemType(Mat, const PetscScalar *[]);
683cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayWriteAndMemType(Mat, PetscScalar *[], PetscMemType *);
684cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayWriteAndMemType(Mat, PetscScalar *[]);
685014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetBlockSize(Mat, PetscInt *);
686014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSize(Mat, PetscInt);
687014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetBlockSizes(Mat, PetscInt *, PetscInt *);
688014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSizes(Mat, PetscInt, PetscInt);
68933d57670SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSizesFromMats(Mat, Mat, Mat);
6900da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode    MatSetVariableBlockSizes(Mat, PetscInt, PetscInt *);
6910da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode    MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt **);
6920da83c2eSBarry Smith 
69386aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]);
69486aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]);
6956947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *);
6966947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *);
6976947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *);
6986947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *);
6996947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *);
7006947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *);
701a2748737SPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
7025ea7661aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *);
7031620fd73SBarry Smith 
704014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec);
705014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec);
706014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec);
707014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec);
708014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec);
709014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *);
710014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *);
711014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec);
712014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec);
713014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat);
714bdc285e1SStefano Zampini PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat);
715eb3ef3b2SHong Zhang PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat);
716f9426fe0SMark Adams PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec);
717f5edf698SHong Zhang 
718d91e6319SBarry Smith /*E
719d91e6319SBarry Smith   MatDuplicateOption - Indicates if a duplicated sparse matrix should have
720d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
721d91e6319SBarry Smith 
7222ef1f0ffSBarry Smith   Values:
7232ef1f0ffSBarry Smith + `MAT_DO_NOT_COPY_VALUES`    - Create a matrix using the same nonzero pattern as the original matrix,
7242ef1f0ffSBarry Smith                                 with zeros for the numerical values
7252ef1f0ffSBarry Smith . `MAT_COPY_VALUES`           - Create a matrix with the same nonzero pattern as the original matrix
7262ef1f0ffSBarry Smith                                 and with the same numerical values.
7272ef1f0ffSBarry Smith - `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix
7282ef1f0ffSBarry Smith                                 and does not copy it, using zeros for the numerical values. The parent and
7292ef1f0ffSBarry Smith                                 child matrices will share their index (i and j) arrays, and you cannot
7302ef1f0ffSBarry Smith                                 insert new nonzero entries into either matrix
7310018da39SRichard Tran Mills 
73216a05f60SBarry Smith   Level: beginner
73316a05f60SBarry Smith 
73487497f52SBarry Smith   Note:
73587497f52SBarry Smith   Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in
73687497f52SBarry Smith   this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified.
73770dcbbb9SBarry Smith 
7381cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicate()`
739d91e6319SBarry Smith E*/
7409371c9d4SSatish Balay typedef enum {
7419371c9d4SSatish Balay   MAT_DO_NOT_COPY_VALUES,
7429371c9d4SSatish Balay   MAT_COPY_VALUES,
7439371c9d4SSatish Balay   MAT_SHARE_NONZERO_PATTERN
7449371c9d4SSatish Balay } MatDuplicateOption;
7452e8a6d31SBarry Smith 
74619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *);
747014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *);
74894a9d846SBarry Smith 
749014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure);
750014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer);
751014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *);
752014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *);
753014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *);
754014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *);
755014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *);
756b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *);
757b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *);
758014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat, PetscBool *, PetscInt *);
759014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer);
7607b80b807SBarry Smith 
7611a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7621a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7631a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7641a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
765d4fbbf0eSBarry Smith 
766d91e6319SBarry Smith /*S
76787497f52SBarry Smith    MatInfo - Context of matrix information, used with `MatGetInfo()`
768d91e6319SBarry Smith 
769d91e6319SBarry Smith    Level: intermediate
770d91e6319SBarry Smith 
7712ef1f0ffSBarry Smith    Fortran Note:
7722ef1f0ffSBarry Smith    Information is stored as a double-precision array of dimension `MAT_INFO_SIZE`
7732ef1f0ffSBarry Smith 
7741cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetInfo()`, `MatInfoType`
775d91e6319SBarry Smith S*/
7764e220ebcSLois Curfman McInnes typedef struct {
777b0a32e0cSBarry Smith   PetscLogDouble block_size;                          /* block size */
778b0a32e0cSBarry Smith   PetscLogDouble nz_allocated, nz_used, nz_unneeded;  /* number of nonzeros */
779b0a32e0cSBarry Smith   PetscLogDouble memory;                              /* memory allocated */
780b0a32e0cSBarry Smith   PetscLogDouble assemblies;                          /* number of matrix assemblies called */
781b0a32e0cSBarry Smith   PetscLogDouble mallocs;                             /* number of mallocs during MatSetValues() */
782b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */
783b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                      /* number of mallocs during factorization */
7844e220ebcSLois Curfman McInnes } MatInfo;
7854e220ebcSLois Curfman McInnes 
786d9274352SBarry Smith /*E
787d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
788d9274352SBarry Smith     the entire parallel matrix or the maximum over all the local parts.
789d9274352SBarry Smith 
7902ef1f0ffSBarry Smith     Values:
7912ef1f0ffSBarry Smith +   `MAT_LOCAL`      - values for each MPI process part of the matrix
7922ef1f0ffSBarry Smith .   `MAT_GLOBAL_MAX` - maximum of each value over all MPI processes
7932ef1f0ffSBarry Smith -   `MAT_GLOBAL_SUM` - sum of each value over all MPI processes
794d9274352SBarry Smith 
79516a05f60SBarry Smith     Level: beginner
79616a05f60SBarry Smith 
7971cc06b55SBarry Smith .seealso: [](ch_matrices), `MatGetInfo()`, `MatInfo`
798d9274352SBarry Smith E*/
7999371c9d4SSatish Balay typedef enum {
8009371c9d4SSatish Balay   MAT_LOCAL      = 1,
8019371c9d4SSatish Balay   MAT_GLOBAL_MAX = 2,
8029371c9d4SSatish Balay   MAT_GLOBAL_SUM = 3
8039371c9d4SSatish Balay } MatInfoType;
804014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *);
805014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec);
806014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]);
807014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]);
808014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]);
809014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]);
810014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec);
811014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *);
8127fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *);
8137fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat);
814014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *);
815014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *);
816014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec);
817014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode);
818a52676ecSHong Zhang 
819014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *);
820014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *);
821014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *);
822014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
823014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
824e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
825e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
826a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
827a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
828cc48ffa7SToby Isaac PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
8294222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
830447fed29SStefano Zampini PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
83186919fd6SHong Zhang PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *);
8327b80b807SBarry Smith 
833014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *);
834014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *);
835857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *);
836857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *);
837857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *);
838857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *);
839857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *);
840857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *);
841857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *);
842014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat);
8431b2b9847SBarry Smith PETSC_EXTERN PetscErrorCode MatSetInf(Mat);
844014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
845014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec);
846014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
847014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
848014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
849014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec);
8507b80b807SBarry Smith 
851014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *);
852014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *);
853014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *);
854014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **);
855014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *);
856014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **);
857566876eaSJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *);
8585ef9f2a5SBarry Smith 
8597dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
860edd03b47SJacob Faibussowitsch 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[])
861d71ae5a4SJacob Faibussowitsch {
8629371c9d4SSatish Balay   return MatCreateSubMatrices(mat, n, irow, icol, scall, submat);
8639371c9d4SSatish Balay }
8647dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
865edd03b47SJacob Faibussowitsch 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[])
866d71ae5a4SJacob Faibussowitsch {
8679371c9d4SSatish Balay   return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat);
8689371c9d4SSatish Balay }
869014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]);
870df750dc8SHong Zhang PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]);
8717dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *);
872edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatrix()", ) static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat)
873d71ae5a4SJacob Faibussowitsch {
8749371c9d4SSatish Balay   return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat);
8759371c9d4SSatish Balay }
876014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *);
877014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *);
878014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *);
879014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *);
8807b80b807SBarry Smith 
881014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *);
882014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *);
883014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat);
884014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *);
8858a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *);
886014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
887ed502f03SStefano Zampini PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *);
888f2afee66SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *);
889014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *);
890014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]);
8918efafbd8SBarry Smith 
892014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt);
893aa1e27eaSFande Kong PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat mat, PetscInt n, IS is[], PetscInt ov);
894d2b2a242SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool);
8957b80b807SBarry Smith 
896014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
89722440eb1SKris Buschelman 
8987bab7c10SHong Zhang PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
8992df6c5c3SPatrick Farrell PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
9007bab7c10SHong Zhang 
901014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *);
902014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *);
90322440eb1SKris Buschelman 
904014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
905014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *);
906bc011b1eSHong Zhang 
907014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure);
908014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure);
9091c741599SHong Zhang 
910014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar);
911014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar);
9127b80b807SBarry Smith 
913014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping);
914014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
915a93ff8c4SPeter Brune PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *);
91681fa06acSBarry Smith PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout);
917014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
918014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
919014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
920014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
921e265f6d6SPatrick Sanan PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
922014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
923014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
924052efed2SBarry Smith 
925014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt);
926014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
92790f02eecSBarry Smith 
928014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec);
929014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec);
930014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec);
93130b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *);
93230b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *);
93330b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *);
9342a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *);
935edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 6, 0, "MatCreateVecs()", ) static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y)
936d71ae5a4SJacob Faibussowitsch {
9379371c9d4SSatish Balay   return MatCreateVecs(mat, x, y);
9389371c9d4SSatish Balay }
93953cd1579SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *);
940014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *);
941014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *);
9423a062f41SBarry Smith PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *);
9439c8f2541SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *);
944bd481603SBarry Smith 
945c8d6c325SJunchao Zhang /*@C
9461620fd73SBarry Smith    MatSetValue - Set a single entry into a matrix.
9471620fd73SBarry Smith 
948e1c5b2e2SJose E. Roman    Not Collective
949a9834a7dSSatish Balay 
9501620fd73SBarry Smith    Input Parameters:
951c8d6c325SJunchao Zhang +  mat  - the matrix
95216a05f60SBarry Smith .  i    - the row location of the entry
95316a05f60SBarry Smith .  j    - the column location of the entry
95416a05f60SBarry Smith .  va   - the value to insert
95587497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
9561620fd73SBarry Smith 
9571620fd73SBarry Smith    Level: beginner
9581620fd73SBarry Smith 
95995bd0b28SBarry Smith    Notes:
96095bd0b28SBarry Smith    This value may be cached, so `MatAssemblyBegin()` and `MatAssemblyEnd()`
96195bd0b28SBarry Smith    MUST be called after all calls to `MatSetValue()` have been completed.
96295bd0b28SBarry Smith 
9632ef1f0ffSBarry Smith    For efficiency one should use `MatSetValues()` and set several values simultaneously.
9642ef1f0ffSBarry Smith 
965b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `InsertMode`, `MatGetValue()`, `MatSetValues()`,
9662ef1f0ffSBarry Smith           `MatSetValueLocal()`, `MatSetValuesLocal()`
967c8d6c325SJunchao Zhang @*/
968c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValue(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
969d71ae5a4SJacob Faibussowitsch {
970c8d6c325SJunchao Zhang   return MatSetValues(mat, 1, &i, 1, &j, &va, mode);
9719371c9d4SSatish Balay }
9721620fd73SBarry Smith 
973e5e5a7b5SPatrick Sanan /*@C
974e5e5a7b5SPatrick Sanan    MatGetValue - Gets a single value from a matrix
9751620fd73SBarry Smith 
976e5e5a7b5SPatrick Sanan    Not Collective; can only return a value owned by the given process
977e5e5a7b5SPatrick Sanan 
978e5e5a7b5SPatrick Sanan    Input Parameters:
979e5e5a7b5SPatrick Sanan +  mat - the matrix
980e5e5a7b5SPatrick Sanan .  row - the row location of the entry
981e5e5a7b5SPatrick Sanan -  col - the column location of the entry
982e5e5a7b5SPatrick Sanan 
983e5e5a7b5SPatrick Sanan    Output Parameter:
984e5e5a7b5SPatrick Sanan .  va - the value
985e5e5a7b5SPatrick Sanan 
9862ef1f0ffSBarry Smith    Level: advanced
9872ef1f0ffSBarry Smith 
988e5e5a7b5SPatrick Sanan    Notes:
989b43fc34aSPierre Jolivet    The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd()` before this call
9902ef1f0ffSBarry Smith 
99187497f52SBarry Smith    For efficiency one should use `MatGetValues()` and get several values simultaneously.
992e5e5a7b5SPatrick Sanan 
99387497f52SBarry Smith    See notes for `MatGetValues()`.
994e5e5a7b5SPatrick Sanan 
995b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValue()`, `MatGetValueLocal()`, `MatGetValues()`
996e5e5a7b5SPatrick Sanan @*/
997d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va)
998d71ae5a4SJacob Faibussowitsch {
9999371c9d4SSatish Balay   return MatGetValues(mat, 1, &row, 1, &col, va);
10009371c9d4SSatish Balay }
1001e5e5a7b5SPatrick Sanan 
1002c8d6c325SJunchao Zhang /*@C
10032ef1f0ffSBarry Smith    MatSetValueLocal - Inserts or adds a single value into a matrix, using a local numbering of the nodes.
1004e5e5a7b5SPatrick Sanan 
1005e5e5a7b5SPatrick Sanan    Not Collective
1006e5e5a7b5SPatrick Sanan 
1007e5e5a7b5SPatrick Sanan    Input Parameters:
1008c8d6c325SJunchao Zhang +  mat  - the matrix
100916a05f60SBarry Smith .  i    - the row location of the entry
101016a05f60SBarry Smith .  j    - the column location of the entry
101116a05f60SBarry Smith .  va   - the value to insert
101287497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
1013e5e5a7b5SPatrick Sanan 
10142ef1f0ffSBarry Smith    Level: intermediate
10152ef1f0ffSBarry Smith 
1016e5e5a7b5SPatrick Sanan    Notes:
101787497f52SBarry Smith    For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously.
1018e5e5a7b5SPatrick Sanan 
101987497f52SBarry Smith    See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used.
1020e5e5a7b5SPatrick Sanan 
10211cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSetValue()`, `MatSetValuesLocal()`
1022c8d6c325SJunchao Zhang @*/
1023c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValueLocal(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
1024d71ae5a4SJacob Faibussowitsch {
1025c8d6c325SJunchao Zhang   return MatSetValuesLocal(mat, 1, &i, 1, &j, &va, mode);
10269371c9d4SSatish Balay }
10271620fd73SBarry Smith 
10281620fd73SBarry Smith /*MC
1029d0609cedSBarry Smith    MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per
1030bd481603SBarry Smith    row in a matrix providing the data that one can use to correctly preallocate the matrix.
1031bd481603SBarry Smith 
1032bd481603SBarry Smith    Synopsis:
1033aaa7dc30SBarry Smith    #include <petscmat.h>
1034d0609cedSBarry Smith    PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
1035bd481603SBarry Smith 
1036d083f849SBarry Smith    Collective
1037bd481603SBarry Smith 
1038bd481603SBarry Smith    Input Parameters:
1039bd481603SBarry Smith +  comm  - the communicator that will share the eventually allocated matrix
1040859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
1041859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
1042bd481603SBarry Smith 
1043bd481603SBarry Smith    Output Parameters:
1044bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
1045a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1046bd481603SBarry Smith 
10472ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1048bd481603SBarry Smith 
1049bd481603SBarry Smith    Notes:
10502ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
10512ef1f0ffSBarry Smith    the use of this routine
10522ef1f0ffSBarry Smith 
1053d0609cedSBarry Smith    This is a macro that handles its own error checking, it does not return an error code.
1054d0609cedSBarry Smith 
10552ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1056bd481603SBarry Smith 
10572ef1f0ffSBarry Smith    Developer Note:
1058af27ebaaSBarry Smith    This is a MACRO, not a function, because it has a leading { that is closed by `PetscPreallocateFinalize()`.
1059bd481603SBarry Smith 
10601cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1061db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
1062bd481603SBarry Smith M*/
10639371c9d4SSatish Balay #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \
10649371c9d4SSatish Balay   do { \
10653ba16761SJacob Faibussowitsch     PetscInt              __nrows = (nrows), __ncols = (ncols), __rstart, __end = 0; \
10663ba16761SJacob Faibussowitsch     PetscInt PETSC_UNUSED __start; \
10679566063dSJacob Faibussowitsch     PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \
10689566063dSJacob Faibussowitsch     PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \
10699371c9d4SSatish Balay     __start = __end - __ncols; \
10709371c9d4SSatish Balay     (void)__start; \
10719566063dSJacob Faibussowitsch     PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \
10725f80ce2aSJacob Faibussowitsch   __rstart -= __nrows
10737c922b88SBarry Smith 
1074edd03b47SJacob Faibussowitsch #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateBegin()", ) MatPreallocateBegin(__VA_ARGS__)
1075d0609cedSBarry Smith 
1076bd481603SBarry Smith /*MC
1077bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1078bd481603SBarry Smith    inserted using a local number of the rows and columns
1079bd481603SBarry Smith 
1080bd481603SBarry Smith    Synopsis:
1081aaa7dc30SBarry Smith    #include <petscmat.h>
1082c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1083bd481603SBarry Smith 
1084bd481603SBarry Smith    Not Collective
1085bd481603SBarry Smith 
1086bd481603SBarry Smith    Input Parameters:
1087784ac674SJed Brown +  map   - the row mapping from local numbering to global numbering
1088bd481603SBarry Smith .  nrows - the number of rows indicated
10891d73ed98SBarry Smith .  rows  - the indices of the rows
1090784ac674SJed Brown .  cmap  - the column mapping from local to global numbering
1091bd481603SBarry Smith .  ncols - the number of columns in the matrix
1092bd481603SBarry Smith .  cols  - the columns indicated
1093bd481603SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1094a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1095bd481603SBarry Smith 
10962ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1097bd481603SBarry Smith 
1098bd481603SBarry Smith    Notes:
10992ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11002ef1f0ffSBarry Smith    the use of this routine
1101bd481603SBarry Smith 
11022ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1103bd481603SBarry Smith 
11041cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1105db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()`
1106bd481603SBarry Smith M*/
110794bad497SJacob Faibussowitsch #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
11089371c9d4SSatish Balay   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));)
1109c4f061fbSSatish Balay 
1110bd481603SBarry Smith /*MC
1111c1154cd5SBarry Smith    MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1112c1154cd5SBarry Smith    inserted using a local number of the rows and columns. This version removes any duplicate columns in cols
1113c1154cd5SBarry Smith 
1114c1154cd5SBarry Smith    Synopsis:
1115c1154cd5SBarry Smith    #include <petscmat.h>
1116c1154cd5SBarry Smith    PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1117c1154cd5SBarry Smith 
1118c1154cd5SBarry Smith    Not Collective
1119c1154cd5SBarry Smith 
1120c1154cd5SBarry Smith    Input Parameters:
1121c1154cd5SBarry Smith +  map   - the row mapping from local numbering to global numbering
1122c1154cd5SBarry Smith .  nrows - the number of rows indicated
1123c1154cd5SBarry Smith .  rows  - the indices of the rows (these values are mapped to the global values)
1124c1154cd5SBarry Smith .  cmap  - the column mapping from local to global numbering
1125c1154cd5SBarry Smith .  ncols - the number of columns in the matrix   (this value will be changed if duplicate columns are found)
1126c1154cd5SBarry Smith .  cols  - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed)
1127c1154cd5SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1128a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1129c1154cd5SBarry Smith 
11302ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1131c1154cd5SBarry Smith 
1132c1154cd5SBarry Smith    Notes:
11332ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11342ef1f0ffSBarry Smith    the use of this routine
1135c1154cd5SBarry Smith 
11362ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1137c1154cd5SBarry Smith 
11381cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1139db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1140c1154cd5SBarry Smith M*/
114194bad497SJacob Faibussowitsch #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
11429371c9d4SSatish Balay   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));)
1143c1154cd5SBarry Smith 
1144c1154cd5SBarry Smith /*MC
1145d6e23781SBarry Smith    MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1146bd481603SBarry Smith    inserted using a local number of the rows and columns
1147bd481603SBarry Smith 
1148bd481603SBarry Smith    Synopsis:
1149aaa7dc30SBarry Smith    #include <petscmat.h>
1150d6e23781SBarry Smith    PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1151d6e23781SBarry Smith 
1152d6e23781SBarry Smith    Not Collective
1153d6e23781SBarry Smith 
1154d6e23781SBarry Smith    Input Parameters:
1155d6e23781SBarry Smith +  map   - the row mapping from local numbering to global numbering
1156d6e23781SBarry Smith .  nrows - the number of rows indicated
1157d6e23781SBarry Smith .  rows  - the indices of the rows
1158d6e23781SBarry Smith .  cmap  - the column mapping from local to global numbering
1159d6e23781SBarry Smith .  ncols - the number of columns in the matrix
1160d6e23781SBarry Smith .  cols  - the columns indicated
1161d6e23781SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1162a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1163d6e23781SBarry Smith 
11642ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1165d6e23781SBarry Smith 
1166d6e23781SBarry Smith    Notes:
11672ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11682ef1f0ffSBarry Smith    the use of this routine
1169d6e23781SBarry Smith 
11702ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1171d6e23781SBarry Smith 
11721cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1173db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`
1174d6e23781SBarry Smith M*/
117594bad497SJacob Faibussowitsch #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
11769371c9d4SSatish Balay   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));)
1177d6e23781SBarry Smith 
1178d6e23781SBarry Smith /*MC
1179d6e23781SBarry Smith    MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1180d6e23781SBarry Smith    inserted using a local number of the rows and columns
1181d6e23781SBarry Smith 
1182d6e23781SBarry Smith    Synopsis:
1183d6e23781SBarry Smith    #include <petscmat.h>
1184d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1185bd481603SBarry Smith 
1186bd481603SBarry Smith    Not Collective
1187bd481603SBarry Smith 
1188bd481603SBarry Smith    Input Parameters:
1189bd481603SBarry Smith +  map   - the mapping between local numbering and global numbering
1190bd481603SBarry Smith .  nrows - the number of rows indicated
11911d73ed98SBarry Smith .  rows  - the indices of the rows
1192bd481603SBarry Smith .  ncols - the number of columns in the matrix
1193bd481603SBarry Smith .  cols  - the columns indicated
1194bd481603SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1195a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1196bd481603SBarry Smith 
11972ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1198bd481603SBarry Smith 
1199bd481603SBarry Smith    Notes:
12002ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
12012ef1f0ffSBarry Smith    the use of this routine
1202bd481603SBarry Smith 
12032ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1204bd481603SBarry Smith 
12051cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`
1206db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1207bd481603SBarry Smith M*/
120894bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \
12099371c9d4SSatish Balay   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));)
1210e83a5d19SLisandro Dalcin 
1211bd481603SBarry Smith /*MC
1212bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1213bd481603SBarry Smith    inserted using a local number of the rows and columns
1214bd481603SBarry Smith 
1215bd481603SBarry Smith    Synopsis:
1216aaa7dc30SBarry Smith    #include <petscmat.h>
1217c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1218bd481603SBarry Smith 
1219bd481603SBarry Smith    Not Collective
1220bd481603SBarry Smith 
1221bd481603SBarry Smith    Input Parameters:
122264075487SBarry Smith +  row   - the row
1223bd481603SBarry Smith .  ncols - the number of columns in the matrix
1224a50f8bf6SHong Zhang -  cols  - the columns indicated
1225a50f8bf6SHong Zhang 
1226a50f8bf6SHong Zhang    Output Parameters:
1227a50f8bf6SHong Zhang +  dnz - the array that will be passed to the matrix preallocation routines
1228a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1229bd481603SBarry Smith 
12302ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1231bd481603SBarry Smith 
1232bd481603SBarry Smith    Notes:
12332ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
12342ef1f0ffSBarry Smith    the use of this routine
1235bd481603SBarry Smith 
12362ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1237bd481603SBarry Smith 
1238af27ebaaSBarry Smith    This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin().
12391620fd73SBarry Smith 
12401cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1241db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1242bd481603SBarry Smith M*/
12439371c9d4SSatish Balay #define MatPreallocateSet(row, nc, cols, dnz, onz) \
12449371c9d4SSatish Balay   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) { \
124564075487SBarry Smith     if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \
1246a6042fd4SStefano Zampini     else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \
12479371c9d4SSatish Balay   })
12487c922b88SBarry Smith 
1249bd481603SBarry Smith /*MC
1250d6e23781SBarry Smith    MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1251bd481603SBarry Smith    inserted using a local number of the rows and columns
1252bd481603SBarry Smith 
1253bd481603SBarry Smith    Synopsis:
1254aaa7dc30SBarry Smith    #include <petscmat.h>
1255d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1256bd481603SBarry Smith 
1257bd481603SBarry Smith    Not Collective
1258bd481603SBarry Smith 
1259bd481603SBarry Smith    Input Parameters:
1260bd481603SBarry Smith +  nrows - the number of rows indicated
12611d73ed98SBarry Smith .  rows  - the indices of the rows
1262bd481603SBarry Smith .  ncols - the number of columns in the matrix
1263bd481603SBarry Smith .  cols  - the columns indicated
1264bd481603SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1265a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1266bd481603SBarry Smith 
12672ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1268bd481603SBarry Smith 
1269bd481603SBarry Smith    Notes:
12702ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
12712ef1f0ffSBarry Smith    the use of this routine
1272bd481603SBarry Smith 
12732ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1274bd481603SBarry Smith 
1275af27ebaaSBarry Smith    This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin().
12761620fd73SBarry Smith 
12771cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`,
1278db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1279bd481603SBarry Smith M*/
128094bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \
12819371c9d4SSatish Balay   PetscMacroReturnStandard(for (PetscInt __i = 0; __i < nc; __i++) { \
1282d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
1283a6042fd4SStefano Zampini     else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \
12849371c9d4SSatish Balay   })
1285d3d32019SBarry Smith 
1286bd481603SBarry Smith /*MC
1287a6042fd4SStefano Zampini    MatPreallocateLocation -  An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists
128816371a99SBarry Smith 
128916371a99SBarry Smith    Synopsis:
1290aaa7dc30SBarry Smith    #include <petscmat.h>
129116371a99SBarry Smith    PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz)
129216371a99SBarry Smith 
129316371a99SBarry Smith    Not Collective
129416371a99SBarry Smith 
129516371a99SBarry Smith    Input Parameters:
1296a2b725a8SWilliam Gropp +  A     - matrix
129716371a99SBarry Smith .  row   - row where values exist (must be local to this process)
129816371a99SBarry Smith .  ncols - number of columns
129916371a99SBarry Smith .  cols  - columns with nonzeros
130016371a99SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1301a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
130216371a99SBarry Smith 
13032ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
130416371a99SBarry Smith 
130516371a99SBarry Smith    Notes:
13062ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
13072ef1f0ffSBarry Smith    the use of this routine
130816371a99SBarry Smith 
13092ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
131016371a99SBarry Smith 
1311af27ebaaSBarry Smith    Developer Note:
1312af27ebaaSBarry Smith    This is a MACRO, not a function, because it uses a bunch of variables private to the MatPreallocation.... routines.
131316371a99SBarry Smith 
13141cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1315db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
131616371a99SBarry Smith M*/
1317d0609cedSBarry Smith #define MatPreallocateLocation(A, row, ncols, cols, dnz, onz) (A ? MatSetValues(A, 1, &row, ncols, cols, NULL, INSERT_VALUES) : MatPreallocateSet(row, ncols, cols, dnz, onz))
131816371a99SBarry Smith 
131916371a99SBarry Smith /*MC
1320d0609cedSBarry Smith    MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per
1321bd481603SBarry Smith    row in a matrix providing the data that one can use to correctly preallocate the matrix.
1322bd481603SBarry Smith 
1323bd481603SBarry Smith    Synopsis:
1324aaa7dc30SBarry Smith    #include <petscmat.h>
1325d0609cedSBarry Smith    PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz)
1326bd481603SBarry Smith 
1327d083f849SBarry Smith    Collective
1328bd481603SBarry Smith 
1329bd481603SBarry Smith    Input Parameters:
133016371a99SBarry Smith +  dnz - the array that was be passed to the matrix preallocation routines
1331a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1332bd481603SBarry Smith 
13332ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1334bd481603SBarry Smith 
1335bd481603SBarry Smith    Notes:
13362ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
13372ef1f0ffSBarry Smith    the use of this routine
1338d0609cedSBarry Smith 
13392ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1340bd481603SBarry Smith 
13412ef1f0ffSBarry Smith    Developer Note:
1342af27ebaaSBarry Smith    This is a MACRO, not a function, because it closes the { started in MatPreallocateBegin().
13431620fd73SBarry Smith 
13441cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1345db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
1346bd481603SBarry Smith M*/
13479371c9d4SSatish Balay #define MatPreallocateEnd(dnz, onz) \
13489371c9d4SSatish Balay   PetscCall(PetscFree2(dnz, onz)); \
13499371c9d4SSatish Balay   } \
13509371c9d4SSatish Balay   while (0)
1351d0609cedSBarry Smith 
1352edd03b47SJacob Faibussowitsch #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateEnd()", ) MatPreallocateEnd(__VA_ARGS__)
13537c922b88SBarry Smith 
13547b80b807SBarry Smith /* Routines unique to particular data structures */
1355014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, void *);
1356698d4c6aSKris Buschelman 
1357014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *);
1358014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *);
1359698d4c6aSKris Buschelman 
1360014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]);
1361014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]);
1362014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1363014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1364014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscInt, PetscBool);
13667b80b807SBarry Smith 
1367a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4
1368a96a251dSBarry Smith 
1369014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1370014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1371014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]);
137219b08ed1SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt);
1373273d9f13SBarry Smith 
1374014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1375014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1376014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1377014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1378014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1379014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1380014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1381014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]);
1382b44e7856SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *);
1383252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *);
1384014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]);
1385014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]);
13869230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
13879230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
1388014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *);
1389273d9f13SBarry Smith 
139049a6ff4bSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *);
1391ad16ce7aSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt);
1392edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatDenseSetLDA()", ) static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda)
1393d71ae5a4SJacob Faibussowitsch {
13949371c9d4SSatish Balay   return MatDenseSetLDA(A, lda);
13959371c9d4SSatish Balay }
1396014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *);
13971b807ce4Svictorle 
1398621e819fSSatish Balay PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1399621e819fSSatish Balay 
1400014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStoreValues(Mat);
1401014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat);
14022e8a6d31SBarry Smith 
1403014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *);
14047cfe41e4SPatrick Farrell PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *);
14057b80b807SBarry Smith /*
14067b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
140794b7f48cSBarry Smith   done through the KSP and PC interfaces.
14087b80b807SBarry Smith */
14097b80b807SBarry Smith 
141076bdecfbSBarry Smith /*J
14112ef1f0ffSBarry Smith    MatOrderingType - String with the name of a PETSc matrix ordering. These orderings are most commonly used
14122ef1f0ffSBarry Smith    to reduce fill in sparse factorizations.
1413d9274352SBarry Smith 
1414d9274352SBarry Smith    Level: beginner
1415d9274352SBarry Smith 
14162c7c0729SBarry Smith    Notes:
141716a05f60SBarry Smith    If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and instead the external factorization solver package called utilizes one
141816a05f60SBarry Smith    of its own.
14192c7c0729SBarry Smith 
14202ef1f0ffSBarry Smith    There is no `MatOrdering` object, the ordering is obtained directly from the matrix with `MatGetOrdering()`
14212ef1f0ffSBarry Smith 
14222ef1f0ffSBarry Smith    Developer Note:
14232ef1f0ffSBarry Smith    This API should be converted to an API similar to those for `MatColoring` and `MatPartitioning`
14242ef1f0ffSBarry Smith 
14251cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatGetFactor()`, `MatGetOrdering()`, `MatColoringType`, `MatPartitioningType`, `MatCoarsenType`, `MatCoarsenType`,
14262ef1f0ffSBarry Smith           `PCFactorSetOrderingType()`
142776bdecfbSBarry Smith J*/
142819fd82e9SBarry Smith typedef const char *MatOrderingType;
14292692d6eeSBarry Smith #define MATORDERINGNATURAL       "natural"
14302692d6eeSBarry Smith #define MATORDERINGND            "nd"
14312692d6eeSBarry Smith #define MATORDERING1WD           "1wd"
14322692d6eeSBarry Smith #define MATORDERINGRCM           "rcm"
14332692d6eeSBarry Smith #define MATORDERINGQMD           "qmd"
14342692d6eeSBarry Smith #define MATORDERINGROWLENGTH     "rowlength"
1435510184a7SJed Brown #define MATORDERINGWBM           "wbm"
1436fc1bef75SJed Brown #define MATORDERINGSPECTRAL      "spectral"
1437312e372aSBarry Smith #define MATORDERINGAMD           "amd"           /* only works if UMFPACK is installed with PETSc */
1438048412efSPablo Brubeck #define MATORDERINGMETISND       "metisnd"       /* only works if METIS is installed with PETSc */
14399bd791bbSBarry Smith #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 */
14402c7c0729SBarry Smith #define MATORDERINGEXTERNAL      "external"      /* uses an ordering type internal to the factorization package */
1441b12f92e5SBarry Smith 
144219fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode    MatGetOrdering(Mat, MatOrderingType, IS *, IS *);
1443140e18c1SBarry Smith PETSC_EXTERN PetscErrorCode    MatGetOrderingList(PetscFunctionList *);
1444bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode    MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *));
1445140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatOrderingList;
1446d4fbbf0eSBarry Smith 
1447013e2dc7SBarry Smith #include "petscmatcoarsen.h"
1448013e2dc7SBarry Smith 
1449014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS);
1450fc1bef75SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *);
1451a2ce50c7SBarry Smith 
14524ac6704cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *);
14534ac6704cSBarry Smith 
1454d91e6319SBarry Smith /*S
14552ef1f0ffSBarry Smith    MatFactorShiftType - Type of numeric shift used for factorizations
1456d90ac83dSHong Zhang 
14572ef1f0ffSBarry Smith    Values:
14582ef1f0ffSBarry Smith +  `MAT_SHIFT_NONE`              - do not shift the matrix diagonal entries
14592ef1f0ffSBarry Smith .  `MAT_SHIFT_NONZERO`           - shift the entries to be non-zero
14602ef1f0ffSBarry Smith .  `MAT_SHIFT_POSITIVE_DEFINITE` - shift the entries to force the factorization to be positive definite
14612ef1f0ffSBarry Smith -  `MAT_SHIFT_INBLOCKS`          - only shift the factors inside the small dense diagonal blocks of the matrix, for example with `MATBAIJ`
1462d90ac83dSHong Zhang 
14632ef1f0ffSBarry Smith    Level: intermediate
14642ef1f0ffSBarry Smith 
14651cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `PCFactorSetShiftType()`
1466d90ac83dSHong Zhang S*/
14679371c9d4SSatish Balay typedef enum {
14689371c9d4SSatish Balay   MAT_SHIFT_NONE,
14699371c9d4SSatish Balay   MAT_SHIFT_NONZERO,
14709371c9d4SSatish Balay   MAT_SHIFT_POSITIVE_DEFINITE,
14719371c9d4SSatish Balay   MAT_SHIFT_INBLOCKS
14729371c9d4SSatish Balay } MatFactorShiftType;
14736a6fc655SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypes[];
14745e9742b9SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypesDetail[];
1475d90ac83dSHong Zhang 
1476d90ac83dSHong Zhang /*S
1477ec5066bdSBarry Smith     MatFactorError - indicates what type of error was generated in a matrix factorization
14789aa7eafdSHong Zhang 
14792ef1f0ffSBarry Smith     Values:
14802ef1f0ffSBarry Smith +   `MAT_FACTOR_NOERROR`           - there was no error during the factorization
14812ef1f0ffSBarry Smith .   `MAT_FACTOR_STRUCT_ZEROPIVOT`  - there was a missing entry in a diagonal location of the matrix
14822ef1f0ffSBarry Smith .   `MAT_FACTOR_NUMERIC_ZEROPIVOT` - there was a (near) zero pivot during the factorization
14832ef1f0ffSBarry Smith .   `MAT_FACTOR_OUTMEMORY`         - the factorization has run out of memory
14842ef1f0ffSBarry Smith -   `MAT_FACTOR_OTHER`             - some other error has occurred.
14859aa7eafdSHong Zhang 
14862ef1f0ffSBarry Smith     Level: intermediate
148700e125f8SBarry Smith 
14882ef1f0ffSBarry Smith     Note:
14892ef1f0ffSBarry Smith     When a factorization is done in a preconditioner `PC` the error may be propagated up to a `PCFailedReason` or a `KSPConvergedReason`
14902ef1f0ffSBarry Smith 
14911cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `MatFactorGetError()`, `MatFactorGetErrorZeroPivot()`, `MatFactorClearError()`,
14922ef1f0ffSBarry Smith           `PCFailedReason`, `PCGetFailedReason()`, `KSPConvergedReason`
14939aa7eafdSHong Zhang S*/
14949371c9d4SSatish Balay typedef enum {
14959371c9d4SSatish Balay   MAT_FACTOR_NOERROR,
14969371c9d4SSatish Balay   MAT_FACTOR_STRUCT_ZEROPIVOT,
14979371c9d4SSatish Balay   MAT_FACTOR_NUMERIC_ZEROPIVOT,
14989371c9d4SSatish Balay   MAT_FACTOR_OUTMEMORY,
14999371c9d4SSatish Balay   MAT_FACTOR_OTHER
15009371c9d4SSatish Balay } MatFactorError;
15019aa7eafdSHong Zhang 
150200e125f8SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *);
1503b8b68cfdSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat);
15047b6c816cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *);
150500e125f8SBarry Smith 
15069aa7eafdSHong Zhang /*S
1507422a814eSBarry Smith    MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization
1508b00f7748SHong Zhang 
1509b00f7748SHong Zhang    Level: developer
1510b00f7748SHong Zhang 
15112ef1f0ffSBarry Smith    Note:
15122ef1f0ffSBarry Smith    You can use `MatFactorInfoInitialize()` to set default values.
1513b00f7748SHong Zhang 
15142ef1f0ffSBarry Smith    Fortran Note:
15152ef1f0ffSBarry Smith    The data is available in a double precision arrays of size `MAT_FACTORINFO_SIZE`
15162ef1f0ffSBarry Smith 
15171cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatInfo`, `MatGetFactor()`, `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`,
15182ef1f0ffSBarry Smith           `MatICCFactorSymbolic()`, `MatICCFactor()`, `MatFactorInfoInitialize()`
1519b00f7748SHong Zhang S*/
1520b00f7748SHong Zhang typedef struct {
152115e8a5b3SHong Zhang   PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */
152285317021SBarry Smith   PetscReal usedt;
152315e8a5b3SHong Zhang   PetscReal dt;            /* drop tolerance */
1524b00f7748SHong Zhang   PetscReal dtcol;         /* tolerance for pivoting */
152515e8a5b3SHong Zhang   PetscReal dtcount;       /* maximum nonzeros to be allowed per row */
152667e28bfeSBarry Smith   PetscReal fill;          /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */
1527348344bbSBarry Smith   PetscReal levels;        /* ICC/ILU(levels) */
1528bcd9e38bSBarry Smith   PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
1529bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
153015e8a5b3SHong Zhang   PetscReal zeropivot;     /* pivot is called zero if less than this */
1531f4db908eSBarry Smith   PetscReal shifttype;     /* type of shift added to matrix factor to prevent zero pivots */
1532f4db908eSBarry Smith   PetscReal shiftamount;   /* how large the shift is */
153315e8a5b3SHong Zhang } MatFactorInfo;
1534ffa6d0a5SLois Curfman McInnes 
1535014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *);
15369a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *);
15379a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15389a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *);
15399a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *);
15409a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *);
15419a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
15429a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
15439a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15449a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *);
15459a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *);
15463f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *);
15473f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15483f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *);
1549014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *);
1550014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec);
1551014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec);
1552014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec);
1553014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec);
1554014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec);
1555014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec);
1556014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs);
15577c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat);
15587c2f51b8SStefano Zampini 
15599371c9d4SSatish Balay typedef enum {
15609371c9d4SSatish Balay   MAT_FACTOR_SCHUR_UNFACTORED,
15619371c9d4SSatish Balay   MAT_FACTOR_SCHUR_FACTORED,
15629371c9d4SSatish Balay   MAT_FACTOR_SCHUR_INVERTED
15639371c9d4SSatish Balay } MatFactorSchurStatus;
15648e7ba810SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS);
15657c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
15667c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus);
15675a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat);
15687c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
15695a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec);
15705a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec);
15716dba178dSStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat);
1572bb5a7306SBarry Smith 
15738a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat);
1574d91e6319SBarry Smith /*E
1575d91e6319SBarry Smith    MatSORType - What type of (S)SOR to perform
1576bb1eb677SSatish Balay 
15772ef1f0ffSBarry Smith    Values:
15782ef1f0ffSBarry Smith +  `SOR_FORWARD_SWEEP`         - do a sweep from the first row of the matrix to the last
15792ef1f0ffSBarry Smith .  `SOR_BACKWARD_SWEEP`        - do a sweep from the last row to the first
15802ef1f0ffSBarry Smith .  `SOR_SYMMETRIC_SWEEP`       - do a sweep from the first row to the last and then back to the first
1581af27ebaaSBarry Smith .  `SOR_LOCAL_FORWARD_SWEEP`   - each MPI process does its own forward sweep with no communication
1582af27ebaaSBarry Smith .  `SOR_LOCAL_BACKWARD_SWEEP`  - each MPI process does its own backward sweep with no communication
1583af27ebaaSBarry Smith .  `SOR_LOCAL_SYMMETRIC_SWEEP` - each MPI process does its own symmetric sweep with no communication
15842ef1f0ffSBarry Smith .  `SOR_ZERO_INITIAL_GUESS`    - indicates the initial solution is zero so the sweep can avoid unneeded computation
15852ef1f0ffSBarry Smith .  `SOR_EISENSTAT`             - apply the Eisentat application of SOR, see `PCEISENSTAT`
15862ef1f0ffSBarry Smith .  `SOR_APPLY_UPPER`           - multiply by the upper triangular portion of the matrix
15872ef1f0ffSBarry Smith -  `SOR_APPLY_LOWER`           - multiply by the lower triangular portion of the matrix
15882ef1f0ffSBarry Smith 
1589d91e6319SBarry Smith    Level: beginner
1590d91e6319SBarry Smith 
15912ef1f0ffSBarry Smith    Note:
15922ef1f0ffSBarry Smith    These may be bitwise ORd together
1593d9274352SBarry Smith 
15942ef1f0ffSBarry Smith    Developer Note:
15952ef1f0ffSBarry Smith    Since `MatSORType` may be bitwise ORd together, so do not change the numerical values below
1596d91e6319SBarry Smith 
15971cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSOR()`
1598d91e6319SBarry Smith E*/
15999371c9d4SSatish Balay typedef enum {
16009371c9d4SSatish Balay   SOR_FORWARD_SWEEP         = 1,
16019371c9d4SSatish Balay   SOR_BACKWARD_SWEEP        = 2,
16029371c9d4SSatish Balay   SOR_SYMMETRIC_SWEEP       = 3,
16039371c9d4SSatish Balay   SOR_LOCAL_FORWARD_SWEEP   = 4,
16049371c9d4SSatish Balay   SOR_LOCAL_BACKWARD_SWEEP  = 8,
16059371c9d4SSatish Balay   SOR_LOCAL_SYMMETRIC_SWEEP = 12,
16069371c9d4SSatish Balay   SOR_ZERO_INITIAL_GUESS    = 16,
16079371c9d4SSatish Balay   SOR_EISENSTAT             = 32,
16089371c9d4SSatish Balay   SOR_APPLY_UPPER           = 64,
16099371c9d4SSatish Balay   SOR_APPLY_LOWER           = 128
16109371c9d4SSatish Balay } MatSORType;
1611014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec);
16128ed539a5SBarry Smith 
16137086a01eSPeter Brune /*S
16147086a01eSPeter Brune    MatColoring - Object for managing the coloring of matrices.
16157086a01eSPeter Brune 
16167086a01eSPeter Brune    Level: beginner
16177086a01eSPeter Brune 
1618ec5066bdSBarry Smith    Notes:
161987497f52SBarry Smith    Coloring of matrices can be computed directly from the sparse matrix nonzero structure via the `MatColoring` object or from the mesh from which the
162087497f52SBarry Smith    matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors).
1621ec5066bdSBarry Smith 
162287497f52SBarry Smith    Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This
16232ef1f0ffSBarry Smith    same object can also be used to efficiently convert data created by Automatic Differentiation tools to PETSc sparse matrices.
1624ec5066bdSBarry Smith 
16251cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`,
16262ef1f0ffSBarry Smith           `MatPartitioning`, `MatColoringType`, `MatPartitioningType`, `MatOrderingType`, `MatColoringSetWeightType()`,
16272ef1f0ffSBarry Smith           `MatColoringSetWeights()`, `MatCoarsenType`, `MatCoarsen`
16287086a01eSPeter Brune S*/
1629d4db15c4SBarry Smith typedef struct _p_MatColoring *MatColoring;
1630d4db15c4SBarry Smith 
1631d4db15c4SBarry Smith /*J
1632d4db15c4SBarry Smith    MatColoringType - String with the name of a PETSc matrix coloring
1633d9274352SBarry Smith 
1634d9274352SBarry Smith    Level: beginner
1635d9274352SBarry Smith 
16361cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatFDColoringCreate()`, `MatColoringSetType()`, `MatColoring`
163776bdecfbSBarry Smith J*/
163819fd82e9SBarry Smith typedef const char *MatColoringType;
16395567d71aSPeter Brune #define MATCOLORINGJP      "jp"
1640b9acb617SPeter Brune #define MATCOLORINGPOWER   "power"
16412692d6eeSBarry Smith #define MATCOLORINGNATURAL "natural"
16422692d6eeSBarry Smith #define MATCOLORINGSL      "sl"
16432692d6eeSBarry Smith #define MATCOLORINGLF      "lf"
16442692d6eeSBarry Smith #define MATCOLORINGID      "id"
16458121bdceSPeter Brune #define MATCOLORINGGREEDY  "greedy"
1646b12f92e5SBarry Smith 
16478ac6da0aSPeter Brune /*E
16482ef1f0ffSBarry Smith    MatColoringWeightType - Type of weight scheme used for the coloring algorithm
16498ac6da0aSPeter Brune 
16502ef1f0ffSBarry Smith    Values:
165187497f52SBarry Smith +  `MAT_COLORING_RANDOM`  - Random weights
165287497f52SBarry Smith .  `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering.
165387497f52SBarry Smith -  `MAT_COLORING_LF`      - Last-first weighting.
16548ac6da0aSPeter Brune 
16558ac6da0aSPeter Brune     Level: intermediate
16568ac6da0aSPeter Brune 
16571cc06b55SBarry Smith .seealso: [](ch_matrices), `MatColoring`, `MatColoringCreate()`, `MatColoringSetWeightType()`, `MatColoringSetWeights()`
16588ac6da0aSPeter Brune E*/
16599371c9d4SSatish Balay typedef enum {
16609371c9d4SSatish Balay   MAT_COLORING_WEIGHT_RANDOM,
16619371c9d4SSatish Balay   MAT_COLORING_WEIGHT_LEXICAL,
16629371c9d4SSatish Balay   MAT_COLORING_WEIGHT_LF,
16639371c9d4SSatish Balay   MAT_COLORING_WEIGHT_SL
16649371c9d4SSatish Balay } MatColoringWeightType;
16658ac6da0aSPeter Brune 
1666335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *);
1667d7f2a307SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *);
1668335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *);
1669335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer);
1670335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType);
1671335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring);
1672335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt);
1673335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *);
1674335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt);
1675335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *);
1676335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *);
1677335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring));
1678014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *);
16798ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType);
1680c29971fcSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *);
16818ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm);
1682bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring);
1683edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatColoringTest()", ) static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring)
1684d71ae5a4SJacob Faibussowitsch {
16859371c9d4SSatish Balay   return MatColoringTest(matcoloring, iscoloring);
16869371c9d4SSatish Balay }
1687bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring);
1688639f9d9dSBarry Smith 
1689d9274352SBarry Smith /*S
169087497f52SBarry Smith    MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring
1691639f9d9dSBarry Smith 
1692d9274352SBarry Smith    Level: beginner
1693d9274352SBarry Smith 
1694ec5066bdSBarry Smith    Notes:
169587497f52SBarry Smith    This object is creating utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()`
1696ec5066bdSBarry Smith 
16972ef1f0ffSBarry Smith    The `SNES` option `-snes_fd_coloring` will cause the Jacobian needed by `SNES` to be computed via a use of this object
16982ef1f0ffSBarry Smith 
16991cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()`
1700d9274352SBarry Smith S*/
1701e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
1702639f9d9dSBarry Smith 
1703014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *);
1704014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *);
1705014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer);
1706014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, PetscErrorCode (*)(void), void *);
1707014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, PetscErrorCode (**)(void), void **);
1708014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal);
1709014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring);
1710d1e9a80fSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *);
1711014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec);
1712edaa7c33SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]);
1713f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring);
1714f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt);
1715bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *);
1716b1683b59SHong Zhang 
1717b1683b59SHong Zhang /*S
1718af27ebaaSBarry Smith    MatTransposeColoring - Object for computing a sparse matrix product $C = A*B^T$ via coloring
1719b1683b59SHong Zhang 
17202ef1f0ffSBarry Smith    Level: developer
1721b1683b59SHong Zhang 
17221cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatProductType`, `MatTransposeColoringCreate()`
1723b1683b59SHong Zhang S*/
1724b9af6bddSHong Zhang typedef struct _p_MatTransposeColoring *MatTransposeColoring;
1725b1683b59SHong Zhang 
1726014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *);
1727014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat);
1728014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat);
1729014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *);
1730b1683b59SHong Zhang 
1731d9274352SBarry Smith /*S
1732d9274352SBarry Smith    MatPartitioning - Object for managing the partitioning of a matrix or graph
1733d9274352SBarry Smith 
1734d9274352SBarry Smith    Level: beginner
1735d9274352SBarry Smith 
173687497f52SBarry Smith    Note:
173787497f52SBarry Smith    There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations
173887497f52SBarry Smith    via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`)
1739ec5066bdSBarry Smith 
1740b5e6e808SPierre Jolivet    Developer Note:
17412ef1f0ffSBarry Smith    It is an extra maintenance and documentation cost to have two objects with the same functionality. `PetscPartitioner` should be removed
1742ec5066bdSBarry Smith 
17431cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`, `MatOrderingType`,
17442ef1f0ffSBarry Smith           `MatCoarsenType`, `MatCoarsenType`
1745d9274352SBarry Smith S*/
174691e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
1747d9274352SBarry Smith 
174876bdecfbSBarry Smith /*J
17498f6c3df8SBarry Smith     MatPartitioningType - String with the name of a PETSc matrix partitioning
1750d9274352SBarry Smith 
1751d9274352SBarry Smith    Level: beginner
17520d04baf8SBarry Smith dm
17531cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`, `MatColoringType`, `MatOrderingType`,
17542ef1f0ffSBarry Smith           `MatCoarsenType`, `MatCoarsenType`
175576bdecfbSBarry Smith J*/
175619fd82e9SBarry Smith typedef const char *MatPartitioningType;
17572692d6eeSBarry Smith #define MATPARTITIONINGCURRENT  "current"
1758aa1e27eaSFande Kong #define MATPARTITIONINGAVERAGE  "average"
17592692d6eeSBarry Smith #define MATPARTITIONINGSQUARE   "square"
17602692d6eeSBarry Smith #define MATPARTITIONINGPARMETIS "parmetis"
17612692d6eeSBarry Smith #define MATPARTITIONINGCHACO    "chaco"
17622692d6eeSBarry Smith #define MATPARTITIONINGPARTY    "party"
176350d91057SBarry Smith #define MATPARTITIONINGPTSCOTCH "ptscotch"
176488d2ac2bSFande Kong #define MATPARTITIONINGHIERARCH "hierarch"
176571306c60Sjroman 
1766014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *);
176719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType);
1768014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt);
1769014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat);
1770252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt);
1771014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]);
1772014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]);
1773ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool);
1774ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *);
1775014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *);
1776fdd1c351SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *);
1777668144dbSFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS);
1778f3ad2dabSStefano Zampini PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *);
1779014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *);
1780bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning));
1781014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer);
1782fe2efc57SMark PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]);
1783014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning);
178419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *);
1785ca161407SBarry Smith 
178627538973SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part);
1787014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
1788014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *);
17890752156aSBarry Smith 
17909371c9d4SSatish Balay typedef enum {
17919371c9d4SSatish Balay   MP_CHACO_MULTILEVEL = 1,
17929371c9d4SSatish Balay   MP_CHACO_SPECTRAL   = 2,
17939371c9d4SSatish Balay   MP_CHACO_LINEAR     = 4,
17949371c9d4SSatish Balay   MP_CHACO_RANDOM     = 5,
17959371c9d4SSatish Balay   MP_CHACO_SCATTERED  = 6
17969371c9d4SSatish Balay } MPChacoGlobalType;
17976a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoGlobalTypes[];
17989371c9d4SSatish Balay typedef enum {
17999371c9d4SSatish Balay   MP_CHACO_KERNIGHAN = 1,
18009371c9d4SSatish Balay   MP_CHACO_NONE      = 2
18019371c9d4SSatish Balay } MPChacoLocalType;
18026a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoLocalTypes[];
18039371c9d4SSatish Balay typedef enum {
18049371c9d4SSatish Balay   MP_CHACO_LANCZOS = 0,
18059371c9d4SSatish Balay   MP_CHACO_RQI     = 1
18069371c9d4SSatish Balay } MPChacoEigenType;
18076a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoEigenTypes[];
1808b6956c12SJose Roman 
1809014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
1810014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *);
1811014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1812014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *);
1813014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal);
1814014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType);
1815014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *);
1816014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1817014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *);
1818014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
1819014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *);
182071306c60Sjroman 
182171306c60Sjroman #define MP_PARTY_OPT "opt"
182271306c60Sjroman #define MP_PARTY_LIN "lin"
182371306c60Sjroman #define MP_PARTY_SCA "sca"
182471306c60Sjroman #define MP_PARTY_RAN "ran"
182571306c60Sjroman #define MP_PARTY_GBF "gbf"
182671306c60Sjroman #define MP_PARTY_GCF "gcf"
182771306c60Sjroman #define MP_PARTY_BUB "bub"
182871306c60Sjroman #define MP_PARTY_DEF "def"
1829014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *);
183071306c60Sjroman #define MP_PARTY_HELPFUL_SETS  "hs"
183171306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
183271306c60Sjroman #define MP_PARTY_NONE          "no"
1833014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *);
1834014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal);
1835014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool);
1836014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool);
183771306c60Sjroman 
18389371c9d4SSatish Balay typedef enum {
18399371c9d4SSatish Balay   MP_PTSCOTCH_DEFAULT,
18409371c9d4SSatish Balay   MP_PTSCOTCH_QUALITY,
18419371c9d4SSatish Balay   MP_PTSCOTCH_SPEED,
18429371c9d4SSatish Balay   MP_PTSCOTCH_BALANCE,
18439371c9d4SSatish Balay   MP_PTSCOTCH_SAFETY,
18449371c9d4SSatish Balay   MP_PTSCOTCH_SCALABILITY
18459371c9d4SSatish Balay } MPPTScotchStrategyType;
18466a6fc655SJed Brown PETSC_EXTERN const char *const MPPTScotchStrategyTypes[];
1847e0f1cffaSJose Roman 
1848014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal);
1849014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *);
1850014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType);
1851014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *);
185271306c60Sjroman 
1853b43b03e9SMark F. Adams /*
18546294fa2bSFande Kong  * hierarchical partitioning
18556294fa2bSFande Kong  */
18564e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *);
18574e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *);
18584e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt);
18594e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt);
18606294fa2bSFande Kong 
1861014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *);
1862591294e4SBarry Smith 
18630752156aSBarry Smith /*
1864c786d857SStefano Zampini     If you add entries here you must also add them to src/mat/f90-mod/petscmat.h
1865c786d857SStefano Zampini     If any of the enum values are changed, also update dMatOps dict at src/binding/petsc4py/src/libpetsc4py/libpetsc4py.pyx
1866d4fbbf0eSBarry Smith */
18679371c9d4SSatish Balay typedef enum {
18689371c9d4SSatish Balay   MATOP_SET_VALUES               = 0,
18691c1c02c0SLois Curfman McInnes   MATOP_GET_ROW                  = 1,
18701c1c02c0SLois Curfman McInnes   MATOP_RESTORE_ROW              = 2,
18711c1c02c0SLois Curfman McInnes   MATOP_MULT                     = 3,
18721c1c02c0SLois Curfman McInnes   MATOP_MULT_ADD                 = 4,
18737c922b88SBarry Smith   MATOP_MULT_TRANSPOSE           = 5,
18747c922b88SBarry Smith   MATOP_MULT_TRANSPOSE_ADD       = 6,
18751c1c02c0SLois Curfman McInnes   MATOP_SOLVE                    = 7,
18761c1c02c0SLois Curfman McInnes   MATOP_SOLVE_ADD                = 8,
18777c922b88SBarry Smith   MATOP_SOLVE_TRANSPOSE          = 9,
18787c922b88SBarry Smith   MATOP_SOLVE_TRANSPOSE_ADD      = 10,
18791c1c02c0SLois Curfman McInnes   MATOP_LUFACTOR                 = 11,
18801c1c02c0SLois Curfman McInnes   MATOP_CHOLESKYFACTOR           = 12,
1881a714c06dSBarry Smith   MATOP_SOR                      = 13,
18821c1c02c0SLois Curfman McInnes   MATOP_TRANSPOSE                = 14,
18831c1c02c0SLois Curfman McInnes   MATOP_GETINFO                  = 15,
18841c1c02c0SLois Curfman McInnes   MATOP_EQUAL                    = 16,
18851c1c02c0SLois Curfman McInnes   MATOP_GET_DIAGONAL             = 17,
18861c1c02c0SLois Curfman McInnes   MATOP_DIAGONAL_SCALE           = 18,
18871c1c02c0SLois Curfman McInnes   MATOP_NORM                     = 19,
18881c1c02c0SLois Curfman McInnes   MATOP_ASSEMBLY_BEGIN           = 20,
18891c1c02c0SLois Curfman McInnes   MATOP_ASSEMBLY_END             = 21,
1890d519adbfSMatthew Knepley   MATOP_SET_OPTION               = 22,
1891d519adbfSMatthew Knepley   MATOP_ZERO_ENTRIES             = 23,
1892d519adbfSMatthew Knepley   MATOP_ZERO_ROWS                = 24,
1893d519adbfSMatthew Knepley   MATOP_LUFACTOR_SYMBOLIC        = 25,
1894d519adbfSMatthew Knepley   MATOP_LUFACTOR_NUMERIC         = 26,
1895d519adbfSMatthew Knepley   MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27,
1896d519adbfSMatthew Knepley   MATOP_CHOLESKY_FACTOR_NUMERIC  = 28,
1897e5f2d425SStefano Zampini   MATOP_SETUP                    = 29,
1898d519adbfSMatthew Knepley   MATOP_ILUFACTOR_SYMBOLIC       = 30,
1899d519adbfSMatthew Knepley   MATOP_ICCFACTOR_SYMBOLIC       = 31,
1900a5b7ff6bSBarry Smith   MATOP_GET_DIAGONAL_BLOCK       = 32,
1901e5f2d425SStefano Zampini   MATOP_SET_INF                  = 33,
1902d519adbfSMatthew Knepley   MATOP_DUPLICATE                = 34,
1903d519adbfSMatthew Knepley   MATOP_FORWARD_SOLVE            = 35,
1904d519adbfSMatthew Knepley   MATOP_BACKWARD_SOLVE           = 36,
1905d519adbfSMatthew Knepley   MATOP_ILUFACTOR                = 37,
1906d519adbfSMatthew Knepley   MATOP_ICCFACTOR                = 38,
1907d519adbfSMatthew Knepley   MATOP_AXPY                     = 39,
19087dae84e0SHong Zhang   MATOP_CREATE_SUBMATRICES       = 40,
1909d519adbfSMatthew Knepley   MATOP_INCREASE_OVERLAP         = 41,
1910d519adbfSMatthew Knepley   MATOP_GET_VALUES               = 42,
1911d519adbfSMatthew Knepley   MATOP_COPY                     = 43,
1912d519adbfSMatthew Knepley   MATOP_GET_ROW_MAX              = 44,
1913d519adbfSMatthew Knepley   MATOP_SCALE                    = 45,
1914d519adbfSMatthew Knepley   MATOP_SHIFT                    = 46,
191535153367SBarry Smith   MATOP_DIAGONAL_SET             = 47,
19169d39f69dSJed Brown   MATOP_ZERO_ROWS_COLUMNS        = 48,
19179d39f69dSJed Brown   MATOP_SET_RANDOM               = 49,
1918d519adbfSMatthew Knepley   MATOP_GET_ROW_IJ               = 50,
1919d519adbfSMatthew Knepley   MATOP_RESTORE_ROW_IJ           = 51,
1920d519adbfSMatthew Knepley   MATOP_GET_COLUMN_IJ            = 52,
1921d519adbfSMatthew Knepley   MATOP_RESTORE_COLUMN_IJ        = 53,
1922d519adbfSMatthew Knepley   MATOP_FDCOLORING_CREATE        = 54,
1923d519adbfSMatthew Knepley   MATOP_COLORING_PATCH           = 55,
1924d519adbfSMatthew Knepley   MATOP_SET_UNFACTORED           = 56,
1925d519adbfSMatthew Knepley   MATOP_PERMUTE                  = 57,
1926d519adbfSMatthew Knepley   MATOP_SET_VALUES_BLOCKED       = 58,
19277dae84e0SHong Zhang   MATOP_CREATE_SUBMATRIX         = 59,
1928d519adbfSMatthew Knepley   MATOP_DESTROY                  = 60,
1929d519adbfSMatthew Knepley   MATOP_VIEW                     = 61,
1930d519adbfSMatthew Knepley   MATOP_CONVERT_FROM             = 62,
1931e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_63=63 */
19327bab7c10SHong Zhang   MATOP_MATMAT_MULT_SYMBOLIC    = 64,
19337bab7c10SHong Zhang   MATOP_MATMAT_MULT_NUMERIC     = 65,
1934d519adbfSMatthew Knepley   MATOP_SET_LOCAL_TO_GLOBAL_MAP = 66,
1935d519adbfSMatthew Knepley   MATOP_SET_VALUES_LOCAL        = 67,
1936d519adbfSMatthew Knepley   MATOP_ZERO_ROWS_LOCAL         = 68,
1937d519adbfSMatthew Knepley   MATOP_GET_ROW_MAX_ABS         = 69,
1938d519adbfSMatthew Knepley   MATOP_GET_ROW_MIN_ABS         = 70,
1939d519adbfSMatthew Knepley   MATOP_CONVERT                 = 71,
1940e5f2d425SStefano Zampini   MATOP_HAS_OPERATION           = 72,
19419d39f69dSJed Brown   /* MATOP_PLACEHOLDER_73=73, */
1942d519adbfSMatthew Knepley   MATOP_SET_VALUES_ADIFOR = 74,
1943d519adbfSMatthew Knepley   MATOP_FD_COLORING_APPLY = 75,
1944d519adbfSMatthew Knepley   MATOP_SET_FROM_OPTIONS  = 76,
1945e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_77=77, */
1946e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_78=78, */
19479d39f69dSJed Brown   MATOP_FIND_ZERO_DIAGONALS       = 79,
1948d519adbfSMatthew Knepley   MATOP_MULT_MULTIPLE             = 80,
1949d519adbfSMatthew Knepley   MATOP_SOLVE_MULTIPLE            = 81,
1950d519adbfSMatthew Knepley   MATOP_GET_INERTIA               = 82,
1951d519adbfSMatthew Knepley   MATOP_LOAD                      = 83,
1952d519adbfSMatthew Knepley   MATOP_IS_SYMMETRIC              = 84,
1953d519adbfSMatthew Knepley   MATOP_IS_HERMITIAN              = 85,
1954d519adbfSMatthew Knepley   MATOP_IS_STRUCTURALLY_SYMMETRIC = 86,
1955820469bcSHong Zhang   MATOP_SET_VALUES_BLOCKEDLOCAL   = 87,
1956b41ce5d5SBarry Smith   MATOP_CREATE_VECS               = 88,
1957e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_89=89, */
1958d519adbfSMatthew Knepley   MATOP_MAT_MULT_SYMBOLIC = 90,
1959d519adbfSMatthew Knepley   MATOP_MAT_MULT_NUMERIC  = 91,
1960e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_92=92, */
1961d519adbfSMatthew Knepley   MATOP_PTAP_SYMBOLIC = 93,
1962d519adbfSMatthew Knepley   MATOP_PTAP_NUMERIC  = 94,
1963e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_95=95, */
1964bda6c4cbSBarry Smith   MATOP_MAT_TRANSPOSE_MULT_SYMBO = 96,
1965bda6c4cbSBarry Smith   MATOP_MAT_TRANSPOSE_MULT_NUMER = 97,
1966e5f2d425SStefano Zampini   MATOP_BIND_TO_CPU              = 98,
19677a3c3d58SStefano Zampini   MATOP_PRODUCTSETFROMOPTIONS    = 99,
19687a3c3d58SStefano Zampini   MATOP_PRODUCTSYMBOLIC          = 100,
19697a3c3d58SStefano Zampini   MATOP_PRODUCTNUMERIC           = 101,
1970d519adbfSMatthew Knepley   MATOP_CONJUGATE                = 102,
1971e5f2d425SStefano Zampini   MATOP_VIEW_NATIVE              = 103,
1972d519adbfSMatthew Knepley   MATOP_SET_VALUES_ROW           = 104,
1973d519adbfSMatthew Knepley   MATOP_REAL_PART                = 105,
1974bda6c4cbSBarry Smith   MATOP_IMAGINARY_PART           = 106,
1975bda6c4cbSBarry Smith   MATOP_GET_ROW_UPPER_TRIANGULAR = 107,
1976bda6c4cbSBarry Smith   MATOP_RESTORE_ROW_UPPER_TRIANG = 108,
1977bda6c4cbSBarry Smith   MATOP_MAT_SOLVE                = 109,
197829eadf9eSStefano Zampini   MATOP_MAT_SOLVE_TRANSPOSE      = 110,
1979d519adbfSMatthew Knepley   MATOP_GET_ROW_MIN              = 111,
19800e8d04f7SBarry Smith   MATOP_GET_COLUMN_VECTOR        = 112,
1981d519adbfSMatthew Knepley   MATOP_MISSING_DIAGONAL         = 113,
19820e8d04f7SBarry Smith   MATOP_GET_SEQ_NONZERO_STRUCTUR = 114,
198389c6957cSBarry Smith   MATOP_CREATE                   = 115,
198489c6957cSBarry Smith   MATOP_GET_GHOSTS               = 116,
19850e8d04f7SBarry Smith   MATOP_GET_LOCAL_SUB_MATRIX     = 117,
19860e8d04f7SBarry Smith   MATOP_RESTORE_LOCALSUB_MATRIX  = 118,
1987eeffb40dSHong Zhang   MATOP_MULT_DIAGONAL_BLOCK      = 119,
19880e8d04f7SBarry Smith   MATOP_HERMITIAN_TRANSPOSE      = 120,
19890e8d04f7SBarry Smith   MATOP_MULT_HERMITIAN_TRANSPOSE = 121,
19900e8d04f7SBarry Smith   MATOP_MULT_HERMITIAN_TRANS_ADD = 122,
19910e8d04f7SBarry Smith   MATOP_GET_MULTI_PROC_BLOCK     = 123,
19929d39f69dSJed Brown   MATOP_FIND_NONZERO_ROWS        = 124,
19930e8d04f7SBarry Smith   MATOP_GET_COLUMN_NORMS         = 125,
19949d39f69dSJed Brown   MATOP_INVERT_BLOCK_DIAGONAL    = 126,
1995e5f2d425SStefano Zampini   MATOP_INVERT_VBLOCK_DIAGONAL   = 127,
1996b41ce5d5SBarry Smith   MATOP_CREATE_SUB_MATRICES_MPI  = 128,
19972b8ad9a3SHong Zhang   MATOP_SET_VALUES_BATCH         = 129,
1998e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_130=130, */
19990e8d04f7SBarry Smith   MATOP_TRANSPOSE_MAT_MULT_SYMBO = 131,
2000e9b602ebSSatish Balay   MATOP_TRANSPOSE_MAT_MULT_NUMER = 132,
20010e8d04f7SBarry Smith   MATOP_TRANSPOSE_COLORING_CREAT = 133,
20020e8d04f7SBarry Smith   MATOP_TRANS_COLORING_APPLY_SPT = 134,
20030e8d04f7SBarry Smith   MATOP_TRANS_COLORING_APPLY_DEN = 135,
2004e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_136=136, */
20050e8d04f7SBarry Smith   MATOP_RART_SYMBOLIC         = 137,
20060e8d04f7SBarry Smith   MATOP_RART_NUMERIC          = 138,
2007e09a3074SHong Zhang   MATOP_SET_BLOCK_SIZES       = 139,
2008f9426fe0SMark Adams   MATOP_AYPX                  = 140,
20091919a2e2SJed Brown   MATOP_RESIDUAL              = 141,
20109c8f2541SHong Zhang   MATOP_FDCOLORING_SETUP      = 142,
2011e5f2d425SStefano Zampini   MATOP_FIND_OFFBLOCK_ENTRIES = 143,
20122d033e1fSHong Zhang   MATOP_MPICONCATENATESEQ     = 144,
2013bb01b7b0SPatrick Sanan   MATOP_DESTROYSUBMATRICES    = 145,
2014e265f6d6SPatrick Sanan   MATOP_TRANSPOSE_SOLVE       = 146,
2015e265f6d6SPatrick Sanan   MATOP_GET_VALUES_LOCAL      = 147
2016fae171e0SBarry Smith } MatOperation;
20170c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, void (*)(void));
2018976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, void (**)(void));
2019976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *);
202094342113SStefano Zampini PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *);
2021edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatProductClear()", ) static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A)
2022d71ae5a4SJacob Faibussowitsch {
20239371c9d4SSatish Balay   return MatProductClear(A);
20249371c9d4SSatish Balay }
2025014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, void (*)(void));
2026014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, void (**)(void));
2027014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, void *);
2028800f99ffSJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscErrorCode (*)(void *));
2029db77db73SJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType);
2030f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
2031f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
20320c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat);
2033b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscErrorCode (*)(void *), MatType, MatType);
2034b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *);
2035112a2221SBarry Smith 
203690ace30eSBarry Smith /*
203790ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
203890ace30eSBarry Smith    stored in a universal format. By changing the format with
20396a9046bcSBarry Smith    PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will
204090ace30eSBarry Smith    be stored in a way natural for the matrix, for example dense matrices
204190ace30eSBarry Smith    would be stored as dense. Matrices stored this way may only be
2042f4403165SShri Abhyankar    read into matrices of the same type.
204390ace30eSBarry Smith */
204490ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
204590ace30eSBarry Smith 
2046014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal);
204775d48cdbSStefano Zampini 
20488546b261SStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType);
204975d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
205075d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool);
2051f03112d0SStefano Zampini PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool);
2052014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *);
20533b3b1effSJed Brown PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *);
2054014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat);
2055e432b41dSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
2056edd03b47SJacob Faibussowitsch PETSC_EXTERN PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatConvert()", ) PetscErrorCode MatISGetMPIXAIJ(Mat, MatReuse, Mat *);
20571f4e1ec7SBarry Smith 
2058d9274352SBarry Smith /*S
2059d9274352SBarry Smith    MatNullSpace - Object that removes a null space from a vector, i.e.
2060cb6b9846SMatthew Knepley                   orthogonalizes the vector to a subspace
2061d9274352SBarry Smith 
2062f7a9e4ceSBarry Smith    Level: advanced
2063d9274352SBarry Smith 
20641cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
2065d9274352SBarry Smith S*/
206674637425SBarry Smith typedef struct _p_MatNullSpace *MatNullSpace;
2067d9274352SBarry Smith 
2068014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *);
2069014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, PetscErrorCode (*)(MatNullSpace, Vec, void *), void *);
2070014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *);
2071d0195637SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec);
2072014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *);
20735fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *);
20745fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace);
2075014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace);
2076014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace);
2077014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *);
2078014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *);
2079014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer);
2080014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **);
2081014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *);
208274637425SBarry Smith 
2083014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS);
2084014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat, PetscReal);
2085014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *);
20863f1d51d7SBarry Smith 
2087014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *);
2088014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *);
2089014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *);
2090c4f061fbSSatish Balay 
20910bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *);
20920bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *);
20930bacdadaSStefano Zampini 
2094edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperator()", ) static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B)
2095d71ae5a4SJacob Faibussowitsch {
2096f22e26b7SPierre Jolivet   return MatComputeOperator(A, PETSC_NULLPTR, B);
20979371c9d4SSatish Balay }
2098edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperatorTranspose()", ) static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B)
2099d71ae5a4SJacob Faibussowitsch {
2100f22e26b7SPierre Jolivet   return MatComputeOperatorTranspose(A, PETSC_NULLPTR, B);
21019371c9d4SSatish Balay }
2102b0a32e0cSBarry Smith 
210349bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *);
210449bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *);
2105a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **);
2106a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2107a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **);
2108a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **);
2109a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **);
2110a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2111a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **);
2112a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **);
2113dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat);
2114dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]);
2115dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]);
2116910cf402Sprj- PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *);
211749bd79ccSDebojyoti Ghosh 
2118014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec);
211904f1ad80SBarry Smith 
21204bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDInitializePackage(void);
21214bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDFinalizePackage(void);
21224bf303faSJacob Faibussowitsch 
2123014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2124014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec);
2125014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, PetscErrorCode (*)(void *, Vec, Vec), void *);
2126014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, PetscErrorCode (*)(void *, PetscInt, Vec, PetscScalar *));
2127014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, PetscErrorCode (*)(void *, Vec));
2128014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt);
2129014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat);
2130014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal);
2131014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt);
2132014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *);
2133014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]);
2134014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *);
2135014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, PetscErrorCode (*)(void *, Vec, Vec, PetscScalar *), void *);
2136e884886fSBarry Smith 
21376370053bSBarry Smith /*S
21386370053bSBarry Smith     MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free
21396370053bSBarry Smith               Jacobian vector products
2140e884886fSBarry Smith 
21412ef1f0ffSBarry Smith     Level: developer
21422ef1f0ffSBarry Smith 
214395452b02SPatrick Sanan     Notes:
214487497f52SBarry Smith     `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure
21456370053bSBarry Smith 
21462ef1f0ffSBarry Smith      MatMFFD*() methods actually take the `Mat` as their first argument. Not a `MatMFFD` data structure
21476370053bSBarry Smith 
21482ef1f0ffSBarry Smith     This functionality is often obtained using `MatCreateSNESMF()` or with `SNES` solvers using `-snes_mf` or `-snes_mf_operator`
21496370053bSBarry Smith 
21501cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDType`, `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`,
21512ef1f0ffSBarry Smith           `MatCreateSNESMF()`, `SNES`, `-snes_mf`, `-snes_mf_operator`
21526370053bSBarry Smith S*/
2153e884886fSBarry Smith typedef struct _p_MatMFFD *MatMFFD;
2154e884886fSBarry Smith 
215576bdecfbSBarry Smith /*J
21562ef1f0ffSBarry Smith    MatMFFDType - algorithm used to compute the `h` used in computing matrix-vector products via differencing of a function
2157e884886fSBarry Smith 
215816a05f60SBarry Smith    Values:
2159af27ebaaSBarry Smith +   `MATMFFD_DS` - an algorithm described by Dennis and Schnabel {cite}`dennis:83`
2160af27ebaaSBarry Smith -   `MATMFFD_WP` - the Walker-Pernice {cite}`pw98` strategy.
216116a05f60SBarry Smith 
2162e884886fSBarry Smith    Level: beginner
2163e884886fSBarry Smith 
21641cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDSetType()`, `MatMFFDRegister()`, `MatMFFDSetFunction()`, `MatCreateMFFD()`
216576bdecfbSBarry Smith J*/
216619fd82e9SBarry Smith typedef const char *MatMFFDType;
2167e884886fSBarry Smith #define MATMFFD_DS "ds"
2168e884886fSBarry Smith #define MATMFFD_WP "wp"
2169e884886fSBarry Smith 
217019fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType);
2171bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD));
2172e884886fSBarry Smith 
2173014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal);
2174014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool);
2175e884886fSBarry Smith 
217661ab5df0SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType);
217761ab5df0SBarry Smith 
2178014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
2179014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
21807dbadf16SMatthew Knepley 
218153022affSStefano Zampini #ifdef PETSC_HAVE_H2OPUS
218253022affSStefano Zampini PETSC_EXTERN_TYPEDEF typedef PetscScalar (*MatH2OpusKernel)(PetscInt, PetscReal[], PetscReal[], void *);
218353022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernel, void *, PetscReal, PetscInt, PetscInt, Mat *);
218453022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *);
218553022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal);
218653022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat);
218753022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal);
218853022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool);
218953022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *);
219053022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *);
219153022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *);
2192300d917bSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar);
2193a0d2e7d8SStefano Zampini #endif
2194a0d2e7d8SStefano Zampini 
2195c7a4214aSPierre Jolivet #ifdef PETSC_HAVE_HTOOL
219698e73e17SPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatHtoolKernel)(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *);
2197c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernel, void *, Mat *);
2198c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernel, void *);
219998e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *);
220098e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *);
220198e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool);
22022ef1f0ffSBarry Smith 
2203c7a4214aSPierre Jolivet /*E
220487497f52SBarry Smith    MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL`
2205c7a4214aSPierre Jolivet 
2206c7a4214aSPierre Jolivet    Values:
220787497f52SBarry Smith +  `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation
220887497f52SBarry Smith .  `MAT_HTOOL_COMPRESSOR_FULL_ACA`                 - full adaptive cross approximation
220987497f52SBarry Smith -  `MAT_HTOOL_COMPRESSOR_SVD`                      - singular value decomposition
2210c7a4214aSPierre Jolivet 
221116a05f60SBarry Smith    Level: intermediate
221216a05f60SBarry Smith 
22131cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType`
2214c7a4214aSPierre Jolivet E*/
22159371c9d4SSatish Balay typedef enum {
22169371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA,
22179371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_FULL_ACA,
22189371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_SVD
22199371c9d4SSatish Balay } MatHtoolCompressorType;
22202ef1f0ffSBarry Smith 
222198e73e17SPierre Jolivet /*E
222287497f52SBarry Smith    MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL`
222398e73e17SPierre Jolivet 
222498e73e17SPierre Jolivet    Values:
222587497f52SBarry Smith +  `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default)    - axis computed via principle component analysis, split uniformly
222687497f52SBarry Smith .  `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC`            - axis computed via principle component analysis, split barycentrically
222787497f52SBarry Smith .  `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR`   - axis along the largest extent of the bounding box, split uniformly
222887497f52SBarry Smith -  `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically
222998e73e17SPierre Jolivet 
223016a05f60SBarry Smith    Level: intermediate
223116a05f60SBarry Smith 
22322ef1f0ffSBarry Smith    Note:
22332ef1f0ffSBarry Smith    Higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types
223498e73e17SPierre Jolivet 
22351cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType`
223698e73e17SPierre Jolivet E*/
22379371c9d4SSatish Balay typedef enum {
22389371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_PCA_REGULAR,
22399371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC,
22409371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR,
22419371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC
22429371c9d4SSatish Balay } MatHtoolClusteringType;
2243c7a4214aSPierre Jolivet #endif
2244c7a4214aSPierre Jolivet 
224597969023SHong Zhang #ifdef PETSC_HAVE_MUMPS
2246014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt);
2247bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *);
2248b9e9ea26SSatish Balay PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal);
2249bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *);
2250bc6112feSHong Zhang 
2251ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *);
2252ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *);
2253ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *);
2254ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *);
22555c0bae8cSAshish Patel PETSC_EXTERN PetscErrorCode MatMumpsGetNullPivots(Mat, PetscInt *, PetscInt **);
225689a9c03aSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat);
22570e6b8875SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat);
225897969023SHong Zhang #endif
225923a5497aSJed Brown 
2260b500a6b7SJose David Bermeol #ifdef PETSC_HAVE_MKL_PARDISO
2261d615f992SSatish Balay PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt);
2262b500a6b7SJose David Bermeol #endif
2263b500a6b7SJose David Bermeol 
2264d305a81bSVasiliy Kozyrev #ifdef PETSC_HAVE_MKL_CPARDISO
2265d305a81bSVasiliy Kozyrev PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt);
2266d305a81bSVasiliy Kozyrev #endif
2267d305a81bSVasiliy Kozyrev 
2268d954db57SHong Zhang #ifdef PETSC_HAVE_SUPERLU
2269014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal);
2270d954db57SHong Zhang #endif
2271d954db57SHong Zhang 
2272fb785984SHong Zhang #ifdef PETSC_HAVE_SUPERLU_DIST
2273fb785984SHong Zhang PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *);
2274fb785984SHong Zhang #endif
2275fb785984SHong Zhang 
2276575704cbSPieter Ghysels #ifdef PETSC_HAVE_STRUMPACK
2277542aee0fSPieter Ghysels /*E
227829e0a805SPieter Ghysels     MatSTRUMPACKReordering - sparsity reducing ordering to be used in `MATSOLVERSTRUMPACK`
2279542aee0fSPieter Ghysels 
22802ef1f0ffSBarry Smith     Values:
22812ef1f0ffSBarry Smith +  `MAT_STRUMPACK_NATURAL`   - use the current ordering
22822ef1f0ffSBarry Smith .  `MAT_STRUMPACK_METIS`     - use MeTis to compute an ordering
22832ef1f0ffSBarry Smith .  `MAT_STRUMPACK_PARMETIS`  - use ParMeTis to compute an ordering
22842ef1f0ffSBarry Smith .  `MAT_STRUMPACK_SCOTCH`    - use Scotch to compute an ordering
22852ef1f0ffSBarry Smith .  `MAT_STRUMPACK_PTSCOTCH`  - use parallel Scotch to compute an ordering
228629e0a805SPieter Ghysels .  `MAT_STRUMPACK_RCM`       - use an RCM ordering
228729e0a805SPieter Ghysels .  `MAT_STRUMPACK_GEOMETRIC` - use a geometric ordering (needs mesh info from user)
228829e0a805SPieter Ghysels .  `MAT_STRUMPACK_AMD`       - approximate minimum degree
228929e0a805SPieter Ghysels .  `MAT_STRUMPACK_MMD`       - multiple minimum degree
229029e0a805SPieter Ghysels .  `MAT_STRUMPACK_AND`       - approximate nested dissection
229129e0a805SPieter Ghysels .  `MAT_STRUMPACK_MLF`       - minimum local fill
229229e0a805SPieter Ghysels -  `MAT_STRUMPACK_SPECTRAL`  - spectral nested dissection
22932ef1f0ffSBarry Smith 
229416a05f60SBarry Smith     Level: intermediate
229516a05f60SBarry Smith 
22962ef1f0ffSBarry Smith     Developer Note:
22972ef1f0ffSBarry Smith     Should be called `MatSTRUMPACKReorderingType`
22982ef1f0ffSBarry Smith 
229929e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetReordering()`
2300542aee0fSPieter Ghysels E*/
23019371c9d4SSatish Balay typedef enum {
230229e0a805SPieter Ghysels   MAT_STRUMPACK_NATURAL,
230329e0a805SPieter Ghysels   MAT_STRUMPACK_METIS,
230429e0a805SPieter Ghysels   MAT_STRUMPACK_PARMETIS,
230529e0a805SPieter Ghysels   MAT_STRUMPACK_SCOTCH,
230629e0a805SPieter Ghysels   MAT_STRUMPACK_PTSCOTCH,
230729e0a805SPieter Ghysels   MAT_STRUMPACK_RCM,
230829e0a805SPieter Ghysels   MAT_STRUMPACK_GEOMETRIC,
230929e0a805SPieter Ghysels   MAT_STRUMPACK_AMD,
231029e0a805SPieter Ghysels   MAT_STRUMPACK_MMD,
231129e0a805SPieter Ghysels   MAT_STRUMPACK_AND,
231229e0a805SPieter Ghysels   MAT_STRUMPACK_MLF,
231329e0a805SPieter Ghysels   MAT_STRUMPACK_SPECTRAL
23149371c9d4SSatish Balay } MatSTRUMPACKReordering;
23152ef1f0ffSBarry Smith 
231634f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering);
231729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetReordering(Mat, MatSTRUMPACKReordering *);
231829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricNxyz(Mat, PetscInt, PetscInt, PetscInt);
231929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricComponents(Mat, PetscInt);
232029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricWidth(Mat, PetscInt);
2321575704cbSPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool);
232229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetColPerm(Mat, PetscBool *);
232329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGPU(Mat, PetscBool);
232429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetGPU(Mat, PetscBool *);
232529e0a805SPieter Ghysels 
232629e0a805SPieter Ghysels /*E
232729e0a805SPieter Ghysels     MatSTRUMPACKCompressionType - Compression used in the approximate sparse factorization solver `MATSOLVERSTRUMPACK`
232829e0a805SPieter Ghysels 
232929e0a805SPieter Ghysels     Values:
233029e0a805SPieter Ghysels +  `MAT_STRUMPACK_COMPRESSION_TYPE_NONE`          - no compression, direct solver
233129e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_HSS`           - hierarchically semi-separable
233229e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_BLR`           - block low rank
233329e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_HODLR`         - hierarchically off-diagonal low rank (requires ButterfyPACK support, configure with --download-butterflypack)
233429e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR`     - hybrid of BLR and HODLR (requires ButterfyPACK support, configure with --download-butterflypack)
233529e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR` - hybrid of lossy (ZFP), BLR and HODLR (requires ButterfyPACK and ZFP support, configure with --download-butterflypack --download-zfp)
233629e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS`      - lossless compression (requires ZFP support, configure with --download-zfp)
233729e0a805SPieter Ghysels -  `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY`         - lossy compression (requires ZFP support, configure with --download-zfp)
233829e0a805SPieter Ghysels 
233929e0a805SPieter Ghysels     Level: intermediate
234029e0a805SPieter Ghysels 
234129e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetCompression()`
234229e0a805SPieter Ghysels E*/
234329e0a805SPieter Ghysels typedef enum {
234429e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_NONE,
234529e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_HSS,
234629e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_BLR,
234729e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_HODLR,
234829e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR,
234929e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR,
235029e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS,
235129e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY
235229e0a805SPieter Ghysels } MatSTRUMPACKCompressionType;
235329e0a805SPieter Ghysels 
235429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompression(Mat, MatSTRUMPACKCompressionType);
235529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompression(Mat, MatSTRUMPACKCompressionType *);
235629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompRelTol(Mat, PetscReal);
235729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompRelTol(Mat, PetscReal *);
235829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompAbsTol(Mat, PetscReal);
235929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompAbsTol(Mat, PetscReal *);
236029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompMinSepSize(Mat, PetscInt);
236129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompMinSepSize(Mat, PetscInt *);
236229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLeafSize(Mat, PetscInt);
236329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLeafSize(Mat, PetscInt *);
236429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLossyPrecision(Mat, PetscInt);
236529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLossyPrecision(Mat, PetscInt *);
236629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompButterflyLevels(Mat, PetscInt);
236729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompButterflyLevels(Mat, PetscInt *);
2368575704cbSPieter Ghysels #endif
2369575704cbSPieter Ghysels 
2370b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool);
23712216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *);
2372edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 13, 0, "MatBindToCPU()", ) static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg)
2373d71ae5a4SJacob Faibussowitsch {
23749371c9d4SSatish Balay   return MatBindToCPU(A, flg);
23759371c9d4SSatish Balay }
237665a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool);
2377e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *);
2378e7e92044SBarry Smith 
2379aa372e3fSPaul Mullowney #ifdef PETSC_HAVE_CUDA
23803f9c0db1SPaul Mullowney /*E
23812ef1f0ffSBarry Smith     MatCUSPARSEStorageFormat - indicates the storage format for `MATAIJCUSPARSE` (GPU)
23822692e278SPaul Mullowney     matrices.
2383e057df02SPaul Mullowney 
23842ef1f0ffSBarry Smith     Values:
238587497f52SBarry Smith +   `MAT_CUSPARSE_CSR` - Compressed Sparse Row
238687497f52SBarry Smith .   `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later).
238787497f52SBarry Smith -   `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later).
2388e057df02SPaul Mullowney 
2389e057df02SPaul Mullowney     Level: intermediate
2390e057df02SPaul Mullowney 
23911cc06b55SBarry Smith .seealso: [](ch_matrices), `MATAIJCUSPARSE`, `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation`
2392e057df02SPaul Mullowney E*/
2393e057df02SPaul Mullowney 
23949371c9d4SSatish Balay typedef enum {
23959371c9d4SSatish Balay   MAT_CUSPARSE_CSR,
23969371c9d4SSatish Balay   MAT_CUSPARSE_ELL,
23979371c9d4SSatish Balay   MAT_CUSPARSE_HYB
23989371c9d4SSatish Balay } MatCUSPARSEStorageFormat;
2399e057df02SPaul Mullowney 
2400e057df02SPaul Mullowney /* these will be strings associated with enumerated type defined above */
2401e057df02SPaul Mullowney PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[];
2402e057df02SPaul Mullowney 
24033f9c0db1SPaul Mullowney /*E
24042ef1f0ffSBarry Smith     MatCUSPARSEFormatOperation - indicates the operation of `MATAIJCUSPARSE` (GPU)
24052692e278SPaul Mullowney     matrices whose operation should use a particular storage format.
2406e057df02SPaul Mullowney 
24072ef1f0ffSBarry Smith     Values:
24084cf0e950SBarry Smith +   `MAT_CUSPARSE_MULT_DIAG`    - sets the storage format for the diagonal matrix in the parallel `MatMult()`
24094cf0e950SBarry Smith .   `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()`
24104cf0e950SBarry Smith .   `MAT_CUSPARSE_MULT`         - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
24112ef1f0ffSBarry Smith -   `MAT_CUSPARSE_ALL`          - sets the storage format for all `MATAIJCUSPARSE` (GPU) matrices
2412e057df02SPaul Mullowney 
2413e057df02SPaul Mullowney     Level: intermediate
2414e057df02SPaul Mullowney 
24151cc06b55SBarry Smith .seealso: [](ch_matrices), `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat`
2416e057df02SPaul Mullowney E*/
24179371c9d4SSatish Balay typedef enum {
24189371c9d4SSatish Balay   MAT_CUSPARSE_MULT_DIAG,
24199371c9d4SSatish Balay   MAT_CUSPARSE_MULT_OFFDIAG,
24209371c9d4SSatish Balay   MAT_CUSPARSE_MULT,
24219371c9d4SSatish Balay   MAT_CUSPARSE_ALL
24229371c9d4SSatish Balay } MatCUSPARSEFormatOperation;
2423e057df02SPaul Mullowney 
242410e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
242510e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2426e057df02SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat);
2427365b711fSMark Adams PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool);
24285f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const int **, const int **);
24295f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const int **, const int **);
24305f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **);
24315f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **);
24325f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **);
24335f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **);
24345f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **);
24355f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **);
2436637a0070SStefano Zampini 
2437637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
2438637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
2439637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **);
2440637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **);
2441637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **);
2442637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **);
2443637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **);
2444637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **);
2445637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *);
2446d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *);
2447637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat);
24483d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseCUDASetPreallocation(Mat, PetscScalar *);
24492d1451d4SHong Zhang 
24502d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
24512d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
24529ae82921SPaul Mullowney #endif
24539ae82921SPaul Mullowney 
245447d993e7Ssuyashtn #ifdef PETSC_HAVE_HIP
245547d993e7Ssuyashtn /*E
24562ef1f0ffSBarry Smith     MatHIPSPARSEStorageFormat - indicates the storage format for `MATAIJHIPSPARSE` (GPU)
245747d993e7Ssuyashtn     matrices.
245847d993e7Ssuyashtn 
24592ef1f0ffSBarry Smith     Values:
24602ef1f0ffSBarry Smith +   `MAT_HIPSPARSE_CSR` - Compressed Sparse Row
24612ef1f0ffSBarry Smith .   `MAT_HIPSPARSE_ELL` - Ellpack
24622ef1f0ffSBarry Smith -   `MAT_HIPSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format
246347d993e7Ssuyashtn 
246416a05f60SBarry Smith     Level: intermediate
246516a05f60SBarry Smith 
24661cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEFormatOperation`
246747d993e7Ssuyashtn E*/
246847d993e7Ssuyashtn 
246947d993e7Ssuyashtn typedef enum {
247047d993e7Ssuyashtn   MAT_HIPSPARSE_CSR,
247147d993e7Ssuyashtn   MAT_HIPSPARSE_ELL,
247247d993e7Ssuyashtn   MAT_HIPSPARSE_HYB
247347d993e7Ssuyashtn } MatHIPSPARSEStorageFormat;
247447d993e7Ssuyashtn 
247547d993e7Ssuyashtn /* these will be strings associated with enumerated type defined above */
247647d993e7Ssuyashtn PETSC_EXTERN const char *const MatHIPSPARSEStorageFormats[];
247747d993e7Ssuyashtn 
247847d993e7Ssuyashtn /*E
24792ef1f0ffSBarry Smith     MatHIPSPARSEFormatOperation - indicates the operation of `MATAIJHIPSPARSE` (GPU)
248047d993e7Ssuyashtn     matrices whose operation should use a particular storage format.
248147d993e7Ssuyashtn 
24822ef1f0ffSBarry Smith     Values:
24832ef1f0ffSBarry Smith +   `MAT_HIPSPARSE_MULT_DIAG`    - sets the storage format for the diagonal matrix in the parallel `MatMult()`
24844cf0e950SBarry Smith .   `MAT_HIPSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()`
24852ef1f0ffSBarry Smith .   `MAT_HIPSPARSE_MULT`         - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
24862ef1f0ffSBarry Smith -   `MAT_HIPSPARSE_ALL`          - sets the storage format for all HIPSPARSE (GPU) matrices
24872ef1f0ffSBarry Smith 
248816a05f60SBarry Smith     Level: intermediate
248916a05f60SBarry Smith 
24901cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEStorageFormat`
249147d993e7Ssuyashtn E*/
249247d993e7Ssuyashtn typedef enum {
249347d993e7Ssuyashtn   MAT_HIPSPARSE_MULT_DIAG,
249447d993e7Ssuyashtn   MAT_HIPSPARSE_MULT_OFFDIAG,
249547d993e7Ssuyashtn   MAT_HIPSPARSE_MULT,
249647d993e7Ssuyashtn   MAT_HIPSPARSE_ALL
249747d993e7Ssuyashtn } MatHIPSPARSEFormatOperation;
249847d993e7Ssuyashtn 
249947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
250047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
250147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetFormat(Mat, MatHIPSPARSEFormatOperation, MatHIPSPARSEStorageFormat);
250247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetUseCPUSolve(Mat, PetscBool);
250347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetIJ(Mat, PetscBool, const int **, const int **);
250447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreIJ(Mat, PetscBool, const int **, const int **);
250547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayRead(Mat, const PetscScalar **);
250647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayRead(Mat, const PetscScalar **);
250747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayWrite(Mat, PetscScalar **);
250847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayWrite(Mat, PetscScalar **);
250947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArray(Mat, PetscScalar **);
251047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArray(Mat, PetscScalar **);
251147d993e7Ssuyashtn 
251247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
251347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
251447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayWrite(Mat, PetscScalar **);
251547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayRead(Mat, const PetscScalar **);
251647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArray(Mat, PetscScalar **);
251747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayWrite(Mat, PetscScalar **);
251847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayRead(Mat, const PetscScalar **);
251947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArray(Mat, PetscScalar **);
252047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPPlaceArray(Mat, const PetscScalar *);
252147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPReplaceArray(Mat, const PetscScalar *);
252247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPResetArray(Mat);
25233d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseHIPSetPreallocation(Mat, PetscScalar *);
252447d993e7Ssuyashtn #endif
252547d993e7Ssuyashtn 
2526d67ff14aSKarl Rupp #if defined(PETSC_HAVE_VIENNACL)
2527d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2528d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2529d67ff14aSKarl Rupp #endif
2530d67ff14aSKarl Rupp 
25314bf303faSJacob Faibussowitsch #if PetscDefined(HAVE_KOKKOS)
25324bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
25334bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
25344bf303faSJacob Faibussowitsch #endif
25354bf303faSJacob Faibussowitsch 
253654efbe56SHong Zhang #if defined(PETSC_HAVE_FFTW)
2537014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec);
2538014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec);
25392a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *);
254054efbe56SHong Zhang #endif
254154efbe56SHong Zhang 
2542d24d4204SJose E. Roman #if defined(PETSC_HAVE_SCALAPACK)
2543d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2544d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt);
2545d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *);
2546d24d4204SJose E. Roman #endif
2547d24d4204SJose E. Roman 
2548014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *);
2549014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *);
2550014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]);
2551014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]);
2552014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***);
2553014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *);
255419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType);
2555014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]);
2556014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat);
2557d8588912SDave May 
25582ce66baaSPierre Jolivet PETSC_EXTERN PetscErrorCode MatFilter(Mat, PetscReal, PetscBool, PetscBool);
25592ce66baaSPierre Jolivet PETSC_DEPRECATED_FUNCTION(3, 20, 0, "MatFilter()", ) static inline PetscErrorCode MatChop(Mat A, PetscReal tol)
25602ce66baaSPierre Jolivet {
25612ce66baaSPierre Jolivet   return MatFilter(A, tol, PETSC_FALSE, PETSC_FALSE);
25622ce66baaSPierre Jolivet }
2563e0a58c10SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *);
25644325cce7SMatthew G Knepley 
2565b541e6a4SDmitry Karpeev PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **);
256653dd7562SDmitry Karpeev 
2567c094ef40SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat);
2568c094ef40SMatthew G. Knepley 
256902218ef1SBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderMerge(Mat, Mat *);
2570539c167fSBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *);
25711a2c6b5cSJunchao Zhang 
25727ee59b9bSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *);
257372833a62Smarkadams4 
2574e02fb3cdSMark Adams PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, PetscReal, PetscInt, PetscInt[], Mat *);
257558c11ad4SPierre Jolivet PETSC_EXTERN PetscErrorCode MatEliminateZeros(Mat, PetscBool);
2576ad6ad4e1SHansol  Suh 
2577d16ceb75SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseFromVecType(MPI_Comm, VecType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *);
25783444e80cSBarry Smith 
25793444e80cSBarry Smith PETSC_EXTERN PetscErrorCode MatSetHPL(Mat, int);
25803444e80cSBarry Smith #define PETSCBMHPL "hpl"
2581