xref: /petsc/include/petscmat.h (revision 2d1451d43b73a0495cd81c074cbc1e0206888947)
12eac72dbSBarry Smith /*
22eac72dbSBarry Smith      Include file for the matrix component of PETSc
32eac72dbSBarry Smith */
426bd1501SBarry Smith #ifndef PETSCMAT_H
526bd1501SBarry Smith #define PETSCMAT_H
6ac09b921SBarry Smith 
72c8e378dSBarry Smith #include <petscvec.h>
82eac72dbSBarry Smith 
9ac09b921SBarry Smith /* SUBMANSEC = Mat */
10ac09b921SBarry Smith 
11d9274352SBarry Smith /*S
128f6c3df8SBarry Smith      Mat - Abstract PETSc matrix object used to manage all linear operators in PETSc, even those without
138f6c3df8SBarry Smith            an explicit sparse representation (such as matrix-free operators)
142eac72dbSBarry Smith 
15d91e6319SBarry Smith    Level: beginner
16d91e6319SBarry Smith 
172ef1f0ffSBarry Smith    Note:
182ef1f0ffSBarry Smith    See [](doc_matrix) and `MatType` for available matrix types
192ef1f0ffSBarry Smith 
202ef1f0ffSBarry Smith .seealso: [](chapter_matrices), [](doc_matrix), `MatCreate()`, `MatType`, `MatSetType()`, `MatDestroy()`
21d9274352SBarry Smith S*/
22d9274352SBarry Smith typedef struct _p_Mat *Mat;
23d9274352SBarry Smith 
2476bdecfbSBarry Smith /*J
258f6c3df8SBarry Smith     MatType - String with the name of a PETSc matrix type
26d9274352SBarry Smith 
27d9274352SBarry Smith    Level: beginner
28d9274352SBarry Smith 
292ef1f0ffSBarry Smith    Note:
302ef1f0ffSBarry Smith    [](doc_matrix) for a table of available matrix types
312ef1f0ffSBarry Smith 
322ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()`
3376bdecfbSBarry Smith J*/
3419fd82e9SBarry Smith typedef const char *MatType;
35273d9f13SBarry Smith #define MATSAME                      "same"
365a11e1b2SBarry Smith #define MATMAIJ                      "maij"
37273d9f13SBarry Smith #define MATSEQMAIJ                   "seqmaij"
38273d9f13SBarry Smith #define MATMPIMAIJ                   "mpimaij"
3949bd79ccSDebojyoti Ghosh #define MATKAIJ                      "kaij"
4049bd79ccSDebojyoti Ghosh #define MATSEQKAIJ                   "seqkaij"
4149bd79ccSDebojyoti Ghosh #define MATMPIKAIJ                   "mpikaij"
42273d9f13SBarry Smith #define MATIS                        "is"
435a11e1b2SBarry Smith #define MATAIJ                       "aij"
44273d9f13SBarry Smith #define MATSEQAIJ                    "seqaij"
45273d9f13SBarry Smith #define MATMPIAIJ                    "mpiaij"
465a11e1b2SBarry Smith #define MATAIJCRL                    "aijcrl"
475a11e1b2SBarry Smith #define MATSEQAIJCRL                 "seqaijcrl"
485a11e1b2SBarry Smith #define MATMPIAIJCRL                 "mpiaijcrl"
499ae82921SPaul Mullowney #define MATAIJCUSPARSE               "aijcusparse"
509ae82921SPaul Mullowney #define MATSEQAIJCUSPARSE            "seqaijcusparse"
519ae82921SPaul Mullowney #define MATMPIAIJCUSPARSE            "mpiaijcusparse"
5247d993e7Ssuyashtn #define MATAIJHIPSPARSE              "aijhipsparse"
5347d993e7Ssuyashtn #define MATSEQAIJHIPSPARSE           "seqaijhipsparse"
5447d993e7Ssuyashtn #define MATMPIAIJHIPSPARSE           "mpiaijhipsparse"
558c3ff71bSJunchao Zhang #define MATAIJKOKKOS                 "aijkokkos"
568c3ff71bSJunchao Zhang #define MATSEQAIJKOKKOS              "seqaijkokkos"
578c3ff71bSJunchao Zhang #define MATMPIAIJKOKKOS              "mpiaijkokkos"
58d67ff14aSKarl Rupp #define MATAIJVIENNACL               "aijviennacl"
59d67ff14aSKarl Rupp #define MATSEQAIJVIENNACL            "seqaijviennacl"
60d67ff14aSKarl Rupp #define MATMPIAIJVIENNACL            "mpiaijviennacl"
615a11e1b2SBarry Smith #define MATAIJPERM                   "aijperm"
625a11e1b2SBarry Smith #define MATSEQAIJPERM                "seqaijperm"
635a11e1b2SBarry Smith #define MATMPIAIJPERM                "mpiaijperm"
644dfdc2d9SRichard Tran Mills #define MATAIJSELL                   "aijsell"
654dfdc2d9SRichard Tran Mills #define MATSEQAIJSELL                "seqaijsell"
664dfdc2d9SRichard Tran Mills #define MATMPIAIJSELL                "mpiaijsell"
674a2a386eSRichard Tran Mills #define MATAIJMKL                    "aijmkl"
684a2a386eSRichard Tran Mills #define MATSEQAIJMKL                 "seqaijmkl"
694a2a386eSRichard Tran Mills #define MATMPIAIJMKL                 "mpiaijmkl"
70b5b72c8aSIrina Sokolova #define MATBAIJMKL                   "baijmkl"
71b5b72c8aSIrina Sokolova #define MATSEQBAIJMKL                "seqbaijmkl"
72b5b72c8aSIrina Sokolova #define MATMPIBAIJMKL                "mpibaijmkl"
73273d9f13SBarry Smith #define MATSHELL                     "shell"
74c1fff1c6SRichard Tran Mills #define MATCENTERING                 "centering"
755a11e1b2SBarry Smith #define MATDENSE                     "dense"
76637a0070SStefano Zampini #define MATDENSECUDA                 "densecuda"
7747d993e7Ssuyashtn #define MATDENSEHIP                  "densehip"
78209238afSKris Buschelman #define MATSEQDENSE                  "seqdense"
79bfc799aaSStefano Zampini #define MATSEQDENSECUDA              "seqdensecuda"
8047d993e7Ssuyashtn #define MATSEQDENSEHIP               "seqdensehip"
81273d9f13SBarry Smith #define MATMPIDENSE                  "mpidense"
82637a0070SStefano Zampini #define MATMPIDENSECUDA              "mpidensecuda"
8347d993e7Ssuyashtn #define MATMPIDENSEHIP               "mpidensehip"
84db31f6deSJed Brown #define MATELEMENTAL                 "elemental"
85d24d4204SJose E. Roman #define MATSCALAPACK                 "scalapack"
865a11e1b2SBarry Smith #define MATBAIJ                      "baij"
87273d9f13SBarry Smith #define MATSEQBAIJ                   "seqbaij"
88273d9f13SBarry Smith #define MATMPIBAIJ                   "mpibaij"
89273d9f13SBarry Smith #define MATMPIADJ                    "mpiadj"
905a11e1b2SBarry Smith #define MATSBAIJ                     "sbaij"
91273d9f13SBarry Smith #define MATSEQSBAIJ                  "seqsbaij"
92273d9f13SBarry Smith #define MATMPISBAIJ                  "mpisbaij"
93cebc7f6cSBarry Smith #define MATMFFD                      "mffd"
94c8a8475eSBarry Smith #define MATNORMAL                    "normal"
95c5e4d11fSDmitry Karpeev #define MATNORMALHERMITIAN           "normalh"
96ab92ecdeSBarry Smith #define MATLRC                       "lrc"
972a6744ebSBarry Smith #define MATSCATTER                   "scatter"
98421e10b8SBarry Smith #define MATBLOCKMAT                  "blockmat"
99793850ffSBarry Smith #define MATCOMPOSITE                 "composite"
1001f8c7532SHong Zhang #define MATFFT                       "fft"
1011f8c7532SHong Zhang #define MATFFTW                      "fftw"
102e133240eSMatthew G Knepley #define MATSEQCUFFT                  "seqcufft"
10347d993e7Ssuyashtn #define MATSEQHIPFFT                 "seqhipfft"
104013e2dc7SBarry Smith #define MATTRANSPOSEMAT              PETSC_DEPRECATED_MACRO("GCC warning \"MATTRANSPOSEMAT macro is deprecated use MATTRANSPOSEVIRTUAL (since version 3.18)\"") "transpose"
105013e2dc7SBarry Smith #define MATTRANSPOSEVIRTUAL          "transpose"
106013e2dc7SBarry Smith #define MATHERMITIANTRANSPOSEVIRTUAL "hermitiantranspose"
10772ca8751SBarry Smith #define MATSCHURCOMPLEMENT           "schurcomplement"
1081d6018f0SLisandro Dalcin #define MATPYTHON                    "python"
10963c07aadSStefano Zampini #define MATHYPRE                     "hypre"
110f91d8e95SBarry Smith #define MATHYPRESTRUCT               "hyprestruct"
111a9e6138eSGlenn Hammond #define MATHYPRESSTRUCT              "hypresstruct"
112ee1cef2cSJed Brown #define MATSUBMATRIX                 "submatrix"
1132c0dbf93SJed Brown #define MATLOCALREF                  "localref"
114d8588912SDave May #define MATNEST                      "nest"
115c094ef40SMatthew G. Knepley #define MATPREALLOCATOR              "preallocator"
116d4002b98SHong Zhang #define MATSELL                      "sell"
117d4002b98SHong Zhang #define MATSEQSELL                   "seqsell"
118d4002b98SHong Zhang #define MATMPISELL                   "mpisell"
119*2d1451d4SHong Zhang #define MATSELLCUDA                  "sellcuda"
120*2d1451d4SHong Zhang #define MATSEQSELLCUDA               "seqsellcuda"
121*2d1451d4SHong Zhang #define MATMPISELLCUDA               "mpisellcuda"
122a3b2e22bSHong Zhang #define MATDUMMY                     "dummy"
123cd929ea3SAlp Dener #define MATLMVM                      "lmvm"
12478e4361aSAlp Dener #define MATLMVMDFP                   "lmvmdfp"
12578e4361aSAlp Dener #define MATLMVMBFGS                  "lmvmbfgs"
12678e4361aSAlp Dener #define MATLMVMSR1                   "lmvmsr1"
127864588a7SAlp Dener #define MATLMVMBROYDEN               "lmvmbroyden"
128864588a7SAlp Dener #define MATLMVMBADBROYDEN            "lmvmbadbroyden"
129864588a7SAlp Dener #define MATLMVMSYMBROYDEN            "lmvmsymbroyden"
130864588a7SAlp Dener #define MATLMVMSYMBADBROYDEN         "lmvmsymbadbroyden"
131864588a7SAlp Dener #define MATLMVMDIAGBROYDEN           "lmvmdiagbroyden"
1323423f386SBarry Smith #define MATCONSTANTDIAGONAL          "constantdiagonal"
133c7a4214aSPierre Jolivet #define MATHTOOL                     "htool"
13453022affSStefano Zampini #define MATH2OPUS                    "h2opus"
135773941d6SBarry Smith 
13676bdecfbSBarry Smith /*J
1373ca39a21SBarry Smith     MatSolverType - String with the name of a PETSc matrix solver type.
1389989ab13SBarry Smith 
139c2b89b5dSBarry Smith     For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc
1409989ab13SBarry Smith 
1419989ab13SBarry Smith    Level: beginner
1429989ab13SBarry Smith 
1432ef1f0ffSBarry Smith    Note:
1442ef1f0ffSBarry Smith    `MATSOLVERUMFPACK`, `MATSOLVERCHOLMOD`, `MATSOLVERKLU`, `MATSOLVERSPQR` form the SuiteSparse package for which you can use --download-suitesparse
145c7ccbb75SBarry Smith 
1462ef1f0ffSBarry Smith .seealso: [](sec_matfactor), [](chapter_matrices), `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()`
14776bdecfbSBarry Smith J*/
148ea799195SBarry Smith typedef const char *MatSolverType;
1492692d6eeSBarry Smith #define MATSOLVERSUPERLU       "superlu"
1502692d6eeSBarry Smith #define MATSOLVERSUPERLU_DIST  "superlu_dist"
15108f5efcfSPieter Ghysels #define MATSOLVERSTRUMPACK     "strumpack"
1522692d6eeSBarry Smith #define MATSOLVERUMFPACK       "umfpack"
15320db9a53SJed Brown #define MATSOLVERCHOLMOD       "cholmod"
154d89f5e7aSBarry Smith #define MATSOLVERKLU           "klu"
155d89f5e7aSBarry Smith #define MATSOLVERELEMENTAL     "elemental"
156d24d4204SJose E. Roman #define MATSOLVERSCALAPACK     "scalapack"
1572692d6eeSBarry Smith #define MATSOLVERESSL          "essl"
1582692d6eeSBarry Smith #define MATSOLVERLUSOL         "lusol"
1592692d6eeSBarry Smith #define MATSOLVERMUMPS         "mumps"
160d615f992SSatish Balay #define MATSOLVERMKL_PARDISO   "mkl_pardiso"
161d305a81bSVasiliy Kozyrev #define MATSOLVERMKL_CPARDISO  "mkl_cpardiso"
1622692d6eeSBarry Smith #define MATSOLVERPASTIX        "pastix"
1632692d6eeSBarry Smith #define MATSOLVERMATLAB        "matlab"
1642692d6eeSBarry Smith #define MATSOLVERPETSC         "petsc"
1652692d6eeSBarry Smith #define MATSOLVERBAS           "bas"
1669ae82921SPaul Mullowney #define MATSOLVERCUSPARSE      "cusparse"
167bddcd29dSMark Adams #define MATSOLVERCUSPARSEBAND  "cusparseband"
168bfc799aaSStefano Zampini #define MATSOLVERCUDA          "cuda"
16947d993e7Ssuyashtn #define MATSOLVERHIPSPARSE     "hipsparse"
17047d993e7Ssuyashtn #define MATSOLVERHIPSPARSEBAND "hipsparseband"
17147d993e7Ssuyashtn #define MATSOLVERHIP           "hip"
172930e68a5SMark Adams #define MATSOLVERKOKKOS        "kokkos"
1738f7e8f9dSMark Adams #define MATSOLVERKOKKOSDEVICE  "kokkosdevice"
174a2fc1e05SToby Isaac #define MATSOLVERSPQR          "spqr"
175c0cdd4a1SDahai Guo 
176b24902e0SBarry Smith /*E
177b24902e0SBarry Smith     MatFactorType - indicates what type of factorization is requested
178b24902e0SBarry Smith 
179b24902e0SBarry Smith     Level: beginner
180b24902e0SBarry Smith 
1812ef1f0ffSBarry Smith     Values:
1822ef1f0ffSBarry Smith +  `MAT_FACTOR_LU` - LU factorization
1832ef1f0ffSBarry Smith .  `MAT_FACTOR_CHOLESKY` - Cholesky factorization
1842ef1f0ffSBarry Smith .  `MAT_FACTOR_ILU` - ILU factorization
1852ef1f0ffSBarry Smith .  `MAT_FACTOR_ICC` - incomplete Cholesky factorization
1862ef1f0ffSBarry Smith .  `MAT_FACTOR_ILUDT` - ILU factorization with drop tolerance
1872ef1f0ffSBarry Smith -  `MAT_FACTOR_QR` - QR factorization
188b24902e0SBarry Smith 
1892ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()`
190b24902e0SBarry Smith E*/
1919371c9d4SSatish Balay typedef enum {
1929371c9d4SSatish Balay   MAT_FACTOR_NONE,
1939371c9d4SSatish Balay   MAT_FACTOR_LU,
1949371c9d4SSatish Balay   MAT_FACTOR_CHOLESKY,
1959371c9d4SSatish Balay   MAT_FACTOR_ILU,
1969371c9d4SSatish Balay   MAT_FACTOR_ICC,
1979371c9d4SSatish Balay   MAT_FACTOR_ILUDT,
1989371c9d4SSatish Balay   MAT_FACTOR_QR,
1999371c9d4SSatish Balay   MAT_FACTOR_NUM_TYPES
2009371c9d4SSatish Balay } MatFactorType;
201014dd563SJed Brown PETSC_EXTERN const char *const MatFactorTypes[];
202e92e720dSBarry Smith 
203ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactor(Mat, MatSolverType, MatFactorType, Mat *);
204ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat, MatSolverType, MatFactorType, PetscBool *);
205f73b0415SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool *);
206d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatFactorGetCanUseOrdering() (since version 3.15)") static inline PetscErrorCode MatFactorGetUseOrdering(Mat A, PetscBool *b)
207d71ae5a4SJacob Faibussowitsch {
2089371c9d4SSatish Balay   return MatFactorGetCanUseOrdering(A, b);
2099371c9d4SSatish Balay }
210ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat, MatSolverType *);
211014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat, MatFactorType *);
2127abd51d3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat, MatFactorType);
2132430ea28SJose E. Roman PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatSolverFunction)(Mat, MatFactorType, Mat *);
2142430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode            MatSolverTypeRegister(MatSolverType, MatType, MatFactorType, MatSolverFunction);
2152430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode            MatSolverTypeGet(MatSolverType, MatType, MatFactorType, PetscBool *, PetscBool *, MatSolverFunction *);
21625ef9dfeSBarry Smith typedef MatSolverType MatSolverPackage PETSC_DEPRECATED_TYPEDEF("Use MatSolverType (since version 3.9)");
217d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatSolverTypeRegister() (since version 3.9)") static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype, MatType mtype, MatFactorType ftype, MatSolverFunction f)
218d71ae5a4SJacob Faibussowitsch {
2199371c9d4SSatish Balay   return MatSolverTypeRegister(stype, mtype, ftype, f);
2209371c9d4SSatish Balay }
221d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatSolverTypeGet() (since version 3.9)") static inline PetscErrorCode MatSolverPackageGet(MatSolverType stype, MatType mtype, MatFactorType ftype, PetscBool *foundmtype, PetscBool *foundstype, MatSolverFunction *f)
222d71ae5a4SJacob Faibussowitsch {
2239371c9d4SSatish Balay   return MatSolverTypeGet(stype, mtype, ftype, foundmtype, foundstype, f);
2249371c9d4SSatish Balay }
2259989ab13SBarry Smith 
2264222ddf1SHong Zhang /*E
2274222ddf1SHong Zhang     MatProductType - indicates what type of matrix product is requested
2284222ddf1SHong Zhang 
2294222ddf1SHong Zhang     Level: beginner
2304222ddf1SHong Zhang 
2312ef1f0ffSBarry Smith     Values:
2322ef1f0ffSBarry Smith +  `MATPRODUCT_AB` - product of two matrices
2332ef1f0ffSBarry Smith .  `MATPRODUCT_AtB` - product of the transpose of a given matrix with a matrix
2342ef1f0ffSBarry Smith .  `MATPRODUCT_ABt` - product of a matrix with the transpose of another given matrix
2352ef1f0ffSBarry Smith .  `MATPRODUCT_PtAP` - the triple product of the transpose of a matrix with another matrix and itself
2362ef1f0ffSBarry Smith .  `MATPRODUCT_RARt` - the triple product of a matrix, another matrix and the transpose of the first matrix
2372ef1f0ffSBarry Smith -  `MATPRODUCT_ABC` - the product of three matrices
2382ef1f0ffSBarry Smith 
2392ef1f0ffSBarry Smith .seealso: [](sec_matmatproduct), [](chapter_matrices), `MatProductSetType()`
2404222ddf1SHong Zhang E*/
2419371c9d4SSatish Balay typedef enum {
2429371c9d4SSatish Balay   MATPRODUCT_UNSPECIFIED = 0,
2439371c9d4SSatish Balay   MATPRODUCT_AB,
2449371c9d4SSatish Balay   MATPRODUCT_AtB,
2459371c9d4SSatish Balay   MATPRODUCT_ABt,
2469371c9d4SSatish Balay   MATPRODUCT_PtAP,
2479371c9d4SSatish Balay   MATPRODUCT_RARt,
2489371c9d4SSatish Balay   MATPRODUCT_ABC
2499371c9d4SSatish Balay } MatProductType;
250544a5e07SHong Zhang PETSC_EXTERN const char *const MatProductTypes[];
2514222ddf1SHong Zhang 
2524222ddf1SHong Zhang /*J
2534222ddf1SHong Zhang     MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation
2544222ddf1SHong Zhang 
2554222ddf1SHong Zhang    Level: beginner
2564222ddf1SHong Zhang 
2572ef1f0ffSBarry Smith .seealso: [](sec_matmatproduct), [](chapter_matrices), `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType`
2584222ddf1SHong Zhang J*/
2594222ddf1SHong Zhang typedef const char *MatProductAlgorithm;
2603e662e0bSHong Zhang #define MATPRODUCTALGORITHMDEFAULT         "default"
2613e662e0bSHong Zhang #define MATPRODUCTALGORITHMSORTED          "sorted"
2623e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLE        "scalable"
2633e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLEFAST    "scalable_fast"
2643e662e0bSHong Zhang #define MATPRODUCTALGORITHMHEAP            "heap"
2653e662e0bSHong Zhang #define MATPRODUCTALGORITHMBHEAP           "btheap"
2663e662e0bSHong Zhang #define MATPRODUCTALGORITHMLLCONDENSED     "llcondensed"
2673e662e0bSHong Zhang #define MATPRODUCTALGORITHMROWMERGE        "rowmerge"
2683e662e0bSHong Zhang #define MATPRODUCTALGORITHMOUTERPRODUCT    "outerproduct"
2693e662e0bSHong Zhang #define MATPRODUCTALGORITHMATB             "at*b"
2703e662e0bSHong Zhang #define MATPRODUCTALGORITHMRAP             "rap"
2713e662e0bSHong Zhang #define MATPRODUCTALGORITHMNONSCALABLE     "nonscalable"
2723e662e0bSHong Zhang #define MATPRODUCTALGORITHMSEQMPI          "seqmpi"
2733e662e0bSHong Zhang #define MATPRODUCTALGORITHMBACKEND         "backend"
2743e662e0bSHong Zhang #define MATPRODUCTALGORITHMOVERLAPPING     "overlapping"
2753e662e0bSHong Zhang #define MATPRODUCTALGORITHMMERGED          "merged"
2763e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCE       "allatonce"
2773e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged"
2783e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLGATHERV      "allgatherv"
2793e662e0bSHong Zhang #define MATPRODUCTALGORITHMCYCLIC          "cyclic"
2803e662e0bSHong Zhang #if defined(PETSC_HAVE_HYPRE)
2813e662e0bSHong Zhang   #define MATPRODUCTALGORITHMHYPRE "hypre"
2823e662e0bSHong Zhang #endif
2834222ddf1SHong Zhang 
2844222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreate(Mat, Mat, Mat, Mat *);
2854222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat, Mat, Mat, Mat);
2864222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetType(Mat, MatProductType);
2874222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat, MatProductAlgorithm);
2884222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat, PetscReal);
2894222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat);
2904222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat);
2914222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat);
2924222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat, Mat, Mat, Mat);
2934417c5e8SHong Zhang PETSC_EXTERN PetscErrorCode MatProductClear(Mat);
2946718818eSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductView(Mat, PetscViewer);
295c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetType(Mat, MatProductType *);
296c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat, Mat *, Mat *, Mat *);
2974222ddf1SHong Zhang 
298c06d978dSMatthew Knepley /* Logging support */
2990700a824SBarry Smith #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */
300014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_CLASSID;
301335efc43SPeter Brune PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID;
302014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID;
303014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID;
304014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID;
305014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID;
306014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID;
307014dd563SJed Brown PETSC_EXTERN PetscClassId MATMFFD_CLASSID;
308c06d978dSMatthew Knepley 
309ceb03754SKris Buschelman /*E
3102ef1f0ffSBarry Smith     MatReuse - Indicates if matrices obtained from a previous call to `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatConvert()` or several other functions
311cf37664fSBarry Smith      are to be reused to store the new matrix values.
312cf37664fSBarry Smith 
3132ef1f0ffSBarry Smith    Values:
3142ef1f0ffSBarry Smith +  `MAT_INITIAL_MATRIX` - create a new matrix
3152ef1f0ffSBarry Smith .  `MAT_REUSE_MATRIX` - reuse the matrix created with a previous call that used `MAT_INITIAL_MATRIX`
3162ef1f0ffSBarry Smith .  `MAT_INPLACE_MATRIX` - replace the first input matrix with the new matrix (not applicable to all functions)
3172ef1f0ffSBarry Smith -  `MAT_IGNORE_MATRIX` - do not create a new matrix or reuse a give matrix, just ignore that matrix argument (not applicable to all functions)
318ceb03754SKris Buschelman 
319ceb03754SKris Buschelman     Level: beginner
320ceb03754SKris Buschelman 
3212ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()`
322ceb03754SKris Buschelman E*/
3239371c9d4SSatish Balay typedef enum {
3249371c9d4SSatish Balay   MAT_INITIAL_MATRIX,
3259371c9d4SSatish Balay   MAT_REUSE_MATRIX,
3269371c9d4SSatish Balay   MAT_IGNORE_MATRIX,
3279371c9d4SSatish Balay   MAT_INPLACE_MATRIX
3289371c9d4SSatish Balay } MatReuse;
329ceb03754SKris Buschelman 
3305494a064SHong Zhang /*E
3312ef1f0ffSBarry Smith     MatCreateSubMatrixOption - Indicates if matrices obtained from a call to `MatCreateSubMatrices()`
3322ef1f0ffSBarry Smith      include the matrix values. Currently it is only used by `MatGetSeqNonzeroStructure()`.
3335494a064SHong Zhang 
3342ef1f0ffSBarry Smith     Level: developer
3355494a064SHong Zhang 
3362ef1f0ffSBarry Smith     Values:
3372ef1f0ffSBarry Smith +  `MAT_DO_NOT_GET_VALUES` - do not copy the matrix values
3382ef1f0ffSBarry Smith -  `MAT_GET_VALUES` - copy the matrix values
3392ef1f0ffSBarry Smith 
3402ef1f0ffSBarry Smith     Developer Note:
3412ef1f0ffSBarry Smith     Why is not just a boolean used for this information?
3422ef1f0ffSBarry Smith 
3432ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatDuplicateOption`, `PetscCopyMode`, `MatGetSeqNonzeroStructure()`
3445494a064SHong Zhang E*/
3459371c9d4SSatish Balay typedef enum {
3469371c9d4SSatish Balay   MAT_DO_NOT_GET_VALUES,
3479371c9d4SSatish Balay   MAT_GET_VALUES
3489371c9d4SSatish Balay } MatCreateSubMatrixOption;
3495494a064SHong Zhang 
350607a6623SBarry Smith PETSC_EXTERN PetscErrorCode MatInitializePackage(void);
351c06d978dSMatthew Knepley 
352014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm, Mat *);
353014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetSizes(Mat, PetscInt, PetscInt, PetscInt, PetscInt);
35419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatSetType(Mat, MatType);
3550d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatGetVecType(Mat, VecType *);
3560d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetVecType(Mat, VecType);
357014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat);
358fe2efc57SMark PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat, PetscObject, const char[]);
359bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatRegister(const char[], PetscErrorCode (*)(Mat));
36023bebc0bSBarry Smith PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[], const char[], const char[]);
361014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat, const char[]);
36226cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat, const char[]);
36326cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat, const char[]);
364014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat, const char[]);
365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat, const char *[]);
36684d44b13SHong Zhang PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat, PetscBool);
367f69a0ea3SMatthew Knepley 
368140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatList;
369140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatColoringList;
370140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatPartitioningList;
37128988994SBarry Smith 
3723b224e63SBarry Smith /*E
373aa6c7ce3SBarry Smith     MatStructure - Indicates if two matrices have the same nonzero structure
3743b224e63SBarry Smith 
3753b224e63SBarry Smith     Level: beginner
3763b224e63SBarry Smith 
3772ef1f0ffSBarry Smith    Values:
3782ef1f0ffSBarry Smith +  `SAME_NONZERO_PATTERN`  - the two matrices have identical nonzero patterns
3792ef1f0ffSBarry Smith .  `DIFFERENT_NONZERO_PATTERN` - the two matrices may have different nonzero patterns
3802ef1f0ffSBarry Smith .  `SUBSET_NONZERO_PATTERN` - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix
3812ef1f0ffSBarry Smith -  `UNKNOWN_NONZERO_PATTERN` - there is no known relationship between the nonzero patterns. In this case the implementations
3822ef1f0ffSBarry Smith                                may try to detect a relationship to optimize the operation
383531d0c6aSBarry Smith 
3842ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatCopy()`, `MatAXPY()`, `MatAYPX()`
3853b224e63SBarry Smith E*/
3869371c9d4SSatish Balay typedef enum {
3879371c9d4SSatish Balay   DIFFERENT_NONZERO_PATTERN,
3889371c9d4SSatish Balay   SUBSET_NONZERO_PATTERN,
3899371c9d4SSatish Balay   SAME_NONZERO_PATTERN,
3909371c9d4SSatish Balay   UNKNOWN_NONZERO_PATTERN
3919371c9d4SSatish Balay } MatStructure;
392d60b7d5cSBarry Smith PETSC_EXTERN const char *const MatStructures[];
3933b224e63SBarry Smith 
3949779e05dSSatish Balay #if defined                 PETSC_HAVE_MKL_SPARSE
395ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
396ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
39780095d54SIrina Sokolova PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
398ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
39980095d54SIrina Sokolova #endif
400cd929ea3SAlp Dener 
401d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
402d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
403d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat, PetscInt, const PetscInt[]);
404d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
40580095d54SIrina Sokolova 
406014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
407014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
408014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
409014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
410014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
4118f8f2f0dSBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
4126a3d2595SBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat, const PetscScalar[]);
413014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], PetscInt[], PetscInt[], PetscScalar[], Mat *);
4143b00a383SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm, Mat, Mat, const PetscInt[], Mat *);
4153b00a383SHong Zhang 
416014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
417014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
418014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
4197e8381f9SStefano Zampini 
420e8729f6fSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat, PetscCount, PetscInt[], PetscInt[]);
42182a78a4eSJed Brown PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat, PetscCount, PetscInt[], PetscInt[]);
4227e8381f9SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat, const PetscScalar[], InsertMode);
423d21a29f3SJed Brown 
424014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscInt[], Mat *);
425014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
426d21a29f3SJed Brown 
427014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
428014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[], Mat *);
42938f409ebSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
430014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
4314cce697cSJed Brown PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscInt[], const PetscInt[]);
432dfb205c3SBarry Smith 
433014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, void *, Mat *);
434c1fff1c6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm, PetscInt, PetscInt, Mat *);
435014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat, Mat *);
436c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat, Mat *);
437986c4d72SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat, Mat, Vec, Mat, Mat *);
438267ca84cSJose E. Roman PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat, Mat *, Mat *, Vec *, Mat *);
439c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, ISLocalToGlobalMapping, ISLocalToGlobalMapping, Mat *);
440014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
441014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
442c0cdd4a1SDahai Guo 
443014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm, VecScatter, Mat *);
444014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat, VecScatter);
445014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat, VecScatter *);
446014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt *, Mat *);
447014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat, Mat);
448014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat);
4499371c9d4SSatish Balay typedef enum {
4509371c9d4SSatish Balay   MAT_COMPOSITE_MERGE_RIGHT,
4519371c9d4SSatish Balay   MAT_COMPOSITE_MERGE_LEFT
4529371c9d4SSatish Balay } MatCompositeMergeType;
4538c8613bfSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat, MatCompositeMergeType);
454014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm, PetscInt, const Mat *, Mat *);
4559371c9d4SSatish Balay typedef enum {
4569371c9d4SSatish Balay   MAT_COMPOSITE_ADDITIVE,
4579371c9d4SSatish Balay   MAT_COMPOSITE_MULTIPLICATIVE
4589371c9d4SSatish Balay } MatCompositeType;
459014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat, MatCompositeType);
4606dbc55e5SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat, MatCompositeType *);
4613b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat, MatStructure);
4623b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat, MatStructure *);
4636d0add67SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat, PetscInt *);
4648b5c3584SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat, PetscInt, Mat *);
46503049c21SJunchao Zhang PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat, const PetscScalar *);
4666d7c1e57SBarry Smith 
46719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm, PetscInt, const PetscInt[], MatType, Mat *);
468014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm, PetscInt, const PetscInt[], Mat *);
469dedccee8SHong Zhang 
470014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat, Mat *);
4718060fb66Sstefano_zampini PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat, Mat *);
472d0de2241SAndrew Spott PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat, Mat *);
47306511a5cSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat, Mat *);
474fa80d070SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat, Mat *);
47565f45395SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat, Mat *);
47654e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat, IS, IS, Mat *);
47754e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat, Mat, IS, IS);
478014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat, IS, IS, Mat *);
4793423f386SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar, Mat *);
4801472f72bSBarry Smith 
481978814f1SStefano Zampini #if defined(PETSC_HAVE_HYPRE)
482d975228cSstefano_zampini PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
483978814f1SStefano Zampini #endif
484978814f1SStefano Zampini 
485014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat, const char[]);
486ebead697SStefano Zampini PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat, const char *[]);
4871d6018f0SLisandro Dalcin 
488846b4da1SFande Kong PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat);
489014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetUp(Mat);
490014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroy(Mat *);
491e56f5c9eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat, PetscObjectState *);
49221c89e3eSBarry Smith 
493014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatConjugate(Mat);
494014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRealPart(Mat);
495014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat);
496014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat, Mat *);
497014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetTrace(Mat, PetscScalar *);
498713ccfa9SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat, const PetscScalar **);
4990da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat, PetscInt, const PetscInt *, PetscScalar *);
500479a70c0SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat, Mat);
5018a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat, MatReuse, Mat *);
50299cafbc1SBarry Smith 
5038ed539a5SBarry Smith /* ------------------------------------------------------------*/
504014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
5058a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat, IS, IS, const PetscScalar[], InsertMode);
506014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
507014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat, PetscInt, const PetscScalar[]);
508014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat, PetscInt, const PetscScalar[]);
509014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat, PetscInt, PetscInt, PetscInt[], const PetscScalar[]);
51073a71a0fSBarry Smith PETSC_EXTERN PetscErrorCode MatSetRandom(Mat, PetscRandom);
51184cb2905SBarry Smith 
5122ef4de8bSBarry Smith /*S
5132ef1f0ffSBarry Smith      MatStencil - Data structure (C struct) for storing information about rows and
5142ef1f0ffSBarry Smith         columns of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()`
51562ef0227SBarry Smith 
5162ef1f0ffSBarry Smith    Level: beginner
5172ef1f0ffSBarry Smith 
5182ef1f0ffSBarry Smith    Notes:
51962ef0227SBarry 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).
52087497f52SBarry Smith    The c represents the the degrees of freedom at each grid point (the dof argument to `DMDASetDOF()`). If dof is 1 then this entry is ignored.
52162ef0227SBarry Smith 
52287497f52SBarry Smith    For stencil access to vectors see `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`.
523be479b30SJed Brown 
5242ef1f0ffSBarry Smith    For staggered grids, see `DMStagStencil`
5252ef4de8bSBarry Smith 
5262ef1f0ffSBarry Smith    Fortran Note:
5272ef1f0ffSBarry Smith    See `MatSetValuesStencil()` for details.
5282ef4de8bSBarry Smith 
5292ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`,
5302ef1f0ffSBarry Smith           `DMStagStencil`
5312ef4de8bSBarry Smith S*/
532435da068SBarry Smith typedef struct {
533c1ac3661SBarry Smith   PetscInt k, j, i, c;
534435da068SBarry Smith } MatStencil;
5352ef4de8bSBarry Smith 
536014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
537014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat, PetscInt, const MatStencil[], PetscInt, const MatStencil[], const PetscScalar[], InsertMode);
538014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetStencil(Mat, PetscInt, const PetscInt[], const PetscInt[], PetscInt);
539435da068SBarry Smith 
540d91e6319SBarry Smith /*E
5412ef1f0ffSBarry Smith     MatAssemblyType - Indicates if the process of setting values into the matrix is complete, and the matrix is ready for use
542d91e6319SBarry Smith 
543d91e6319SBarry Smith     Level: beginner
544d91e6319SBarry Smith 
5452ef1f0ffSBarry Smith     Values:
5462ef1f0ffSBarry Smith +   `MAT_FLUSH_ASSEMBLY` - you will continue to put values into the matrix
5472ef1f0ffSBarry Smith -   `MAT_FINAL_ASSEMBLY` - you wish to use the matrix with the values currently inserted
5482ef1f0ffSBarry Smith 
5492ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatSetValues`, `MatAssemblyBegin()`, `MatAssemblyEnd()`
550d91e6319SBarry Smith E*/
5519371c9d4SSatish Balay typedef enum {
5529371c9d4SSatish Balay   MAT_FLUSH_ASSEMBLY = 1,
5539371c9d4SSatish Balay   MAT_FINAL_ASSEMBLY = 0
5549371c9d4SSatish Balay } MatAssemblyType;
555014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat, MatAssemblyType);
556014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat, MatAssemblyType);
557014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssembled(Mat, PetscBool *);
5584f9c727eSBarry Smith 
559d91e6319SBarry Smith /*E
5602ef1f0ffSBarry Smith     MatOption - Options that may be set for a matrix that indicate properties of the matrix or affect its behavior or storage
561d91e6319SBarry Smith 
562d91e6319SBarry Smith     Level: beginner
563d91e6319SBarry Smith 
5642ef1f0ffSBarry Smith    Note:
5652ef1f0ffSBarry Smith    See `MatSetOption()` for the use of the options
5662ef1f0ffSBarry Smith 
5672ef1f0ffSBarry Smith    Developer Note:
56895452b02SPatrick Sanan    Entries that are negative need not be called collectively by all processes.
569382164b0SBarry Smith 
5702ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatSetOption()`
571d91e6319SBarry Smith E*/
5729371c9d4SSatish Balay typedef enum {
5739371c9d4SSatish Balay   MAT_OPTION_MIN                  = -3,
574c5e4d11fSDmitry Karpeev   MAT_UNUSED_NONZERO_LOCATION_ERR = -2,
57592d4d306SBarry Smith   MAT_ROW_ORIENTED                = -1,
576382164b0SBarry Smith   MAT_SYMMETRIC                   = 1,
577382164b0SBarry Smith   MAT_STRUCTURALLY_SYMMETRIC      = 2,
5788c78258cSHong Zhang   MAT_FORCE_DIAGONAL_ENTRIES      = 3,
579382164b0SBarry Smith   MAT_IGNORE_OFF_PROC_ENTRIES     = 4,
580382164b0SBarry Smith   MAT_USE_HASH_TABLE              = 5,
581382164b0SBarry Smith   MAT_KEEP_NONZERO_PATTERN        = 6,
582382164b0SBarry Smith   MAT_IGNORE_ZERO_ENTRIES         = 7,
583382164b0SBarry Smith   MAT_USE_INODES                  = 8,
584382164b0SBarry Smith   MAT_HERMITIAN                   = 9,
585382164b0SBarry Smith   MAT_SYMMETRY_ETERNAL            = 10,
586c5e4d11fSDmitry Karpeev   MAT_NEW_NONZERO_LOCATION_ERR    = 11,
587382164b0SBarry Smith   MAT_IGNORE_LOWER_TRIANGULAR     = 12,
588382164b0SBarry Smith   MAT_ERROR_LOWER_TRIANGULAR      = 13,
589382164b0SBarry Smith   MAT_GETROW_UPPERTRIANGULAR      = 14,
590382164b0SBarry Smith   MAT_SPD                         = 15,
59192d4d306SBarry Smith   MAT_NO_OFF_PROC_ZERO_ROWS       = 16,
59292d4d306SBarry Smith   MAT_NO_OFF_PROC_ENTRIES         = 17,
59392d4d306SBarry Smith   MAT_NEW_NONZERO_LOCATIONS       = 18,
594c5e4d11fSDmitry Karpeev   MAT_NEW_NONZERO_ALLOCATION_ERR  = 19,
595c5e4d11fSDmitry Karpeev   MAT_SUBSET_OFF_PROC_ENTRIES     = 20,
596c10200c1SHong Zhang   MAT_SUBMAT_SINGLEIS             = 21,
597957cac9fSHong Zhang   MAT_STRUCTURE_ONLY              = 22,
598071fcb05SBarry Smith   MAT_SORTED_FULL                 = 23,
5991a2c6b5cSJunchao Zhang   MAT_FORM_EXPLICIT_TRANSPOSE     = 24,
600b94d7dedSBarry Smith   MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25,
601b94d7dedSBarry Smith   MAT_SPD_ETERNAL                 = 26,
6029371c9d4SSatish Balay   MAT_OPTION_MAX                  = 27
6039371c9d4SSatish Balay } MatOption;
604e057df02SPaul Mullowney 
6050f8fb01aSBarry Smith PETSC_EXTERN const char *const *MatOptions;
606014dd563SJed Brown PETSC_EXTERN PetscErrorCode     MatSetOption(Mat, MatOption, PetscBool);
6077d68702bSBarry Smith PETSC_EXTERN PetscErrorCode     MatGetOption(Mat, MatOption, PetscBool *);
608856afa8bSStefano Zampini PETSC_EXTERN PetscErrorCode     MatPropagateSymmetryOptions(Mat, Mat);
60919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode     MatGetType(Mat, MatType *);
61084cb2905SBarry Smith 
611014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetValues(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
612014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
613014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatRestoreRow(Mat, PetscInt, PetscInt *, const PetscInt *[], const PetscScalar *[]);
614014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetRowUpperTriangular(Mat);
615014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatRestoreRowUpperTriangular(Mat);
616014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetColumnVector(Mat, Vec, PetscInt);
6178c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArray(Mat, PetscScalar *[]);
6188f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArrayRead(Mat, const PetscScalar *[]);
619d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatSeqAIJGetArrayWrite(Mat, PetscScalar *[]);
6208c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArray(Mat, PetscScalar *[]);
6218f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArrayRead(Mat, const PetscScalar *[]);
622d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatSeqAIJRestoreArrayWrite(Mat, PetscScalar *[]);
62321e72a00SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJGetMaxRowNonzeros(Mat, PetscInt *);
624bd04181cSBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJSetValuesLocalFast(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
6254099cc6bSBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqAIJSetType(Mat, MatType);
626ad7e164aSPierre Jolivet PETSC_EXTERN PetscErrorCode    MatSeqAIJKron(Mat, Mat, MatReuse, Mat *);
627388d47a6SSatish Balay PETSC_EXTERN PetscErrorCode    MatSeqAIJRegister(const char[], PetscErrorCode (*)(Mat, MatType, MatReuse, Mat *));
6284099cc6bSBarry Smith PETSC_EXTERN PetscFunctionList MatSeqAIJList;
629cda14afcSprj- PETSC_EXTERN PetscErrorCode    MatSeqBAIJGetArray(Mat, PetscScalar *[]);
630cda14afcSprj- PETSC_EXTERN PetscErrorCode    MatSeqBAIJRestoreArray(Mat, PetscScalar *[]);
6318397e458SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqSBAIJGetArray(Mat, PetscScalar *[]);
6328397e458SBarry Smith PETSC_EXTERN PetscErrorCode    MatSeqSBAIJRestoreArray(Mat, PetscScalar *[]);
6338c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseGetArray(Mat, PetscScalar *[]);
6348c778c55SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseRestoreArray(Mat, PetscScalar *[]);
635d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode    MatDensePlaceArray(Mat, const PetscScalar[]);
636d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseReplaceArray(Mat, const PetscScalar[]);
637d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseResetArray(Mat);
6388572280aSBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseGetArrayRead(Mat, const PetscScalar *[]);
6398572280aSBarry Smith PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayRead(Mat, const PetscScalar *[]);
6406947451fSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseGetArrayWrite(Mat, PetscScalar *[]);
6416947451fSStefano Zampini PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayWrite(Mat, PetscScalar *[]);
642cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayAndMemType(Mat, PetscScalar *[], PetscMemType *);
643cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayAndMemType(Mat, PetscScalar *[]);
644cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayReadAndMemType(Mat, const PetscScalar *[], PetscMemType *);
645cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayReadAndMemType(Mat, const PetscScalar *[]);
646cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseGetArrayWriteAndMemType(Mat, PetscScalar *[], PetscMemType *);
647cd3f9d89SJunchao Zhang PETSC_EXTERN PetscErrorCode    MatDenseRestoreArrayWriteAndMemType(Mat, PetscScalar *[]);
648014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetBlockSize(Mat, PetscInt *);
649014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSize(Mat, PetscInt);
650014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatGetBlockSizes(Mat, PetscInt *, PetscInt *);
651014dd563SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSizes(Mat, PetscInt, PetscInt);
65233d57670SJed Brown PETSC_EXTERN PetscErrorCode    MatSetBlockSizesFromMats(Mat, Mat, Mat);
6530da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode    MatSetVariableBlockSizes(Mat, PetscInt, PetscInt *);
6540da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode    MatGetVariableBlockSizes(Mat, PetscInt *, const PetscInt **);
6550da83c2eSBarry Smith 
65686aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat, PetscInt, PetscScalar *[]);
65786aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat, PetscScalar *[]);
6586947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat, PetscInt, Vec *);
6596947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat, PetscInt, Vec *);
6606947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat, PetscInt, Vec *);
6616947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat, PetscInt, Vec *);
6626947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat, PetscInt, Vec *);
6636947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat, PetscInt, Vec *);
664a2748737SPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
6655ea7661aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat, Mat *);
6661620fd73SBarry Smith 
667014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMult(Mat, Vec, Vec);
668014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat, Vec, Vec);
669014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAdd(Mat, Vec, Vec, Vec);
670014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat, Vec, Vec);
671014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat, Vec, Vec);
672014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat, Mat, PetscReal, PetscBool *);
673014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat, Mat, PetscReal, PetscBool *);
674014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat, Vec, Vec, Vec);
675014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat, Vec, Vec, Vec);
676014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatSolve(Mat, Mat, Mat);
677bdc285e1SStefano Zampini PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat, Mat, Mat);
678eb3ef3b2SHong Zhang PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat, Mat, Mat);
679f9426fe0SMark Adams PETSC_EXTERN PetscErrorCode MatResidual(Mat, Vec, Vec, Vec);
680f5edf698SHong Zhang 
681d91e6319SBarry Smith /*E
682d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
683d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
684d91e6319SBarry Smith 
685d91e6319SBarry Smith     Level: beginner
686d91e6319SBarry Smith 
6872ef1f0ffSBarry Smith     Values:
6882ef1f0ffSBarry Smith +   `MAT_DO_NOT_COPY_VALUES`    - Create a matrix using the same nonzero pattern as the original matrix,
6892ef1f0ffSBarry Smith                                with zeros for the numerical values
6902ef1f0ffSBarry Smith .   `MAT_COPY_VALUES`           - Create a matrix with the same nonzero pattern as the original matrix
6912ef1f0ffSBarry Smith                                and with the same numerical values.
6922ef1f0ffSBarry Smith -   `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix
6932ef1f0ffSBarry Smith                                and does not copy it, using zeros for the numerical values. The parent and
6942ef1f0ffSBarry Smith                                child matrices will share their index (i and j) arrays, and you cannot
6952ef1f0ffSBarry Smith                                insert new nonzero entries into either matrix
6960018da39SRichard Tran Mills 
69787497f52SBarry Smith   Note:
69887497f52SBarry Smith   Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in
69987497f52SBarry Smith   this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified.
70070dcbbb9SBarry Smith 
7012ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatDuplicate()`
702d91e6319SBarry Smith E*/
7039371c9d4SSatish Balay typedef enum {
7049371c9d4SSatish Balay   MAT_DO_NOT_COPY_VALUES,
7059371c9d4SSatish Balay   MAT_COPY_VALUES,
7069371c9d4SSatish Balay   MAT_SHARE_NONZERO_PATTERN
7079371c9d4SSatish Balay } MatDuplicateOption;
7082e8a6d31SBarry Smith 
70919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatConvert(Mat, MatType, MatReuse, Mat *);
710014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDuplicate(Mat, MatDuplicateOption, Mat *);
71194a9d846SBarry Smith 
712014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCopy(Mat, Mat, MatStructure);
713014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatView(Mat, PetscViewer);
714014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat, PetscReal, PetscBool *);
715014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat, PetscBool *);
716014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat, PetscReal, PetscBool *);
717014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat, PetscBool *, PetscBool *);
718014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat, PetscBool *, PetscBool *);
719b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat, PetscBool *, PetscBool *);
720b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat, PetscBool *, PetscBool *);
721014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat, PetscBool *, PetscInt *);
722014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer);
7237b80b807SBarry Smith 
7241a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7251a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7261a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
7271a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat, PetscInt, PetscBool, PetscBool, PetscInt *, const PetscInt *[], const PetscInt *[], PetscBool *);
728d4fbbf0eSBarry Smith 
729d91e6319SBarry Smith /*S
73087497f52SBarry Smith      MatInfo - Context of matrix information, used with `MatGetInfo()`
731d91e6319SBarry Smith 
732d91e6319SBarry Smith    Level: intermediate
733d91e6319SBarry Smith 
7342ef1f0ffSBarry Smith    Fortran Note:
7352ef1f0ffSBarry Smith    Information is stored as a double-precision array of dimension `MAT_INFO_SIZE`
7362ef1f0ffSBarry Smith 
7372ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatGetInfo()`, `MatInfoType`
738d91e6319SBarry Smith S*/
7394e220ebcSLois Curfman McInnes typedef struct {
740b0a32e0cSBarry Smith   PetscLogDouble block_size;                          /* block size */
741b0a32e0cSBarry Smith   PetscLogDouble nz_allocated, nz_used, nz_unneeded;  /* number of nonzeros */
742b0a32e0cSBarry Smith   PetscLogDouble memory;                              /* memory allocated */
743b0a32e0cSBarry Smith   PetscLogDouble assemblies;                          /* number of matrix assemblies called */
744b0a32e0cSBarry Smith   PetscLogDouble mallocs;                             /* number of mallocs during MatSetValues() */
745b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given, fill_ratio_needed; /* fill ratio for LU/ILU */
746b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                      /* number of mallocs during factorization */
7474e220ebcSLois Curfman McInnes } MatInfo;
7484e220ebcSLois Curfman McInnes 
749d9274352SBarry Smith /*E
750d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
751d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
752d9274352SBarry Smith 
753d9274352SBarry Smith     Level: beginner
754d9274352SBarry Smith 
7552ef1f0ffSBarry Smith     Values:
7562ef1f0ffSBarry Smith +   `MAT_LOCAL` - values for each MPI process part of the matrix
7572ef1f0ffSBarry Smith .   `MAT_GLOBAL_MAX` - maximum of each value over all MPI processes
7582ef1f0ffSBarry Smith -   `MAT_GLOBAL_SUM` - sum of each value over all MPI processes
759d9274352SBarry Smith 
7602ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatGetInfo()`, `MatInfo`
761d9274352SBarry Smith E*/
7629371c9d4SSatish Balay typedef enum {
7639371c9d4SSatish Balay   MAT_LOCAL      = 1,
7649371c9d4SSatish Balay   MAT_GLOBAL_MAX = 2,
7659371c9d4SSatish Balay   MAT_GLOBAL_SUM = 3
7669371c9d4SSatish Balay } MatInfoType;
767014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInfo(Mat, MatInfoType, MatInfo *);
768014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat, Vec);
769014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat, Vec, PetscInt[]);
770014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat, Vec, PetscInt[]);
771014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat, Vec, PetscInt[]);
772014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat, Vec, PetscInt[]);
773014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat, Vec);
774014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTranspose(Mat, MatReuse, Mat *);
7757fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat, Mat *);
7767fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat, Mat);
777014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat, MatReuse, Mat *);
778014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPermute(Mat, IS, IS, Mat *);
779014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat, Vec, Vec);
780014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat, Vec, InsertMode);
781a52676ecSHong Zhang 
782014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatEqual(Mat, Mat, PetscBool *);
783014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultEqual(Mat, Mat, PetscInt, PetscBool *);
784014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat, Mat, PetscInt, PetscBool *);
785014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
786014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
787e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat, Mat, PetscInt, PetscBool *);
788e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat, Mat, PetscInt, PetscBool *);
789a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
790a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
791cc48ffa7SToby Isaac PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
7924222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
793447fed29SStefano Zampini PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat, Mat, Mat, PetscInt, PetscBool *);
79486919fd6SHong Zhang PETSC_EXTERN PetscErrorCode MatIsLinear(Mat, PetscInt, PetscBool *);
7957b80b807SBarry Smith 
796014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNorm(Mat, NormType, PetscReal *);
797014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat, NormType, PetscReal *);
798857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat, PetscScalar *);
799857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat, PetscReal *);
800857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat, PetscReal *);
801857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat, PetscScalar *);
802857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat, PetscReal *);
803857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat, PetscReal *);
804857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat, PetscInt, PetscReal *);
805014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat);
8061b2b9847SBarry Smith PETSC_EXTERN PetscErrorCode MatSetInf(Mat);
807014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRows(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
808014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat, IS, PetscScalar, Vec, Vec);
809014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
810014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat, PetscInt, const MatStencil[], PetscScalar, Vec, Vec);
811014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
812014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat, IS, PetscScalar, Vec, Vec);
8137b80b807SBarry Smith 
814014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSize(Mat, PetscInt *, PetscInt *);
815014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat, PetscInt *, PetscInt *);
816014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat, PetscInt *, PetscInt *);
817014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat, const PetscInt **);
818014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat, PetscInt *, PetscInt *);
819014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat, const PetscInt **);
820566876eaSJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat, IS *, IS *);
8215ef9f2a5SBarry Smith 
8227dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
823d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatrices() (since version 3.8)") static inline PetscErrorCode MatGetSubMatrices(Mat mat, PetscInt n, const IS irow[], const IS icol[], MatReuse scall, Mat *submat[])
824d71ae5a4SJacob Faibussowitsch {
8259371c9d4SSatish Balay   return MatCreateSubMatrices(mat, n, irow, icol, scall, submat);
8269371c9d4SSatish Balay }
8277dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat, PetscInt, const IS[], const IS[], MatReuse, Mat *[]);
828d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatricesMPI() (since version 3.8)") static inline PetscErrorCode MatGetSubMatricesMPI(Mat mat, PetscInt n, const IS irow[], const IS icol[], MatReuse scall, Mat *submat[])
829d71ae5a4SJacob Faibussowitsch {
8309371c9d4SSatish Balay   return MatCreateSubMatricesMPI(mat, n, irow, icol, scall, submat);
8319371c9d4SSatish Balay }
832014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt, Mat *[]);
833df750dc8SHong Zhang PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt, Mat *[]);
8347dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat, IS, IS, MatReuse, Mat *);
835d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatrix() (since version 3.8)") static inline PetscErrorCode MatGetSubMatrix(Mat mat, IS isrow, IS iscol, MatReuse cll, Mat *newmat)
836d71ae5a4SJacob Faibussowitsch {
8379371c9d4SSatish Balay   return MatCreateSubMatrix(mat, isrow, iscol, cll, newmat);
8389371c9d4SSatish Balay }
839014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat, IS, IS, Mat *);
840014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat, IS, IS, Mat *);
841014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat, Mat *);
842014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat *);
8437b80b807SBarry Smith 
844014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm, Mat, PetscInt, PetscInt, MatReuse, Mat *);
845014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm, Mat, PetscInt, PetscInt, Mat *);
846014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat, Mat);
847014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat, MatReuse, Mat *);
8488a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat, Mat *);
849014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat, MatReuse, IS *, IS *, Mat *);
850ed502f03SStefano Zampini PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat, MatReuse, IS *, Mat *);
851f2afee66SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat, PetscCount *);
852014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat, Mat, MatReuse, IS *, IS *, Mat *);
853014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *, const PetscInt *[]);
8548efafbd8SBarry Smith 
855014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat, PetscInt, IS[], PetscInt);
856aa1e27eaSFande Kong PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat mat, PetscInt n, IS is[], PetscInt ov);
857d2b2a242SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat, PetscBool);
8587b80b807SBarry Smith 
859014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
86022440eb1SKris Buschelman 
8617bab7c10SHong Zhang PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
8622df6c5c3SPatrick Farrell PETSC_EXTERN PetscErrorCode MatGalerkin(Mat, Mat, Mat, MatReuse, PetscReal, Mat *);
8637bab7c10SHong Zhang 
864014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAP(Mat, Mat, MatReuse, PetscReal, Mat *);
865014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARt(Mat, Mat, MatReuse, PetscReal, Mat *);
86622440eb1SKris Buschelman 
867014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat, Mat, MatReuse, PetscReal, Mat *);
868014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat, Mat, MatReuse, PetscReal, Mat *);
869bc011b1eSHong Zhang 
870014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAXPY(Mat, PetscScalar, Mat, MatStructure);
871014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAYPX(Mat, PetscScalar, Mat, MatStructure);
8721c741599SHong Zhang 
873014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScale(Mat, PetscScalar);
874014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShift(Mat, PetscScalar);
8757b80b807SBarry Smith 
876014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping, ISLocalToGlobalMapping);
877014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
878a93ff8c4SPeter Brune PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat, PetscLayout *, PetscLayout *);
87981fa06acSBarry Smith PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat, PetscLayout, PetscLayout);
880014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
881014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
882014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat, PetscInt, const PetscInt[], PetscScalar, Vec, Vec);
883014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat, IS, PetscScalar, Vec, Vec);
884e265f6d6SPatrick Sanan PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], PetscScalar[]);
885014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
886014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
887052efed2SBarry Smith 
888014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat, PetscInt, PetscInt);
889014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
89090f02eecSBarry Smith 
891014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolate(Mat, Vec, Vec);
892014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat, Vec, Vec, Vec);
893014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestrict(Mat, Vec, Vec);
89430b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat, Mat, Mat *);
89530b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat, Mat, Mat, Mat *);
89630b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat, Mat, Mat *);
8972a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat, Vec *, Vec *);
898d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatCreateVecs() (since version 3.6)") static inline PetscErrorCode MatGetVecs(Mat mat, Vec *x, Vec *y)
899d71ae5a4SJacob Faibussowitsch {
9009371c9d4SSatish Balay   return MatCreateVecs(mat, x, y);
9019371c9d4SSatish Balay }
90253cd1579SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat, PetscInt, MPI_Comm, MatReuse, Mat *);
903014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat, MPI_Comm, MatReuse, Mat *);
904014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat, IS *);
9053a062f41SBarry Smith PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat, IS *);
9069c8f2541SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm, Mat, PetscInt, MatReuse, Mat *);
907bd481603SBarry Smith 
908bd481603SBarry Smith /*MC
9091620fd73SBarry Smith    MatSetValue - Set a single entry into a matrix.
9101620fd73SBarry Smith 
91120f4b53cSBarry Smith    Not Collective
9121620fd73SBarry Smith 
913a9834a7dSSatish Balay    Synopsis:
914a9834a7dSSatish Balay      #include <petscmat.h>
915a9834a7dSSatish Balay      PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode)
916a9834a7dSSatish Balay 
9171620fd73SBarry Smith    Input Parameters:
9181620fd73SBarry Smith +  m - the matrix
9191620fd73SBarry Smith .  row - the row location of the entry
9201620fd73SBarry Smith .  col - the column location of the entry
9211620fd73SBarry Smith .  value - the value to insert
92287497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
9231620fd73SBarry Smith 
9241620fd73SBarry Smith    Level: beginner
9251620fd73SBarry Smith 
9262ef1f0ffSBarry Smith    Note:
9272ef1f0ffSBarry Smith    For efficiency one should use `MatSetValues()` and set several values simultaneously.
9282ef1f0ffSBarry Smith 
9292ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd`, `InsertMode`, `MatGetValue()`, `MatSetValues()`,
9302ef1f0ffSBarry Smith           `MatSetValueLocal()`, `MatSetValuesLocal()`
9311620fd73SBarry Smith M*/
932d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode MatSetValue(Mat v, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
933d71ae5a4SJacob Faibussowitsch {
9349371c9d4SSatish Balay   return MatSetValues(v, 1, &i, 1, &j, &va, mode);
9359371c9d4SSatish Balay }
9361620fd73SBarry Smith 
937e5e5a7b5SPatrick Sanan /*@C
938e5e5a7b5SPatrick Sanan    MatGetValue - Gets a single value from a matrix
9391620fd73SBarry Smith 
940e5e5a7b5SPatrick Sanan    Not Collective; can only return a value owned by the given process
941e5e5a7b5SPatrick Sanan 
942e5e5a7b5SPatrick Sanan    Input Parameters:
943e5e5a7b5SPatrick Sanan +  mat - the matrix
944e5e5a7b5SPatrick Sanan .  row - the row location of the entry
945e5e5a7b5SPatrick Sanan -  col - the column location of the entry
946e5e5a7b5SPatrick Sanan 
947e5e5a7b5SPatrick Sanan    Output Parameter:
948e5e5a7b5SPatrick Sanan .  va - the value
949e5e5a7b5SPatrick Sanan 
9502ef1f0ffSBarry Smith    Level: advanced
9512ef1f0ffSBarry Smith 
952e5e5a7b5SPatrick Sanan    Notes:
9532ef1f0ffSBarry Smith    The matrix must have been assembled with `MatAssemblyBegin()` and `MatAssemblyEnd` before this call
9542ef1f0ffSBarry Smith 
95587497f52SBarry Smith    For efficiency one should use `MatGetValues()` and get several values simultaneously.
956e5e5a7b5SPatrick Sanan 
95787497f52SBarry Smith    See notes for `MatGetValues()`.
958e5e5a7b5SPatrick Sanan 
9592ef1f0ffSBarry Smith .seealso: [](chapter_matrices),  `Mat`, `MatAssemblyBegin()`, `MatAssemblyEnd`, `MatSetValue()`, `MatGetValueLocal()`, `MatGetValues()`
960e5e5a7b5SPatrick Sanan @*/
961d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode MatGetValue(Mat mat, PetscInt row, PetscInt col, PetscScalar *va)
962d71ae5a4SJacob Faibussowitsch {
9639371c9d4SSatish Balay   return MatGetValues(mat, 1, &row, 1, &col, va);
9649371c9d4SSatish Balay }
965e5e5a7b5SPatrick Sanan 
966e5e5a7b5SPatrick Sanan /*MC
9672ef1f0ffSBarry Smith    MatSetValueLocal - Inserts or adds a single value into a matrix, using a local numbering of the nodes.
968e5e5a7b5SPatrick Sanan 
969e5e5a7b5SPatrick Sanan    Not Collective
970e5e5a7b5SPatrick Sanan 
971e5e5a7b5SPatrick Sanan    Input Parameters:
972e5e5a7b5SPatrick Sanan +  m - the matrix
973e5e5a7b5SPatrick Sanan .  row - the row location of the entry
974e5e5a7b5SPatrick Sanan .  col - the column location of the entry
975e5e5a7b5SPatrick Sanan .  value - the value to insert
97687497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
977e5e5a7b5SPatrick Sanan 
9782ef1f0ffSBarry Smith    Level: intermediate
9792ef1f0ffSBarry Smith 
980e5e5a7b5SPatrick Sanan    Notes:
98187497f52SBarry Smith    For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously.
982e5e5a7b5SPatrick Sanan 
98387497f52SBarry Smith    See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used.
984e5e5a7b5SPatrick Sanan 
9852ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatSetValue()`, `MatSetValuesLocal()`
986e5e5a7b5SPatrick Sanan M*/
987d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode MatSetValueLocal(Mat v, PetscInt i, PetscInt j, PetscScalar va, InsertMode mode)
988d71ae5a4SJacob Faibussowitsch {
9899371c9d4SSatish Balay   return MatSetValuesLocal(v, 1, &i, 1, &j, &va, mode);
9909371c9d4SSatish Balay }
9911620fd73SBarry Smith 
9921620fd73SBarry Smith /*MC
993d0609cedSBarry Smith    MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per
994bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
995bd481603SBarry Smith 
996bd481603SBarry Smith    Synopsis:
997aaa7dc30SBarry Smith    #include <petscmat.h>
998d0609cedSBarry Smith    PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
999bd481603SBarry Smith 
1000d083f849SBarry Smith    Collective
1001bd481603SBarry Smith 
1002bd481603SBarry Smith    Input Parameters:
1003bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
1004859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
1005859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
1006bd481603SBarry Smith 
1007bd481603SBarry Smith    Output Parameters:
1008bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
1009a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1010bd481603SBarry Smith 
10112ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1012bd481603SBarry Smith 
1013bd481603SBarry Smith    Notes:
10142ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
10152ef1f0ffSBarry Smith    the use of this routine
10162ef1f0ffSBarry Smith 
1017d0609cedSBarry Smith    This is a macro that handles its own error checking, it does not return an error code.
1018d0609cedSBarry Smith 
10192ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1020bd481603SBarry Smith 
10212ef1f0ffSBarry Smith    Developer Note:
10222ef1f0ffSBarry Smith     This is a MACRO not a function because it has a leading { that is closed by `PetscPreallocateFinalize()`.
1023bd481603SBarry Smith 
10242ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1025db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
1026bd481603SBarry Smith M*/
10279371c9d4SSatish Balay #define MatPreallocateBegin(comm, nrows, ncols, dnz, onz) \
10289371c9d4SSatish Balay   do { \
10293ba16761SJacob Faibussowitsch     PetscInt              __nrows = (nrows), __ncols = (ncols), __rstart, __end = 0; \
10303ba16761SJacob Faibussowitsch     PetscInt PETSC_UNUSED __start; \
10319566063dSJacob Faibussowitsch     PetscCall(PetscCalloc2(__nrows, &(dnz), __nrows, &(onz))); \
10329566063dSJacob Faibussowitsch     PetscCallMPI(MPI_Scan(&__ncols, &__end, 1, MPIU_INT, MPI_SUM, comm)); \
10339371c9d4SSatish Balay     __start = __end - __ncols; \
10349371c9d4SSatish Balay     (void)__start; \
10359566063dSJacob Faibussowitsch     PetscCallMPI(MPI_Scan(&__nrows, &__rstart, 1, MPIU_INT, MPI_SUM, comm)); \
10365f80ce2aSJacob Faibussowitsch   __rstart -= __nrows
10377c922b88SBarry Smith 
1038d0609cedSBarry Smith #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO("GCC warning \"Use MatPreallocateBegin() (since version 3.18)\"") MatPreallocateBegin(__VA_ARGS__)
1039d0609cedSBarry Smith 
1040bd481603SBarry Smith /*MC
1041bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1042bd481603SBarry Smith        inserted using a local number of the rows and columns
1043bd481603SBarry Smith 
1044bd481603SBarry Smith    Synopsis:
1045aaa7dc30SBarry Smith    #include <petscmat.h>
1046c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1047bd481603SBarry Smith 
1048bd481603SBarry Smith    Not Collective
1049bd481603SBarry Smith 
1050bd481603SBarry Smith    Input Parameters:
1051784ac674SJed Brown +  map - the row mapping from local numbering to global numbering
1052bd481603SBarry Smith .  nrows - the number of rows indicated
10531d73ed98SBarry Smith .  rows - the indices of the rows
1054784ac674SJed Brown .  cmap - the column mapping from local to global numbering
1055bd481603SBarry Smith .  ncols - the number of columns in the matrix
1056bd481603SBarry Smith .  cols - the columns indicated
1057bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1058a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1059bd481603SBarry Smith 
10602ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1061bd481603SBarry Smith 
1062bd481603SBarry Smith    Notes:
10632ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
10642ef1f0ffSBarry Smith    the use of this routine
1065bd481603SBarry Smith 
10662ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1067bd481603SBarry Smith 
10682ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1069db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()`
1070bd481603SBarry Smith M*/
107194bad497SJacob Faibussowitsch #define MatPreallocateSetLocal(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
10729371c9d4SSatish 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));)
1073c4f061fbSSatish Balay 
1074bd481603SBarry Smith /*MC
1075c1154cd5SBarry Smith    MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1076c1154cd5SBarry Smith        inserted using a local number of the rows and columns. This version removes any duplicate columns in cols
1077c1154cd5SBarry Smith 
1078c1154cd5SBarry Smith    Synopsis:
1079c1154cd5SBarry Smith    #include <petscmat.h>
1080c1154cd5SBarry Smith    PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1081c1154cd5SBarry Smith 
1082c1154cd5SBarry Smith    Not Collective
1083c1154cd5SBarry Smith 
1084c1154cd5SBarry Smith    Input Parameters:
1085c1154cd5SBarry Smith +  map - the row mapping from local numbering to global numbering
1086c1154cd5SBarry Smith .  nrows - the number of rows indicated
1087c1154cd5SBarry Smith .  rows - the indices of the rows (these values are mapped to the global values)
1088c1154cd5SBarry Smith .  cmap - the column mapping from local to global numbering
1089c1154cd5SBarry Smith .  ncols - the number of columns in the matrix   (this value will be changed if duplicate columns are found)
1090c1154cd5SBarry Smith .  cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed)
1091c1154cd5SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1092a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1093c1154cd5SBarry Smith 
10942ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1095c1154cd5SBarry Smith 
1096c1154cd5SBarry Smith    Notes:
10972ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
10982ef1f0ffSBarry Smith    the use of this routine
1099c1154cd5SBarry Smith 
11002ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1101c1154cd5SBarry Smith 
11022ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1103db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1104c1154cd5SBarry Smith M*/
110594bad497SJacob Faibussowitsch #define MatPreallocateSetLocalRemoveDups(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
11069371c9d4SSatish 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));)
1107c1154cd5SBarry Smith 
1108c1154cd5SBarry Smith /*MC
1109d6e23781SBarry Smith    MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1110bd481603SBarry Smith        inserted using a local number of the rows and columns
1111bd481603SBarry Smith 
1112bd481603SBarry Smith    Synopsis:
1113aaa7dc30SBarry Smith    #include <petscmat.h>
1114d6e23781SBarry Smith    PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1115d6e23781SBarry Smith 
1116d6e23781SBarry Smith    Not Collective
1117d6e23781SBarry Smith 
1118d6e23781SBarry Smith    Input Parameters:
1119d6e23781SBarry Smith +  map - the row mapping from local numbering to global numbering
1120d6e23781SBarry Smith .  nrows - the number of rows indicated
1121d6e23781SBarry Smith .  rows - the indices of the rows
1122d6e23781SBarry Smith .  cmap - the column mapping from local to global numbering
1123d6e23781SBarry Smith .  ncols - the number of columns in the matrix
1124d6e23781SBarry Smith .  cols - the columns indicated
1125d6e23781SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1126a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1127d6e23781SBarry Smith 
11282ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1129d6e23781SBarry Smith 
1130d6e23781SBarry Smith    Notes:
11312ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11322ef1f0ffSBarry Smith    the use of this routine
1133d6e23781SBarry Smith 
11342ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1135d6e23781SBarry Smith 
11362ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1137db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`
1138d6e23781SBarry Smith M*/
113994bad497SJacob Faibussowitsch #define MatPreallocateSetLocalBlock(rmap, nrows, rows, cmap, ncols, cols, dnz, onz) \
11409371c9d4SSatish 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));)
1141d6e23781SBarry Smith 
1142d6e23781SBarry Smith /*MC
1143d6e23781SBarry Smith    MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1144d6e23781SBarry Smith        inserted using a local number of the rows and columns
1145d6e23781SBarry Smith 
1146d6e23781SBarry Smith    Synopsis:
1147d6e23781SBarry Smith    #include <petscmat.h>
1148d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1149bd481603SBarry Smith 
1150bd481603SBarry Smith    Not Collective
1151bd481603SBarry Smith 
1152bd481603SBarry Smith    Input Parameters:
1153bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
1154bd481603SBarry Smith .  nrows - the number of rows indicated
11551d73ed98SBarry Smith .  rows - the indices of the rows
1156bd481603SBarry Smith .  ncols - the number of columns in the matrix
1157bd481603SBarry Smith .  cols - the columns indicated
1158bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1159a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1160bd481603SBarry Smith 
11612ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1162bd481603SBarry Smith 
1163bd481603SBarry Smith    Notes:
11642ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11652ef1f0ffSBarry Smith    the use of this routine
1166bd481603SBarry Smith 
11672ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1168bd481603SBarry Smith 
11692ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`
1170db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1171bd481603SBarry Smith M*/
117294bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetLocalBlock(map, nrows, rows, ncols, cols, dnz, onz) \
11739371c9d4SSatish 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));)
1174e83a5d19SLisandro Dalcin 
1175bd481603SBarry Smith /*MC
1176bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1177bd481603SBarry Smith        inserted using a local number of the rows and columns
1178bd481603SBarry Smith 
1179bd481603SBarry Smith    Synopsis:
1180aaa7dc30SBarry Smith    #include <petscmat.h>
1181c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1182bd481603SBarry Smith 
1183bd481603SBarry Smith    Not Collective
1184bd481603SBarry Smith 
1185bd481603SBarry Smith    Input Parameters:
118664075487SBarry Smith +  row - the row
1187bd481603SBarry Smith .  ncols - the number of columns in the matrix
1188a50f8bf6SHong Zhang -  cols - the columns indicated
1189a50f8bf6SHong Zhang 
1190a50f8bf6SHong Zhang    Output Parameters:
1191a50f8bf6SHong Zhang +  dnz - the array that will be passed to the matrix preallocation routines
1192a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1193bd481603SBarry Smith 
11942ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1195bd481603SBarry Smith 
1196bd481603SBarry Smith    Notes:
11972ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
11982ef1f0ffSBarry Smith    the use of this routine
1199bd481603SBarry Smith 
12002ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1201bd481603SBarry Smith 
1202d0609cedSBarry Smith    This is a MACRO not a function because it uses variables declared in MatPreallocateBegin().
12031620fd73SBarry Smith 
12042ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1205db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1206bd481603SBarry Smith M*/
12079371c9d4SSatish Balay #define MatPreallocateSet(row, nc, cols, dnz, onz) \
12089371c9d4SSatish 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) { \
120964075487SBarry Smith     if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \
1210a6042fd4SStefano Zampini     else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \
12119371c9d4SSatish Balay   })
12127c922b88SBarry Smith 
1213bd481603SBarry Smith /*MC
1214d6e23781SBarry Smith    MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1215bd481603SBarry Smith        inserted using a local number of the rows and columns
1216bd481603SBarry Smith 
1217bd481603SBarry Smith    Synopsis:
1218aaa7dc30SBarry Smith    #include <petscmat.h>
1219d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1220bd481603SBarry Smith 
1221bd481603SBarry Smith    Not Collective
1222bd481603SBarry Smith 
1223bd481603SBarry Smith    Input Parameters:
1224bd481603SBarry Smith +  nrows - the number of rows indicated
12251d73ed98SBarry Smith .  rows - the indices of the rows
1226bd481603SBarry Smith .  ncols - the number of columns in the matrix
1227bd481603SBarry Smith .  cols - the columns indicated
1228bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1229a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1230bd481603SBarry Smith 
12312ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1232bd481603SBarry Smith 
1233bd481603SBarry Smith    Notes:
12342ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
12352ef1f0ffSBarry Smith    the use of this routine
1236bd481603SBarry Smith 
12372ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
1238bd481603SBarry Smith 
1239d0609cedSBarry Smith    This is a MACRO not a function because it uses variables declared in MatPreallocateBegin().
12401620fd73SBarry Smith 
12412ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`,
1242db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1243bd481603SBarry Smith M*/
124494bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetBlock(row, nc, cols, dnz, onz) \
12459371c9d4SSatish Balay   PetscMacroReturnStandard(for (PetscInt __i = 0; __i < nc; __i++) { \
1246d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
1247a6042fd4SStefano Zampini     else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++; \
12489371c9d4SSatish Balay   })
1249d3d32019SBarry Smith 
1250bd481603SBarry Smith /*MC
1251a6042fd4SStefano Zampini    MatPreallocateLocation -  An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists
125216371a99SBarry Smith 
125316371a99SBarry Smith    Synopsis:
1254aaa7dc30SBarry Smith    #include <petscmat.h>
125516371a99SBarry Smith    PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz)
125616371a99SBarry Smith 
125716371a99SBarry Smith    Not Collective
125816371a99SBarry Smith 
125916371a99SBarry Smith    Input Parameters:
1260a2b725a8SWilliam Gropp +  A - matrix
126116371a99SBarry Smith .  row - row where values exist (must be local to this process)
126216371a99SBarry Smith .  ncols - number of columns
126316371a99SBarry Smith .  cols - columns with nonzeros
126416371a99SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1265a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
126616371a99SBarry Smith 
12672ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
126816371a99SBarry Smith 
126916371a99SBarry Smith    Notes:
12702ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
12712ef1f0ffSBarry Smith    the use of this routine
127216371a99SBarry Smith 
12732ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz` that is handled internally by these routines
127416371a99SBarry Smith 
127516371a99SBarry Smith    This is a MACRO not a function because it uses a bunch of variables private to the MatPreallocation.... routines.
127616371a99SBarry Smith 
12772ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1278db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
127916371a99SBarry Smith M*/
1280d0609cedSBarry 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))
128116371a99SBarry Smith 
128216371a99SBarry Smith /*MC
1283d0609cedSBarry Smith    MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per
1284bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
1285bd481603SBarry Smith 
1286bd481603SBarry Smith    Synopsis:
1287aaa7dc30SBarry Smith    #include <petscmat.h>
1288d0609cedSBarry Smith    PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz)
1289bd481603SBarry Smith 
1290d083f849SBarry Smith    Collective
1291bd481603SBarry Smith 
1292bd481603SBarry Smith    Input Parameters:
129316371a99SBarry Smith +  dnz - the array that was be passed to the matrix preallocation routines
1294a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1295bd481603SBarry Smith 
12962ef1f0ffSBarry Smith    Level: deprecated (since v3.19)
1297bd481603SBarry Smith 
1298bd481603SBarry Smith    Notes:
12992ef1f0ffSBarry Smith    This routine is no longer needed since assembling matrices without explicit preallocation will not be slower than
13002ef1f0ffSBarry Smith    the use of this routine
1301d0609cedSBarry Smith 
13022ef1f0ffSBarry Smith    Do not malloc or free `dnz` and `onz`, that is handled internally by these routines
1303bd481603SBarry Smith 
13042ef1f0ffSBarry Smith    Developer Note:
1305d0609cedSBarry Smith     This is a MACRO not a function because it closes the { started in MatPreallocateBegin().
13061620fd73SBarry Smith 
13072ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1308db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
1309bd481603SBarry Smith M*/
13109371c9d4SSatish Balay #define MatPreallocateEnd(dnz, onz) \
13119371c9d4SSatish Balay   PetscCall(PetscFree2(dnz, onz)); \
13129371c9d4SSatish Balay   } \
13139371c9d4SSatish Balay   while (0)
1314d0609cedSBarry Smith 
1315d0609cedSBarry Smith #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO("GCC warning \"Use MatPreallocateEnd() (since version 3.18)\"") MatPreallocateEnd(__VA_ARGS__)
13167c922b88SBarry Smith 
13177b80b807SBarry Smith /* Routines unique to particular data structures */
1318014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat, void *);
1319698d4c6aSKris Buschelman 
1320014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat, IS *, IS *);
1321014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat, PetscInt *, PetscInt *[], PetscInt *);
1322698d4c6aSKris Buschelman 
1323014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat, PetscInt[]);
1324014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat, PetscInt[]);
1325014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1326014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1327014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *);
1328014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscScalar[], Mat *, PetscInt, PetscBool);
13297b80b807SBarry Smith 
1330a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4
1331a96a251dSBarry Smith 
1332014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1333014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1334014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat, PetscInt, const PetscInt[]);
133519b08ed1SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat, PetscInt);
1336273d9f13SBarry Smith 
1337014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1338014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1339014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
1340014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1341014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1342014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat, const PetscInt[], const PetscInt[], const PetscScalar[]);
1343014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat, PetscInt, const PetscInt[], const PetscInt[], const PetscScalar[]);
1344014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat, PetscInt[], PetscInt[], PetscInt[]);
1345b44e7856SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat, Mat *);
1346252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat, Mat *);
1347014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat, PetscScalar[]);
1348014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat, PetscScalar[]);
13499230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
13509230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat, Mat *, Mat *, const PetscInt *[]);
1351014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat, Mat *);
1352273d9f13SBarry Smith 
135349a6ff4bSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat, PetscInt *);
1354ad16ce7aSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat, PetscInt);
1355d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatDenseSetLDA() (since version 3.14)") static inline PetscErrorCode MatSeqDenseSetLDA(Mat A, PetscInt lda)
1356d71ae5a4SJacob Faibussowitsch {
13579371c9d4SSatish Balay   return MatDenseSetLDA(A, lda);
13589371c9d4SSatish Balay }
1359014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat, Mat *);
13601b807ce4Svictorle 
1361621e819fSSatish Balay PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat, PetscInt, PetscInt, const PetscInt[]);
1362621e819fSSatish Balay 
1363014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStoreValues(Mat);
1364014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat);
13652e8a6d31SBarry Smith 
1366014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat, IS *);
13677cfe41e4SPatrick Farrell PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat, IS *);
13687b80b807SBarry Smith /*
13697b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
137094b7f48cSBarry Smith   done through the KSP and PC interfaces.
13717b80b807SBarry Smith */
13727b80b807SBarry Smith 
137376bdecfbSBarry Smith /*J
13742ef1f0ffSBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering. These orderings are most commonly used
13752ef1f0ffSBarry Smith     to reduce fill in sparse factorizations.
1376d9274352SBarry Smith 
1377d9274352SBarry Smith    Level: beginner
1378d9274352SBarry Smith 
13792c7c0729SBarry Smith    Notes:
13802ef1f0ffSBarry Smith    If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and instead the external package called utilizes one
13812ef1f0ffSBarry Smith    in the external the factorization package
13822c7c0729SBarry Smith 
13832ef1f0ffSBarry Smith    There is no `MatOrdering` object, the ordering is obtained directly from the matrix with `MatGetOrdering()`
13842ef1f0ffSBarry Smith 
13852ef1f0ffSBarry Smith    Developer Note:
13862ef1f0ffSBarry Smith    This API should be converted to an API similar to those for `MatColoring` and `MatPartitioning`
13872ef1f0ffSBarry Smith 
13882ef1f0ffSBarry Smith .seealso: [](chapter_matrices), [](sec_graph), `MatGetFactor()`, `MatGetOrdering()`, `MatColoringType`, `MatPartitioningType`, `MatCoarsenType`, `MatCoarsenType`,
13892ef1f0ffSBarry Smith           `PCFactorSetOrderingType()`
139076bdecfbSBarry Smith J*/
139119fd82e9SBarry Smith typedef const char *MatOrderingType;
13922692d6eeSBarry Smith #define MATORDERINGNATURAL       "natural"
13932692d6eeSBarry Smith #define MATORDERINGND            "nd"
13942692d6eeSBarry Smith #define MATORDERING1WD           "1wd"
13952692d6eeSBarry Smith #define MATORDERINGRCM           "rcm"
13962692d6eeSBarry Smith #define MATORDERINGQMD           "qmd"
13972692d6eeSBarry Smith #define MATORDERINGROWLENGTH     "rowlength"
1398510184a7SJed Brown #define MATORDERINGWBM           "wbm"
1399fc1bef75SJed Brown #define MATORDERINGSPECTRAL      "spectral"
1400312e372aSBarry Smith #define MATORDERINGAMD           "amd"           /* only works if UMFPACK is installed with PETSc */
1401048412efSPablo Brubeck #define MATORDERINGMETISND       "metisnd"       /* only works if METIS is installed with PETSc */
14029bd791bbSBarry 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 */
14032c7c0729SBarry Smith #define MATORDERINGEXTERNAL      "external"      /* uses an ordering type internal to the factorization package */
1404b12f92e5SBarry Smith 
140519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode    MatGetOrdering(Mat, MatOrderingType, IS *, IS *);
1406140e18c1SBarry Smith PETSC_EXTERN PetscErrorCode    MatGetOrderingList(PetscFunctionList *);
1407bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode    MatOrderingRegister(const char[], PetscErrorCode (*)(Mat, MatOrderingType, IS *, IS *));
1408140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatOrderingList;
1409d4fbbf0eSBarry Smith 
1410013e2dc7SBarry Smith #include "petscmatcoarsen.h"
1411013e2dc7SBarry Smith 
1412014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat, PetscReal, IS, IS);
1413fc1bef75SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat, PetscReal, PetscBool, Mat *);
1414a2ce50c7SBarry Smith 
14154ac6704cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat, MatFactorType, MatOrderingType *);
14164ac6704cSBarry Smith 
1417d91e6319SBarry Smith /*S
14182ef1f0ffSBarry Smith     MatFactorShiftType - Type of numeric shift used for factorizations
1419d90ac83dSHong Zhang 
14202ef1f0ffSBarry Smith    Values:
14212ef1f0ffSBarry Smith +  `MAT_SHIFT_NONE` - do not shift the matrix diagonal entries
14222ef1f0ffSBarry Smith .  `MAT_SHIFT_NONZERO` - shift the entries to be non-zero
14232ef1f0ffSBarry Smith .  `MAT_SHIFT_POSITIVE_DEFINITE` - shift the entries to force the factorization to be positive definite
14242ef1f0ffSBarry Smith -  `MAT_SHIFT_INBLOCKS` - only shift the factors inside the small dense diagonal blocks of the matrix, for example with `MATBAIJ`
1425d90ac83dSHong Zhang 
14262ef1f0ffSBarry Smith    Level: intermediate
14272ef1f0ffSBarry Smith 
14282ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatGetFactor()`, `PCFactorSetShiftType()`
1429d90ac83dSHong Zhang S*/
14309371c9d4SSatish Balay typedef enum {
14319371c9d4SSatish Balay   MAT_SHIFT_NONE,
14329371c9d4SSatish Balay   MAT_SHIFT_NONZERO,
14339371c9d4SSatish Balay   MAT_SHIFT_POSITIVE_DEFINITE,
14349371c9d4SSatish Balay   MAT_SHIFT_INBLOCKS
14359371c9d4SSatish Balay } MatFactorShiftType;
14366a6fc655SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypes[];
14375e9742b9SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypesDetail[];
1438d90ac83dSHong Zhang 
1439d90ac83dSHong Zhang /*S
1440ec5066bdSBarry Smith     MatFactorError - indicates what type of error was generated in a matrix factorization
14419aa7eafdSHong Zhang 
14422ef1f0ffSBarry Smith     Values:
14432ef1f0ffSBarry Smith +   `MAT_FACTOR_NOERROR` - there was no error during the factorization
14442ef1f0ffSBarry Smith .   `MAT_FACTOR_STRUCT_ZEROPIVOT` - there was a missing entry in a diagonal location of the matrix
14452ef1f0ffSBarry Smith .   `MAT_FACTOR_NUMERIC_ZEROPIVOT` - there was a (near) zero pivot during the factorization
14462ef1f0ffSBarry Smith .   `MAT_FACTOR_OUTMEMORY` - the factorization has run out of memory
14472ef1f0ffSBarry Smith -   `MAT_FACTOR_OTHER` - some other error has occurred.
14489aa7eafdSHong Zhang 
14492ef1f0ffSBarry Smith     Level: intermediate
145000e125f8SBarry Smith 
14512ef1f0ffSBarry Smith     Note:
14522ef1f0ffSBarry Smith     When a factorization is done in a preconditioner `PC` the error may be propagated up to a `PCFailedReason` or a `KSPConvergedReason`
14532ef1f0ffSBarry Smith 
14542ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatGetFactor()`, `MatFactorGetError()`, `MatFactorGetErrorZeroPivot()`, `MatFactorClearError()`,
14552ef1f0ffSBarry Smith           `PCFailedReason`, `PCGetFailedReason()`, `KSPConvergedReason`
14569aa7eafdSHong Zhang S*/
14579371c9d4SSatish Balay typedef enum {
14589371c9d4SSatish Balay   MAT_FACTOR_NOERROR,
14599371c9d4SSatish Balay   MAT_FACTOR_STRUCT_ZEROPIVOT,
14609371c9d4SSatish Balay   MAT_FACTOR_NUMERIC_ZEROPIVOT,
14619371c9d4SSatish Balay   MAT_FACTOR_OUTMEMORY,
14629371c9d4SSatish Balay   MAT_FACTOR_OTHER
14639371c9d4SSatish Balay } MatFactorError;
14649aa7eafdSHong Zhang 
146500e125f8SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat, MatFactorError *);
1466b8b68cfdSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat);
14677b6c816cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat, PetscReal *, PetscInt *);
146800e125f8SBarry Smith 
14699aa7eafdSHong Zhang /*S
1470422a814eSBarry Smith    MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization
1471b00f7748SHong Zhang 
1472b00f7748SHong Zhang    Level: developer
1473b00f7748SHong Zhang 
14742ef1f0ffSBarry Smith    Note:
14752ef1f0ffSBarry Smith    You can use `MatFactorInfoInitialize()` to set default values.
1476b00f7748SHong Zhang 
14772ef1f0ffSBarry Smith    Fortran Note:
14782ef1f0ffSBarry Smith    The data is available in a double precision arrays of size `MAT_FACTORINFO_SIZE`
14792ef1f0ffSBarry Smith 
14802ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatInfo`, `MatGetFactor()`, `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`,
14812ef1f0ffSBarry Smith           `MatICCFactorSymbolic()`, `MatICCFactor()`,  `MatFactorInfoInitialize()`
1482b00f7748SHong Zhang S*/
1483b00f7748SHong Zhang typedef struct {
148415e8a5b3SHong Zhang   PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */
148585317021SBarry Smith   PetscReal usedt;
148615e8a5b3SHong Zhang   PetscReal dt;            /* drop tolerance */
1487b00f7748SHong Zhang   PetscReal dtcol;         /* tolerance for pivoting */
148815e8a5b3SHong Zhang   PetscReal dtcount;       /* maximum nonzeros to be allowed per row */
148967e28bfeSBarry Smith   PetscReal fill;          /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */
1490348344bbSBarry Smith   PetscReal levels;        /* ICC/ILU(levels) */
1491bcd9e38bSBarry Smith   PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
1492bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
149315e8a5b3SHong Zhang   PetscReal zeropivot;     /* pivot is called zero if less than this */
1494f4db908eSBarry Smith   PetscReal shifttype;     /* type of shift added to matrix factor to prevent zero pivots */
1495f4db908eSBarry Smith   PetscReal shiftamount;   /* how large the shift is */
149615e8a5b3SHong Zhang } MatFactorInfo;
1497ffa6d0a5SLois Curfman McInnes 
1498014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo *);
14999a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat, IS, const MatFactorInfo *);
15009a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15019a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat, Mat, const MatFactorInfo *);
15029a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactor(Mat, IS, IS, const MatFactorInfo *);
15039a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactor(Mat, IS, IS, const MatFactorInfo *);
15049a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
15059a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat, Mat, IS, IS, const MatFactorInfo *);
15069a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15079a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactor(Mat, IS, const MatFactorInfo *);
15089a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat, Mat, const MatFactorInfo *);
15093f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactor(Mat, IS, const MatFactorInfo *);
15103f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat, Mat, IS, const MatFactorInfo *);
15113f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat, Mat, const MatFactorInfo *);
1512014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInertia(Mat, PetscInt *, PetscInt *, PetscInt *);
1513014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolve(Mat, Vec, Vec);
1514014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat, Vec, Vec);
1515014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat, Vec, Vec);
1516014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat, Vec, Vec, Vec);
1517014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat, Vec, Vec);
1518014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat, Vec, Vec, Vec);
1519014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolves(Mat, Vecs, Vecs);
15207c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat);
15217c2f51b8SStefano Zampini 
15229371c9d4SSatish Balay typedef enum {
15239371c9d4SSatish Balay   MAT_FACTOR_SCHUR_UNFACTORED,
15249371c9d4SSatish Balay   MAT_FACTOR_SCHUR_FACTORED,
15259371c9d4SSatish Balay   MAT_FACTOR_SCHUR_INVERTED
15269371c9d4SSatish Balay } MatFactorSchurStatus;
15278e7ba810SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat, IS);
15287c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
15297c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat, Mat *, MatFactorSchurStatus);
15305a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat);
15317c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat, Mat *, MatFactorSchurStatus *);
15325a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat, Vec, Vec);
15335a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat, Vec, Vec);
15346dba178dSStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat);
1535bb5a7306SBarry Smith 
15368a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat);
1537d91e6319SBarry Smith /*E
1538d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
1539bb1eb677SSatish Balay 
15402ef1f0ffSBarry Smith    Values:
15412ef1f0ffSBarry Smith +  `SOR_FORWARD_SWEEP` - do a sweep from the first row of the matrix to the last
15422ef1f0ffSBarry Smith .  `SOR_BACKWARD_SWEEP` -  do a sweep from the last row to the first
15432ef1f0ffSBarry Smith .  `SOR_SYMMETRIC_SWEEP` - do a sweep from the first row to the last and then back to the first
15442ef1f0ffSBarry Smith .  `SOR_LOCAL_FORWARD_SWEEP` - each MPI rank does its own forward sweep with no communication
15452ef1f0ffSBarry Smith .  `SOR_LOCAL_BACKWARD_SWEEP` - each MPI rank does its own backward sweep with no communication
15462ef1f0ffSBarry Smith .  `SOR_LOCAL_SYMMETRIC_SWEEP` - each MPI rank does its own symmetric sweep with no communication
15472ef1f0ffSBarry Smith .  `SOR_ZERO_INITIAL_GUESS` - indicates the initial solution is zero so the sweep can avoid unneeded computation
15482ef1f0ffSBarry Smith .  `SOR_EISENSTAT` - apply the Eisentat application of SOR, see `PCEISENSTAT`
15492ef1f0ffSBarry Smith .  `SOR_APPLY_UPPER` - multiply by the upper triangular portion of the matrix
15502ef1f0ffSBarry Smith -  `SOR_APPLY_LOWER` - multiply by the lower triangular portion of the matrix
15512ef1f0ffSBarry Smith 
1552d91e6319SBarry Smith     Level: beginner
1553d91e6319SBarry Smith 
15542ef1f0ffSBarry Smith    Note:
15552ef1f0ffSBarry Smith    These may be bitwise ORd together
1556d9274352SBarry Smith 
15572ef1f0ffSBarry Smith    Developer Note:
15582ef1f0ffSBarry Smith    Since `MatSORType` may be bitwise ORd together, so do not change the numerical values below
1559d91e6319SBarry Smith 
15602ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatSOR()`
1561d91e6319SBarry Smith E*/
15629371c9d4SSatish Balay typedef enum {
15639371c9d4SSatish Balay   SOR_FORWARD_SWEEP         = 1,
15649371c9d4SSatish Balay   SOR_BACKWARD_SWEEP        = 2,
15659371c9d4SSatish Balay   SOR_SYMMETRIC_SWEEP       = 3,
15669371c9d4SSatish Balay   SOR_LOCAL_FORWARD_SWEEP   = 4,
15679371c9d4SSatish Balay   SOR_LOCAL_BACKWARD_SWEEP  = 8,
15689371c9d4SSatish Balay   SOR_LOCAL_SYMMETRIC_SWEEP = 12,
15699371c9d4SSatish Balay   SOR_ZERO_INITIAL_GUESS    = 16,
15709371c9d4SSatish Balay   SOR_EISENSTAT             = 32,
15719371c9d4SSatish Balay   SOR_APPLY_UPPER           = 64,
15729371c9d4SSatish Balay   SOR_APPLY_LOWER           = 128
15739371c9d4SSatish Balay } MatSORType;
1574014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSOR(Mat, Vec, PetscReal, MatSORType, PetscReal, PetscInt, PetscInt, Vec);
15758ed539a5SBarry Smith 
15767086a01eSPeter Brune /*S
15777086a01eSPeter Brune      MatColoring - Object for managing the coloring of matrices.
15787086a01eSPeter Brune 
15797086a01eSPeter Brune    Level: beginner
15807086a01eSPeter Brune 
1581ec5066bdSBarry Smith    Notes:
158287497f52SBarry 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
158387497f52SBarry Smith    matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors).
1584ec5066bdSBarry Smith 
158587497f52SBarry Smith    Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This
15862ef1f0ffSBarry Smith    same object can also be used to efficiently convert data created by Automatic Differentiation tools to PETSc sparse matrices.
1587ec5066bdSBarry Smith 
15882ef1f0ffSBarry Smith .seealso: [](chapter_matrices), [](sec_graph), `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`,
15892ef1f0ffSBarry Smith           `MatPartitioning`, `MatColoringType`, `MatPartitioningType`, `MatOrderingType`,  `MatColoringSetWeightType()`,
15902ef1f0ffSBarry Smith           `MatColoringSetWeights()`, `MatCoarsenType`,  `MatCoarsen`
15917086a01eSPeter Brune S*/
1592d4db15c4SBarry Smith typedef struct _p_MatColoring *MatColoring;
1593d4db15c4SBarry Smith 
1594d4db15c4SBarry Smith /*J
1595d4db15c4SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring
1596d9274352SBarry Smith 
1597d9274352SBarry Smith    Level: beginner
1598d9274352SBarry Smith 
15992ef1f0ffSBarry Smith .seealso: [](chapter_matrices), [](sec_graph), `Mat`, `MatFDColoringCreate()`, `MatColoringSetType()`, `MatColoring`
160076bdecfbSBarry Smith J*/
160119fd82e9SBarry Smith typedef const char *MatColoringType;
16025567d71aSPeter Brune #define MATCOLORINGJP      "jp"
1603b9acb617SPeter Brune #define MATCOLORINGPOWER   "power"
16042692d6eeSBarry Smith #define MATCOLORINGNATURAL "natural"
16052692d6eeSBarry Smith #define MATCOLORINGSL      "sl"
16062692d6eeSBarry Smith #define MATCOLORINGLF      "lf"
16072692d6eeSBarry Smith #define MATCOLORINGID      "id"
16088121bdceSPeter Brune #define MATCOLORINGGREEDY  "greedy"
1609b12f92e5SBarry Smith 
16108ac6da0aSPeter Brune /*E
16112ef1f0ffSBarry Smith    MatColoringWeightType - Type of weight scheme used for the coloring algorithm
16128ac6da0aSPeter Brune 
16132ef1f0ffSBarry Smith     Values:
161487497f52SBarry Smith +   `MAT_COLORING_RANDOM`  - Random weights
161587497f52SBarry Smith .   `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering.
161687497f52SBarry Smith -   `MAT_COLORING_LF`      - Last-first weighting.
16178ac6da0aSPeter Brune 
16188ac6da0aSPeter Brune     Level: intermediate
16198ac6da0aSPeter Brune 
16202ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatColoring`, `MatColoringCreate()`, `MatColoringSetWeightType()`, `MatColoringSetWeights()`
16218ac6da0aSPeter Brune E*/
16229371c9d4SSatish Balay typedef enum {
16239371c9d4SSatish Balay   MAT_COLORING_WEIGHT_RANDOM,
16249371c9d4SSatish Balay   MAT_COLORING_WEIGHT_LEXICAL,
16259371c9d4SSatish Balay   MAT_COLORING_WEIGHT_LF,
16269371c9d4SSatish Balay   MAT_COLORING_WEIGHT_SL
16279371c9d4SSatish Balay } MatColoringWeightType;
16288ac6da0aSPeter Brune 
1629335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat, MatColoring *);
1630d7f2a307SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat, PetscInt, PetscInt *);
1631335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring *);
1632335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring, PetscViewer);
1633335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring, MatColoringType);
1634335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring);
1635335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring, PetscInt);
1636335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring, PetscInt *);
1637335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring, PetscInt);
1638335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring, PetscInt *);
1639335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring, ISColoring *);
1640335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[], PetscErrorCode (*)(MatColoring));
1641014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat, PetscInt, PetscInt, ISColoringValue[], ISColoring *);
16428ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring, MatColoringWeightType);
1643c29971fcSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring, PetscReal *, PetscInt *);
16448ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring, PetscReal **, PetscInt **lperm);
1645bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring, ISColoring);
1646d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatColoringTest() (since version 3.10)") static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring, ISColoring iscoloring)
1647d71ae5a4SJacob Faibussowitsch {
16489371c9d4SSatish Balay   return MatColoringTest(matcoloring, iscoloring);
16499371c9d4SSatish Balay }
1650bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat, ISColoring);
1651639f9d9dSBarry Smith 
1652d9274352SBarry Smith /*S
165387497f52SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring
1654639f9d9dSBarry Smith 
1655d9274352SBarry Smith    Level: beginner
1656d9274352SBarry Smith 
1657ec5066bdSBarry Smith    Notes:
165887497f52SBarry Smith    This object is creating utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()`
1659ec5066bdSBarry Smith 
16602ef1f0ffSBarry Smith    The `SNES` option `-snes_fd_coloring` will cause the Jacobian needed by `SNES` to be computed via a use of this object
16612ef1f0ffSBarry Smith 
16622ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()`
1663d9274352SBarry Smith S*/
1664e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
1665639f9d9dSBarry Smith 
1666014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat, ISColoring, MatFDColoring *);
1667014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring *);
1668014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring, PetscViewer);
1669014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring, PetscErrorCode (*)(void), void *);
1670014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring, PetscErrorCode (**)(void), void **);
1671014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring, PetscReal, PetscReal);
1672014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring);
1673d1e9a80fSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat, MatFDColoring, Vec, void *);
1674014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring, Vec);
1675edaa7c33SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring, PetscInt *, const PetscInt *[]);
1676f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat, ISColoring, MatFDColoring);
1677f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring, PetscInt, PetscInt);
1678bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat, MatFDColoring, const PetscScalar *);
1679b1683b59SHong Zhang 
1680b1683b59SHong Zhang /*S
1681b9af6bddSHong Zhang      MatTransposeColoring - Object for computing a sparse matrix product C=A*B^T via coloring
1682b1683b59SHong Zhang 
16832ef1f0ffSBarry Smith    Level: developer
1684b1683b59SHong Zhang 
16852ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatProductType`, `MatTransposeColoringCreate()`
1686b1683b59SHong Zhang S*/
1687b9af6bddSHong Zhang typedef struct _p_MatTransposeColoring *MatTransposeColoring;
1688b1683b59SHong Zhang 
1689014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat, ISColoring, MatTransposeColoring *);
1690014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring, Mat, Mat);
1691014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring, Mat, Mat);
1692014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring *);
1693b1683b59SHong Zhang 
1694d9274352SBarry Smith /*S
1695d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
1696d9274352SBarry Smith 
1697d9274352SBarry Smith    Level: beginner
1698d9274352SBarry Smith 
169987497f52SBarry Smith    Note:
170087497f52SBarry Smith      There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations
170187497f52SBarry Smith      via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`)
1702ec5066bdSBarry Smith 
1703ec5066bdSBarry Smith    Developers Note:
17042ef1f0ffSBarry Smith      It is an extra maintenance and documentation cost to have two objects with the same functionality. `PetscPartitioner` should be removed
1705ec5066bdSBarry Smith 
17062ef1f0ffSBarry Smith .seealso: [](chapter_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`, `MatOrderingType`,
17072ef1f0ffSBarry Smith           `MatCoarsenType`, `MatCoarsenType`
1708d9274352SBarry Smith S*/
170991e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
1710d9274352SBarry Smith 
171176bdecfbSBarry Smith /*J
17128f6c3df8SBarry Smith     MatPartitioningType - String with the name of a PETSc matrix partitioning
1713d9274352SBarry Smith 
1714d9274352SBarry Smith    Level: beginner
17150d04baf8SBarry Smith dm
17162ef1f0ffSBarry Smith .seealso: [](chapter_matrices), [](sec_graph), `Mat`, `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`, `MatColoringType`, `MatOrderingType`,
17172ef1f0ffSBarry Smith           `MatCoarsenType`, `MatCoarsenType`
171876bdecfbSBarry Smith J*/
171919fd82e9SBarry Smith typedef const char *MatPartitioningType;
17202692d6eeSBarry Smith #define MATPARTITIONINGCURRENT  "current"
1721aa1e27eaSFande Kong #define MATPARTITIONINGAVERAGE  "average"
17222692d6eeSBarry Smith #define MATPARTITIONINGSQUARE   "square"
17232692d6eeSBarry Smith #define MATPARTITIONINGPARMETIS "parmetis"
17242692d6eeSBarry Smith #define MATPARTITIONINGCHACO    "chaco"
17252692d6eeSBarry Smith #define MATPARTITIONINGPARTY    "party"
172650d91057SBarry Smith #define MATPARTITIONINGPTSCOTCH "ptscotch"
172788d2ac2bSFande Kong #define MATPARTITIONINGHIERARCH "hierarch"
172871306c60Sjroman 
1729014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm, MatPartitioning *);
173019fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning, MatPartitioningType);
1731014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning, PetscInt);
1732014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning, Mat);
1733252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning, PetscInt);
1734014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning, const PetscInt[]);
1735014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning, const PetscReal[]);
1736ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning, PetscBool);
1737ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning, PetscBool *);
1738014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning, IS *);
1739fdd1c351SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning, IS *);
1740668144dbSFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning, IS);
1741f3ad2dabSStefano Zampini PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning, IS *);
1742014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning *);
1743bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[], PetscErrorCode (*)(MatPartitioning));
1744014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning, PetscViewer);
1745fe2efc57SMark PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning, PetscObject, const char[]);
1746014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning);
174719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning, MatPartitioningType *);
1748ca161407SBarry Smith 
174927538973SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part);
1750014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
1751014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *);
17520752156aSBarry Smith 
17539371c9d4SSatish Balay typedef enum {
17549371c9d4SSatish Balay   MP_CHACO_MULTILEVEL = 1,
17559371c9d4SSatish Balay   MP_CHACO_SPECTRAL   = 2,
17569371c9d4SSatish Balay   MP_CHACO_LINEAR     = 4,
17579371c9d4SSatish Balay   MP_CHACO_RANDOM     = 5,
17589371c9d4SSatish Balay   MP_CHACO_SCATTERED  = 6
17599371c9d4SSatish Balay } MPChacoGlobalType;
17606a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoGlobalTypes[];
17619371c9d4SSatish Balay typedef enum {
17629371c9d4SSatish Balay   MP_CHACO_KERNIGHAN = 1,
17639371c9d4SSatish Balay   MP_CHACO_NONE      = 2
17649371c9d4SSatish Balay } MPChacoLocalType;
17656a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoLocalTypes[];
17669371c9d4SSatish Balay typedef enum {
17679371c9d4SSatish Balay   MP_CHACO_LANCZOS = 0,
17689371c9d4SSatish Balay   MP_CHACO_RQI     = 1
17699371c9d4SSatish Balay } MPChacoEigenType;
17706a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoEigenTypes[];
1771b6956c12SJose Roman 
1772014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
1773014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning, MPChacoGlobalType *);
1774014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1775014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning, MPChacoLocalType *);
1776014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning, PetscReal);
1777014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning, MPChacoEigenType);
1778014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning, MPChacoEigenType *);
1779014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1780014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning, PetscReal *);
1781014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
1782014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning, PetscInt *);
178371306c60Sjroman 
178471306c60Sjroman #define MP_PARTY_OPT "opt"
178571306c60Sjroman #define MP_PARTY_LIN "lin"
178671306c60Sjroman #define MP_PARTY_SCA "sca"
178771306c60Sjroman #define MP_PARTY_RAN "ran"
178871306c60Sjroman #define MP_PARTY_GBF "gbf"
178971306c60Sjroman #define MP_PARTY_GCF "gcf"
179071306c60Sjroman #define MP_PARTY_BUB "bub"
179171306c60Sjroman #define MP_PARTY_DEF "def"
1792014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char *);
179371306c60Sjroman #define MP_PARTY_HELPFUL_SETS  "hs"
179471306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
179571306c60Sjroman #define MP_PARTY_NONE          "no"
1796014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char *);
1797014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning, PetscReal);
1798014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning, PetscBool);
1799014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning, PetscBool);
180071306c60Sjroman 
18019371c9d4SSatish Balay typedef enum {
18029371c9d4SSatish Balay   MP_PTSCOTCH_DEFAULT,
18039371c9d4SSatish Balay   MP_PTSCOTCH_QUALITY,
18049371c9d4SSatish Balay   MP_PTSCOTCH_SPEED,
18059371c9d4SSatish Balay   MP_PTSCOTCH_BALANCE,
18069371c9d4SSatish Balay   MP_PTSCOTCH_SAFETY,
18079371c9d4SSatish Balay   MP_PTSCOTCH_SCALABILITY
18089371c9d4SSatish Balay } MPPTScotchStrategyType;
18096a6fc655SJed Brown PETSC_EXTERN const char *const MPPTScotchStrategyTypes[];
1810e0f1cffaSJose Roman 
1811014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning, PetscReal);
1812014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning, PetscReal *);
1813014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning, MPPTScotchStrategyType);
1814014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning, MPPTScotchStrategyType *);
181571306c60Sjroman 
1816b43b03e9SMark F. Adams /*
18176294fa2bSFande Kong  * hierarchical partitioning
18186294fa2bSFande Kong  */
18194e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning, IS *);
18204e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning, IS *);
18214e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning, PetscInt);
18224e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt);
18236294fa2bSFande Kong 
1824014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat, PetscInt, Mat *);
1825591294e4SBarry Smith 
18260752156aSBarry Smith /*
1827c786d857SStefano Zampini     If you add entries here you must also add them to src/mat/f90-mod/petscmat.h
1828c786d857SStefano Zampini     If any of the enum values are changed, also update dMatOps dict at src/binding/petsc4py/src/libpetsc4py/libpetsc4py.pyx
1829d4fbbf0eSBarry Smith */
18309371c9d4SSatish Balay typedef enum {
18319371c9d4SSatish Balay   MATOP_SET_VALUES               = 0,
18321c1c02c0SLois Curfman McInnes   MATOP_GET_ROW                  = 1,
18331c1c02c0SLois Curfman McInnes   MATOP_RESTORE_ROW              = 2,
18341c1c02c0SLois Curfman McInnes   MATOP_MULT                     = 3,
18351c1c02c0SLois Curfman McInnes   MATOP_MULT_ADD                 = 4,
18367c922b88SBarry Smith   MATOP_MULT_TRANSPOSE           = 5,
18377c922b88SBarry Smith   MATOP_MULT_TRANSPOSE_ADD       = 6,
18381c1c02c0SLois Curfman McInnes   MATOP_SOLVE                    = 7,
18391c1c02c0SLois Curfman McInnes   MATOP_SOLVE_ADD                = 8,
18407c922b88SBarry Smith   MATOP_SOLVE_TRANSPOSE          = 9,
18417c922b88SBarry Smith   MATOP_SOLVE_TRANSPOSE_ADD      = 10,
18421c1c02c0SLois Curfman McInnes   MATOP_LUFACTOR                 = 11,
18431c1c02c0SLois Curfman McInnes   MATOP_CHOLESKYFACTOR           = 12,
1844a714c06dSBarry Smith   MATOP_SOR                      = 13,
18451c1c02c0SLois Curfman McInnes   MATOP_TRANSPOSE                = 14,
18461c1c02c0SLois Curfman McInnes   MATOP_GETINFO                  = 15,
18471c1c02c0SLois Curfman McInnes   MATOP_EQUAL                    = 16,
18481c1c02c0SLois Curfman McInnes   MATOP_GET_DIAGONAL             = 17,
18491c1c02c0SLois Curfman McInnes   MATOP_DIAGONAL_SCALE           = 18,
18501c1c02c0SLois Curfman McInnes   MATOP_NORM                     = 19,
18511c1c02c0SLois Curfman McInnes   MATOP_ASSEMBLY_BEGIN           = 20,
18521c1c02c0SLois Curfman McInnes   MATOP_ASSEMBLY_END             = 21,
1853d519adbfSMatthew Knepley   MATOP_SET_OPTION               = 22,
1854d519adbfSMatthew Knepley   MATOP_ZERO_ENTRIES             = 23,
1855d519adbfSMatthew Knepley   MATOP_ZERO_ROWS                = 24,
1856d519adbfSMatthew Knepley   MATOP_LUFACTOR_SYMBOLIC        = 25,
1857d519adbfSMatthew Knepley   MATOP_LUFACTOR_NUMERIC         = 26,
1858d519adbfSMatthew Knepley   MATOP_CHOLESKY_FACTOR_SYMBOLIC = 27,
1859d519adbfSMatthew Knepley   MATOP_CHOLESKY_FACTOR_NUMERIC  = 28,
1860e5f2d425SStefano Zampini   MATOP_SETUP                    = 29,
1861d519adbfSMatthew Knepley   MATOP_ILUFACTOR_SYMBOLIC       = 30,
1862d519adbfSMatthew Knepley   MATOP_ICCFACTOR_SYMBOLIC       = 31,
1863a5b7ff6bSBarry Smith   MATOP_GET_DIAGONAL_BLOCK       = 32,
1864e5f2d425SStefano Zampini   MATOP_SET_INF                  = 33,
1865d519adbfSMatthew Knepley   MATOP_DUPLICATE                = 34,
1866d519adbfSMatthew Knepley   MATOP_FORWARD_SOLVE            = 35,
1867d519adbfSMatthew Knepley   MATOP_BACKWARD_SOLVE           = 36,
1868d519adbfSMatthew Knepley   MATOP_ILUFACTOR                = 37,
1869d519adbfSMatthew Knepley   MATOP_ICCFACTOR                = 38,
1870d519adbfSMatthew Knepley   MATOP_AXPY                     = 39,
18717dae84e0SHong Zhang   MATOP_CREATE_SUBMATRICES       = 40,
1872d519adbfSMatthew Knepley   MATOP_INCREASE_OVERLAP         = 41,
1873d519adbfSMatthew Knepley   MATOP_GET_VALUES               = 42,
1874d519adbfSMatthew Knepley   MATOP_COPY                     = 43,
1875d519adbfSMatthew Knepley   MATOP_GET_ROW_MAX              = 44,
1876d519adbfSMatthew Knepley   MATOP_SCALE                    = 45,
1877d519adbfSMatthew Knepley   MATOP_SHIFT                    = 46,
187835153367SBarry Smith   MATOP_DIAGONAL_SET             = 47,
18799d39f69dSJed Brown   MATOP_ZERO_ROWS_COLUMNS        = 48,
18809d39f69dSJed Brown   MATOP_SET_RANDOM               = 49,
1881d519adbfSMatthew Knepley   MATOP_GET_ROW_IJ               = 50,
1882d519adbfSMatthew Knepley   MATOP_RESTORE_ROW_IJ           = 51,
1883d519adbfSMatthew Knepley   MATOP_GET_COLUMN_IJ            = 52,
1884d519adbfSMatthew Knepley   MATOP_RESTORE_COLUMN_IJ        = 53,
1885d519adbfSMatthew Knepley   MATOP_FDCOLORING_CREATE        = 54,
1886d519adbfSMatthew Knepley   MATOP_COLORING_PATCH           = 55,
1887d519adbfSMatthew Knepley   MATOP_SET_UNFACTORED           = 56,
1888d519adbfSMatthew Knepley   MATOP_PERMUTE                  = 57,
1889d519adbfSMatthew Knepley   MATOP_SET_VALUES_BLOCKED       = 58,
18907dae84e0SHong Zhang   MATOP_CREATE_SUBMATRIX         = 59,
1891d519adbfSMatthew Knepley   MATOP_DESTROY                  = 60,
1892d519adbfSMatthew Knepley   MATOP_VIEW                     = 61,
1893d519adbfSMatthew Knepley   MATOP_CONVERT_FROM             = 62,
1894e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_63=63 */
18957bab7c10SHong Zhang   MATOP_MATMAT_MULT_SYMBOLIC    = 64,
18967bab7c10SHong Zhang   MATOP_MATMAT_MULT_NUMERIC     = 65,
1897d519adbfSMatthew Knepley   MATOP_SET_LOCAL_TO_GLOBAL_MAP = 66,
1898d519adbfSMatthew Knepley   MATOP_SET_VALUES_LOCAL        = 67,
1899d519adbfSMatthew Knepley   MATOP_ZERO_ROWS_LOCAL         = 68,
1900d519adbfSMatthew Knepley   MATOP_GET_ROW_MAX_ABS         = 69,
1901d519adbfSMatthew Knepley   MATOP_GET_ROW_MIN_ABS         = 70,
1902d519adbfSMatthew Knepley   MATOP_CONVERT                 = 71,
1903e5f2d425SStefano Zampini   MATOP_HAS_OPERATION           = 72,
19049d39f69dSJed Brown   /* MATOP_PLACEHOLDER_73=73, */
1905d519adbfSMatthew Knepley   MATOP_SET_VALUES_ADIFOR = 74,
1906d519adbfSMatthew Knepley   MATOP_FD_COLORING_APPLY = 75,
1907d519adbfSMatthew Knepley   MATOP_SET_FROM_OPTIONS  = 76,
1908e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_77=77, */
1909e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_78=78, */
19109d39f69dSJed Brown   MATOP_FIND_ZERO_DIAGONALS       = 79,
1911d519adbfSMatthew Knepley   MATOP_MULT_MULTIPLE             = 80,
1912d519adbfSMatthew Knepley   MATOP_SOLVE_MULTIPLE            = 81,
1913d519adbfSMatthew Knepley   MATOP_GET_INERTIA               = 82,
1914d519adbfSMatthew Knepley   MATOP_LOAD                      = 83,
1915d519adbfSMatthew Knepley   MATOP_IS_SYMMETRIC              = 84,
1916d519adbfSMatthew Knepley   MATOP_IS_HERMITIAN              = 85,
1917d519adbfSMatthew Knepley   MATOP_IS_STRUCTURALLY_SYMMETRIC = 86,
1918820469bcSHong Zhang   MATOP_SET_VALUES_BLOCKEDLOCAL   = 87,
1919b41ce5d5SBarry Smith   MATOP_CREATE_VECS               = 88,
1920e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_89=89, */
1921d519adbfSMatthew Knepley   MATOP_MAT_MULT_SYMBOLIC = 90,
1922d519adbfSMatthew Knepley   MATOP_MAT_MULT_NUMERIC  = 91,
1923e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_92=92, */
1924d519adbfSMatthew Knepley   MATOP_PTAP_SYMBOLIC = 93,
1925d519adbfSMatthew Knepley   MATOP_PTAP_NUMERIC  = 94,
1926e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_95=95, */
1927bda6c4cbSBarry Smith   MATOP_MAT_TRANSPOSE_MULT_SYMBO = 96,
1928bda6c4cbSBarry Smith   MATOP_MAT_TRANSPOSE_MULT_NUMER = 97,
1929e5f2d425SStefano Zampini   MATOP_BIND_TO_CPU              = 98,
19307a3c3d58SStefano Zampini   MATOP_PRODUCTSETFROMOPTIONS    = 99,
19317a3c3d58SStefano Zampini   MATOP_PRODUCTSYMBOLIC          = 100,
19327a3c3d58SStefano Zampini   MATOP_PRODUCTNUMERIC           = 101,
1933d519adbfSMatthew Knepley   MATOP_CONJUGATE                = 102,
1934e5f2d425SStefano Zampini   MATOP_VIEW_NATIVE              = 103,
1935d519adbfSMatthew Knepley   MATOP_SET_VALUES_ROW           = 104,
1936d519adbfSMatthew Knepley   MATOP_REAL_PART                = 105,
1937bda6c4cbSBarry Smith   MATOP_IMAGINARY_PART           = 106,
1938bda6c4cbSBarry Smith   MATOP_GET_ROW_UPPER_TRIANGULAR = 107,
1939bda6c4cbSBarry Smith   MATOP_RESTORE_ROW_UPPER_TRIANG = 108,
1940bda6c4cbSBarry Smith   MATOP_MAT_SOLVE                = 109,
194129eadf9eSStefano Zampini   MATOP_MAT_SOLVE_TRANSPOSE      = 110,
1942d519adbfSMatthew Knepley   MATOP_GET_ROW_MIN              = 111,
19430e8d04f7SBarry Smith   MATOP_GET_COLUMN_VECTOR        = 112,
1944d519adbfSMatthew Knepley   MATOP_MISSING_DIAGONAL         = 113,
19450e8d04f7SBarry Smith   MATOP_GET_SEQ_NONZERO_STRUCTUR = 114,
194689c6957cSBarry Smith   MATOP_CREATE                   = 115,
194789c6957cSBarry Smith   MATOP_GET_GHOSTS               = 116,
19480e8d04f7SBarry Smith   MATOP_GET_LOCAL_SUB_MATRIX     = 117,
19490e8d04f7SBarry Smith   MATOP_RESTORE_LOCALSUB_MATRIX  = 118,
1950eeffb40dSHong Zhang   MATOP_MULT_DIAGONAL_BLOCK      = 119,
19510e8d04f7SBarry Smith   MATOP_HERMITIAN_TRANSPOSE      = 120,
19520e8d04f7SBarry Smith   MATOP_MULT_HERMITIAN_TRANSPOSE = 121,
19530e8d04f7SBarry Smith   MATOP_MULT_HERMITIAN_TRANS_ADD = 122,
19540e8d04f7SBarry Smith   MATOP_GET_MULTI_PROC_BLOCK     = 123,
19559d39f69dSJed Brown   MATOP_FIND_NONZERO_ROWS        = 124,
19560e8d04f7SBarry Smith   MATOP_GET_COLUMN_NORMS         = 125,
19579d39f69dSJed Brown   MATOP_INVERT_BLOCK_DIAGONAL    = 126,
1958e5f2d425SStefano Zampini   MATOP_INVERT_VBLOCK_DIAGONAL   = 127,
1959b41ce5d5SBarry Smith   MATOP_CREATE_SUB_MATRICES_MPI  = 128,
19602b8ad9a3SHong Zhang   MATOP_SET_VALUES_BATCH         = 129,
1961e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_130=130, */
19620e8d04f7SBarry Smith   MATOP_TRANSPOSE_MAT_MULT_SYMBO = 131,
1963e9b602ebSSatish Balay   MATOP_TRANSPOSE_MAT_MULT_NUMER = 132,
19640e8d04f7SBarry Smith   MATOP_TRANSPOSE_COLORING_CREAT = 133,
19650e8d04f7SBarry Smith   MATOP_TRANS_COLORING_APPLY_SPT = 134,
19660e8d04f7SBarry Smith   MATOP_TRANS_COLORING_APPLY_DEN = 135,
1967e5f2d425SStefano Zampini   /* MATOP_PLACEHOLDER_136=136, */
19680e8d04f7SBarry Smith   MATOP_RART_SYMBOLIC         = 137,
19690e8d04f7SBarry Smith   MATOP_RART_NUMERIC          = 138,
1970e09a3074SHong Zhang   MATOP_SET_BLOCK_SIZES       = 139,
1971f9426fe0SMark Adams   MATOP_AYPX                  = 140,
19721919a2e2SJed Brown   MATOP_RESIDUAL              = 141,
19739c8f2541SHong Zhang   MATOP_FDCOLORING_SETUP      = 142,
1974e5f2d425SStefano Zampini   MATOP_FIND_OFFBLOCK_ENTRIES = 143,
19752d033e1fSHong Zhang   MATOP_MPICONCATENATESEQ     = 144,
1976bb01b7b0SPatrick Sanan   MATOP_DESTROYSUBMATRICES    = 145,
1977e265f6d6SPatrick Sanan   MATOP_TRANSPOSE_SOLVE       = 146,
1978e265f6d6SPatrick Sanan   MATOP_GET_VALUES_LOCAL      = 147
1979fae171e0SBarry Smith } MatOperation;
19800c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOperation(Mat, MatOperation, void (*)(void));
1981976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatGetOperation(Mat, MatOperation, void (**)(void));
1982976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatHasOperation(Mat, MatOperation, PetscBool *);
198394342113SStefano Zampini PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat, PetscBool *);
1984d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatProductClear() (since version 3.14)") static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A)
1985d71ae5a4SJacob Faibussowitsch {
19869371c9d4SSatish Balay   return MatProductClear(A);
19879371c9d4SSatish Balay }
1988014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat, MatOperation, void (*)(void));
1989014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat, MatOperation, void (**)(void));
1990014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat, void *);
1991800f99ffSJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat, PetscErrorCode (*)(void *));
1992db77db73SJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat, VecType);
1993f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
1994f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat, PetscErrorCode (*)(void *, Vec, Vec), Vec, void *, PetscBool *);
19950c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat);
1996b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat, MatProductType, PetscErrorCode (*)(Mat, Mat, Mat, void **), PetscErrorCode (*)(Mat, Mat, Mat, void *), PetscErrorCode (*)(void *), MatType, MatType);
1997b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatIsShell(Mat, PetscBool *);
1998112a2221SBarry Smith 
199990ace30eSBarry Smith /*
200090ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
200190ace30eSBarry Smith    stored in a universal format. By changing the format with
20026a9046bcSBarry Smith    PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will
200390ace30eSBarry Smith    be stored in a way natural for the matrix, for example dense matrices
200490ace30eSBarry Smith    would be stored as dense. Matrices stored this way may only be
2005f4403165SShri Abhyankar    read into matrices of the same type.
200690ace30eSBarry Smith */
200790ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
200890ace30eSBarry Smith 
2009014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat, PetscReal);
201075d48cdbSStefano Zampini 
20118546b261SStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat, MatType);
201275d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat, PetscInt, const PetscInt[], PetscInt, const PetscInt[]);
201375d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat, PetscBool);
2014f03112d0SStefano Zampini PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat, PetscBool);
2015014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat, Mat *);
20163b3b1effSJed Brown PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat, Mat *);
2017014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat, Mat);
2018e432b41dSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat, ISLocalToGlobalMapping *, ISLocalToGlobalMapping *);
201925ef9dfeSBarry Smith PETSC_EXTERN                PETSC_DEPRECATED_FUNCTION("Use the MatConvert() interface (since version 3.10)") PetscErrorCode MatISGetMPIXAIJ(Mat, MatReuse, Mat *);
20201f4e1ec7SBarry Smith 
2021d9274352SBarry Smith /*S
2022d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
2023cb6b9846SMatthew Knepley          orthogonalizes the vector to a subspace
2024d9274352SBarry Smith 
2025f7a9e4ceSBarry Smith    Level: advanced
2026d9274352SBarry Smith 
20272ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
2028d9274352SBarry Smith S*/
202974637425SBarry Smith typedef struct _p_MatNullSpace *MatNullSpace;
2030d9274352SBarry Smith 
2031014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm, PetscBool, PetscInt, const Vec[], MatNullSpace *);
2032014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace, PetscErrorCode (*)(MatNullSpace, Vec, void *), void *);
2033014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace *);
2034d0195637SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace, Vec);
2035014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *);
20365fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *);
20375fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat, MatNullSpace);
2038014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat, MatNullSpace);
2039014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat, MatNullSpace);
2040014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat, MatNullSpace *);
2041014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace, Mat, PetscBool *);
2042014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace, PetscViewer);
2043014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace, PetscBool *, PetscInt *, const Vec **);
2044014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec, MatNullSpace *);
204574637425SBarry Smith 
2046014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat, IS);
2047014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat, PetscReal);
2048014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat, PetscInt *);
20493f1d51d7SBarry Smith 
2050014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat, PetscInt, Mat *);
2051014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat, PetscInt, Mat *);
2052014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat, Mat *);
2053c4f061fbSSatish Balay 
20540bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat, MatType, Mat *);
20550bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat, MatType, Mat *);
20560bacdadaSStefano Zampini 
2057d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatComputeOperator() (since version 3.12)") static inline PetscErrorCode MatComputeExplicitOperator(Mat A, Mat *B)
2058d71ae5a4SJacob Faibussowitsch {
2059f22e26b7SPierre Jolivet   return MatComputeOperator(A, PETSC_NULLPTR, B);
20609371c9d4SSatish Balay }
2061d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatComputeOperatorTranspose() (since version 3.12)") static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A, Mat *B)
2062d71ae5a4SJacob Faibussowitsch {
2063f22e26b7SPierre Jolivet   return MatComputeOperatorTranspose(A, PETSC_NULLPTR, B);
20649371c9d4SSatish Balay }
2065b0a32e0cSBarry Smith 
206649bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat, PetscInt, PetscInt, const PetscScalar[], const PetscScalar[], Mat *);
206749bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat, Mat *);
2068a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat, PetscInt *, PetscInt *, PetscScalar **);
2069a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2070a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat, PetscScalar **);
2071a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat, const PetscScalar **);
2072a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat, PetscInt *, PetscInt *, PetscScalar **);
2073a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat, PetscInt *, PetscInt *, const PetscScalar **);
2074a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat, PetscScalar **);
2075a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat, const PetscScalar **);
2076dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat, Mat);
2077dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat, PetscInt, PetscInt, const PetscScalar[]);
2078dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat, PetscInt, PetscInt, const PetscScalar[]);
2079910cf402Sprj- PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat, PetscBool *);
208049bd79ccSDebojyoti Ghosh 
2081014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat, Vec);
208204f1ad80SBarry Smith 
2083014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2084014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat, Vec, Vec);
2085014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat, PetscErrorCode (*)(void *, Vec, Vec), void *);
2086014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat, PetscErrorCode (*)(void *, PetscInt, Vec, PetscScalar *));
2087014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat, PetscErrorCode (*)(void *, Vec));
2088014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat, PetscScalar[], PetscInt);
2089014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat);
2090014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat, PetscReal);
2091014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat, PetscInt);
2092014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat, PetscScalar *);
2093014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat, const char[]);
2094014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void *, Vec, Vec, PetscScalar *);
2095014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat, PetscErrorCode (*)(void *, Vec, Vec, PetscScalar *), void *);
2096e884886fSBarry Smith 
20976370053bSBarry Smith /*S
20986370053bSBarry Smith     MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free
20996370053bSBarry Smith               Jacobian vector products
2100e884886fSBarry Smith 
21012ef1f0ffSBarry Smith     Level: developer
21022ef1f0ffSBarry Smith 
210395452b02SPatrick Sanan     Notes:
210487497f52SBarry Smith     `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure
21056370053bSBarry Smith 
21062ef1f0ffSBarry Smith      MatMFFD*() methods actually take the `Mat` as their first argument. Not a `MatMFFD` data structure
21076370053bSBarry Smith 
21082ef1f0ffSBarry Smith     This functionality is often obtained using `MatCreateSNESMF()` or with `SNES` solvers using `-snes_mf` or `-snes_mf_operator`
21096370053bSBarry Smith 
21102ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatMFFDType`, `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`,
21112ef1f0ffSBarry Smith           `MatCreateSNESMF()`, `SNES`, `-snes_mf`, `-snes_mf_operator`
21126370053bSBarry Smith S*/
2113e884886fSBarry Smith typedef struct _p_MatMFFD *MatMFFD;
2114e884886fSBarry Smith 
211576bdecfbSBarry Smith /*J
21162ef1f0ffSBarry Smith     MatMFFDType - algorithm used to compute the `h` used in computing matrix-vector products via differencing of a function
2117e884886fSBarry Smith 
2118e884886fSBarry Smith    Level: beginner
2119e884886fSBarry Smith 
21202ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatMFFDSetType()`, `MatMFFDRegister()`, `MatMFFDSetFunction()`, `MatCreateMFFD()`
212176bdecfbSBarry Smith J*/
212219fd82e9SBarry Smith typedef const char *MatMFFDType;
2123e884886fSBarry Smith #define MATMFFD_DS "ds"
2124e884886fSBarry Smith #define MATMFFD_WP "wp"
2125e884886fSBarry Smith 
212619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat, MatMFFDType);
2127bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[], PetscErrorCode (*)(MatMFFD));
2128e884886fSBarry Smith 
2129014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat, PetscReal);
2130014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat, PetscBool);
2131e884886fSBarry Smith 
213261ab5df0SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring, MatMFFDType);
213361ab5df0SBarry Smith 
2134014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
2135014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
21367dbadf16SMatthew Knepley 
213753022affSStefano Zampini #ifdef PETSC_HAVE_H2OPUS
213853022affSStefano Zampini PETSC_EXTERN_TYPEDEF typedef PetscScalar (*MatH2OpusKernel)(PetscInt, PetscReal[], PetscReal[], void *);
213953022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], PetscBool, MatH2OpusKernel, void *, PetscReal, PetscInt, PetscInt, Mat *);
214053022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat, PetscInt, const PetscReal[], PetscBool, PetscReal, PetscInt, PetscInt, PetscInt, PetscReal, Mat *);
214153022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat, Mat, PetscInt, PetscReal);
214253022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat);
214353022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat, PetscReal);
214453022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat, PetscBool);
214553022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat, PetscBool *);
214653022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat, IS *);
214753022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat, PetscBool, Vec, Vec *);
2148300d917bSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat, Mat, Mat, PetscScalar);
2149a0d2e7d8SStefano Zampini #endif
2150a0d2e7d8SStefano Zampini 
2151c7a4214aSPierre Jolivet #ifdef PETSC_HAVE_HTOOL
215298e73e17SPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatHtoolKernel)(PetscInt, PetscInt, PetscInt, const PetscInt *, const PetscInt *, PetscScalar *, void *);
2153c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscReal[], const PetscReal[], MatHtoolKernel, void *, Mat *);
2154c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat, MatHtoolKernel, void *);
215598e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat, IS *);
215698e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat, IS *);
215798e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat, PetscBool);
21582ef1f0ffSBarry Smith 
2159c7a4214aSPierre Jolivet /*E
216087497f52SBarry Smith      MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL`
2161c7a4214aSPierre Jolivet 
21622ef1f0ffSBarry Smith    Level: intermediate
2163c7a4214aSPierre Jolivet 
2164c7a4214aSPierre Jolivet     Values:
216587497f52SBarry Smith +   `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation
216687497f52SBarry Smith .   `MAT_HTOOL_COMPRESSOR_FULL_ACA` - full adaptive cross approximation
216787497f52SBarry Smith -   `MAT_HTOOL_COMPRESSOR_SVD` - singular value decomposition
2168c7a4214aSPierre Jolivet 
21692ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType`
2170c7a4214aSPierre Jolivet E*/
21719371c9d4SSatish Balay typedef enum {
21729371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA,
21739371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_FULL_ACA,
21749371c9d4SSatish Balay   MAT_HTOOL_COMPRESSOR_SVD
21759371c9d4SSatish Balay } MatHtoolCompressorType;
21762ef1f0ffSBarry Smith 
217798e73e17SPierre Jolivet /*E
217887497f52SBarry Smith      MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL`
217998e73e17SPierre Jolivet 
21802ef1f0ffSBarry Smith    Level: intermediate
218198e73e17SPierre Jolivet 
218298e73e17SPierre Jolivet     Values:
218387497f52SBarry Smith +   `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default) - axis computed via principle component analysis, split uniformly
218487497f52SBarry Smith .   `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC` - axis computed via principle component analysis, split barycentrically
218587497f52SBarry Smith .   `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR` - axis along the largest extent of the bounding box, split uniformly
218687497f52SBarry Smith -   `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically
218798e73e17SPierre Jolivet 
21882ef1f0ffSBarry Smith     Note:
21892ef1f0ffSBarry Smith     Higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types
219098e73e17SPierre Jolivet 
21912ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `Mat`, `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType`
219298e73e17SPierre Jolivet E*/
21939371c9d4SSatish Balay typedef enum {
21949371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_PCA_REGULAR,
21959371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC,
21969371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR,
21979371c9d4SSatish Balay   MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC
21989371c9d4SSatish Balay } MatHtoolClusteringType;
2199c7a4214aSPierre Jolivet #endif
2200c7a4214aSPierre Jolivet 
220197969023SHong Zhang #ifdef PETSC_HAVE_MUMPS
2202014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat, PetscInt, PetscInt);
2203bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat, PetscInt, PetscInt *);
2204b9e9ea26SSatish Balay PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat, PetscInt, PetscReal);
2205bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat, PetscInt, PetscReal *);
2206bc6112feSHong Zhang 
2207ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat, PetscInt, PetscInt *);
2208ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat, PetscInt, PetscInt *);
2209ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat, PetscInt, PetscReal *);
2210ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat, PetscInt, PetscReal *);
22115c0bae8cSAshish Patel PETSC_EXTERN PetscErrorCode MatMumpsGetNullPivots(Mat, PetscInt *, PetscInt **);
221289a9c03aSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat, Mat);
22130e6b8875SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat, Mat);
221497969023SHong Zhang #endif
221523a5497aSJed Brown 
2216b500a6b7SJose David Bermeol #ifdef PETSC_HAVE_MKL_PARDISO
2217d615f992SSatish Balay PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat, PetscInt, PetscInt);
2218b500a6b7SJose David Bermeol #endif
2219b500a6b7SJose David Bermeol 
2220d305a81bSVasiliy Kozyrev #ifdef PETSC_HAVE_MKL_CPARDISO
2221d305a81bSVasiliy Kozyrev PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat, PetscInt, PetscInt);
2222d305a81bSVasiliy Kozyrev #endif
2223d305a81bSVasiliy Kozyrev 
2224d954db57SHong Zhang #ifdef PETSC_HAVE_SUPERLU
2225014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat, PetscReal);
2226d954db57SHong Zhang #endif
2227d954db57SHong Zhang 
2228fb785984SHong Zhang #ifdef PETSC_HAVE_SUPERLU_DIST
2229fb785984SHong Zhang PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat, PetscScalar *);
2230fb785984SHong Zhang #endif
2231fb785984SHong Zhang 
2232575704cbSPieter Ghysels #ifdef PETSC_HAVE_STRUMPACK
2233542aee0fSPieter Ghysels /*E
22342ef1f0ffSBarry Smith     MatSTRUMPACKReordering - sparsity reducing ordering to be used in `MATSOLVERSTRUMPACK``
2235542aee0fSPieter Ghysels 
2236542aee0fSPieter Ghysels     Level: intermediate
22372ef1f0ffSBarry Smith 
22382ef1f0ffSBarry Smith     Values:
22392ef1f0ffSBarry Smith +  `MAT_STRUMPACK_NATURAL` - use the current ordering
22402ef1f0ffSBarry Smith .  `MAT_STRUMPACK_METIS` - use MeTis to compute an ordering
22412ef1f0ffSBarry Smith .  `MAT_STRUMPACK_PARMETIS` - use ParMeTis to compute an ordering
22422ef1f0ffSBarry Smith .  `MAT_STRUMPACK_SCOTCH` - use Scotch to compute an ordering
22432ef1f0ffSBarry Smith .  `MAT_STRUMPACK_PTSCOTCH` - use parallel Scotch to compute an ordering
22442ef1f0ffSBarry Smith -  `MAT_STRUMPACK_RCM` - use an RCM ordering
22452ef1f0ffSBarry Smith 
22462ef1f0ffSBarry Smith     Developer Note:
22472ef1f0ffSBarry Smith     Should be called `MatSTRUMPACKReorderingType`
22482ef1f0ffSBarry Smith 
22492ef1f0ffSBarry Smith .seealso: `Mat`, `MATSOLVERSTRUMPACK`, `MatGetFactor()`, `MatSTRUMPACKSetHSSRelTol()`, `MatSTRUMPACKSetReordering()`
2250542aee0fSPieter Ghysels E*/
22519371c9d4SSatish Balay typedef enum {
22529371c9d4SSatish Balay   MAT_STRUMPACK_NATURAL  = 0,
225334f43fa5SPieter Ghysels   MAT_STRUMPACK_METIS    = 1,
225434f43fa5SPieter Ghysels   MAT_STRUMPACK_PARMETIS = 2,
225534f43fa5SPieter Ghysels   MAT_STRUMPACK_SCOTCH   = 3,
225634f43fa5SPieter Ghysels   MAT_STRUMPACK_PTSCOTCH = 4,
22579371c9d4SSatish Balay   MAT_STRUMPACK_RCM      = 5
22589371c9d4SSatish Balay } MatSTRUMPACKReordering;
22592ef1f0ffSBarry Smith 
226034f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat, MatSTRUMPACKReordering);
2261575704cbSPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat, PetscBool);
226234f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSRelTol(Mat, PetscReal);
2263d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatSTRUMPACKSetHSSRelTol() (since version 3.9)") static inline PetscErrorCode MatSTRUMPACKSetHSSRelCompTol(Mat mat, PetscReal rtol)
2264d71ae5a4SJacob Faibussowitsch {
22659371c9d4SSatish Balay   return MatSTRUMPACKSetHSSRelTol(mat, rtol);
22669371c9d4SSatish Balay }
226734f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSAbsTol(Mat, PetscReal);
226834f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSMinSepSize(Mat, PetscInt);
2269d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatSTRUMPACKSetHSSMinSepSize() (since version 3.9)") static inline PetscErrorCode MatSTRUMPACKSetHSSMinSize(Mat mat, PetscInt hssminsize)
2270d71ae5a4SJacob Faibussowitsch {
22719371c9d4SSatish Balay   return MatSTRUMPACKSetHSSMinSepSize(mat, hssminsize);
22729371c9d4SSatish Balay }
227334f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSMaxRank(Mat, PetscInt);
2274a36bf211SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSLeafSize(Mat, PetscInt);
2275575704cbSPieter Ghysels #endif
2276575704cbSPieter Ghysels 
2277b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat, PetscBool);
22782216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat, PetscBool *);
2279d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatBindToCPU (since v3.13)") static inline PetscErrorCode MatPinToCPU(Mat A, PetscBool flg)
2280d71ae5a4SJacob Faibussowitsch {
22819371c9d4SSatish Balay   return MatBindToCPU(A, flg);
22829371c9d4SSatish Balay }
228365a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat, PetscBool);
2284e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat, PetscBool *);
2285e7e92044SBarry Smith 
2286042217e8SBarry Smith typedef struct _n_SplitCSRMat *PetscSplitCSRDataStructure;
2287042217e8SBarry Smith PETSC_EXTERN PetscErrorCode    MatCUSPARSEGetDeviceMatWrite(Mat, PetscSplitCSRDataStructure *);
2288a587d139SMark 
2289a587d139SMark #ifdef PETSC_HAVE_KOKKOS_KERNELS
2290042217e8SBarry Smith PETSC_EXTERN PetscErrorCode MatKokkosGetDeviceMatWrite(Mat, PetscSplitCSRDataStructure *);
2291042217e8SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJKokkosSetDeviceMat(Mat, PetscSplitCSRDataStructure);
2292042217e8SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJKokkosGetDeviceMat(Mat, PetscSplitCSRDataStructure *);
2293a587d139SMark #endif
2294a587d139SMark 
2295aa372e3fSPaul Mullowney #ifdef PETSC_HAVE_CUDA
22963f9c0db1SPaul Mullowney /*E
22972ef1f0ffSBarry Smith     MatCUSPARSEStorageFormat - indicates the storage format for `MATAIJCUSPARSE` (GPU)
22982692e278SPaul Mullowney     matrices.
2299e057df02SPaul Mullowney 
23002ef1f0ffSBarry Smith     Values:
230187497f52SBarry Smith +   `MAT_CUSPARSE_CSR` - Compressed Sparse Row
230287497f52SBarry Smith .   `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later).
230387497f52SBarry Smith -   `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later).
2304e057df02SPaul Mullowney 
2305e057df02SPaul Mullowney     Level: intermediate
2306e057df02SPaul Mullowney 
23072ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MATAIJCUSPARSE`, `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation`
2308e057df02SPaul Mullowney E*/
2309e057df02SPaul Mullowney 
23109371c9d4SSatish Balay typedef enum {
23119371c9d4SSatish Balay   MAT_CUSPARSE_CSR,
23129371c9d4SSatish Balay   MAT_CUSPARSE_ELL,
23139371c9d4SSatish Balay   MAT_CUSPARSE_HYB
23149371c9d4SSatish Balay } MatCUSPARSEStorageFormat;
2315e057df02SPaul Mullowney 
2316e057df02SPaul Mullowney /* these will be strings associated with enumerated type defined above */
2317e057df02SPaul Mullowney PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[];
2318e057df02SPaul Mullowney 
23193f9c0db1SPaul Mullowney /*E
23202ef1f0ffSBarry Smith     MatCUSPARSEFormatOperation - indicates the operation of `MATAIJCUSPARSE` (GPU)
23212692e278SPaul Mullowney     matrices whose operation should use a particular storage format.
2322e057df02SPaul Mullowney 
23232ef1f0ffSBarry Smith     Values:
232487497f52SBarry Smith +   `MAT_CUSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel MatMult
232587497f52SBarry Smith .   `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the offdiagonal matrix in the parallel MatMult
232687497f52SBarry Smith .   `MAT_CUSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) MatMult
23272ef1f0ffSBarry Smith -   `MAT_CUSPARSE_ALL` - sets the storage format for all `MATAIJCUSPARSE` (GPU) matrices
2328e057df02SPaul Mullowney 
2329e057df02SPaul Mullowney     Level: intermediate
2330e057df02SPaul Mullowney 
23312ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat`
2332e057df02SPaul Mullowney E*/
23339371c9d4SSatish Balay typedef enum {
23349371c9d4SSatish Balay   MAT_CUSPARSE_MULT_DIAG,
23359371c9d4SSatish Balay   MAT_CUSPARSE_MULT_OFFDIAG,
23369371c9d4SSatish Balay   MAT_CUSPARSE_MULT,
23379371c9d4SSatish Balay   MAT_CUSPARSE_ALL
23389371c9d4SSatish Balay } MatCUSPARSEFormatOperation;
2339e057df02SPaul Mullowney 
234010e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
234110e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2342e057df02SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat, MatCUSPARSEFormatOperation, MatCUSPARSEStorageFormat);
2343365b711fSMark Adams PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat, PetscBool);
23445f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat, PetscBool, const int **, const int **);
23455f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat, PetscBool, const int **, const int **);
23465f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat, const PetscScalar **);
23475f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat, const PetscScalar **);
23485f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat, PetscScalar **);
23495f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat, PetscScalar **);
23505f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat, PetscScalar **);
23515f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat, PetscScalar **);
2352637a0070SStefano Zampini 
2353637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
2354637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
2355637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat, PetscScalar **);
2356637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat, const PetscScalar **);
2357637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat, PetscScalar **);
2358637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat, PetscScalar **);
2359637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat, const PetscScalar **);
2360637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat, PetscScalar **);
2361637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat, const PetscScalar *);
2362d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat, const PetscScalar *);
2363637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat);
2364*2d1451d4SHong Zhang 
2365*2d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2366*2d1451d4SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELLCUDA(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
23679ae82921SPaul Mullowney #endif
23689ae82921SPaul Mullowney 
236947d993e7Ssuyashtn #ifdef PETSC_HAVE_HIP
237047d993e7Ssuyashtn /*E
23712ef1f0ffSBarry Smith     MatHIPSPARSEStorageFormat - indicates the storage format for `MATAIJHIPSPARSE` (GPU)
237247d993e7Ssuyashtn     matrices.
237347d993e7Ssuyashtn 
237447d993e7Ssuyashtn     Level: intermediate
237547d993e7Ssuyashtn 
23762ef1f0ffSBarry Smith     Values:
23772ef1f0ffSBarry Smith +   `MAT_HIPSPARSE_CSR` - Compressed Sparse Row
23782ef1f0ffSBarry Smith .   `MAT_HIPSPARSE_ELL` - Ellpack
23792ef1f0ffSBarry Smith -   `MAT_HIPSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format
238047d993e7Ssuyashtn 
23812ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEFormatOperation`
238247d993e7Ssuyashtn E*/
238347d993e7Ssuyashtn 
238447d993e7Ssuyashtn typedef enum {
238547d993e7Ssuyashtn   MAT_HIPSPARSE_CSR,
238647d993e7Ssuyashtn   MAT_HIPSPARSE_ELL,
238747d993e7Ssuyashtn   MAT_HIPSPARSE_HYB
238847d993e7Ssuyashtn } MatHIPSPARSEStorageFormat;
238947d993e7Ssuyashtn 
239047d993e7Ssuyashtn /* these will be strings associated with enumerated type defined above */
239147d993e7Ssuyashtn PETSC_EXTERN const char *const MatHIPSPARSEStorageFormats[];
239247d993e7Ssuyashtn 
239347d993e7Ssuyashtn /*E
23942ef1f0ffSBarry Smith     MatHIPSPARSEFormatOperation - indicates the operation of `MATAIJHIPSPARSE` (GPU)
239547d993e7Ssuyashtn     matrices whose operation should use a particular storage format.
239647d993e7Ssuyashtn 
239747d993e7Ssuyashtn     Level: intermediate
239847d993e7Ssuyashtn 
23992ef1f0ffSBarry Smith     Values:
24002ef1f0ffSBarry Smith +   `MAT_HIPSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel `MatMult()`
24012ef1f0ffSBarry Smith .   `MAT_HIPSPARSE_MULT_OFFDIAG` - sets the storage format for the offdiagonal matrix in the parallel `MatMul()t`
24022ef1f0ffSBarry Smith .   `MAT_HIPSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) `MatMult()`
24032ef1f0ffSBarry Smith -   `MAT_HIPSPARSE_ALL` - sets the storage format for all HIPSPARSE (GPU) matrices
24042ef1f0ffSBarry Smith 
24052ef1f0ffSBarry Smith .seealso: [](chapter_matrices), `MatHIPSPARSESetFormat()`, `MatHIPSPARSEStorageFormat`
240647d993e7Ssuyashtn E*/
240747d993e7Ssuyashtn typedef enum {
240847d993e7Ssuyashtn   MAT_HIPSPARSE_MULT_DIAG,
240947d993e7Ssuyashtn   MAT_HIPSPARSE_MULT_OFFDIAG,
241047d993e7Ssuyashtn   MAT_HIPSPARSE_MULT,
241147d993e7Ssuyashtn   MAT_HIPSPARSE_ALL
241247d993e7Ssuyashtn } MatHIPSPARSEFormatOperation;
241347d993e7Ssuyashtn 
241447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
241547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateAIJHIPSPARSE(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
241647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetFormat(Mat, MatHIPSPARSEFormatOperation, MatHIPSPARSEStorageFormat);
241747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatHIPSPARSESetUseCPUSolve(Mat, PetscBool);
241847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetIJ(Mat, PetscBool, const int **, const int **);
241947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreIJ(Mat, PetscBool, const int **, const int **);
242047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayRead(Mat, const PetscScalar **);
242147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayRead(Mat, const PetscScalar **);
242247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArrayWrite(Mat, PetscScalar **);
242347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArrayWrite(Mat, PetscScalar **);
242447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSEGetArray(Mat, PetscScalar **);
242547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatSeqAIJHIPSPARSERestoreArray(Mat, PetscScalar **);
242647d993e7Ssuyashtn 
242747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar[], Mat *);
242847d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatCreateSeqDenseHIP(MPI_Comm, PetscInt, PetscInt, PetscScalar[], Mat *);
242947d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayWrite(Mat, PetscScalar **);
243047d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArrayRead(Mat, const PetscScalar **);
243147d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPGetArray(Mat, PetscScalar **);
243247d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayWrite(Mat, PetscScalar **);
243347d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArrayRead(Mat, const PetscScalar **);
243447d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPRestoreArray(Mat, PetscScalar **);
243547d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPPlaceArray(Mat, const PetscScalar *);
243647d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPReplaceArray(Mat, const PetscScalar *);
243747d993e7Ssuyashtn PETSC_EXTERN PetscErrorCode MatDenseHIPResetArray(Mat);
243847d993e7Ssuyashtn #endif
243947d993e7Ssuyashtn 
2440d67ff14aSKarl Rupp #if defined(PETSC_HAVE_VIENNACL)
2441d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Mat *);
2442d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], PetscInt, const PetscInt[], Mat *);
2443d67ff14aSKarl Rupp #endif
2444d67ff14aSKarl Rupp 
244554efbe56SHong Zhang #if defined(PETSC_HAVE_FFTW)
2446014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat, Vec, Vec);
2447014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat, Vec, Vec);
24482a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat, Vec *, Vec *, Vec *);
244954efbe56SHong Zhang #endif
245054efbe56SHong Zhang 
2451d24d4204SJose E. Roman #if defined(PETSC_HAVE_SCALAPACK)
2452d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, Mat *);
2453d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat, PetscInt, PetscInt);
2454d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat, PetscInt *, PetscInt *);
2455d24d4204SJose E. Roman #endif
2456d24d4204SJose E. Roman 
2457014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm, PetscInt, const IS[], PetscInt, const IS[], const Mat[], Mat *);
2458014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat, PetscInt *, PetscInt *);
2459014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat, IS[], IS[]);
2460014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat, IS[], IS[]);
2461014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat, PetscInt *, PetscInt *, Mat ***);
2462014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat, PetscInt, PetscInt, Mat *);
246319fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat, VecType);
2464014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat, PetscInt, const IS[], PetscInt, const IS[], const Mat[]);
2465014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat, PetscInt, PetscInt, Mat);
2466d8588912SDave May 
24674325cce7SMatthew G Knepley PETSC_EXTERN PetscErrorCode MatChop(Mat, PetscReal);
2468e0a58c10SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat, PetscReal, PetscInt *);
24694325cce7SMatthew G Knepley 
2470b541e6a4SDmitry Karpeev PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat, PetscInt, PetscInt *, IS **);
247153dd7562SDmitry Karpeev 
2472c094ef40SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat, PetscBool, Mat);
2473c094ef40SMatthew G. Knepley 
2474539c167fSBarry Smith PETSC_INTERN PetscErrorCode MatHeaderMerge(Mat, Mat *);
2475539c167fSBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat, Mat *);
24761a2c6b5cSJunchao Zhang 
24777ee59b9bSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat, const PetscInt **, const PetscInt **, PetscScalar **, PetscMemType *);
247872833a62Smarkadams4 
24792d776b49SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat, PetscBool, PetscBool, PetscReal, Mat *);
2480dec0b466SHong Zhang PETSC_EXTERN PetscErrorCode MatEliminateZeros(Mat);
2481ad6ad4e1SHansol  Suh 
2482ad6ad4e1SHansol  Suh PETSC_EXTERN PetscErrorCode VecCreateMatDense(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar *, Mat *);
248323a5497aSJed Brown #endif
2484