xref: /petsc/include/petscmat.h (revision d1a032db6cd7c39db5bfaa476c8e42d0c0ea531b)
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
250b4b7b1cSBarry Smith    MatType - String with the name of a PETSc matrix type. These are all the matrix formats that PETSc provides.
26d9274352SBarry Smith 
27d9274352SBarry Smith    Level: beginner
28d9274352SBarry Smith 
290b4b7b1cSBarry Smith    Notes:
302ef1f0ffSBarry Smith    [](doc_matrix) for a table of available matrix types
312ef1f0ffSBarry Smith 
32ce78bad3SBarry Smith    Use `MatSetType()` or the options database keys `-mat_type` or `-dm_mat_type` to set the matrix format to use for a given `Mat`
330b4b7b1cSBarry Smith 
341cc06b55SBarry Smith .seealso: [](doc_matrix), [](ch_matrices), `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()`
3576bdecfbSBarry Smith J*/
3619fd82e9SBarry Smith typedef const char *MatType;
37273d9f13SBarry Smith #define MATSAME                      "same"
385a11e1b2SBarry Smith #define MATMAIJ                      "maij"
39273d9f13SBarry Smith #define MATSEQMAIJ                   "seqmaij"
40273d9f13SBarry Smith #define MATMPIMAIJ                   "mpimaij"
4149bd79ccSDebojyoti Ghosh #define MATKAIJ                      "kaij"
4249bd79ccSDebojyoti Ghosh #define MATSEQKAIJ                   "seqkaij"
4349bd79ccSDebojyoti Ghosh #define MATMPIKAIJ                   "mpikaij"
44273d9f13SBarry Smith #define MATIS                        "is"
455a11e1b2SBarry Smith #define MATAIJ                       "aij"
46273d9f13SBarry Smith #define MATSEQAIJ                    "seqaij"
47273d9f13SBarry Smith #define MATMPIAIJ                    "mpiaij"
485a11e1b2SBarry Smith #define MATAIJCRL                    "aijcrl"
495a11e1b2SBarry Smith #define MATSEQAIJCRL                 "seqaijcrl"
505a11e1b2SBarry Smith #define MATMPIAIJCRL                 "mpiaijcrl"
519ae82921SPaul Mullowney #define MATAIJCUSPARSE               "aijcusparse"
529ae82921SPaul Mullowney #define MATSEQAIJCUSPARSE            "seqaijcusparse"
539ae82921SPaul Mullowney #define MATMPIAIJCUSPARSE            "mpiaijcusparse"
5447d993e7Ssuyashtn #define MATAIJHIPSPARSE              "aijhipsparse"
5547d993e7Ssuyashtn #define MATSEQAIJHIPSPARSE           "seqaijhipsparse"
5647d993e7Ssuyashtn #define MATMPIAIJHIPSPARSE           "mpiaijhipsparse"
578c3ff71bSJunchao Zhang #define MATAIJKOKKOS                 "aijkokkos"
588c3ff71bSJunchao Zhang #define MATSEQAIJKOKKOS              "seqaijkokkos"
598c3ff71bSJunchao Zhang #define MATMPIAIJKOKKOS              "mpiaijkokkos"
60d67ff14aSKarl Rupp #define MATAIJVIENNACL               "aijviennacl"
61d67ff14aSKarl Rupp #define MATSEQAIJVIENNACL            "seqaijviennacl"
62d67ff14aSKarl Rupp #define MATMPIAIJVIENNACL            "mpiaijviennacl"
635a11e1b2SBarry Smith #define MATAIJPERM                   "aijperm"
645a11e1b2SBarry Smith #define MATSEQAIJPERM                "seqaijperm"
655a11e1b2SBarry Smith #define MATMPIAIJPERM                "mpiaijperm"
664dfdc2d9SRichard Tran Mills #define MATAIJSELL                   "aijsell"
674dfdc2d9SRichard Tran Mills #define MATSEQAIJSELL                "seqaijsell"
684dfdc2d9SRichard Tran Mills #define MATMPIAIJSELL                "mpiaijsell"
694a2a386eSRichard Tran Mills #define MATAIJMKL                    "aijmkl"
704a2a386eSRichard Tran Mills #define MATSEQAIJMKL                 "seqaijmkl"
714a2a386eSRichard Tran Mills #define MATMPIAIJMKL                 "mpiaijmkl"
72b5b72c8aSIrina Sokolova #define MATBAIJMKL                   "baijmkl"
73b5b72c8aSIrina Sokolova #define MATSEQBAIJMKL                "seqbaijmkl"
74b5b72c8aSIrina Sokolova #define MATMPIBAIJMKL                "mpibaijmkl"
75273d9f13SBarry Smith #define MATSHELL                     "shell"
76c1fff1c6SRichard Tran Mills #define MATCENTERING                 "centering"
775a11e1b2SBarry Smith #define MATDENSE                     "dense"
78637a0070SStefano Zampini #define MATDENSECUDA                 "densecuda"
7947d993e7Ssuyashtn #define MATDENSEHIP                  "densehip"
80209238afSKris Buschelman #define MATSEQDENSE                  "seqdense"
81bfc799aaSStefano Zampini #define MATSEQDENSECUDA              "seqdensecuda"
8247d993e7Ssuyashtn #define MATSEQDENSEHIP               "seqdensehip"
83273d9f13SBarry Smith #define MATMPIDENSE                  "mpidense"
84637a0070SStefano Zampini #define MATMPIDENSECUDA              "mpidensecuda"
8547d993e7Ssuyashtn #define MATMPIDENSEHIP               "mpidensehip"
86db31f6deSJed Brown #define MATELEMENTAL                 "elemental"
87d24d4204SJose E. Roman #define MATSCALAPACK                 "scalapack"
885a11e1b2SBarry Smith #define MATBAIJ                      "baij"
89273d9f13SBarry Smith #define MATSEQBAIJ                   "seqbaij"
90273d9f13SBarry Smith #define MATMPIBAIJ                   "mpibaij"
91273d9f13SBarry Smith #define MATMPIADJ                    "mpiadj"
925a11e1b2SBarry Smith #define MATSBAIJ                     "sbaij"
93273d9f13SBarry Smith #define MATSEQSBAIJ                  "seqsbaij"
94273d9f13SBarry Smith #define MATMPISBAIJ                  "mpisbaij"
95cebc7f6cSBarry Smith #define MATMFFD                      "mffd"
96c8a8475eSBarry Smith #define MATNORMAL                    "normal"
97c5e4d11fSDmitry Karpeev #define MATNORMALHERMITIAN           "normalh"
98ab92ecdeSBarry Smith #define MATLRC                       "lrc"
992a6744ebSBarry Smith #define MATSCATTER                   "scatter"
100421e10b8SBarry Smith #define MATBLOCKMAT                  "blockmat"
101793850ffSBarry Smith #define MATCOMPOSITE                 "composite"
1021f8c7532SHong Zhang #define MATFFT                       "fft"
1031f8c7532SHong Zhang #define MATFFTW                      "fftw"
104e133240eSMatthew G Knepley #define MATSEQCUFFT                  "seqcufft"
10547d993e7Ssuyashtn #define MATSEQHIPFFT                 "seqhipfft"
106edd03b47SJacob Faibussowitsch #define MATTRANSPOSEMAT              PETSC_DEPRECATED_MACRO(3, 18, 0, "MATTRANSPOSEVIRTUAL", ) "transpose"
107013e2dc7SBarry Smith #define MATTRANSPOSEVIRTUAL          "transpose"
108013e2dc7SBarry Smith #define MATHERMITIANTRANSPOSEVIRTUAL "hermitiantranspose"
10972ca8751SBarry Smith #define MATSCHURCOMPLEMENT           "schurcomplement"
1101d6018f0SLisandro Dalcin #define MATPYTHON                    "python"
11163c07aadSStefano Zampini #define MATHYPRE                     "hypre"
112f91d8e95SBarry Smith #define MATHYPRESTRUCT               "hyprestruct"
113a9e6138eSGlenn Hammond #define MATHYPRESSTRUCT              "hypresstruct"
114ee1cef2cSJed Brown #define MATSUBMATRIX                 "submatrix"
1152c0dbf93SJed Brown #define MATLOCALREF                  "localref"
116d8588912SDave May #define MATNEST                      "nest"
117c094ef40SMatthew G. Knepley #define MATPREALLOCATOR              "preallocator"
118d4002b98SHong Zhang #define MATSELL                      "sell"
119d4002b98SHong Zhang #define MATSEQSELL                   "seqsell"
120d4002b98SHong Zhang #define MATMPISELL                   "mpisell"
1212d1451d4SHong Zhang #define MATSELLCUDA                  "sellcuda"
1222d1451d4SHong Zhang #define MATSEQSELLCUDA               "seqsellcuda"
1232d1451d4SHong Zhang #define MATMPISELLCUDA               "mpisellcuda"
124773bf0f6SHong Zhang #define MATSELLHIP                   "sellhip"
125773bf0f6SHong Zhang #define MATSEQSELLHIP                "seqsellhip"
126773bf0f6SHong Zhang #define MATMPISELLHIP                "mpisellhip"
127a3b2e22bSHong Zhang #define MATDUMMY                     "dummy"
128cd929ea3SAlp Dener #define MATLMVM                      "lmvm"
12978e4361aSAlp Dener #define MATLMVMDFP                   "lmvmdfp"
130bbb72809SHansol Suh #define MATLMVMDDFP                  "lmvmddfp"
13178e4361aSAlp Dener #define MATLMVMBFGS                  "lmvmbfgs"
132bbb72809SHansol Suh #define MATLMVMDBFGS                 "lmvmdbfgs"
133bbb72809SHansol Suh #define MATLMVMDQN                   "lmvmdqn"
13478e4361aSAlp Dener #define MATLMVMSR1                   "lmvmsr1"
135864588a7SAlp Dener #define MATLMVMBROYDEN               "lmvmbroyden"
136864588a7SAlp Dener #define MATLMVMBADBROYDEN            "lmvmbadbroyden"
137864588a7SAlp Dener #define MATLMVMSYMBROYDEN            "lmvmsymbroyden"
138864588a7SAlp Dener #define MATLMVMSYMBADBROYDEN         "lmvmsymbadbroyden"
139864588a7SAlp Dener #define MATLMVMDIAGBROYDEN           "lmvmdiagbroyden"
1403423f386SBarry Smith #define MATCONSTANTDIAGONAL          "constantdiagonal"
141345a4b08SToby Isaac #define MATDIAGONAL                  "diagonal"
142c7a4214aSPierre Jolivet #define MATHTOOL                     "htool"
14353022affSStefano Zampini #define MATH2OPUS                    "h2opus"
144773941d6SBarry Smith 
14576bdecfbSBarry Smith /*J
146af27ebaaSBarry Smith    MatSolverType - String with the name of a PETSc factorization-based matrix solver type.
1479989ab13SBarry Smith 
148c2b89b5dSBarry Smith    For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc
1499989ab13SBarry Smith 
1509989ab13SBarry Smith    Level: beginner
1519989ab13SBarry Smith 
1522ef1f0ffSBarry Smith    Note:
15316a05f60SBarry Smith    `MATSOLVERUMFPACK`, `MATSOLVERCHOLMOD`, `MATSOLVERKLU`, `MATSOLVERSPQR` form the SuiteSparse package; you can use `--download-suitesparse` as
15416a05f60SBarry Smith    a ./configure option to install them
155c7ccbb75SBarry Smith 
1561cc06b55SBarry Smith .seealso: [](sec_matfactor), [](ch_matrices), `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()`
15776bdecfbSBarry Smith J*/
158ea799195SBarry Smith typedef const char *MatSolverType;
1592692d6eeSBarry Smith #define MATSOLVERSUPERLU      "superlu"
1602692d6eeSBarry Smith #define MATSOLVERSUPERLU_DIST "superlu_dist"
16108f5efcfSPieter Ghysels #define MATSOLVERSTRUMPACK    "strumpack"
1622692d6eeSBarry Smith #define MATSOLVERUMFPACK      "umfpack"
16320db9a53SJed Brown #define MATSOLVERCHOLMOD      "cholmod"
164d89f5e7aSBarry Smith #define MATSOLVERKLU          "klu"
165d89f5e7aSBarry Smith #define MATSOLVERELEMENTAL    "elemental"
166d24d4204SJose E. Roman #define MATSOLVERSCALAPACK    "scalapack"
1672692d6eeSBarry Smith #define MATSOLVERESSL         "essl"
1682692d6eeSBarry Smith #define MATSOLVERLUSOL        "lusol"
1692692d6eeSBarry Smith #define MATSOLVERMUMPS        "mumps"
170d615f992SSatish Balay #define MATSOLVERMKL_PARDISO  "mkl_pardiso"
171d305a81bSVasiliy Kozyrev #define MATSOLVERMKL_CPARDISO "mkl_cpardiso"
1722692d6eeSBarry Smith #define MATSOLVERPASTIX       "pastix"
1732692d6eeSBarry Smith #define MATSOLVERMATLAB       "matlab"
1742692d6eeSBarry Smith #define MATSOLVERPETSC        "petsc"
1752692d6eeSBarry Smith #define MATSOLVERBAS          "bas"
1769ae82921SPaul Mullowney #define MATSOLVERCUSPARSE     "cusparse"
177bfc799aaSStefano Zampini #define MATSOLVERCUDA         "cuda"
17847d993e7Ssuyashtn #define MATSOLVERHIPSPARSE    "hipsparse"
17947d993e7Ssuyashtn #define MATSOLVERHIP          "hip"
180930e68a5SMark Adams #define MATSOLVERKOKKOS       "kokkos"
181a2fc1e05SToby Isaac #define MATSOLVERSPQR         "spqr"
1821dd4f53aSPierre Jolivet #define MATSOLVERHTOOL        "htool"
183c0cdd4a1SDahai Guo 
184b24902e0SBarry Smith /*E
185b24902e0SBarry Smith     MatFactorType - indicates what type of factorization is requested
186b24902e0SBarry Smith 
1872ef1f0ffSBarry Smith     Values:
1882ef1f0ffSBarry Smith +  `MAT_FACTOR_LU`       - LU factorization
1892ef1f0ffSBarry Smith .  `MAT_FACTOR_CHOLESKY` - Cholesky factorization
1902ef1f0ffSBarry Smith .  `MAT_FACTOR_ILU`      - ILU factorization
1912ef1f0ffSBarry Smith .  `MAT_FACTOR_ICC`      - incomplete Cholesky factorization
1922ef1f0ffSBarry Smith .  `MAT_FACTOR_ILUDT`    - ILU factorization with drop tolerance
1932ef1f0ffSBarry Smith -  `MAT_FACTOR_QR`       - QR factorization
194b24902e0SBarry Smith 
19516a05f60SBarry Smith     Level: beginner
19616a05f60SBarry Smith 
1971cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()`
198b24902e0SBarry Smith E*/
1999371c9d4SSatish Balay typedef enum {
2009371c9d4SSatish Balay   MAT_FACTOR_NONE,
2019371c9d4SSatish Balay   MAT_FACTOR_LU,
2029371c9d4SSatish Balay   MAT_FACTOR_CHOLESKY,
2039371c9d4SSatish Balay   MAT_FACTOR_ILU,
2049371c9d4SSatish Balay   MAT_FACTOR_ICC,
2059371c9d4SSatish Balay   MAT_FACTOR_ILUDT,
2069371c9d4SSatish Balay   MAT_FACTOR_QR,
2079371c9d4SSatish Balay   MAT_FACTOR_NUM_TYPES
2089371c9d4SSatish Balay } MatFactorType;
209014dd563SJed Brown PETSC_EXTERN const char *const MatFactorTypes[];
210e92e720dSBarry Smith 
211ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactor(Mat, MatSolverType, MatFactorType, Mat *);
212ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat, MatSolverType, MatFactorType, PetscBool *);
213f73b0415SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool *);
214edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 15, 0, "MatFactorGetCanUseOrdering()", ) static inline PetscErrorCode MatFactorGetUseOrdering(Mat A, PetscBool *b)
215d71ae5a4SJacob Faibussowitsch {
2169371c9d4SSatish Balay   return MatFactorGetCanUseOrdering(A, b);
2179371c9d4SSatish Balay }
218ea799195SBarry Smith PETSC_EXTERN PetscErrorCode                 MatFactorGetSolverType(Mat, MatSolverType *);
219014dd563SJed Brown PETSC_EXTERN PetscErrorCode                 MatGetFactorType(Mat, MatFactorType *);
2207abd51d3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode                 MatSetFactorType(Mat, MatFactorType);
221348d23efSPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatSolverFn(Mat, MatFactorType, Mat *);
2228434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef MatSolverFn   *MatSolverFunction;
22307e0ed13SBarry Smith 
2248434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType, MatType, MatFactorType, MatSolverFn *);
2258434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType, MatType, MatFactorType, PetscBool *, PetscBool *, MatSolverFn **);
226edd03b47SJacob Faibussowitsch typedef MatSolverType       MatSolverPackage PETSC_DEPRECATED_TYPEDEF(3, 9, 0, "MatSolverType", );
2278434afd1SBarry Smith PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeRegister()", ) static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype, MatType mtype, MatFactorType ftype, MatSolverFn *f)
228d71ae5a4SJacob Faibussowitsch {
2299371c9d4SSatish Balay   return MatSolverTypeRegister(stype, mtype, ftype, f);
2309371c9d4SSatish Balay }
2318434afd1SBarry Smith PETSC_DEPRECATED_FUNCTION(3, 9, 0, "MatSolverTypeGet()", ) static inline PetscErrorCode MatSolverPackageGet(MatSolverType stype, MatType mtype, MatFactorType ftype, PetscBool *foundmtype, PetscBool *foundstype, MatSolverFn **f)
232d71ae5a4SJacob Faibussowitsch {
2339371c9d4SSatish Balay   return MatSolverTypeGet(stype, mtype, ftype, foundmtype, foundstype, f);
2349371c9d4SSatish Balay }
2359989ab13SBarry Smith 
2364222ddf1SHong Zhang /*E
23795bd0b28SBarry Smith     MatProductType - indicates what type of matrix product to compute
2384222ddf1SHong Zhang 
2392ef1f0ffSBarry Smith     Values:
2402ef1f0ffSBarry Smith +  `MATPRODUCT_AB`   - product of two matrices
2412ef1f0ffSBarry Smith .  `MATPRODUCT_AtB`  - product of the transpose of a given matrix with a matrix
2422ef1f0ffSBarry Smith .  `MATPRODUCT_ABt`  - product of a matrix with the transpose of another given matrix
2432ef1f0ffSBarry Smith .  `MATPRODUCT_PtAP` - the triple product of the transpose of a matrix with another matrix and itself
2442ef1f0ffSBarry Smith .  `MATPRODUCT_RARt` - the triple product of a matrix, another matrix and the transpose of the first matrix
2452ef1f0ffSBarry Smith -  `MATPRODUCT_ABC`  - the product of three matrices
2462ef1f0ffSBarry Smith 
24716a05f60SBarry Smith     Level: beginner
24816a05f60SBarry Smith 
2491cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatProductSetType()`
2504222ddf1SHong Zhang E*/
2519371c9d4SSatish Balay typedef enum {
252ce78bad3SBarry Smith   MATPRODUCT_UNSPECIFIED,
2539371c9d4SSatish Balay   MATPRODUCT_AB,
2549371c9d4SSatish Balay   MATPRODUCT_AtB,
2559371c9d4SSatish Balay   MATPRODUCT_ABt,
2569371c9d4SSatish Balay   MATPRODUCT_PtAP,
2579371c9d4SSatish Balay   MATPRODUCT_RARt,
2589371c9d4SSatish Balay   MATPRODUCT_ABC
2599371c9d4SSatish Balay } MatProductType;
260544a5e07SHong Zhang PETSC_EXTERN const char *const MatProductTypes[];
2614222ddf1SHong Zhang 
2624222ddf1SHong Zhang /*J
2634222ddf1SHong Zhang     MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation
2644222ddf1SHong Zhang 
2654222ddf1SHong Zhang    Level: beginner
2664222ddf1SHong Zhang 
2671cc06b55SBarry Smith .seealso: [](sec_matmatproduct), [](ch_matrices), `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType`
2684222ddf1SHong Zhang J*/
2694222ddf1SHong Zhang typedef const char *MatProductAlgorithm;
2703e662e0bSHong Zhang #define MATPRODUCTALGORITHMDEFAULT         "default"
2713e662e0bSHong Zhang #define MATPRODUCTALGORITHMSORTED          "sorted"
2723e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLE        "scalable"
2733e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLEFAST    "scalable_fast"
2743e662e0bSHong Zhang #define MATPRODUCTALGORITHMHEAP            "heap"
2753e662e0bSHong Zhang #define MATPRODUCTALGORITHMBHEAP           "btheap"
2763e662e0bSHong Zhang #define MATPRODUCTALGORITHMLLCONDENSED     "llcondensed"
2773e662e0bSHong Zhang #define MATPRODUCTALGORITHMROWMERGE        "rowmerge"
2783e662e0bSHong Zhang #define MATPRODUCTALGORITHMOUTERPRODUCT    "outerproduct"
2793e662e0bSHong Zhang #define MATPRODUCTALGORITHMATB             "at*b"
2803e662e0bSHong Zhang #define MATPRODUCTALGORITHMRAP             "rap"
2813e662e0bSHong Zhang #define MATPRODUCTALGORITHMNONSCALABLE     "nonscalable"
2823e662e0bSHong Zhang #define MATPRODUCTALGORITHMSEQMPI          "seqmpi"
2833e662e0bSHong Zhang #define MATPRODUCTALGORITHMBACKEND         "backend"
2843e662e0bSHong Zhang #define MATPRODUCTALGORITHMOVERLAPPING     "overlapping"
2853e662e0bSHong Zhang #define MATPRODUCTALGORITHMMERGED          "merged"
2863e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCE       "allatonce"
2873e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged"
2883e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLGATHERV      "allgatherv"
2893e662e0bSHong Zhang #define MATPRODUCTALGORITHMCYCLIC          "cyclic"
2903e662e0bSHong Zhang #define MATPRODUCTALGORITHMHYPRE           "hypre"
2914222ddf1SHong Zhang 
2924222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreate(Mat, Mat, Mat, Mat *);
2934222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat, Mat, Mat, Mat);
2944222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetType(Mat, MatProductType);
2954222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat, MatProductAlgorithm);
2968fcac130SJose E. Roman PETSC_EXTERN PetscErrorCode MatProductGetAlgorithm(Mat, MatProductAlgorithm *);
2974222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat, PetscReal);
2984222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat);
2994222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat);
3004222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat);
3014222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat, Mat, Mat, Mat);
3024417c5e8SHong Zhang PETSC_EXTERN PetscErrorCode MatProductClear(Mat);
3036718818eSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductView(Mat, PetscViewer);
304c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetType(Mat, MatProductType *);
305c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat, Mat *, Mat *, Mat *);
3064222ddf1SHong Zhang 
307c06d978dSMatthew Knepley /* Logging support */
3080700a824SBarry Smith #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */
309014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_CLASSID;
310335efc43SPeter Brune PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID;
311014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID;
312014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID;
313014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID;
314014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID;
315014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID;
316014dd563SJed Brown PETSC_EXTERN PetscClassId MATMFFD_CLASSID;
317c06d978dSMatthew Knepley 
318ceb03754SKris Buschelman /*E
3192ef1f0ffSBarry Smith    MatReuse - Indicates if matrices obtained from a previous call to `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatConvert()` or several other functions
320cf37664fSBarry Smith    are to be reused to store the new matrix values.
321cf37664fSBarry Smith 
3222ef1f0ffSBarry Smith    Values:
3232ef1f0ffSBarry Smith +  `MAT_INITIAL_MATRIX` - create a new matrix
3242ef1f0ffSBarry Smith .  `MAT_REUSE_MATRIX`   - reuse the matrix created with a previous call that used `MAT_INITIAL_MATRIX`
3252ef1f0ffSBarry Smith .  `MAT_INPLACE_MATRIX` - replace the first input matrix with the new matrix (not applicable to all functions)
3262ef1f0ffSBarry 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)
327ceb03754SKris Buschelman 
328ceb03754SKris Buschelman     Level: beginner
329ceb03754SKris Buschelman 
3301cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()`
331ceb03754SKris Buschelman E*/
3329371c9d4SSatish Balay typedef enum {
3339371c9d4SSatish Balay   MAT_INITIAL_MATRIX,
3349371c9d4SSatish Balay   MAT_REUSE_MATRIX,
3359371c9d4SSatish Balay   MAT_IGNORE_MATRIX,
3369371c9d4SSatish Balay   MAT_INPLACE_MATRIX
3379371c9d4SSatish Balay } MatReuse;
338ceb03754SKris Buschelman 
3395494a064SHong Zhang /*E
3402ef1f0ffSBarry Smith     MatCreateSubMatrixOption - Indicates if matrices obtained from a call to `MatCreateSubMatrices()`
3412ef1f0ffSBarry Smith     include the matrix values. Currently it is only used by `MatGetSeqNonzeroStructure()`.
3425494a064SHong Zhang 
3432ef1f0ffSBarry Smith     Values:
3442ef1f0ffSBarry Smith +  `MAT_DO_NOT_GET_VALUES` - do not copy the matrix values
3452ef1f0ffSBarry Smith -  `MAT_GET_VALUES`        - copy the matrix values
3462ef1f0ffSBarry Smith 
34795bd0b28SBarry Smith     Level: developer
34895bd0b28SBarry Smith 
3492ef1f0ffSBarry Smith     Developer Note:
3502ef1f0ffSBarry Smith     Why is not just a boolean used for this information?
3512ef1f0ffSBarry Smith 
3521cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicateOption`, `PetscCopyMode`, `MatGetSeqNonzeroStructure()`
3535494a064SHong Zhang E*/
3549371c9d4SSatish Balay typedef enum {
3559371c9d4SSatish Balay   MAT_DO_NOT_GET_VALUES,
3569371c9d4SSatish Balay   MAT_GET_VALUES
3579371c9d4SSatish Balay } MatCreateSubMatrixOption;
3585494a064SHong Zhang 
359607a6623SBarry Smith PETSC_EXTERN PetscErrorCode MatInitializePackage(void);
3604bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatFinalizePackage(void);
361c06d978dSMatthew Knepley 
362014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *);
36377433607SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFromOptions(MPI_Comm, const char *, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
364014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt);
36519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType);
3660d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *);
3670d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType);
368014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat);
369fe2efc57SMark PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]);
370bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat));
37123bebc0bSBarry Smith PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]);
372014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]);
37326cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]);
37426cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]);
375014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]);
376014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]);
3775d5d24bbSJeremy L Thompson PETSC_EXTERN PetscErrorCode MatGetState(Mat, PetscObjectState *);
37884d44b13SHong Zhang PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool);
379f69a0ea3SMatthew Knepley 
380140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatList;
381140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatColoringList;
382140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatPartitioningList;
38328988994SBarry Smith 
3843b224e63SBarry Smith /*E
385aa6c7ce3SBarry Smith    MatStructure - Indicates if two matrices have the same nonzero structure
3863b224e63SBarry Smith 
3872ef1f0ffSBarry Smith    Values:
3882ef1f0ffSBarry Smith +  `SAME_NONZERO_PATTERN`      - the two matrices have identical nonzero patterns
3892ef1f0ffSBarry Smith .  `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns
3902ef1f0ffSBarry Smith .  `SUBSET_NONZERO_PATTERN`    - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix
3912ef1f0ffSBarry Smith -  `UNKNOWN_NONZERO_PATTERN`   - there is no known relationship between the nonzero patterns. In this case the implementations
3922ef1f0ffSBarry Smith                                  may try to detect a relationship to optimize the operation
393531d0c6aSBarry Smith 
39416a05f60SBarry Smith    Level: beginner
39516a05f60SBarry Smith 
396af27ebaaSBarry Smith    Note:
397af27ebaaSBarry 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
398af27ebaaSBarry 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
399af27ebaaSBarry Smith    to certain PETSc routines.
400af27ebaaSBarry Smith 
4011cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()`
4023b224e63SBarry Smith E*/
4039371c9d4SSatish Balay typedef enum {
4049371c9d4SSatish Balay   DIFFERENT_NONZERO_PATTERN,
4059371c9d4SSatish Balay   SUBSET_NONZERO_PATTERN,
4069371c9d4SSatish Balay   SAME_NONZERO_PATTERN,
4079371c9d4SSatish Balay   UNKNOWN_NONZERO_PATTERN
4089371c9d4SSatish Balay } MatStructure;
409d60b7d5cSBarry Smith PETSC_EXTERN const char *const MatStructures[];
4103b224e63SBarry Smith 
4119779e05dSSatish Balay #if defined PETSC_HAVE_MKL_SPARSE
412ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
413ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
41480095d54SIrina Sokolova PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
415ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
41680095d54SIrina Sokolova #endif
417cd929ea3SAlp Dener 
4184bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
4194bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJPERM(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
4204bf303faSJacob Faibussowitsch 
421d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
422d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
423d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]);
424d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
42507e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetFillRatio(Mat, PetscReal *);
42607e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetMaxSliceWidth(Mat, PetscInt *);
42707e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetAvgSliceWidth(Mat, PetscReal *);
42807e43b41SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetSliceHeight(Mat, PetscInt);
429b921024eSHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLGetVarSliceSize(Mat, PetscReal *);
43080095d54SIrina Sokolova 
4314bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
4324bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
433fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
434fa078d78SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMPISELLGetSeqSELL(Mat, Mat *, Mat *, const PetscInt *[]);
4354bf303faSJacob Faibussowitsch 
436014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
437014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
438014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
439014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
440014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
4418f8f2f0dSBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
4426a3d2595SBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]);
443014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *);
444c0c276a7Ssdargavi PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, PetscInt, PetscInt, Mat, Mat, PetscInt *, Mat *);
4453b00a383SHong Zhang 
446014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
447014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
448014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
4497e8381f9SStefano Zampini 
450e8729f6fSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]);
45182a78a4eSJed Brown PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]);
4527e8381f9SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode);
453d21a29f3SJed Brown 
454014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *);
455014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
456d21a29f3SJed Brown 
457014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
458014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
45938f409ebSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
460014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
4614cce697cSJed Brown PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]);
462dfb205c3SBarry Smith 
463014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, void *, Mat *);
464c1fff1c6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *);
465014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *);
466c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *);
467986c4d72SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *);
468267ca84cSJose E. Roman PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *);
469bcf2175cSMatthew Knepley PETSC_EXTERN PetscErrorCode MatLRCSetMats(Mat, Mat, Mat, Vec, Mat);
470c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *);
471014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
472014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
473c0cdd4a1SDahai Guo 
474014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *);
475014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter);
476014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *);
477014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *);
478014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat);
479014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat);
4809371c9d4SSatish Balay typedef enum {
4819371c9d4SSatish Balay   MAT_COMPOSITE_MERGE_RIGHT,
4829371c9d4SSatish Balay   MAT_COMPOSITE_MERGE_LEFT
4839371c9d4SSatish Balay } MatCompositeMergeType;
4848c8613bfSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType);
485014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *);
4860da935d5SPierre Jolivet /*E
4870da935d5SPierre Jolivet     MatCompositeType - indicates what type of `MATCOMPOSITE` is used
4880da935d5SPierre Jolivet 
4890da935d5SPierre Jolivet     Values:
4900da935d5SPierre Jolivet +  `MAT_COMPOSITE_ADDITIVE`       - sum of matrices (default)
4910da935d5SPierre Jolivet -  `MAT_COMPOSITE_MULTIPLICATIVE` - product of matrices
4920da935d5SPierre Jolivet 
4930da935d5SPierre Jolivet     Level: beginner
4940da935d5SPierre Jolivet 
4950da935d5SPierre Jolivet .seealso: [](ch_matrices), `MATCOMPOSITE`, `MatCompositeSetType()`, `MatCompositeGetType()`
4960da935d5SPierre Jolivet E*/
4979371c9d4SSatish Balay typedef enum {
4989371c9d4SSatish Balay   MAT_COMPOSITE_ADDITIVE,
4999371c9d4SSatish Balay   MAT_COMPOSITE_MULTIPLICATIVE
5009371c9d4SSatish Balay } MatCompositeType;
501014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType);
5026dbc55e5SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *);
5033b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure);
5043b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *);
5056d0add67SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *);
5068b5c3584SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *);
50703049c21SJunchao Zhang PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *);
5086d7c1e57SBarry Smith 
50919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *);
510014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *);
511dedccee8SHong Zhang 
512014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *);
5138060fb66Sstefano_zampini PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *);
514d0de2241SAndrew Spott PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *);
51506511a5cSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *);
516fa80d070SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *);
51765f45395SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *);
51854e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *);
51954e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS);
520014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *);
5213423f386SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *);
522345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatCreateDiagonal(Vec, Mat *);
523345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetDiagonal(Mat, Vec *);
524345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreDiagonal(Mat, Vec *);
525345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalGetInverseDiagonal(Mat, Vec *);
526345a4b08SToby Isaac PETSC_EXTERN PetscErrorCode MatDiagonalRestoreInverseDiagonal(Mat, Vec *);
5278a1df862SToby Isaac PETSC_EXTERN PetscErrorCode MatConstantDiagonalGetConstant(Mat, PetscScalar *);
52803db1824SAlex Lindsay PETSC_EXTERN PetscErrorCode MatGetCurrentMemType(Mat, PetscMemType *);
5291472f72bSBarry Smith 
530978814f1SStefano Zampini #if defined(PETSC_HAVE_HYPRE)
531d975228cSstefano_zampini PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
532978814f1SStefano Zampini #endif
533978814f1SStefano Zampini 
534014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]);
535ebead697SStefano Zampini PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]);
536cc4c1da9SBarry Smith PETSC_EXTERN PetscErrorCode MatPythonCreate(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const char[], Mat *);
5371d6018f0SLisandro Dalcin 
538846b4da1SFande Kong PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat);
539674b392bSAlexander PETSC_EXTERN PetscErrorCode MatResetHash(Mat);
540014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetUp(Mat);
541014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroy(Mat *);
542e56f5c9eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *);
54321c89e3eSBarry Smith 
544014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatConjugate(Mat);
545014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRealPart(Mat);
546014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat);
547014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *);
548014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *);
549713ccfa9SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **);
5500da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *);
551479a70c0SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat);
5528a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *);
55320c04d79SPierre Jolivet PETSC_EXTERN PetscErrorCode MatComputeVariableBlockEnvelope(Mat);
55499cafbc1SBarry Smith 
555014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
5568a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode);
557014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
558014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]);
559014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]);
560014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]);
56173a71a0fSBarry Smith PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom);
56284cb2905SBarry Smith 
5632ef4de8bSBarry Smith /*S
5642ef1f0ffSBarry Smith    MatStencil - Data structure (C struct) for storing information about rows and
5652ef1f0ffSBarry Smith    columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()`
56662ef0227SBarry Smith 
5672ef1f0ffSBarry Smith    Level: beginner
5682ef1f0ffSBarry Smith 
5692ef1f0ffSBarry Smith    Notes:
57062ef0227SBarry 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).
57115229ffcSPierre Jolivet    The c represents the degrees of freedom at each grid point (the dof argument to `DMDASetDOF()`). If dof is 1 then this entry is ignored.
57262ef0227SBarry Smith 
573ce78bad3SBarry Smith    For stencil access to vectors see `DMDAVecGetArray()`
574be479b30SJed Brown 
5752ef1f0ffSBarry Smith    For staggered grids, see `DMStagStencil`
5762ef4de8bSBarry Smith 
577ce78bad3SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`
5782ef1f0ffSBarry Smith           `DMStagStencil`
5792ef4de8bSBarry Smith S*/
580435da068SBarry Smith typedef struct {
581c1ac3661SBarry Smith   PetscInt k, j, i, c;
582435da068SBarry Smith } MatStencil;
5832ef4de8bSBarry Smith 
584014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
585014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
586014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt);
587435da068SBarry Smith 
588d91e6319SBarry Smith /*E
5892ef1f0ffSBarry Smith     MatAssemblyType - Indicates if the process of setting values into the matrix is complete, and the matrix is ready for use
590d91e6319SBarry Smith 
5912ef1f0ffSBarry Smith     Values:
5922ef1f0ffSBarry Smith +   `MAT_FLUSH_ASSEMBLY` - you will continue to put values into the matrix
5932ef1f0ffSBarry Smith -   `MAT_FINAL_ASSEMBLY` - you wish to use the matrix with the values currently inserted
5942ef1f0ffSBarry Smith 
59516a05f60SBarry Smith     Level: beginner
59616a05f60SBarry Smith 
5971cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetValues`, `MatAssemblyBegin()`, `MatAssemblyEnd()`
598d91e6319SBarry Smith E*/
5999371c9d4SSatish Balay typedef enum {
6009371c9d4SSatish Balay   MAT_FLUSH_ASSEMBLY = 1,
6019371c9d4SSatish Balay   MAT_FINAL_ASSEMBLY = 0
6029371c9d4SSatish Balay } MatAssemblyType;
6034f58015eSStefano Zampini 
604014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType);
605014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType);
606014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *);
6074f9c727eSBarry Smith 
608d91e6319SBarry Smith /*E
6092ef1f0ffSBarry Smith    MatOption - Options that may be set for a matrix that indicate properties of the matrix or affect its behavior or storage
610d91e6319SBarry Smith 
611d91e6319SBarry Smith    Level: beginner
612d91e6319SBarry Smith 
6132ef1f0ffSBarry Smith    Note:
6142ef1f0ffSBarry Smith    See `MatSetOption()` for the use of the options
6152ef1f0ffSBarry Smith 
6162ef1f0ffSBarry Smith    Developer Note:
61795452b02SPatrick Sanan    Entries that are negative need not be called collectively by all processes.
618382164b0SBarry Smith 
6191cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatSetOption()`
620d91e6319SBarry Smith E*/
6219371c9d4SSatish Balay typedef enum {
6229371c9d4SSatish Balay   MAT_OPTION_MIN                  = -3,
623c5e4d11fSDmitry Karpeev   MAT_UNUSED_NONZERO_LOCATION_ERR = -2,
62492d4d306SBarry Smith   MAT_ROW_ORIENTED                = -1,
625382164b0SBarry Smith   MAT_SYMMETRIC                   = 1,
626382164b0SBarry Smith   MAT_STRUCTURALLY_SYMMETRIC      = 2,
6278c78258cSHong Zhang   MAT_FORCE_DIAGONAL_ENTRIES      = 3,
628382164b0SBarry Smith   MAT_IGNORE_OFF_PROC_ENTRIES     = 4,
629382164b0SBarry Smith   MAT_USE_HASH_TABLE              = 5,
630382164b0SBarry Smith   MAT_KEEP_NONZERO_PATTERN        = 6,
631382164b0SBarry Smith   MAT_IGNORE_ZERO_ENTRIES         = 7,
632382164b0SBarry Smith   MAT_USE_INODES                  = 8,
633382164b0SBarry Smith   MAT_HERMITIAN                   = 9,
634382164b0SBarry Smith   MAT_SYMMETRY_ETERNAL            = 10,
635c5e4d11fSDmitry Karpeev   MAT_NEW_NONZERO_LOCATION_ERR    = 11,
636382164b0SBarry Smith   MAT_IGNORE_LOWER_TRIANGULAR     = 12,
637382164b0SBarry Smith   MAT_ERROR_LOWER_TRIANGULAR      = 13,
638382164b0SBarry Smith   MAT_GETROW_UPPERTRIANGULAR      = 14,
639382164b0SBarry Smith   MAT_SPD                         = 15,
64092d4d306SBarry Smith   MAT_NO_OFF_PROC_ZERO_ROWS       = 16,
64192d4d306SBarry Smith   MAT_NO_OFF_PROC_ENTRIES         = 17,
64292d4d306SBarry Smith   MAT_NEW_NONZERO_LOCATIONS       = 18,
643c5e4d11fSDmitry Karpeev   MAT_NEW_NONZERO_ALLOCATION_ERR  = 19,
644c5e4d11fSDmitry Karpeev   MAT_SUBSET_OFF_PROC_ENTRIES     = 20,
645c10200c1SHong Zhang   MAT_SUBMAT_SINGLEIS             = 21,
646957cac9fSHong Zhang   MAT_STRUCTURE_ONLY              = 22,
647071fcb05SBarry Smith   MAT_SORTED_FULL                 = 23,
6481a2c6b5cSJunchao Zhang   MAT_FORM_EXPLICIT_TRANSPOSE     = 24,
649b94d7dedSBarry Smith   MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25,
650b94d7dedSBarry Smith   MAT_SPD_ETERNAL                 = 26,
6519371c9d4SSatish Balay   MAT_OPTION_MAX                  = 27
6529371c9d4SSatish Balay } MatOption;
653e057df02SPaul Mullowney 
6540f8fb01aSBarry Smith PETSC_EXTERN const char *const *MatOptions;
655014dd563SJed Brown PETSC_EXTERN PetscErrorCode     MatSetOption(Mat, MatOption, PetscBool);
6567d68702bSBarry Smith PETSC_EXTERN PetscErrorCode     MatGetOption(Mat, MatOption, PetscBool *);
657856afa8bSStefano Zampini PETSC_EXTERN PetscErrorCode     MatPropagateSymmetryOptions(Mat, Mat);
65819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode     MatGetType(Mat, MatType *);
65984cb2905SBarry Smith 
660014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
661014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
662014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
663014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetRowUpperTriangular(Mat);
664014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatRestoreRowUpperTriangular(Mat);
665014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetColumnVector(Mat, Vec, PetscInt);
6668c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArray(Mat, PetscScalar *[]);
6678f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]);
668d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]);
6698c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArray(Mat, PetscScalar *[]);
6708f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]);
671d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]);
67221e72a00SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *);
673bd04181cSBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
6744099cc6bSBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJSetType(Mat, MatType);
675ad7e164aSPierre Jolivet PETSC_EXTERN PetscErrorCode    MatSeqAIJKron(Mat, Mat, MatReuse, Mat *);
676388d47a6SSatish Balay PETSC_EXTERN PetscErrorCode    MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *));
6774099cc6bSBarry Smith PETSC_EXTERN PetscFunctionList MatSeqAIJList;
678cda14afcSprj- PETSC_EXTERN PetscErrorCode    MatSeqBAIJGetArray(Mat, PetscScalar *[]);
679cda14afcSprj- PETSC_EXTERN PetscErrorCode    MatSeqBAIJRestoreArray(Mat, PetscScalar *[]);
6808397e458SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqSBAIJGetArray(Mat, PetscScalar *[]);
6818397e458SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]);
6828c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseGetArray(Mat, PetscScalar *[]);
6838c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseRestoreArray(Mat, PetscScalar *[]);
684d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode    MatDensePlaceArray(Mat, const PetscScalar[]);
685d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseReplaceArray(Mat, const PetscScalar[]);
686d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseResetArray(Mat);
6878572280aSBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseGetArrayRead(Mat, const PetscScalar *[]);
6888572280aSBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayRead(Mat, const PetscScalar *[]);
6896947451fSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseGetArrayWrite(Mat, PetscScalar *[]);
6906947451fSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayWrite(Mat, PetscScalar *[]);
691cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayAndMemType(Mat, PetscScalar *[], PetscMemType *);
692cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayAndMemType(Mat, PetscScalar *[]);
693cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayReadAndMemType(Mat, const PetscScalar *[], PetscMemType *);
694cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayReadAndMemType(Mat, const PetscScalar *[]);
695cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayWriteAndMemType(Mat, PetscScalar *[], PetscMemType *);
696cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayWriteAndMemType(Mat, PetscScalar *[]);
697014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetBlockSize(Mat, PetscInt *);
698014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSize(Mat, PetscInt);
699014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetBlockSizes(Mat, PetscInt *, PetscInt *);
700014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSizes(Mat, PetscInt, PetscInt);
70133d57670SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSizesFromMats(Mat, Mat, Mat);
7026e25ca73SStefano Zampini PETSC_EXTERN PetscErrorCode    MatSetVariableBlockSizes(Mat, PetscInt, const PetscInt[]);
7036e25ca73SStefano Zampini PETSC_EXTERN PetscErrorCode    MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt *[]);
704d7ff4d9fSStefano Zampini PETSC_EXTERN PetscErrorCode    MatSelectVariableBlockSizes(Mat, Mat, IS);
7050da83c2eSBarry Smith 
70686aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]);
70786aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]);
7086947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *);
7096947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *);
7106947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *);
7116947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *);
7126947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *);
7136947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *);
714a2748737SPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
7155ea7661aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *);
7161620fd73SBarry Smith 
717014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec);
718014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec);
719014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec);
720014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec);
721014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec);
722014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *);
723014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *);
724014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec);
725014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec);
726014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat);
727bdc285e1SStefano Zampini PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat);
728eb3ef3b2SHong Zhang PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat);
729f9426fe0SMark Adams PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec);
730f5edf698SHong Zhang 
731d91e6319SBarry Smith /*E
732d91e6319SBarry Smith   MatDuplicateOption - Indicates if a duplicated sparse matrix should have
733d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
734d91e6319SBarry Smith 
7352ef1f0ffSBarry Smith   Values:
7362ef1f0ffSBarry Smith + `MAT_DO_NOT_COPY_VALUES`    - Create a matrix using the same nonzero pattern as the original matrix,
7372ef1f0ffSBarry Smith                                 with zeros for the numerical values
7382ef1f0ffSBarry Smith . `MAT_COPY_VALUES`           - Create a matrix with the same nonzero pattern as the original matrix
7392ef1f0ffSBarry Smith                                 and with the same numerical values.
7402ef1f0ffSBarry Smith - `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix
7412ef1f0ffSBarry Smith                                 and does not copy it, using zeros for the numerical values. The parent and
7422ef1f0ffSBarry Smith                                 child matrices will share their index (i and j) arrays, and you cannot
7432ef1f0ffSBarry Smith                                 insert new nonzero entries into either matrix
7440018da39SRichard Tran Mills 
74516a05f60SBarry Smith   Level: beginner
74616a05f60SBarry Smith 
74787497f52SBarry Smith   Note:
74887497f52SBarry Smith   Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in
74987497f52SBarry Smith   this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified.
75070dcbbb9SBarry Smith 
7511cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatDuplicate()`
752d91e6319SBarry Smith E*/
7539371c9d4SSatish Balay typedef enum {
7549371c9d4SSatish Balay   MAT_DO_NOT_COPY_VALUES,
7559371c9d4SSatish Balay   MAT_COPY_VALUES,
7569371c9d4SSatish Balay   MAT_SHARE_NONZERO_PATTERN
7579371c9d4SSatish Balay } MatDuplicateOption;
7582e8a6d31SBarry Smith 
75919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *);
760014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *);
76194a9d846SBarry Smith 
762014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure);
763014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer);
764014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *);
765014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *);
766014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *);
767014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *);
768014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *);
769b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *);
770b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *);
771014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat, PetscBool *, PetscInt *);
772014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer);
7737b80b807SBarry Smith 
7741a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7751a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7761a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7771a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
778d4fbbf0eSBarry Smith 
779d91e6319SBarry Smith /*S
78087497f52SBarry Smith    MatInfo - Context of matrix information, used with `MatGetInfo()`
781d91e6319SBarry Smith 
782d91e6319SBarry Smith    Level: intermediate
783d91e6319SBarry Smith 
7842ef1f0ffSBarry Smith    Fortran Note:
785687234bfSJose E. Roman    `MatInfo` is a derived type, use e.g. `matinfo%nz_allocated` to access its components.
7862ef1f0ffSBarry Smith 
7871cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetInfo()`, `MatInfoType`
788d91e6319SBarry Smith S*/
7894e220ebcSLois Curfman McInnes typedef struct {
790b0a32e0cSBarry Smith   PetscLogDouble block_size;                          /* block size */
791b0a32e0cSBarry Smith   PetscLogDouble nz_allocated, nz_used, nz_unneeded;  /* number of nonzeros */
792b0a32e0cSBarry Smith   PetscLogDouble memory;                              /* memory allocated */
793b0a32e0cSBarry Smith   PetscLogDouble assemblies;                          /* number of matrix assemblies called */
794b0a32e0cSBarry Smith   PetscLogDouble mallocs;                             /* number of mallocs during MatSetValues() */
795b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */
796b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                      /* number of mallocs during factorization */
7974e220ebcSLois Curfman McInnes } MatInfo;
7984e220ebcSLois Curfman McInnes 
799d9274352SBarry Smith /*E
800d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
801d9274352SBarry Smith     the entire parallel matrix or the maximum over all the local parts.
802d9274352SBarry Smith 
8032ef1f0ffSBarry Smith     Values:
8042ef1f0ffSBarry Smith +   `MAT_LOCAL`      - values for each MPI process part of the matrix
8052ef1f0ffSBarry Smith .   `MAT_GLOBAL_MAX` - maximum of each value over all MPI processes
8062ef1f0ffSBarry Smith -   `MAT_GLOBAL_SUM` - sum of each value over all MPI processes
807d9274352SBarry Smith 
80816a05f60SBarry Smith     Level: beginner
80916a05f60SBarry Smith 
8101cc06b55SBarry Smith .seealso: [](ch_matrices), `MatGetInfo()`, `MatInfo`
811d9274352SBarry Smith E*/
8129371c9d4SSatish Balay typedef enum {
8139371c9d4SSatish Balay   MAT_LOCAL      = 1,
8149371c9d4SSatish Balay   MAT_GLOBAL_MAX = 2,
8159371c9d4SSatish Balay   MAT_GLOBAL_SUM = 3
8169371c9d4SSatish Balay } MatInfoType;
817014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *);
818014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec);
819014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]);
820014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]);
821014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]);
822eede4a3fSMark Adams PETSC_EXTERN PetscErrorCode MatGetRowSumAbs(Mat, Vec);
823014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]);
824014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec);
825014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *);
8267fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *);
8277fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat);
828014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *);
829014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *);
830014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec);
831014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode);
832a52676ecSHong Zhang 
833014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *);
834014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *);
835014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *);
836014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
837014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
838e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
839e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
840a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
841a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
842cc48ffa7SToby Isaac PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
8434222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
844447fed29SStefano Zampini PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
84586919fd6SHong Zhang PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *);
8467b80b807SBarry Smith 
847014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *);
848014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *);
849857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *);
850857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *);
851857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *);
852857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *);
853857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *);
854857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *);
855857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *);
856014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat);
8571b2b9847SBarry Smith PETSC_EXTERN PetscErrorCode MatSetInf(Mat);
858014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
859014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec);
860014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
861014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
862014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
863014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec);
8647b80b807SBarry Smith 
865014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *);
866014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *);
867014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *);
868014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **);
869014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *);
870014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **);
871566876eaSJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *);
8725ef9f2a5SBarry Smith 
8737dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
874edd03b47SJacob 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[])
875d71ae5a4SJacob Faibussowitsch {
8769371c9d4SSatish Balay   return MatCreateSubMatrices(mat, n, irow, icol, scall, submat);
8779371c9d4SSatish Balay }
8787dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
879edd03b47SJacob 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[])
880d71ae5a4SJacob Faibussowitsch {
8819371c9d4SSatish Balay   return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat);
8829371c9d4SSatish Balay }
883014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]);
884df750dc8SHong Zhang PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]);
8857dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *);
886edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 8, 0, "MatCreateSubMatrix()", ) static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat)
887d71ae5a4SJacob Faibussowitsch {
8889371c9d4SSatish Balay   return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat);
8899371c9d4SSatish Balay }
890014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *);
891014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *);
892014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *);
893014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *);
8947b80b807SBarry Smith 
895014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *);
896014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *);
897014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat);
898014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *);
8998a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *);
900014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
901ed502f03SStefano Zampini PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *);
902f2afee66SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *);
903014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *);
904014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]);
9058efafbd8SBarry Smith 
906014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt);
907ce78bad3SBarry Smith PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat, PetscInt, IS[], PetscInt);
908d2b2a242SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool);
9097b80b807SBarry Smith 
910014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
91122440eb1SKris Buschelman 
9127bab7c10SHong Zhang PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
9132df6c5c3SPatrick Farrell PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
9147bab7c10SHong Zhang 
915014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *);
916014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *);
91722440eb1SKris Buschelman 
918014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
919014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *);
920bc011b1eSHong Zhang 
921014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure);
922014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure);
9231c741599SHong Zhang 
924014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar);
925014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar);
9267b80b807SBarry Smith 
927014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping);
928014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
929a93ff8c4SPeter Brune PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *);
93081fa06acSBarry Smith PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout);
931014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
932014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
933014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
934014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
935e265f6d6SPatrick Sanan PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
936014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
937014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
938052efed2SBarry Smith 
939014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt);
940014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
94190f02eecSBarry Smith 
942014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec);
943014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec);
944014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec);
94530b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *);
94630b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *);
94730b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *);
9482a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *);
949edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 6, 0, "MatCreateVecs()", ) static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y)
950d71ae5a4SJacob Faibussowitsch {
9519371c9d4SSatish Balay   return MatCreateVecs(mat, x, y);
9529371c9d4SSatish Balay }
95353cd1579SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *);
954014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *);
955014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *);
9563a062f41SBarry Smith PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *);
9579c8f2541SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *);
958bd481603SBarry Smith 
959fe1fc275SAlexander PETSC_EXTERN PetscErrorCode MatCopyHashToXAIJ(Mat A, Mat B);
960c8d6c325SJunchao Zhang /*@C
9611620fd73SBarry Smith    MatSetValue - Set a single entry into a matrix.
9621620fd73SBarry Smith 
963e1c5b2e2SJose E. Roman    Not Collective
964a9834a7dSSatish Balay 
9651620fd73SBarry Smith    Input Parameters:
966c8d6c325SJunchao Zhang +  mat  - the matrix
96716a05f60SBarry Smith .  i    - the row location of the entry
96816a05f60SBarry Smith .  j    - the column location of the entry
96916a05f60SBarry Smith .  va   - the value to insert
97087497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
9711620fd73SBarry Smith 
9721620fd73SBarry Smith    Level: beginner
9731620fd73SBarry Smith 
97495bd0b28SBarry Smith    Notes:
97595bd0b28SBarry Smith    This value may be cached, so `MatAssemblyBegin()` and `MatAssemblyEnd()`
97695bd0b28SBarry Smith    MUST be called after all calls to `MatSetValue()` have been completed.
97795bd0b28SBarry Smith 
9782ef1f0ffSBarry Smith    For efficiency one should use `MatSetValues()` and set several values simultaneously.
9792ef1f0ffSBarry Smith 
980b43fc34aSPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `InsertMode`, `MatGetValue()`, `MatSetValues()`,
9812ef1f0ffSBarry Smith           `MatSetValueLocal()`, `MatSetValuesLocal()`
982c8d6c325SJunchao Zhang @*/
983c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValue(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
984d71ae5a4SJacob Faibussowitsch {
985c8d6c325SJunchao Zhang   return MatSetValues(mat, 1, &i, 1, &j, &va, mode);
9869371c9d4SSatish Balay }
9871620fd73SBarry Smith 
988e5e5a7b5SPatrick Sanan /*@C
989e5e5a7b5SPatrick Sanan    MatGetValue - Gets a single value from a matrix
9901620fd73SBarry Smith 
991e5e5a7b5SPatrick Sanan    Not Collective; can only return a value owned by the given process
992e5e5a7b5SPatrick Sanan 
993e5e5a7b5SPatrick Sanan    Input Parameters:
994e5e5a7b5SPatrick Sanan +  mat - the matrix
995e5e5a7b5SPatrick Sanan .  row - the row location of the entry
996e5e5a7b5SPatrick Sanan -  col - the column location of the entry
997e5e5a7b5SPatrick Sanan 
998e5e5a7b5SPatrick Sanan    Output Parameter:
999e5e5a7b5SPatrick Sanan .  va - the value
1000e5e5a7b5SPatrick Sanan 
10012ef1f0ffSBarry Smith    Level: advanced
10022ef1f0ffSBarry Smith 
1003e5e5a7b5SPatrick Sanan    Notes:
1004b43fc34aSPierre Jolivet    The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd()` before this call
10052ef1f0ffSBarry Smith 
100687497f52SBarry Smith    For efficiency one should use `MatGetValues()` and get several values simultaneously.
1007e5e5a7b5SPatrick Sanan 
100887497f52SBarry Smith    See notes for `MatGetValues()`.
1009e5e5a7b5SPatrick Sanan 
1010bfe80ac4SPierre Jolivet .seealso: [](ch_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd()`, `MatSetValue()`, `MatGetValuesLocal()`, `MatGetValues()`
1011e5e5a7b5SPatrick Sanan @*/
1012d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va)
1013d71ae5a4SJacob Faibussowitsch {
10149371c9d4SSatish Balay   return MatGetValues(mat, 1, &row, 1, &col, va);
10159371c9d4SSatish Balay }
1016e5e5a7b5SPatrick Sanan 
1017c8d6c325SJunchao Zhang /*@C
10182ef1f0ffSBarry Smith    MatSetValueLocal - Inserts or adds a single value into a matrix, using a local numbering of the nodes.
1019e5e5a7b5SPatrick Sanan 
1020e5e5a7b5SPatrick Sanan    Not Collective
1021e5e5a7b5SPatrick Sanan 
1022e5e5a7b5SPatrick Sanan    Input Parameters:
1023c8d6c325SJunchao Zhang +  mat  - the matrix
102416a05f60SBarry Smith .  i    - the row location of the entry
102516a05f60SBarry Smith .  j    - the column location of the entry
102616a05f60SBarry Smith .  va   - the value to insert
102787497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
1028e5e5a7b5SPatrick Sanan 
10292ef1f0ffSBarry Smith    Level: intermediate
10302ef1f0ffSBarry Smith 
1031e5e5a7b5SPatrick Sanan    Notes:
103287497f52SBarry Smith    For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously.
1033e5e5a7b5SPatrick Sanan 
103487497f52SBarry Smith    See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used.
1035e5e5a7b5SPatrick Sanan 
10361cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSetValue()`, `MatSetValuesLocal()`
1037c8d6c325SJunchao Zhang @*/
1038c8d6c325SJunchao Zhang static inline PetscErrorCode MatSetValueLocal(Mat mat, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
1039d71ae5a4SJacob Faibussowitsch {
1040c8d6c325SJunchao Zhang   return MatSetValuesLocal(mat, 1, &i, 1, &j, &va, mode);
10419371c9d4SSatish Balay }
10421620fd73SBarry Smith 
10431620fd73SBarry Smith /*MC
1044d0609cedSBarry Smith    MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per
1045bd481603SBarry Smith    row in a matrix providing the data that one can use to correctly preallocate the matrix.
1046bd481603SBarry Smith 
1047bd481603SBarry Smith    Synopsis:
1048aaa7dc30SBarry Smith    #include <petscmat.h>
1049d0609cedSBarry Smith    PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
1050bd481603SBarry Smith 
1051d083f849SBarry Smith    Collective
1052bd481603SBarry Smith 
1053bd481603SBarry Smith    Input Parameters:
1054bd481603SBarry Smith +  comm  - the communicator that will share the eventually allocated matrix
1055859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
1056859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
1057bd481603SBarry Smith 
1058bd481603SBarry Smith    Output Parameters:
1059bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
1060a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1061bd481603SBarry Smith 
10622ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1063bd481603SBarry Smith 
1064bd481603SBarry Smith    Notes:
10652ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
10662ef1f0ffSBarry Smith    the use of this routine
10672ef1f0ffSBarry Smith 
1068d0609cedSBarry Smith    This is a macro that handles its own error checking, it does not return an error code.
1069d0609cedSBarry Smith 
10702ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1071bd481603SBarry Smith 
10722ef1f0ffSBarry Smith    Developer Note:
1073af27ebaaSBarry Smith    This is a MACRO, not a function, because it has a leading { that is closed by `PetscPreallocateFinalize()`.
1074bd481603SBarry Smith 
10751cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1076db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
1077bd481603SBarry Smith M*/
10789371c9d4SSatish Balay #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \
10799371c9d4SSatish Balay   do { \
10803ba16761SJacob Faibussowitsch     PetscInt              __nrows = (nrows), __ncols = (ncols), __rstart, __end = 0; \
10813ba16761SJacob Faibussowitsch     PetscInt PETSC_UNUSED __start; \
10829566063dSJacob Faibussowitsch     PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \
10839566063dSJacob Faibussowitsch     PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \
10849371c9d4SSatish Balay     __start = __end - __ncols; \
10859371c9d4SSatish Balay     (void)__start; \
10869566063dSJacob Faibussowitsch     PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \
10875f80ce2aSJacob Faibussowitsch   __rstart -= __nrows
10887c922b88SBarry Smith 
1089edd03b47SJacob Faibussowitsch #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateBegin()", ) MatPreallocateBegin(__VA_ARGS__)
1090d0609cedSBarry Smith 
1091bd481603SBarry Smith /*MC
1092bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1093bd481603SBarry Smith    inserted using a local number of the rows and columns
1094bd481603SBarry Smith 
1095bd481603SBarry Smith    Synopsis:
1096aaa7dc30SBarry Smith    #include <petscmat.h>
1097c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1098bd481603SBarry Smith 
1099bd481603SBarry Smith    Not Collective
1100bd481603SBarry Smith 
1101bd481603SBarry Smith    Input Parameters:
1102784ac674SJed Brown +  map   - the row mapping from local numbering to global numbering
1103bd481603SBarry Smith .  nrows - the number of rows indicated
11041d73ed98SBarry Smith .  rows  - the indices of the rows
1105784ac674SJed Brown .  cmap  - the column mapping from local to global numbering
1106bd481603SBarry Smith .  ncols - the number of columns in the matrix
1107bd481603SBarry Smith .  cols  - the columns indicated
1108bd481603SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1109a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1110bd481603SBarry Smith 
11112ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1112bd481603SBarry Smith 
1113bd481603SBarry Smith    Notes:
11142ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11152ef1f0ffSBarry Smith    the use of this routine
1116bd481603SBarry Smith 
11172ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1118bd481603SBarry Smith 
11191cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1120db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()`
1121bd481603SBarry Smith M*/
112294bad497SJacob Faibussowitsch #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
11239371c9d4SSatish 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));)
1124c4f061fbSSatish Balay 
1125bd481603SBarry Smith /*MC
1126c1154cd5SBarry Smith    MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1127c1154cd5SBarry Smith    inserted using a local number of the rows and columns. This version removes any duplicate columns in cols
1128c1154cd5SBarry Smith 
1129c1154cd5SBarry Smith    Synopsis:
1130c1154cd5SBarry Smith    #include <petscmat.h>
1131c1154cd5SBarry Smith    PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1132c1154cd5SBarry Smith 
1133c1154cd5SBarry Smith    Not Collective
1134c1154cd5SBarry Smith 
1135c1154cd5SBarry Smith    Input Parameters:
1136c1154cd5SBarry Smith +  map   - the row mapping from local numbering to global numbering
1137c1154cd5SBarry Smith .  nrows - the number of rows indicated
1138c1154cd5SBarry Smith .  rows  - the indices of the rows (these values are mapped to the global values)
1139c1154cd5SBarry Smith .  cmap  - the column mapping from local to global numbering
1140c1154cd5SBarry Smith .  ncols - the number of columns in the matrix   (this value will be changed if duplicate columns are found)
1141c1154cd5SBarry Smith .  cols  - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed)
1142c1154cd5SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1143a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1144c1154cd5SBarry Smith 
11452ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1146c1154cd5SBarry Smith 
1147c1154cd5SBarry Smith    Notes:
11482ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11492ef1f0ffSBarry Smith    the use of this routine
1150c1154cd5SBarry Smith 
11512ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1152c1154cd5SBarry Smith 
11531cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1154db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1155c1154cd5SBarry Smith M*/
115694bad497SJacob Faibussowitsch #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
11579371c9d4SSatish 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));)
1158c1154cd5SBarry Smith 
1159c1154cd5SBarry Smith /*MC
1160d6e23781SBarry Smith    MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1161bd481603SBarry Smith    inserted using a local number of the rows and columns
1162bd481603SBarry Smith 
1163bd481603SBarry Smith    Synopsis:
1164aaa7dc30SBarry Smith    #include <petscmat.h>
1165d6e23781SBarry Smith    PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1166d6e23781SBarry Smith 
1167d6e23781SBarry Smith    Not Collective
1168d6e23781SBarry Smith 
1169d6e23781SBarry Smith    Input Parameters:
1170d6e23781SBarry Smith +  map   - the row mapping from local numbering to global numbering
1171d6e23781SBarry Smith .  nrows - the number of rows indicated
1172d6e23781SBarry Smith .  rows  - the indices of the rows
1173d6e23781SBarry Smith .  cmap  - the column mapping from local to global numbering
1174d6e23781SBarry Smith .  ncols - the number of columns in the matrix
1175d6e23781SBarry Smith .  cols  - the columns indicated
1176d6e23781SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1177a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1178d6e23781SBarry Smith 
11792ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1180d6e23781SBarry Smith 
1181d6e23781SBarry Smith    Notes:
11822ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11832ef1f0ffSBarry Smith    the use of this routine
1184d6e23781SBarry Smith 
11852ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1186d6e23781SBarry Smith 
11871cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1188db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`
1189d6e23781SBarry Smith M*/
119094bad497SJacob Faibussowitsch #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
11919371c9d4SSatish 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));)
1192d6e23781SBarry Smith 
1193d6e23781SBarry Smith /*MC
1194d6e23781SBarry Smith    MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1195d6e23781SBarry Smith    inserted using a local number of the rows and columns
1196d6e23781SBarry Smith 
1197d6e23781SBarry Smith    Synopsis:
1198d6e23781SBarry Smith    #include <petscmat.h>
1199d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1200bd481603SBarry Smith 
1201bd481603SBarry Smith    Not Collective
1202bd481603SBarry Smith 
1203bd481603SBarry Smith    Input Parameters:
1204bd481603SBarry Smith +  map   - the mapping between local numbering and global numbering
1205bd481603SBarry Smith .  nrows - the number of rows indicated
12061d73ed98SBarry Smith .  rows  - the indices of the rows
1207bd481603SBarry Smith .  ncols - the number of columns in the matrix
1208bd481603SBarry Smith .  cols  - the columns indicated
1209bd481603SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1210a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1211bd481603SBarry Smith 
12122ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1213bd481603SBarry Smith 
1214bd481603SBarry Smith    Notes:
12152ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
12162ef1f0ffSBarry Smith    the use of this routine
1217bd481603SBarry Smith 
12182ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1219bd481603SBarry Smith 
12201cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`
1221db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1222bd481603SBarry Smith M*/
122394bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \
12249371c9d4SSatish 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));)
1225e83a5d19SLisandro Dalcin 
1226bd481603SBarry Smith /*MC
1227bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1228bd481603SBarry Smith    inserted using a local number of the rows and columns
1229bd481603SBarry Smith 
1230bd481603SBarry Smith    Synopsis:
1231aaa7dc30SBarry Smith    #include <petscmat.h>
1232c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1233bd481603SBarry Smith 
1234bd481603SBarry Smith    Not Collective
1235bd481603SBarry Smith 
1236bd481603SBarry Smith    Input Parameters:
123764075487SBarry Smith +  row   - the row
1238bd481603SBarry Smith .  ncols - the number of columns in the matrix
1239a50f8bf6SHong Zhang -  cols  - the columns indicated
1240a50f8bf6SHong Zhang 
1241a50f8bf6SHong Zhang    Output Parameters:
1242a50f8bf6SHong Zhang +  dnz - the array that will be passed to the matrix preallocation routines
1243a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1244bd481603SBarry Smith 
12452ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1246bd481603SBarry Smith 
1247bd481603SBarry Smith    Notes:
12482ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
12492ef1f0ffSBarry Smith    the use of this routine
1250bd481603SBarry Smith 
12512ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1252bd481603SBarry Smith 
1253af27ebaaSBarry Smith    This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin().
12541620fd73SBarry Smith 
12551cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1256db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1257bd481603SBarry Smith M*/
12589371c9d4SSatish Balay #define MatPreallocateSet(row, nc, cols, dnz, onz) \
12599371c9d4SSatish 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) { \
126064075487SBarry Smith     if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \
1261a6042fd4SStefano Zampini     else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \
12629371c9d4SSatish Balay   })
12637c922b88SBarry Smith 
1264bd481603SBarry Smith /*MC
1265d6e23781SBarry Smith    MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1266bd481603SBarry Smith    inserted using a local number of the rows and columns
1267bd481603SBarry Smith 
1268bd481603SBarry Smith    Synopsis:
1269aaa7dc30SBarry Smith    #include <petscmat.h>
1270d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1271bd481603SBarry Smith 
1272bd481603SBarry Smith    Not Collective
1273bd481603SBarry Smith 
1274bd481603SBarry Smith    Input Parameters:
1275bd481603SBarry Smith +  nrows - the number of rows indicated
12761d73ed98SBarry Smith .  rows  - the indices of the rows
1277bd481603SBarry Smith .  ncols - the number of columns in the matrix
1278bd481603SBarry Smith .  cols  - the columns indicated
1279bd481603SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1280a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
1281bd481603SBarry Smith 
12822ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1283bd481603SBarry Smith 
1284bd481603SBarry Smith    Notes:
12852ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
12862ef1f0ffSBarry Smith    the use of this routine
1287bd481603SBarry Smith 
12882ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1289bd481603SBarry Smith 
1290af27ebaaSBarry Smith    This is a MACRO, not a function, because it uses variables declared in MatPreallocateBegin().
12911620fd73SBarry Smith 
12921cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`,
1293db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1294bd481603SBarry Smith M*/
129594bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \
12969371c9d4SSatish Balay   PetscMacroReturnStandard(for (PetscInt __i = 0; __i < nc; __i++) { \
1297d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
1298a6042fd4SStefano Zampini     else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \
12999371c9d4SSatish Balay   })
1300d3d32019SBarry Smith 
1301bd481603SBarry Smith /*MC
1302a6042fd4SStefano Zampini    MatPreallocateLocation -  An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists
130316371a99SBarry Smith 
130416371a99SBarry Smith    Synopsis:
1305aaa7dc30SBarry Smith    #include <petscmat.h>
130616371a99SBarry Smith    PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz)
130716371a99SBarry Smith 
130816371a99SBarry Smith    Not Collective
130916371a99SBarry Smith 
131016371a99SBarry Smith    Input Parameters:
1311a2b725a8SWilliam Gropp +  A     - matrix
131216371a99SBarry Smith .  row   - row where values exist (must be local to this process)
131316371a99SBarry Smith .  ncols - number of columns
131416371a99SBarry Smith .  cols  - columns with nonzeros
131516371a99SBarry Smith .  dnz   - the array that will be passed to the matrix preallocation routines
1316a6042fd4SStefano Zampini -  onz   - the other array passed to the matrix preallocation routines
131716371a99SBarry Smith 
13182ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
131916371a99SBarry Smith 
132016371a99SBarry Smith    Notes:
13212ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
13222ef1f0ffSBarry Smith    the use of this routine
132316371a99SBarry Smith 
13242ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
132516371a99SBarry Smith 
1326af27ebaaSBarry Smith    Developer Note:
1327af27ebaaSBarry Smith    This is a MACRO, not a function, because it uses a bunch of variables private to the MatPreallocation.... routines.
132816371a99SBarry Smith 
13291cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1330db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
133116371a99SBarry Smith M*/
1332d0609cedSBarry 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))
133316371a99SBarry Smith 
133416371a99SBarry Smith /*MC
1335d0609cedSBarry Smith    MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per
1336bd481603SBarry Smith    row in a matrix providing the data that one can use to correctly preallocate the matrix.
1337bd481603SBarry Smith 
1338bd481603SBarry Smith    Synopsis:
1339aaa7dc30SBarry Smith    #include <petscmat.h>
1340d0609cedSBarry Smith    PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz)
1341bd481603SBarry Smith 
1342d083f849SBarry Smith    Collective
1343bd481603SBarry Smith 
1344bd481603SBarry Smith    Input Parameters:
134516371a99SBarry Smith +  dnz - the array that was be passed to the matrix preallocation routines
1346a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1347bd481603SBarry Smith 
13482ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1349bd481603SBarry Smith 
1350bd481603SBarry Smith    Notes:
13512ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
13522ef1f0ffSBarry Smith    the use of this routine
1353d0609cedSBarry Smith 
13542ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1355bd481603SBarry Smith 
13562ef1f0ffSBarry Smith    Developer Note:
1357af27ebaaSBarry Smith    This is a MACRO, not a function, because it closes the { started in MatPreallocateBegin().
13581620fd73SBarry Smith 
13591cc06b55SBarry Smith .seealso: [](ch_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1360db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
1361bd481603SBarry Smith M*/
13629371c9d4SSatish Balay #define MatPreallocateEnd(dnz, onz) \
13639371c9d4SSatish Balay   PetscCall(PetscFree2(dnz, onz)); \
13649371c9d4SSatish Balay   } \
13659371c9d4SSatish Balay   while (0)
1366d0609cedSBarry Smith 
1367edd03b47SJacob Faibussowitsch #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO(3, 18, 0, "MatPreallocateEnd()", ) MatPreallocateEnd(__VA_ARGS__)
13687c922b88SBarry Smith 
13697b80b807SBarry Smith /* Routines unique to particular data structures */
1370014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, void *);
1371698d4c6aSKris Buschelman 
1372014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *);
1373014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *);
1374698d4c6aSKris Buschelman 
1375014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]);
1376014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]);
1377014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1378014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1379014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1380ce78bad3SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscCount, PetscBool);
13817b80b807SBarry Smith 
1382a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4
1383a96a251dSBarry Smith 
1384014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1385014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1386014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]);
138719b08ed1SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt);
1388273d9f13SBarry Smith 
1389014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1390014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1391014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1392014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1393014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1394014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1395014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1396014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]);
1397b44e7856SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *);
1398252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *);
1399014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]);
1400014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]);
14019230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
14029230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
1403014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *);
1404273d9f13SBarry Smith 
140549a6ff4bSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *);
1406ad16ce7aSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt);
1407edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatDenseSetLDA()", ) static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda)
1408d71ae5a4SJacob Faibussowitsch {
14099371c9d4SSatish Balay   return MatDenseSetLDA(A, lda);
14109371c9d4SSatish Balay }
1411014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *);
14121b807ce4Svictorle 
1413621e819fSSatish Balay PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1414621e819fSSatish Balay 
1415014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStoreValues(Mat);
1416014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat);
14172e8a6d31SBarry Smith 
1418014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *);
14197cfe41e4SPatrick Farrell PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *);
14207b80b807SBarry Smith /*
14217b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
142294b7f48cSBarry Smith   done through the KSP and PC interfaces.
14237b80b807SBarry Smith */
14247b80b807SBarry Smith 
142576bdecfbSBarry Smith /*J
14262ef1f0ffSBarry Smith    MatOrderingType - String with the name of a PETSc matrix ordering. These orderings are most commonly used
14272ef1f0ffSBarry Smith    to reduce fill in sparse factorizations.
1428d9274352SBarry Smith 
1429d9274352SBarry Smith    Level: beginner
1430d9274352SBarry Smith 
14312c7c0729SBarry Smith    Notes:
143216a05f60SBarry Smith    If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and instead the external factorization solver package called utilizes one
143316a05f60SBarry Smith    of its own.
14342c7c0729SBarry Smith 
14352ef1f0ffSBarry Smith    There is no `MatOrdering` object, the ordering is obtained directly from the matrix with `MatGetOrdering()`
14362ef1f0ffSBarry Smith 
14372ef1f0ffSBarry Smith    Developer Note:
14382ef1f0ffSBarry Smith    This API should be converted to an API similar to those for `MatColoring` and `MatPartitioning`
14392ef1f0ffSBarry Smith 
14401cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatGetFactor()`, `MatGetOrdering()`, `MatColoringType`, `MatPartitioningType`, `MatCoarsenType`, `MatCoarsenType`,
14412ef1f0ffSBarry Smith           `PCFactorSetOrderingType()`
144276bdecfbSBarry Smith J*/
144319fd82e9SBarry Smith typedef const char *MatOrderingType;
14442692d6eeSBarry Smith #define MATORDERINGNATURAL       "natural"
14452692d6eeSBarry Smith #define MATORDERINGND            "nd"
14462692d6eeSBarry Smith #define MATORDERING1WD           "1wd"
14472692d6eeSBarry Smith #define MATORDERINGRCM           "rcm"
14482692d6eeSBarry Smith #define MATORDERINGQMD           "qmd"
14492692d6eeSBarry Smith #define MATORDERINGROWLENGTH     "rowlength"
1450510184a7SJed Brown #define MATORDERINGWBM           "wbm"
1451fc1bef75SJed Brown #define MATORDERINGSPECTRAL      "spectral"
1452312e372aSBarry Smith #define MATORDERINGAMD           "amd"           /* only works if UMFPACK is installed with PETSc */
1453048412efSPablo Brubeck #define MATORDERINGMETISND       "metisnd"       /* only works if METIS is installed with PETSc */
14549bd791bbSBarry 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 */
14552c7c0729SBarry Smith #define MATORDERINGEXTERNAL      "external"      /* uses an ordering type internal to the factorization package */
1456b12f92e5SBarry Smith 
145719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode    MatGetOrdering(Mat, MatOrderingType, IS *, IS *);
1458140e18c1SBarry Smith PETSC_EXTERN PetscErrorCode    MatGetOrderingList(PetscFunctionList *);
1459bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode    MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *));
1460140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatOrderingList;
1461d4fbbf0eSBarry Smith 
1462013e2dc7SBarry Smith #include "petscmatcoarsen.h"
1463013e2dc7SBarry Smith 
1464014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS);
1465fc1bef75SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *);
1466a2ce50c7SBarry Smith 
14674ac6704cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *);
14684ac6704cSBarry Smith 
1469d91e6319SBarry Smith /*S
14702ef1f0ffSBarry Smith    MatFactorShiftType - Type of numeric shift used for factorizations
1471d90ac83dSHong Zhang 
14722ef1f0ffSBarry Smith    Values:
14732ef1f0ffSBarry Smith +  `MAT_SHIFT_NONE`              - do not shift the matrix diagonal entries
14742ef1f0ffSBarry Smith .  `MAT_SHIFT_NONZERO`           - shift the entries to be non-zero
14752ef1f0ffSBarry Smith .  `MAT_SHIFT_POSITIVE_DEFINITE` - shift the entries to force the factorization to be positive definite
14762ef1f0ffSBarry Smith -  `MAT_SHIFT_INBLOCKS`          - only shift the factors inside the small dense diagonal blocks of the matrix, for example with `MATBAIJ`
1477d90ac83dSHong Zhang 
14782ef1f0ffSBarry Smith    Level: intermediate
14792ef1f0ffSBarry Smith 
14801cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `PCFactorSetShiftType()`
1481d90ac83dSHong Zhang S*/
14829371c9d4SSatish Balay typedef enum {
14839371c9d4SSatish Balay   MAT_SHIFT_NONE,
14849371c9d4SSatish Balay   MAT_SHIFT_NONZERO,
14859371c9d4SSatish Balay   MAT_SHIFT_POSITIVE_DEFINITE,
14869371c9d4SSatish Balay   MAT_SHIFT_INBLOCKS
14879371c9d4SSatish Balay } MatFactorShiftType;
14886a6fc655SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypes[];
14895e9742b9SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypesDetail[];
1490d90ac83dSHong Zhang 
1491d90ac83dSHong Zhang /*S
1492ec5066bdSBarry Smith     MatFactorError - indicates what type of error was generated in a matrix factorization
14939aa7eafdSHong Zhang 
14942ef1f0ffSBarry Smith     Values:
14952ef1f0ffSBarry Smith +   `MAT_FACTOR_NOERROR`           - there was no error during the factorization
14962ef1f0ffSBarry Smith .   `MAT_FACTOR_STRUCT_ZEROPIVOT`  - there was a missing entry in a diagonal location of the matrix
14972ef1f0ffSBarry Smith .   `MAT_FACTOR_NUMERIC_ZEROPIVOT` - there was a (near) zero pivot during the factorization
14982ef1f0ffSBarry Smith .   `MAT_FACTOR_OUTMEMORY`         - the factorization has run out of memory
14992ef1f0ffSBarry Smith -   `MAT_FACTOR_OTHER`             - some other error has occurred.
15009aa7eafdSHong Zhang 
15012ef1f0ffSBarry Smith     Level: intermediate
150200e125f8SBarry Smith 
15032ef1f0ffSBarry Smith     Note:
15042ef1f0ffSBarry Smith     When a factorization is done in a preconditioner `PC` the error may be propagated up to a `PCFailedReason` or a `KSPConvergedReason`
15052ef1f0ffSBarry Smith 
15061cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatGetFactor()`, `MatFactorGetError()`, `MatFactorGetErrorZeroPivot()`, `MatFactorClearError()`,
15072ef1f0ffSBarry Smith           `PCFailedReason`, `PCGetFailedReason()`, `KSPConvergedReason`
15089aa7eafdSHong Zhang S*/
15099371c9d4SSatish Balay typedef enum {
15109371c9d4SSatish Balay   MAT_FACTOR_NOERROR,
15119371c9d4SSatish Balay   MAT_FACTOR_STRUCT_ZEROPIVOT,
15129371c9d4SSatish Balay   MAT_FACTOR_NUMERIC_ZEROPIVOT,
15139371c9d4SSatish Balay   MAT_FACTOR_OUTMEMORY,
15149371c9d4SSatish Balay   MAT_FACTOR_OTHER
15159371c9d4SSatish Balay } MatFactorError;
15169aa7eafdSHong Zhang 
151700e125f8SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *);
1518b8b68cfdSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat);
15197b6c816cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *);
152000e125f8SBarry Smith 
15219aa7eafdSHong Zhang /*S
1522422a814eSBarry Smith    MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization
1523b00f7748SHong Zhang 
1524b00f7748SHong Zhang    Level: developer
1525b00f7748SHong Zhang 
15262ef1f0ffSBarry Smith    Note:
15272ef1f0ffSBarry Smith    You can use `MatFactorInfoInitialize()` to set default values.
1528b00f7748SHong Zhang 
15292ef1f0ffSBarry Smith    Fortran Note:
1530687234bfSJose E. Roman    `MatFactorInfo` is a derived type, use e.g. `matfactorinfo%dt` to access its components.
15312ef1f0ffSBarry Smith 
15321cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatInfo`, `MatGetFactor()`, `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`,
15332ef1f0ffSBarry Smith           `MatICCFactorSymbolic()`, `MatICCFactor()`, `MatFactorInfoInitialize()`
1534b00f7748SHong Zhang S*/
1535b00f7748SHong Zhang typedef struct {
153615e8a5b3SHong Zhang   PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */
153785317021SBarry Smith   PetscReal usedt;
153815e8a5b3SHong Zhang   PetscReal dt;            /* drop tolerance */
1539b00f7748SHong Zhang   PetscReal dtcol;         /* tolerance for pivoting */
154015e8a5b3SHong Zhang   PetscReal dtcount;       /* maximum nonzeros to be allowed per row */
154167e28bfeSBarry Smith   PetscReal fill;          /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */
1542348344bbSBarry Smith   PetscReal levels;        /* ICC/ILU(levels) */
1543ce78bad3SBarry Smith   PetscReal pivotinblocks; /* BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 factorization may be faster if do not pivot */
154415e8a5b3SHong Zhang   PetscReal zeropivot;     /* pivot is called zero if less than this */
1545f4db908eSBarry Smith   PetscReal shifttype;     /* type of shift added to matrix factor to prevent zero pivots */
1546f4db908eSBarry Smith   PetscReal shiftamount;   /* how large the shift is */
1547f82ac72cSJunchao Zhang   PetscBool factoronhost;  /* do factorization on host instead of device (for device matrix types) */
1548f82ac72cSJunchao Zhang   PetscBool solveonhost;   /* do mat solve on host with the factor (for device matrix types) */
154915e8a5b3SHong Zhang } MatFactorInfo;
1550ffa6d0a5SLois Curfman McInnes 
1551014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *);
15529a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *);
15539a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15549a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *);
15559a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *);
15569a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *);
15579a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
15589a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
15599a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15609a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *);
15619a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *);
15623f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *);
15633f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15643f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *);
1565014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *);
1566014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec);
1567014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec);
1568014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec);
1569014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec);
1570014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec);
1571014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec);
1572014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs);
15737c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat);
15747c2f51b8SStefano Zampini 
15759371c9d4SSatish Balay typedef enum {
15769371c9d4SSatish Balay   MAT_FACTOR_SCHUR_UNFACTORED,
15779371c9d4SSatish Balay   MAT_FACTOR_SCHUR_FACTORED,
15789371c9d4SSatish Balay   MAT_FACTOR_SCHUR_INVERTED
15799371c9d4SSatish Balay } MatFactorSchurStatus;
15808e7ba810SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS);
15817c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
15827c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus);
15835a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat);
15847c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
15855a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec);
15865a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec);
15876dba178dSStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat);
1588bb5a7306SBarry Smith 
15898a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat);
1590d91e6319SBarry Smith /*E
1591d91e6319SBarry Smith    MatSORType - What type of (S)SOR to perform
1592bb1eb677SSatish Balay 
15932ef1f0ffSBarry Smith    Values:
15942ef1f0ffSBarry Smith +  `SOR_FORWARD_SWEEP`         - do a sweep from the first row of the matrix to the last
15952ef1f0ffSBarry Smith .  `SOR_BACKWARD_SWEEP`        - do a sweep from the last row to the first
15962ef1f0ffSBarry Smith .  `SOR_SYMMETRIC_SWEEP`       - do a sweep from the first row to the last and then back to the first
1597af27ebaaSBarry Smith .  `SOR_LOCAL_FORWARD_SWEEP`   - each MPI process does its own forward sweep with no communication
1598af27ebaaSBarry Smith .  `SOR_LOCAL_BACKWARD_SWEEP`  - each MPI process does its own backward sweep with no communication
1599af27ebaaSBarry Smith .  `SOR_LOCAL_SYMMETRIC_SWEEP` - each MPI process does its own symmetric sweep with no communication
16002ef1f0ffSBarry Smith .  `SOR_ZERO_INITIAL_GUESS`    - indicates the initial solution is zero so the sweep can avoid unneeded computation
16012ef1f0ffSBarry Smith .  `SOR_EISENSTAT`             - apply the Eisentat application of SOR, see `PCEISENSTAT`
16022ef1f0ffSBarry Smith .  `SOR_APPLY_UPPER`           - multiply by the upper triangular portion of the matrix
16032ef1f0ffSBarry Smith -  `SOR_APPLY_LOWER`           - multiply by the lower triangular portion of the matrix
16042ef1f0ffSBarry Smith 
1605d91e6319SBarry Smith    Level: beginner
1606d91e6319SBarry Smith 
16072ef1f0ffSBarry Smith    Note:
16082ef1f0ffSBarry Smith    These may be bitwise ORd together
1609d9274352SBarry Smith 
16102ef1f0ffSBarry Smith    Developer Note:
16112ef1f0ffSBarry Smith    Since `MatSORType` may be bitwise ORd together, so do not change the numerical values below
1612d91e6319SBarry Smith 
16131cc06b55SBarry Smith .seealso: [](ch_matrices), `MatSOR()`
1614d91e6319SBarry Smith E*/
16159371c9d4SSatish Balay typedef enum {
16169371c9d4SSatish Balay   SOR_FORWARD_SWEEP         = 1,
16179371c9d4SSatish Balay   SOR_BACKWARD_SWEEP        = 2,
16189371c9d4SSatish Balay   SOR_SYMMETRIC_SWEEP       = 3,
16199371c9d4SSatish Balay   SOR_LOCAL_FORWARD_SWEEP   = 4,
16209371c9d4SSatish Balay   SOR_LOCAL_BACKWARD_SWEEP  = 8,
16219371c9d4SSatish Balay   SOR_LOCAL_SYMMETRIC_SWEEP = 12,
16229371c9d4SSatish Balay   SOR_ZERO_INITIAL_GUESS    = 16,
16239371c9d4SSatish Balay   SOR_EISENSTAT             = 32,
16249371c9d4SSatish Balay   SOR_APPLY_UPPER           = 64,
16259371c9d4SSatish Balay   SOR_APPLY_LOWER           = 128
16269371c9d4SSatish Balay } MatSORType;
1627014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec);
16288ed539a5SBarry Smith 
16297086a01eSPeter Brune /*S
16307086a01eSPeter Brune    MatColoring - Object for managing the coloring of matrices.
16317086a01eSPeter Brune 
16327086a01eSPeter Brune    Level: beginner
16337086a01eSPeter Brune 
1634ec5066bdSBarry Smith    Notes:
163587497f52SBarry 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
163687497f52SBarry Smith    matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors).
1637ec5066bdSBarry Smith 
163887497f52SBarry Smith    Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This
16392ef1f0ffSBarry Smith    same object can also be used to efficiently convert data created by Automatic Differentiation tools to PETSc sparse matrices.
1640ec5066bdSBarry Smith 
16411cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`,
16422ef1f0ffSBarry Smith           `MatPartitioning`, `MatColoringType`, `MatPartitioningType`, `MatOrderingType`, `MatColoringSetWeightType()`,
16432ef1f0ffSBarry Smith           `MatColoringSetWeights()`, `MatCoarsenType`, `MatCoarsen`
16447086a01eSPeter Brune S*/
1645d4db15c4SBarry Smith typedef struct _p_MatColoring *MatColoring;
1646d4db15c4SBarry Smith 
1647d4db15c4SBarry Smith /*J
1648d4db15c4SBarry Smith    MatColoringType - String with the name of a PETSc matrix coloring
1649d9274352SBarry Smith 
1650d9274352SBarry Smith    Level: beginner
1651d9274352SBarry Smith 
16521cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatFDColoringCreate()`, `MatColoringSetType()`, `MatColoring`
165376bdecfbSBarry Smith J*/
165419fd82e9SBarry Smith typedef const char *MatColoringType;
16555567d71aSPeter Brune #define MATCOLORINGJP      "jp"
1656b9acb617SPeter Brune #define MATCOLORINGPOWER   "power"
16572692d6eeSBarry Smith #define MATCOLORINGNATURAL "natural"
16582692d6eeSBarry Smith #define MATCOLORINGSL      "sl"
16592692d6eeSBarry Smith #define MATCOLORINGLF      "lf"
16602692d6eeSBarry Smith #define MATCOLORINGID      "id"
16618121bdceSPeter Brune #define MATCOLORINGGREEDY  "greedy"
1662b12f92e5SBarry Smith 
16638ac6da0aSPeter Brune /*E
16642ef1f0ffSBarry Smith    MatColoringWeightType - Type of weight scheme used for the coloring algorithm
16658ac6da0aSPeter Brune 
16662ef1f0ffSBarry Smith    Values:
166787497f52SBarry Smith +  `MAT_COLORING_RANDOM`  - Random weights
166887497f52SBarry Smith .  `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering.
166987497f52SBarry Smith -  `MAT_COLORING_LF`      - Last-first weighting.
16708ac6da0aSPeter Brune 
16718ac6da0aSPeter Brune     Level: intermediate
16728ac6da0aSPeter Brune 
16731cc06b55SBarry Smith .seealso: [](ch_matrices), `MatColoring`, `MatColoringCreate()`, `MatColoringSetWeightType()`, `MatColoringSetWeights()`
16748ac6da0aSPeter Brune E*/
16759371c9d4SSatish Balay typedef enum {
16769371c9d4SSatish Balay   MAT_COLORING_WEIGHT_RANDOM,
16779371c9d4SSatish Balay   MAT_COLORING_WEIGHT_LEXICAL,
16789371c9d4SSatish Balay   MAT_COLORING_WEIGHT_LF,
16799371c9d4SSatish Balay   MAT_COLORING_WEIGHT_SL
16809371c9d4SSatish Balay } MatColoringWeightType;
16818ac6da0aSPeter Brune 
1682335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *);
1683d7f2a307SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *);
1684335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *);
1685335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer);
1686335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType);
1687335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring);
1688335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt);
1689335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *);
1690335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt);
1691335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *);
1692335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *);
1693335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring));
1694014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *);
16958ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType);
1696c29971fcSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *);
16978ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm);
1698bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring);
1699edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 10, 0, "MatColoringTest()", ) static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring)
1700d71ae5a4SJacob Faibussowitsch {
17019371c9d4SSatish Balay   return MatColoringTest(matcoloring, iscoloring);
17029371c9d4SSatish Balay }
1703bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring);
1704639f9d9dSBarry Smith 
1705d9274352SBarry Smith /*S
170687497f52SBarry Smith    MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring
1707639f9d9dSBarry Smith 
1708d9274352SBarry Smith    Level: beginner
1709d9274352SBarry Smith 
17102ba42892SBarry Smith    Options Database Key:
17112ba42892SBarry Smith .  -snes_fd_coloring - cause the Jacobian needed by `SNES` to be computed via a use of this object
1712ec5066bdSBarry Smith 
17132ba42892SBarry Smith    Note:
17142ba42892SBarry Smith    This object is created utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()`
17152ef1f0ffSBarry Smith 
17161cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()`
1717d9274352SBarry Smith S*/
1718e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
1719639f9d9dSBarry Smith 
17202ba42892SBarry Smith /*S
17212ba42892SBarry Smith   MatFDColoringFn - Function provided to `MatFDColoringSetFunction()` that computes the function being differenced
17222ba42892SBarry Smith 
17232ba42892SBarry Smith   Level: advanced
17242ba42892SBarry Smith 
17252ba42892SBarry Smith   Calling Sequence:
17262ba42892SBarry Smith + snes - either a `SNES` object if used within `SNES` otherwise an unused parameter
17272ba42892SBarry Smith . in   - the location where the Jacobian is to be computed
17282ba42892SBarry Smith . out  - the location to put the computed function value
17292ba42892SBarry Smith - fctx - the function context passed into `MatFDColoringSetFunction()`
17302ba42892SBarry Smith 
17312ba42892SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDiFn`, `MatMFFDiBaseFn`
17322ba42892SBarry Smith S*/
1733348d23efSPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatFDColoringFn(void *snes, Vec x, Vec y, void *fctx);
17342ba42892SBarry Smith 
1735014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *);
1736014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *);
1737014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer);
17382ba42892SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, MatFDColoringFn *, void *);
17392ba42892SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, MatFDColoringFn **, void **);
1740014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal);
1741014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring);
1742d1e9a80fSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *);
1743014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec);
1744edaa7c33SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]);
1745f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring);
1746f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt);
1747bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *);
1748b1683b59SHong Zhang 
1749b1683b59SHong Zhang /*S
1750af27ebaaSBarry Smith    MatTransposeColoring - Object for computing a sparse matrix product $C = A*B^T$ via coloring
1751b1683b59SHong Zhang 
17522ef1f0ffSBarry Smith    Level: developer
1753b1683b59SHong Zhang 
17541cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatProductType`, `MatTransposeColoringCreate()`
1755b1683b59SHong Zhang S*/
1756b9af6bddSHong Zhang typedef struct _p_MatTransposeColoring *MatTransposeColoring;
1757b1683b59SHong Zhang 
1758014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *);
1759014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat);
1760014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat);
1761014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *);
1762b1683b59SHong Zhang 
1763d9274352SBarry Smith /*S
1764d9274352SBarry Smith    MatPartitioning - Object for managing the partitioning of a matrix or graph
1765d9274352SBarry Smith 
1766d9274352SBarry Smith    Level: beginner
1767d9274352SBarry Smith 
176887497f52SBarry Smith    Note:
176987497f52SBarry Smith    There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations
177087497f52SBarry Smith    via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`)
1771ec5066bdSBarry Smith 
1772b5e6e808SPierre Jolivet    Developer Note:
17732ef1f0ffSBarry Smith    It is an extra maintenance and documentation cost to have two objects with the same functionality. `PetscPartitioner` should be removed
1774ec5066bdSBarry Smith 
17751cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`, `MatOrderingType`,
17762ef1f0ffSBarry Smith           `MatCoarsenType`, `MatCoarsenType`
1777d9274352SBarry Smith S*/
177891e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
1779d9274352SBarry Smith 
178076bdecfbSBarry Smith /*J
17818f6c3df8SBarry Smith     MatPartitioningType - String with the name of a PETSc matrix partitioning
1782d9274352SBarry Smith 
1783d9274352SBarry Smith    Level: beginner
17840d04baf8SBarry Smith dm
17851cc06b55SBarry Smith .seealso: [](ch_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`, `MatColoringType`, `MatOrderingType`,
17862ef1f0ffSBarry Smith           `MatCoarsenType`, `MatCoarsenType`
178776bdecfbSBarry Smith J*/
178819fd82e9SBarry Smith typedef const char *MatPartitioningType;
17892692d6eeSBarry Smith #define MATPARTITIONINGCURRENT  "current"
1790aa1e27eaSFande Kong #define MATPARTITIONINGAVERAGE  "average"
17912692d6eeSBarry Smith #define MATPARTITIONINGSQUARE   "square"
17922692d6eeSBarry Smith #define MATPARTITIONINGPARMETIS "parmetis"
17932692d6eeSBarry Smith #define MATPARTITIONINGCHACO    "chaco"
17942692d6eeSBarry Smith #define MATPARTITIONINGPARTY    "party"
179550d91057SBarry Smith #define MATPARTITIONINGPTSCOTCH "ptscotch"
179688d2ac2bSFande Kong #define MATPARTITIONINGHIERARCH "hierarch"
179771306c60Sjroman 
1798014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *);
179919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType);
1800014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt);
1801014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat);
1802252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt);
1803014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]);
1804014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]);
1805ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool);
1806ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *);
1807014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *);
1808fdd1c351SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *);
1809668144dbSFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS);
1810f3ad2dabSStefano Zampini PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *);
1811014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *);
1812bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning));
1813014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer);
1814fe2efc57SMark PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]);
1815014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning);
181619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *);
1817ca161407SBarry Smith 
1818ce78bad3SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning);
1819014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
1820014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *);
18210752156aSBarry Smith 
18229371c9d4SSatish Balay typedef enum {
18239371c9d4SSatish Balay   MP_CHACO_MULTILEVEL = 1,
18249371c9d4SSatish Balay   MP_CHACO_SPECTRAL   = 2,
18259371c9d4SSatish Balay   MP_CHACO_LINEAR     = 4,
18269371c9d4SSatish Balay   MP_CHACO_RANDOM     = 5,
18279371c9d4SSatish Balay   MP_CHACO_SCATTERED  = 6
18289371c9d4SSatish Balay } MPChacoGlobalType;
18296a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoGlobalTypes[];
18309371c9d4SSatish Balay typedef enum {
18319371c9d4SSatish Balay   MP_CHACO_KERNIGHAN = 1,
18329371c9d4SSatish Balay   MP_CHACO_NONE      = 2
18339371c9d4SSatish Balay } MPChacoLocalType;
18346a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoLocalTypes[];
18359371c9d4SSatish Balay typedef enum {
18369371c9d4SSatish Balay   MP_CHACO_LANCZOS = 0,
18379371c9d4SSatish Balay   MP_CHACO_RQI     = 1
18389371c9d4SSatish Balay } MPChacoEigenType;
18396a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoEigenTypes[];
1840b6956c12SJose Roman 
1841014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
1842014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *);
1843014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1844014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *);
1845014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal);
1846014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType);
1847014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *);
1848014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1849014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *);
1850014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
1851014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *);
185271306c60Sjroman 
185371306c60Sjroman #define MP_PARTY_OPT "opt"
185471306c60Sjroman #define MP_PARTY_LIN "lin"
185571306c60Sjroman #define MP_PARTY_SCA "sca"
185671306c60Sjroman #define MP_PARTY_RAN "ran"
185771306c60Sjroman #define MP_PARTY_GBF "gbf"
185871306c60Sjroman #define MP_PARTY_GCF "gcf"
185971306c60Sjroman #define MP_PARTY_BUB "bub"
186071306c60Sjroman #define MP_PARTY_DEF "def"
1861014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *);
186271306c60Sjroman #define MP_PARTY_HELPFUL_SETS  "hs"
186371306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
186471306c60Sjroman #define MP_PARTY_NONE          "no"
1865014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *);
1866014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal);
1867014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool);
1868014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool);
186971306c60Sjroman 
18709371c9d4SSatish Balay typedef enum {
18719371c9d4SSatish Balay   MP_PTSCOTCH_DEFAULT,
18729371c9d4SSatish Balay   MP_PTSCOTCH_QUALITY,
18739371c9d4SSatish Balay   MP_PTSCOTCH_SPEED,
18749371c9d4SSatish Balay   MP_PTSCOTCH_BALANCE,
18759371c9d4SSatish Balay   MP_PTSCOTCH_SAFETY,
18769371c9d4SSatish Balay   MP_PTSCOTCH_SCALABILITY
18779371c9d4SSatish Balay } MPPTScotchStrategyType;
18786a6fc655SJed Brown PETSC_EXTERN const char *const MPPTScotchStrategyTypes[];
1879e0f1cffaSJose Roman 
1880014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal);
1881014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *);
1882014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType);
1883014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *);
188471306c60Sjroman 
1885b43b03e9SMark F. Adams /*
18866294fa2bSFande Kong  * hierarchical partitioning
18876294fa2bSFande Kong  */
18884e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *);
18894e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *);
18904e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt);
18914e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt);
18926294fa2bSFande Kong 
1893014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *);
1894591294e4SBarry Smith 
18950752156aSBarry Smith /*
18968bb0f5c6SPierre Jolivet     If any of the enum values are changed, also update dMatOps dict at src/binding/petsc4py/src/petsc4py/PETSc/libpetsc4py.pyx
1897d4fbbf0eSBarry Smith */
18989371c9d4SSatish Balay typedef enum {
18999371c9d4SSatish Balay   MATOP_SET_VALUES                = 0,
19001c1c02c0SLois Curfman McInnes   MATOP_GET_ROW                   = 1,
19011c1c02c0SLois Curfman McInnes   MATOP_RESTORE_ROW               = 2,
19021c1c02c0SLois Curfman McInnes   MATOP_MULT                      = 3,
19031c1c02c0SLois Curfman McInnes   MATOP_MULT_ADD                  = 4,
19047c922b88SBarry Smith   MATOP_MULT_TRANSPOSE            = 5,
19057c922b88SBarry Smith   MATOP_MULT_TRANSPOSE_ADD        = 6,
19061c1c02c0SLois Curfman McInnes   MATOP_SOLVE                     = 7,
19071c1c02c0SLois Curfman McInnes   MATOP_SOLVE_ADD                 = 8,
19087c922b88SBarry Smith   MATOP_SOLVE_TRANSPOSE           = 9,
19097c922b88SBarry Smith   MATOP_SOLVE_TRANSPOSE_ADD       = 10,
19101c1c02c0SLois Curfman McInnes   MATOP_LUFACTOR                  = 11,
19111c1c02c0SLois Curfman McInnes   MATOP_CHOLESKYFACTOR            = 12,
1912a714c06dSBarry Smith   MATOP_SOR                       = 13,
19131c1c02c0SLois Curfman McInnes   MATOP_TRANSPOSE                 = 14,
19141c1c02c0SLois Curfman McInnes   MATOP_GETINFO                   = 15,
19151c1c02c0SLois Curfman McInnes   MATOP_EQUAL                     = 16,
19161c1c02c0SLois Curfman McInnes   MATOP_GET_DIAGONAL              = 17,
19171c1c02c0SLois Curfman McInnes   MATOP_DIAGONAL_SCALE            = 18,
19181c1c02c0SLois Curfman McInnes   MATOP_NORM                      = 19,
19191c1c02c0SLois Curfman McInnes   MATOP_ASSEMBLY_BEGIN            = 20,
19201c1c02c0SLois Curfman McInnes   MATOP_ASSEMBLY_END              = 21,
1921d519adbfSMatthew Knepley   MATOP_SET_OPTION                = 22,
1922d519adbfSMatthew Knepley   MATOP_ZERO_ENTRIES              = 23,
1923d519adbfSMatthew Knepley   MATOP_ZERO_ROWS                 = 24,
1924d519adbfSMatthew Knepley   MATOP_LUFACTOR_SYMBOLIC         = 25,
1925d519adbfSMatthew Knepley   MATOP_LUFACTOR_NUMERIC          = 26,
1926d519adbfSMatthew Knepley   MATOP_CHOLESKY_FACTOR_SYMBOLIC  = 27,
1927d519adbfSMatthew Knepley   MATOP_CHOLESKY_FACTOR_NUMERIC   = 28,
1928e5f2d425SStefano Zampini   MATOP_SETUP                     = 29,
1929d519adbfSMatthew Knepley   MATOP_ILUFACTOR_SYMBOLIC        = 30,
1930d519adbfSMatthew Knepley   MATOP_ICCFACTOR_SYMBOLIC        = 31,
1931a5b7ff6bSBarry Smith   MATOP_GET_DIAGONAL_BLOCK        = 32,
1932e5f2d425SStefano Zampini   MATOP_SET_INF                   = 33,
1933d519adbfSMatthew Knepley   MATOP_DUPLICATE                 = 34,
1934d519adbfSMatthew Knepley   MATOP_FORWARD_SOLVE             = 35,
1935d519adbfSMatthew Knepley   MATOP_BACKWARD_SOLVE            = 36,
1936d519adbfSMatthew Knepley   MATOP_ILUFACTOR                 = 37,
1937d519adbfSMatthew Knepley   MATOP_ICCFACTOR                 = 38,
1938d519adbfSMatthew Knepley   MATOP_AXPY                      = 39,
19397dae84e0SHong Zhang   MATOP_CREATE_SUBMATRICES        = 40,
1940d519adbfSMatthew Knepley   MATOP_INCREASE_OVERLAP          = 41,
1941d519adbfSMatthew Knepley   MATOP_GET_VALUES                = 42,
1942d519adbfSMatthew Knepley   MATOP_COPY                      = 43,
1943d519adbfSMatthew Knepley   MATOP_GET_ROW_MAX               = 44,
1944d519adbfSMatthew Knepley   MATOP_SCALE                     = 45,
1945d519adbfSMatthew Knepley   MATOP_SHIFT                     = 46,
194635153367SBarry Smith   MATOP_DIAGONAL_SET              = 47,
19479d39f69dSJed Brown   MATOP_ZERO_ROWS_COLUMNS         = 48,
19489d39f69dSJed Brown   MATOP_SET_RANDOM                = 49,
1949d519adbfSMatthew Knepley   MATOP_GET_ROW_IJ                = 50,
1950d519adbfSMatthew Knepley   MATOP_RESTORE_ROW_IJ            = 51,
1951d519adbfSMatthew Knepley   MATOP_GET_COLUMN_IJ             = 52,
1952d519adbfSMatthew Knepley   MATOP_RESTORE_COLUMN_IJ         = 53,
1953d519adbfSMatthew Knepley   MATOP_FDCOLORING_CREATE         = 54,
1954d519adbfSMatthew Knepley   MATOP_COLORING_PATCH            = 55,
1955d519adbfSMatthew Knepley   MATOP_SET_UNFACTORED            = 56,
1956d519adbfSMatthew Knepley   MATOP_PERMUTE                   = 57,
1957d519adbfSMatthew Knepley   MATOP_SET_VALUES_BLOCKED        = 58,
19587dae84e0SHong Zhang   MATOP_CREATE_SUBMATRIX          = 59,
1959d519adbfSMatthew Knepley   MATOP_DESTROY                   = 60,
1960d519adbfSMatthew Knepley   MATOP_VIEW                      = 61,
1961d519adbfSMatthew Knepley   MATOP_CONVERT_FROM              = 62,
19628bb0f5c6SPierre Jolivet   MATOP_MATMAT_MULT_SYMBOLIC      = 63,
19638bb0f5c6SPierre Jolivet   MATOP_MATMAT_MULT_NUMERIC       = 64,
19648bb0f5c6SPierre Jolivet   MATOP_SET_LOCAL_TO_GLOBAL_MAP   = 65,
19658bb0f5c6SPierre Jolivet   MATOP_SET_VALUES_LOCAL          = 66,
19668bb0f5c6SPierre Jolivet   MATOP_ZERO_ROWS_LOCAL           = 67,
19678bb0f5c6SPierre Jolivet   MATOP_GET_ROW_MAX_ABS           = 68,
19688bb0f5c6SPierre Jolivet   MATOP_GET_ROW_MIN_ABS           = 69,
19698bb0f5c6SPierre Jolivet   MATOP_CONVERT                   = 70,
19708bb0f5c6SPierre Jolivet   MATOP_HAS_OPERATION             = 71,
19718bb0f5c6SPierre Jolivet   MATOP_FD_COLORING_APPLY         = 72,
19728bb0f5c6SPierre Jolivet   MATOP_SET_FROM_OPTIONS          = 73,
19738bb0f5c6SPierre Jolivet   MATOP_FIND_ZERO_DIAGONALS       = 74,
19748bb0f5c6SPierre Jolivet   MATOP_MULT_MULTIPLE             = 75,
19758bb0f5c6SPierre Jolivet   MATOP_SOLVE_MULTIPLE            = 76,
19768bb0f5c6SPierre Jolivet   MATOP_GET_INERTIA               = 77,
19778bb0f5c6SPierre Jolivet   MATOP_LOAD                      = 78,
19788bb0f5c6SPierre Jolivet   MATOP_IS_SYMMETRIC              = 79,
19798bb0f5c6SPierre Jolivet   MATOP_IS_HERMITIAN              = 80,
19808bb0f5c6SPierre Jolivet   MATOP_IS_STRUCTURALLY_SYMMETRIC = 81,
19818bb0f5c6SPierre Jolivet   MATOP_SET_VALUES_BLOCKEDLOCAL   = 82,
19828bb0f5c6SPierre Jolivet   MATOP_CREATE_VECS               = 83,
19838bb0f5c6SPierre Jolivet   MATOP_MAT_MULT_SYMBOLIC         = 84,
19848bb0f5c6SPierre Jolivet   MATOP_MAT_MULT_NUMERIC          = 85,
19858bb0f5c6SPierre Jolivet   MATOP_PTAP_NUMERIC              = 86,
19868bb0f5c6SPierre Jolivet   MATOP_MAT_TRANSPOSE_MULT_SYMBO  = 87,
19878bb0f5c6SPierre Jolivet   MATOP_MAT_TRANSPOSE_MULT_NUMER  = 88,
19888bb0f5c6SPierre Jolivet   MATOP_BIND_TO_CPU               = 89,
19898bb0f5c6SPierre Jolivet   MATOP_PRODUCTSETFROMOPTIONS     = 90,
19908bb0f5c6SPierre Jolivet   MATOP_PRODUCTSYMBOLIC           = 91,
19918bb0f5c6SPierre Jolivet   MATOP_PRODUCTNUMERIC            = 92,
19928bb0f5c6SPierre Jolivet   MATOP_CONJUGATE                 = 93,
19938bb0f5c6SPierre Jolivet   MATOP_VIEW_NATIVE               = 94,
19948bb0f5c6SPierre Jolivet   MATOP_SET_VALUES_ROW            = 95,
19958bb0f5c6SPierre Jolivet   MATOP_REAL_PART                 = 96,
19968bb0f5c6SPierre Jolivet   MATOP_IMAGINARY_PART            = 97,
19978bb0f5c6SPierre Jolivet   MATOP_GET_ROW_UPPER_TRIANGULAR  = 98,
19988bb0f5c6SPierre Jolivet   MATOP_RESTORE_ROW_UPPER_TRIANG  = 99,
19998bb0f5c6SPierre Jolivet   MATOP_MAT_SOLVE                 = 100,
20008bb0f5c6SPierre Jolivet   MATOP_MAT_SOLVE_TRANSPOSE       = 101,
20018bb0f5c6SPierre Jolivet   MATOP_GET_ROW_MIN               = 102,
20028bb0f5c6SPierre Jolivet   MATOP_GET_COLUMN_VECTOR         = 103,
20038bb0f5c6SPierre Jolivet   MATOP_MISSING_DIAGONAL          = 104,
20048bb0f5c6SPierre Jolivet   MATOP_GET_SEQ_NONZERO_STRUCTUR  = 105,
20058bb0f5c6SPierre Jolivet   MATOP_CREATE                    = 106,
20068bb0f5c6SPierre Jolivet   MATOP_GET_GHOSTS                = 107,
20078bb0f5c6SPierre Jolivet   MATOP_GET_LOCAL_SUB_MATRIX      = 108,
20088bb0f5c6SPierre Jolivet   MATOP_RESTORE_LOCALSUB_MATRIX   = 109,
20098bb0f5c6SPierre Jolivet   MATOP_MULT_DIAGONAL_BLOCK       = 110,
20108bb0f5c6SPierre Jolivet   MATOP_HERMITIAN_TRANSPOSE       = 111,
20118bb0f5c6SPierre Jolivet   MATOP_MULT_HERMITIAN_TRANSPOSE  = 112,
20128bb0f5c6SPierre Jolivet   MATOP_MULT_HERMITIAN_TRANS_ADD  = 113,
20138bb0f5c6SPierre Jolivet   MATOP_GET_MULTI_PROC_BLOCK      = 114,
20148bb0f5c6SPierre Jolivet   MATOP_FIND_NONZERO_ROWS         = 115,
20158bb0f5c6SPierre Jolivet   MATOP_GET_COLUMN_NORMS          = 116,
20168bb0f5c6SPierre Jolivet   MATOP_INVERT_BLOCK_DIAGONAL     = 117,
20178bb0f5c6SPierre Jolivet   MATOP_INVERT_VBLOCK_DIAGONAL    = 118,
20188bb0f5c6SPierre Jolivet   MATOP_CREATE_SUB_MATRICES_MPI   = 119,
20198bb0f5c6SPierre Jolivet   MATOP_SET_VALUES_BATCH          = 120,
20208bb0f5c6SPierre Jolivet   MATOP_TRANSPOSE_MAT_MULT_SYMBO  = 121,
20218bb0f5c6SPierre Jolivet   MATOP_TRANSPOSE_MAT_MULT_NUMER  = 122,
20228bb0f5c6SPierre Jolivet   MATOP_TRANSPOSE_COLORING_CREAT  = 123,
20238bb0f5c6SPierre Jolivet   MATOP_TRANS_COLORING_APPLY_SPT  = 124,
20248bb0f5c6SPierre Jolivet   MATOP_TRANS_COLORING_APPLY_DEN  = 125,
20258bb0f5c6SPierre Jolivet   MATOP_RART_NUMERIC              = 126,
20268bb0f5c6SPierre Jolivet   MATOP_SET_BLOCK_SIZES           = 127,
20278bb0f5c6SPierre Jolivet   MATOP_RESIDUAL                  = 128,
20288bb0f5c6SPierre Jolivet   MATOP_FDCOLORING_SETUP          = 129,
20298bb0f5c6SPierre Jolivet   MATOP_FIND_OFFBLOCK_ENTRIES     = 130,
20308bb0f5c6SPierre Jolivet   MATOP_MPICONCATENATESEQ         = 131,
20318bb0f5c6SPierre Jolivet   MATOP_DESTROYSUBMATRICES        = 132,
20328bb0f5c6SPierre Jolivet   MATOP_MAT_TRANSPOSE_SOLVE       = 133,
20338bb0f5c6SPierre Jolivet   MATOP_GET_VALUES_LOCAL          = 134,
20348bb0f5c6SPierre Jolivet   MATOP_CREATE_GRAPH              = 135,
20358bb0f5c6SPierre Jolivet   MATOP_TRANSPOSE_SYMBOLIC        = 136,
20368bb0f5c6SPierre Jolivet   MATOP_ELIMINATE_ZEROS           = 137,
20378bb0f5c6SPierre Jolivet   MATOP_GET_ROW_SUM_ABS           = 138,
20388bb0f5c6SPierre Jolivet   MATOP_GET_FACTOR                = 139,
20398bb0f5c6SPierre Jolivet   MATOP_GET_BLOCK_DIAGONAL        = 140, /* NOTE: caller of the two op functions owns the returned matrix */
20408bb0f5c6SPierre Jolivet   MATOP_GET_VBLOCK_DIAGONAL       = 141, /* and need to destroy it after use. */
204103db1824SAlex Lindsay   MATOP_COPY_HASH_TO_XAIJ         = 142,
2042c2be7ffeSStefano Zampini   MATOP_GET_CURRENT_MEM_TYPE      = 143,
2043c2be7ffeSStefano Zampini   MATOP_ZERO_ROWS_COLUMNS_LOCAL   = 144
2044fae171e0SBarry Smith } MatOperation;
2045c2be7ffeSStefano Zampini 
204657d50842SBarry Smith PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, PetscErrorCodeFn *);
204757d50842SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, PetscErrorCodeFn **);
2048976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *);
204994342113SStefano Zampini PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *);
2050edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 14, 0, "MatProductClear()", ) static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A)
2051d71ae5a4SJacob Faibussowitsch {
20529371c9d4SSatish Balay   return MatProductClear(A);
20539371c9d4SSatish Balay }
205457d50842SBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, PetscErrorCodeFn *);
205557d50842SBarry Smith PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, PetscErrorCodeFn **);
2056014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, void *);
2057d1319cabSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscCtxDestroyFn *);
2058db77db73SJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType);
2059f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
2060f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
20610c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat);
2062b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscErrorCode (*)(void *), MatType, MatType);
2063b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *);
2064112a2221SBarry Smith 
206590ace30eSBarry Smith /*
206690ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
206790ace30eSBarry Smith    stored in a universal format. By changing the format with
20686a9046bcSBarry Smith    PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will
206990ace30eSBarry Smith    be stored in a way natural for the matrix, for example dense matrices
207090ace30eSBarry Smith    would be stored as dense. Matrices stored this way may only be
2071f4403165SShri Abhyankar    read into matrices of the same type.
207290ace30eSBarry Smith */
207390ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
207490ace30eSBarry Smith 
2075014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal);
207675d48cdbSStefano Zampini 
20778546b261SStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType);
207875d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
20794f58015eSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetAllowRepeated(Mat, PetscBool);
20804f58015eSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetAllowRepeated(Mat, PetscBool *);
208175d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool);
2082f03112d0SStefano Zampini PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool);
2083014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *);
20843b3b1effSJed Brown PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *);
2085014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat);
2086e432b41dSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
20871f4e1ec7SBarry Smith 
2088d9274352SBarry Smith /*S
2089d9274352SBarry Smith    MatNullSpace - Object that removes a null space from a vector, i.e.
2090cb6b9846SMatthew Knepley                   orthogonalizes the vector to a subspace
2091d9274352SBarry Smith 
2092f7a9e4ceSBarry Smith    Level: advanced
2093d9274352SBarry Smith 
20941cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
2095d9274352SBarry Smith S*/
209674637425SBarry Smith typedef struct _p_MatNullSpace *MatNullSpace;
2097d9274352SBarry Smith 
209834731ec5SBarry Smith /*S
209934731ec5SBarry Smith   MatNullSpaceRemoveFn - Function provided to `MatNullSpaceSetFunction()` that removes the null space from a vector
210034731ec5SBarry Smith 
210134731ec5SBarry Smith   Level: advanced
210234731ec5SBarry Smith 
210334731ec5SBarry Smith   Calling Sequence:
210434731ec5SBarry Smith + nsp - the `MatNullSpace` object
210534731ec5SBarry Smith . x   - the vector from which to remove the null space
210634731ec5SBarry Smith - ctx - [optional] user-defined function context provided with `MatNullSpaceSetFunction()`
210734731ec5SBarry Smith 
210834731ec5SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
210934731ec5SBarry Smith S*/
2110348d23efSPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatNullSpaceRemoveFn(MatNullSpace nsp, Vec x, void *ctx);
211134731ec5SBarry Smith 
2112014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *);
211334731ec5SBarry Smith PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, MatNullSpaceRemoveFn *, void *);
2114014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *);
2115d0195637SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec);
2116014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *);
21175fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *);
21185fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace);
2119014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace);
2120014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace);
2121014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *);
21224849c82aSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNullSpaces(PetscInt, Mat[], MatNullSpace *[]);
21234849c82aSBarry Smith PETSC_EXTERN PetscErrorCode MatRestoreNullSpaces(PetscInt, Mat[], MatNullSpace *[]);
2124014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *);
2125014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer);
2126014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **);
2127014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *);
212874637425SBarry Smith 
2129014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS);
2130014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat, PetscReal);
2131014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *);
21323f1d51d7SBarry Smith 
2133014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *);
2134014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *);
2135014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *);
2136c4f061fbSSatish Balay 
21370bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *);
21380bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *);
21390bacdadaSStefano Zampini 
2140edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperator()", ) static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B)
2141d71ae5a4SJacob Faibussowitsch {
2142f22e26b7SPierre Jolivet   return MatComputeOperator(A, PETSC_NULLPTR, B);
21439371c9d4SSatish Balay }
2144edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 12, 0, "MatComputeOperatorTranspose()", ) static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B)
2145d71ae5a4SJacob Faibussowitsch {
2146f22e26b7SPierre Jolivet   return MatComputeOperatorTranspose(A, PETSC_NULLPTR, B);
21479371c9d4SSatish Balay }
2148b0a32e0cSBarry Smith 
214949bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *);
215049bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *);
2151a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **);
2152a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2153a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **);
2154a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **);
2155a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **);
2156a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2157a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **);
2158a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **);
2159dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat);
2160dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]);
2161dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]);
2162910cf402Sprj- PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *);
216349bd79ccSDebojyoti Ghosh 
2164014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec);
216504f1ad80SBarry Smith 
21664bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDInitializePackage(void);
21674bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatMFFDFinalizePackage(void);
21684bf303faSJacob Faibussowitsch 
21694f3e17a8SBarry Smith /*S
21704f3e17a8SBarry Smith   MatMFFDFn - Function provided to `MatMFFDSetFunction()` that computes the function being differenced
21714f3e17a8SBarry Smith 
21724f3e17a8SBarry Smith   Level: advanced
21734f3e17a8SBarry Smith 
21744f3e17a8SBarry Smith   Calling Sequence:
21754f3e17a8SBarry Smith + ctx - [optional] user-defined function context provided with `MatMFFDSetFunction()`
21764f3e17a8SBarry Smith . x   - input vector
21774f3e17a8SBarry Smith - y   - output vector
21784f3e17a8SBarry Smith 
21794f3e17a8SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDiFn`, `MatMFFDiBaseFn`
21804f3e17a8SBarry Smith S*/
2181348d23efSPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDFn(void *ctx, Vec x, Vec y);
21824f3e17a8SBarry Smith 
21834f3e17a8SBarry Smith /*S
21844f3e17a8SBarry Smith   MatMFFDiFn - Function provided to `MatMFFDSetFunctioni()` that computes the function being differenced at a single point
21854f3e17a8SBarry Smith 
21864f3e17a8SBarry Smith   Level: advanced
21874f3e17a8SBarry Smith 
21884f3e17a8SBarry Smith   Calling Sequence:
21894f3e17a8SBarry Smith + ctx    - [optional] user-defined function context provided with `MatMFFDSetFunction()`
21904f3e17a8SBarry Smith . i      - the component of the vector to compute
21914f3e17a8SBarry Smith . x      - input vector
21924f3e17a8SBarry Smith - result - the value of the function at that component (output)
21934f3e17a8SBarry Smith 
21944f3e17a8SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDFn`, `MatMFFDiBaseFn`
21954f3e17a8SBarry Smith S*/
21964f3e17a8SBarry Smith PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDiFn(void *ctx, PetscInt i, Vec x, PetscScalar *result);
21974f3e17a8SBarry Smith 
21984f3e17a8SBarry Smith /*S
21994f3e17a8SBarry Smith   MatMFFDiBaseFn - Function provided to `MatMFFDSetFunctioniBase()` that computes the base of the function evaluations
22004f3e17a8SBarry Smith   that will be used for differencing
22014f3e17a8SBarry Smith 
22024f3e17a8SBarry Smith   Level: advanced
22034f3e17a8SBarry Smith 
22044f3e17a8SBarry Smith   Calling Sequence:
22054f3e17a8SBarry Smith + ctx - [optional] user-defined function context provided with `MatMFFDSetFunction()`
22064f3e17a8SBarry Smith - x   - input base vector
22074f3e17a8SBarry Smith 
22084f3e17a8SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`, `MatMFFDSetFunction()`, `MatMFFDSetFunctioniBase()`, `MatMFFDFn`, `MatMFFDiFn`
22094f3e17a8SBarry Smith S*/
22104f3e17a8SBarry Smith PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDiBaseFn(void *ctx, Vec x);
22114f3e17a8SBarry Smith 
22124f3e17a8SBarry Smith /*S
22134f3e17a8SBarry Smith   MatMFFDCheckhFn - Function provided to `MatMFFDSetCheckh()` that checks and possibly adjusts the value of `h` to ensure some property.
22144f3e17a8SBarry Smith   that will be used for differencing
22154f3e17a8SBarry Smith 
22164f3e17a8SBarry Smith   Level: advanced
22174f3e17a8SBarry Smith 
22184f3e17a8SBarry Smith   Calling Sequence:
22194f3e17a8SBarry Smith + ctx - [optional] user-defined function context provided with `MatMFFDSetCheckh()`
22204f3e17a8SBarry Smith . x   - input base vector
22214f3e17a8SBarry Smith . y   - input step vector that the product is computed with
22224f3e17a8SBarry Smith - h   - input tentative step, output possibly adjusted step
22234f3e17a8SBarry Smith 
22244f3e17a8SBarry Smith   Note:
22254f3e17a8SBarry Smith   `MatMFFDCheckPositivity()` is one such function
22264f3e17a8SBarry Smith 
22274f3e17a8SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateMFFD()`,  `MatMFFDSetCheckh()`, `MatMFFDCheckPositivity()`
22284f3e17a8SBarry Smith S*/
22294f3e17a8SBarry Smith PETSC_EXTERN_TYPEDEF typedef PetscErrorCode MatMFFDCheckhFn(void *ctx, Vec x, Vec y, PetscScalar *h);
22304f3e17a8SBarry Smith 
2231014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2232014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec);
22334f3e17a8SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, MatMFFDFn *, void *);
22344f3e17a8SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, MatMFFDiFn *);
22354f3e17a8SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, MatMFFDiBaseFn *);
2236014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt);
2237014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat);
2238014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal);
2239014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt);
2240014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *);
2241014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]);
2242014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *);
22434f3e17a8SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, MatMFFDCheckhFn *, void *);
2244e884886fSBarry Smith 
22456370053bSBarry Smith /*S
22466370053bSBarry Smith     MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free
22476370053bSBarry Smith               Jacobian vector products
2248e884886fSBarry Smith 
22492ef1f0ffSBarry Smith     Level: developer
22502ef1f0ffSBarry Smith 
225195452b02SPatrick Sanan     Notes:
225287497f52SBarry Smith     `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure
22536370053bSBarry Smith 
22542ef1f0ffSBarry Smith      MatMFFD*() methods actually take the `Mat` as their first argument. Not a `MatMFFD` data structure
22556370053bSBarry Smith 
22562ef1f0ffSBarry Smith     This functionality is often obtained using `MatCreateSNESMF()` or with `SNES` solvers using `-snes_mf` or `-snes_mf_operator`
22576370053bSBarry Smith 
22581cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDType`, `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`,
22592ef1f0ffSBarry Smith           `MatCreateSNESMF()`, `SNES`, `-snes_mf`, `-snes_mf_operator`
22606370053bSBarry Smith S*/
2261e884886fSBarry Smith typedef struct _p_MatMFFD *MatMFFD;
2262e884886fSBarry Smith 
226376bdecfbSBarry Smith /*J
22642ef1f0ffSBarry Smith    MatMFFDType - algorithm used to compute the `h` used in computing matrix-vector products via differencing of a function
2265e884886fSBarry Smith 
226616a05f60SBarry Smith    Values:
2267af27ebaaSBarry Smith +   `MATMFFD_DS` - an algorithm described by Dennis and Schnabel {cite}`dennis:83`
2268af27ebaaSBarry Smith -   `MATMFFD_WP` - the Walker-Pernice {cite}`pw98` strategy.
226916a05f60SBarry Smith 
2270e884886fSBarry Smith    Level: beginner
2271e884886fSBarry Smith 
22721cc06b55SBarry Smith .seealso: [](ch_matrices), `MatMFFDSetType()`, `MatMFFDRegister()`, `MatMFFDSetFunction()`, `MatCreateMFFD()`
227376bdecfbSBarry Smith J*/
227419fd82e9SBarry Smith typedef const char *MatMFFDType;
2275e884886fSBarry Smith #define MATMFFD_DS "ds"
2276e884886fSBarry Smith #define MATMFFD_WP "wp"
2277e884886fSBarry Smith 
227819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType);
2279bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD));
2280e884886fSBarry Smith 
2281014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal);
2282014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool);
2283e884886fSBarry Smith 
228461ab5df0SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType);
228561ab5df0SBarry Smith 
2286014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
2287014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
22887dbadf16SMatthew Knepley 
228953022affSStefano Zampini #ifdef PETSC_HAVE_H2OPUS
22908434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef PetscScalar(MatH2OpusKernelFn)(PetscInt, PetscReal[], PetscReal[], void *);
22918434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef MatH2OpusKernelFn *MatH2OpusKernel;
2292659ebe53SBarry Smith 
22938434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernelFn *, void *, PetscReal, PetscInt, PetscInt, Mat *);
229453022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *);
229553022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal);
229653022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat);
229753022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal);
229853022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool);
229953022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *);
230053022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *);
230153022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *);
2302300d917bSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar);
2303a0d2e7d8SStefano Zampini #endif
2304a0d2e7d8SStefano Zampini 
2305c7a4214aSPierre Jolivet #ifdef PETSC_HAVE_HTOOL
2306348d23efSPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode    MatHtoolKernelFn(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *);
23078434afd1SBarry Smith PETSC_EXTERN_TYPEDEF typedef MatHtoolKernelFn *MatHtoolKernel;
2308659ebe53SBarry Smith 
23098434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernelFn *, void *, Mat *);
23108434afd1SBarry Smith PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernelFn *, void *);
231198e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *);
231298e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *);
231398e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool);
2314c095613aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolUseRecompression(Mat, PetscBool);
23152ef1f0ffSBarry Smith 
2316c7a4214aSPierre Jolivet /*E
231787497f52SBarry Smith    MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL`
2318c7a4214aSPierre Jolivet 
2319c7a4214aSPierre Jolivet    Values:
232087497f52SBarry Smith +  `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation
232187497f52SBarry Smith .  `MAT_HTOOL_COMPRESSOR_FULL_ACA`                 - full adaptive cross approximation
232287497f52SBarry Smith -  `MAT_HTOOL_COMPRESSOR_SVD`                      - singular value decomposition
2323c7a4214aSPierre Jolivet 
232416a05f60SBarry Smith    Level: intermediate
232516a05f60SBarry Smith 
23261cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType`
2327c7a4214aSPierre Jolivet E*/
23289371c9d4SSatish Balay typedef enum {
23299371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA,
23309371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_FULL_ACA,
23319371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_SVD
23329371c9d4SSatish Balay } MatHtoolCompressorType;
23332ef1f0ffSBarry Smith 
233498e73e17SPierre Jolivet /*E
233587497f52SBarry Smith    MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL`
233698e73e17SPierre Jolivet 
233798e73e17SPierre Jolivet    Values:
233887497f52SBarry Smith +  `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default)    - axis computed via principle component analysis, split uniformly
233987497f52SBarry Smith .  `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC`            - axis computed via principle component analysis, split barycentrically
234087497f52SBarry Smith .  `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR`   - axis along the largest extent of the bounding box, split uniformly
234187497f52SBarry Smith -  `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically
234298e73e17SPierre Jolivet 
234316a05f60SBarry Smith    Level: intermediate
234416a05f60SBarry Smith 
23452ef1f0ffSBarry Smith    Note:
23462ef1f0ffSBarry Smith    Higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types
234798e73e17SPierre Jolivet 
23481cc06b55SBarry Smith .seealso: [](ch_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType`
234998e73e17SPierre Jolivet E*/
23509371c9d4SSatish Balay typedef enum {
23519371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_PCA_REGULAR,
23529371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC,
23539371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR,
23549371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC
23559371c9d4SSatish Balay } MatHtoolClusteringType;
2356c7a4214aSPierre Jolivet #endif
2357c7a4214aSPierre Jolivet 
235897969023SHong Zhang #ifdef PETSC_HAVE_MUMPS
2359014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt);
2360bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *);
2361b9e9ea26SSatish Balay PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal);
2362bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *);
2363bc6112feSHong Zhang 
2364ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *);
2365ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *);
2366ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *);
2367ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *);
23685c0bae8cSAshish Patel PETSC_EXTERN PetscErrorCode MatMumpsGetNullPivots(Mat, PetscInt *, PetscInt **);
236989a9c03aSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat);
23700e6b8875SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat);
237193d70b8aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMumpsSetBlk(Mat, PetscInt, const PetscInt[], const PetscInt[]);
237279578405SBarry Smith #else
237379578405SBarry Smith static inline PetscErrorCode MatMumpsSetIcntl(PETSC_UNUSED Mat F, PETSC_UNUSED PetscInt icntl, PETSC_UNUSED PetscInt ival)
237479578405SBarry Smith {
237579578405SBarry Smith   return PETSC_SUCCESS;
237679578405SBarry Smith }
237779578405SBarry Smith static inline PetscErrorCode MatMumpsSetCntl(PETSC_UNUSED Mat F, PETSC_UNUSED PetscInt icntl, PETSC_UNUSED PetscReal val)
237879578405SBarry Smith {
237979578405SBarry Smith   return PETSC_SUCCESS;
238079578405SBarry Smith }
238197969023SHong Zhang #endif
238223a5497aSJed Brown 
2383b500a6b7SJose David Bermeol #ifdef PETSC_HAVE_MKL_PARDISO
2384d615f992SSatish Balay PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt);
2385b500a6b7SJose David Bermeol #endif
2386b500a6b7SJose David Bermeol 
2387d305a81bSVasiliy Kozyrev #ifdef PETSC_HAVE_MKL_CPARDISO
2388d305a81bSVasiliy Kozyrev PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt);
2389d305a81bSVasiliy Kozyrev #endif
2390d305a81bSVasiliy Kozyrev 
2391d954db57SHong Zhang #ifdef PETSC_HAVE_SUPERLU
2392014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal);
2393d954db57SHong Zhang #endif
2394d954db57SHong Zhang 
2395fb785984SHong Zhang #ifdef PETSC_HAVE_SUPERLU_DIST
2396fb785984SHong Zhang PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *);
2397fb785984SHong Zhang #endif
2398fb785984SHong Zhang 
2399575704cbSPieter Ghysels #ifdef PETSC_HAVE_STRUMPACK
2400542aee0fSPieter Ghysels /*E
240129e0a805SPieter Ghysels     MatSTRUMPACKReordering - sparsity reducing ordering to be used in `MATSOLVERSTRUMPACK`
2402542aee0fSPieter Ghysels 
24032ef1f0ffSBarry Smith     Values:
24042ef1f0ffSBarry Smith +  `MAT_STRUMPACK_NATURAL`   - use the current ordering
24052ef1f0ffSBarry Smith .  `MAT_STRUMPACK_METIS`     - use MeTis to compute an ordering
24062ef1f0ffSBarry Smith .  `MAT_STRUMPACK_PARMETIS`  - use ParMeTis to compute an ordering
24072ef1f0ffSBarry Smith .  `MAT_STRUMPACK_SCOTCH`    - use Scotch to compute an ordering
24082ef1f0ffSBarry Smith .  `MAT_STRUMPACK_PTSCOTCH`  - use parallel Scotch to compute an ordering
240929e0a805SPieter Ghysels .  `MAT_STRUMPACK_RCM`       - use an RCM ordering
241029e0a805SPieter Ghysels .  `MAT_STRUMPACK_GEOMETRIC` - use a geometric ordering (needs mesh info from user)
241129e0a805SPieter Ghysels .  `MAT_STRUMPACK_AMD`       - approximate minimum degree
241229e0a805SPieter Ghysels .  `MAT_STRUMPACK_MMD`       - multiple minimum degree
241329e0a805SPieter Ghysels .  `MAT_STRUMPACK_AND`       - approximate nested dissection
241429e0a805SPieter Ghysels .  `MAT_STRUMPACK_MLF`       - minimum local fill
241529e0a805SPieter Ghysels -  `MAT_STRUMPACK_SPECTRAL`  - spectral nested dissection
24162ef1f0ffSBarry Smith 
241716a05f60SBarry Smith     Level: intermediate
241816a05f60SBarry Smith 
24192ef1f0ffSBarry Smith     Developer Note:
24202ef1f0ffSBarry Smith     Should be called `MatSTRUMPACKReorderingType`
24212ef1f0ffSBarry Smith 
242229e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetReordering()`
2423542aee0fSPieter Ghysels E*/
24249371c9d4SSatish Balay typedef enum {
242529e0a805SPieter Ghysels   MAT_STRUMPACK_NATURAL,
242629e0a805SPieter Ghysels   MAT_STRUMPACK_METIS,
242729e0a805SPieter Ghysels   MAT_STRUMPACK_PARMETIS,
242829e0a805SPieter Ghysels   MAT_STRUMPACK_SCOTCH,
242929e0a805SPieter Ghysels   MAT_STRUMPACK_PTSCOTCH,
243029e0a805SPieter Ghysels   MAT_STRUMPACK_RCM,
243129e0a805SPieter Ghysels   MAT_STRUMPACK_GEOMETRIC,
243229e0a805SPieter Ghysels   MAT_STRUMPACK_AMD,
243329e0a805SPieter Ghysels   MAT_STRUMPACK_MMD,
243429e0a805SPieter Ghysels   MAT_STRUMPACK_AND,
243529e0a805SPieter Ghysels   MAT_STRUMPACK_MLF,
243629e0a805SPieter Ghysels   MAT_STRUMPACK_SPECTRAL
24379371c9d4SSatish Balay } MatSTRUMPACKReordering;
24382ef1f0ffSBarry Smith 
243934f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering);
244029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetReordering(Mat, MatSTRUMPACKReordering *);
244129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricNxyz(Mat, PetscInt, PetscInt, PetscInt);
244229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricComponents(Mat, PetscInt);
244329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGeometricWidth(Mat, PetscInt);
2444575704cbSPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool);
244529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetColPerm(Mat, PetscBool *);
244629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetGPU(Mat, PetscBool);
244729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetGPU(Mat, PetscBool *);
244829e0a805SPieter Ghysels 
244929e0a805SPieter Ghysels /*E
245029e0a805SPieter Ghysels     MatSTRUMPACKCompressionType - Compression used in the approximate sparse factorization solver `MATSOLVERSTRUMPACK`
245129e0a805SPieter Ghysels 
245229e0a805SPieter Ghysels     Values:
245329e0a805SPieter Ghysels +  `MAT_STRUMPACK_COMPRESSION_TYPE_NONE`          - no compression, direct solver
245429e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_HSS`           - hierarchically semi-separable
245529e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_BLR`           - block low rank
245629e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_HODLR`         - hierarchically off-diagonal low rank (requires ButterfyPACK support, configure with --download-butterflypack)
245729e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR`     - hybrid of BLR and HODLR (requires ButterfyPACK support, configure with --download-butterflypack)
245829e0a805SPieter 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)
245929e0a805SPieter Ghysels .  `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS`      - lossless compression (requires ZFP support, configure with --download-zfp)
246029e0a805SPieter Ghysels -  `MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY`         - lossy compression (requires ZFP support, configure with --download-zfp)
246129e0a805SPieter Ghysels 
246229e0a805SPieter Ghysels     Level: intermediate
246329e0a805SPieter Ghysels 
246429e0a805SPieter Ghysels .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetCompression()`
246529e0a805SPieter Ghysels E*/
246629e0a805SPieter Ghysels typedef enum {
246729e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_NONE,
246829e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_HSS,
246929e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_BLR,
247029e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_HODLR,
247129e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_BLR_HODLR,
247229e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_ZFP_BLR_HODLR,
247329e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_LOSSLESS,
247429e0a805SPieter Ghysels   MAT_STRUMPACK_COMPRESSION_TYPE_LOSSY
247529e0a805SPieter Ghysels } MatSTRUMPACKCompressionType;
247629e0a805SPieter Ghysels 
247729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompression(Mat, MatSTRUMPACKCompressionType);
247829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompression(Mat, MatSTRUMPACKCompressionType *);
247929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompRelTol(Mat, PetscReal);
248029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompRelTol(Mat, PetscReal *);
248129e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompAbsTol(Mat, PetscReal);
248229e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompAbsTol(Mat, PetscReal *);
248329e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompMinSepSize(Mat, PetscInt);
248429e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompMinSepSize(Mat, PetscInt *);
248529e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLeafSize(Mat, PetscInt);
248629e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLeafSize(Mat, PetscInt *);
248729e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompLossyPrecision(Mat, PetscInt);
248829e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompLossyPrecision(Mat, PetscInt *);
248929e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetCompButterflyLevels(Mat, PetscInt);
249029e0a805SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKGetCompButterflyLevels(Mat, PetscInt *);
2491575704cbSPieter Ghysels #endif
2492575704cbSPieter Ghysels 
2493b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool);
24942216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *);
2495edd03b47SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION(3, 13, 0, "MatBindToCPU()", ) static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg)
2496d71ae5a4SJacob Faibussowitsch {
24979371c9d4SSatish Balay   return MatBindToCPU(A, flg);
24989371c9d4SSatish Balay }
249965a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool);
2500e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *);
2501e7e92044SBarry Smith 
2502aa372e3fSPaul Mullowney #ifdef PETSC_HAVE_CUDA
25033f9c0db1SPaul Mullowney /*E
25042ef1f0ffSBarry Smith     MatCUSPARSEStorageFormat - indicates the storage format for `MATAIJCUSPARSE` (GPU)
25052692e278SPaul Mullowney     matrices.
2506e057df02SPaul Mullowney 
25072ef1f0ffSBarry Smith     Values:
250887497f52SBarry Smith +   `MAT_CUSPARSE_CSR` - Compressed Sparse Row
250987497f52SBarry Smith .   `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later).
251087497f52SBarry Smith -   `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later).
2511e057df02SPaul Mullowney 
2512e057df02SPaul Mullowney     Level: intermediate
2513e057df02SPaul Mullowney 
25141cc06b55SBarry Smith .seealso: [](ch_matrices), `MATAIJCUSPARSE`, `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation`
2515e057df02SPaul Mullowney E*/
2516e057df02SPaul Mullowney 
25179371c9d4SSatish Balay typedef enum {
25189371c9d4SSatish Balay   MAT_CUSPARSE_CSR,
25199371c9d4SSatish Balay   MAT_CUSPARSE_ELL,
25209371c9d4SSatish Balay   MAT_CUSPARSE_HYB
25219371c9d4SSatish Balay } MatCUSPARSEStorageFormat;
2522e057df02SPaul Mullowney 
2523e057df02SPaul Mullowney /* these will be strings associated with enumerated type defined above */
2524e057df02SPaul Mullowney PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[];
2525e057df02SPaul Mullowney 
25263f9c0db1SPaul Mullowney /*E
25272ef1f0ffSBarry Smith     MatCUSPARSEFormatOperation - indicates the operation of `MATAIJCUSPARSE` (GPU)
25282692e278SPaul Mullowney     matrices whose operation should use a particular storage format.
2529e057df02SPaul Mullowney 
25302ef1f0ffSBarry Smith     Values:
25314cf0e950SBarry Smith +   `MAT_CUSPARSE_MULT_DIAG`    - sets the storage format for the diagonal matrix in the parallel `MatMult()`
25324cf0e950SBarry Smith .   `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()`
25334cf0e950SBarry Smith .   `MAT_CUSPARSE_MULT`         - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
25342ef1f0ffSBarry Smith -   `MAT_CUSPARSE_ALL`          - sets the storage format for all `MATAIJCUSPARSE` (GPU) matrices
2535e057df02SPaul Mullowney 
2536e057df02SPaul Mullowney     Level: intermediate
2537e057df02SPaul Mullowney 
25381cc06b55SBarry Smith .seealso: [](ch_matrices), `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat`
2539e057df02SPaul Mullowney E*/
25409371c9d4SSatish Balay typedef enum {
25419371c9d4SSatish Balay   MAT_CUSPARSE_MULT_DIAG,
25429371c9d4SSatish Balay   MAT_CUSPARSE_MULT_OFFDIAG,
25439371c9d4SSatish Balay   MAT_CUSPARSE_MULT,
25449371c9d4SSatish Balay   MAT_CUSPARSE_ALL
25459371c9d4SSatish Balay } MatCUSPARSEFormatOperation;
2546e057df02SPaul Mullowney 
254710e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
254810e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2549e057df02SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat);
2550365b711fSMark Adams PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool);
25515f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const int **, const int **);
25525f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const int **, const int **);
25535f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **);
25545f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **);
25555f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **);
25565f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **);
25575f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **);
25585f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **);
2559637a0070SStefano Zampini 
2560637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
2561637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
2562637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **);
2563637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **);
2564637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **);
2565637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **);
2566637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **);
2567637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **);
2568637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *);
2569d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *);
2570637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat);
25713d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseCUDASetPreallocation(Mat, PetscScalar *);
25722d1451d4SHong Zhang 
25732d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
25742d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
25759ae82921SPaul Mullowney #endif
25769ae82921SPaul Mullowney 
257747d993e7Ssuyashtn #ifdef PETSC_HAVE_HIP
257847d993e7Ssuyashtn /*E
25792ef1f0ffSBarry Smith     MatHIPSPARSEStorageFormat - indicates the storage format for `MATAIJHIPSPARSE` (GPU)
258047d993e7Ssuyashtn     matrices.
258147d993e7Ssuyashtn 
25822ef1f0ffSBarry Smith     Values:
25832ef1f0ffSBarry Smith +   `MAT_HIPSPARSE_CSR` - Compressed Sparse Row
25842ef1f0ffSBarry Smith .   `MAT_HIPSPARSE_ELL` - Ellpack
25852ef1f0ffSBarry Smith -   `MAT_HIPSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format
258647d993e7Ssuyashtn 
258716a05f60SBarry Smith     Level: intermediate
258816a05f60SBarry Smith 
25891cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEFormatOperation`
259047d993e7Ssuyashtn E*/
259147d993e7Ssuyashtn 
259247d993e7Ssuyashtn typedef enum {
259347d993e7Ssuyashtn   MAT_HIPSPARSE_CSR,
259447d993e7Ssuyashtn   MAT_HIPSPARSE_ELL,
259547d993e7Ssuyashtn   MAT_HIPSPARSE_HYB
259647d993e7Ssuyashtn } MatHIPSPARSEStorageFormat;
259747d993e7Ssuyashtn 
259847d993e7Ssuyashtn /* these will be strings associated with enumerated type defined above */
259947d993e7Ssuyashtn PETSC_EXTERN const char *const MatHIPSPARSEStorageFormats[];
260047d993e7Ssuyashtn 
260147d993e7Ssuyashtn /*E
26022ef1f0ffSBarry Smith     MatHIPSPARSEFormatOperation - indicates the operation of `MATAIJHIPSPARSE` (GPU)
260347d993e7Ssuyashtn     matrices whose operation should use a particular storage format.
260447d993e7Ssuyashtn 
26052ef1f0ffSBarry Smith     Values:
26062ef1f0ffSBarry Smith +   `MAT_HIPSPARSE_MULT_DIAG`    - sets the storage format for the diagonal matrix in the parallel `MatMult()`
26074cf0e950SBarry Smith .   `MAT_HIPSPARSE_MULT_OFFDIAG` - sets the storage format for the off-diagonal matrix in the parallel `MatMult()`
26082ef1f0ffSBarry Smith .   `MAT_HIPSPARSE_MULT`         - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
26092ef1f0ffSBarry Smith -   `MAT_HIPSPARSE_ALL`          - sets the storage format for all HIPSPARSE (GPU) matrices
26102ef1f0ffSBarry Smith 
261116a05f60SBarry Smith     Level: intermediate
261216a05f60SBarry Smith 
26131cc06b55SBarry Smith .seealso: [](ch_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEStorageFormat`
261447d993e7Ssuyashtn E*/
261547d993e7Ssuyashtn typedef enum {
261647d993e7Ssuyashtn   MAT_HIPSPARSE_MULT_DIAG,
261747d993e7Ssuyashtn   MAT_HIPSPARSE_MULT_OFFDIAG,
261847d993e7Ssuyashtn   MAT_HIPSPARSE_MULT,
261947d993e7Ssuyashtn   MAT_HIPSPARSE_ALL
262047d993e7Ssuyashtn } MatHIPSPARSEFormatOperation;
262147d993e7Ssuyashtn 
262247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
262347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
262447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetFormat(Mat, MatHIPSPARSEFormatOperation, MatHIPSPARSEStorageFormat);
262547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetUseCPUSolve(Mat, PetscBool);
262647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetIJ(Mat, PetscBool, const int **, const int **);
262747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreIJ(Mat, PetscBool, const int **, const int **);
262847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayRead(Mat, const PetscScalar **);
262947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayRead(Mat, const PetscScalar **);
263047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayWrite(Mat, PetscScalar **);
263147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayWrite(Mat, PetscScalar **);
263247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArray(Mat, PetscScalar **);
263347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArray(Mat, PetscScalar **);
263447d993e7Ssuyashtn 
263547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
263647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
263747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayWrite(Mat, PetscScalar **);
263847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayRead(Mat, const PetscScalar **);
263947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArray(Mat, PetscScalar **);
264047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayWrite(Mat, PetscScalar **);
264147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayRead(Mat, const PetscScalar **);
264247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArray(Mat, PetscScalar **);
264347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPPlaceArray(Mat, const PetscScalar *);
264447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPReplaceArray(Mat, const PetscScalar *);
264547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPResetArray(Mat);
26463d9668e3SJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatDenseHIPSetPreallocation(Mat, PetscScalar *);
2647773bf0f6SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELLHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2648773bf0f6SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELLHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
264947d993e7Ssuyashtn #endif
265047d993e7Ssuyashtn 
2651d67ff14aSKarl Rupp #if defined(PETSC_HAVE_VIENNACL)
2652d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2653d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2654d67ff14aSKarl Rupp #endif
2655d67ff14aSKarl Rupp 
26564bf303faSJacob Faibussowitsch #if PetscDefined(HAVE_KOKKOS)
26574bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
26584bf303faSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode MatCreateSeqAIJKokkos(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
26594bf303faSJacob Faibussowitsch #endif
26604bf303faSJacob Faibussowitsch 
266154efbe56SHong Zhang #if defined(PETSC_HAVE_FFTW)
2662014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec);
2663014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec);
26642a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *);
266554efbe56SHong Zhang #endif
266654efbe56SHong Zhang 
2667*d1a032dbSPierre Jolivet #if defined(PETSC_HAVE_SCALAPACK) && (defined(PETSC_USE_REAL_SINGLE) || defined(PETSC_USE_REAL_DOUBLE))
2668d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2669d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt);
2670d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *);
2671d24d4204SJose E. Roman #endif
2672d24d4204SJose E. Roman 
2673014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *);
2674014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *);
2675014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]);
2676014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]);
2677014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***);
2678014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *);
267919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType);
2680014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]);
2681014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat);
2682d8588912SDave May 
26832ce66baaSPierre Jolivet PETSC_EXTERN PetscErrorCode MatFilter(Mat, PetscReal, PetscBool, PetscBool);
26842ce66baaSPierre Jolivet PETSC_DEPRECATED_FUNCTION(3, 20, 0, "MatFilter()", ) static inline PetscErrorCode MatChop(Mat A, PetscReal tol)
26852ce66baaSPierre Jolivet {
26862ce66baaSPierre Jolivet   return MatFilter(A, tol, PETSC_FALSE, PETSC_FALSE);
26872ce66baaSPierre Jolivet }
2688e0a58c10SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *);
26894325cce7SMatthew G Knepley 
2690b541e6a4SDmitry Karpeev PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **);
269153dd7562SDmitry Karpeev 
2692c094ef40SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat);
2693c094ef40SMatthew G. Knepley 
269402218ef1SBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderMerge(Mat, Mat *);
2695539c167fSBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *);
26961a2c6b5cSJunchao Zhang 
26977ee59b9bSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *);
269872833a62Smarkadams4 
2699e02fb3cdSMark Adams PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, PetscReal, PetscInt, PetscInt[], Mat *);
270058c11ad4SPierre Jolivet PETSC_EXTERN PetscErrorCode MatEliminateZeros(Mat, PetscBool);
2701ad6ad4e1SHansol  Suh 
2702d16ceb75SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseFromVecType(MPI_Comm, VecType, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *);
27033444e80cSBarry Smith 
27043444e80cSBarry Smith PETSC_EXTERN PetscErrorCode MatSetHPL(Mat, int);
27053444e80cSBarry Smith #define PETSCBMHPL "hpl"
2706ce78bad3SBarry Smith 
2707ce78bad3SBarry Smith PETSC_EXTERN PetscErrorCode MatDFischer(Mat, Vec, Vec, Vec, Vec, Vec, Vec, Vec, Vec);
2708