xref: /petsc/include/petscmat.h (revision 87497f523770ea28bdc907071c6e8146b51bca00)
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 
17db781477SPatrick Sanan .seealso: `MatCreate()`, `MatType`, `MatSetType()`, `MatDestroy()`
18d9274352SBarry Smith S*/
19d9274352SBarry Smith typedef struct _p_Mat*           Mat;
20d9274352SBarry Smith 
2176bdecfbSBarry Smith /*J
228f6c3df8SBarry Smith     MatType - String with the name of a PETSc matrix type
23d9274352SBarry Smith 
24d9274352SBarry Smith    Level: beginner
25d9274352SBarry Smith 
26db781477SPatrick Sanan .seealso: `MatSetType()`, `Mat`, `MatSolverType`, `MatRegister()`
2776bdecfbSBarry Smith J*/
2819fd82e9SBarry Smith typedef const char* MatType;
29273d9f13SBarry Smith #define MATSAME            "same"
305a11e1b2SBarry Smith #define MATMAIJ            "maij"
31273d9f13SBarry Smith #define MATSEQMAIJ         "seqmaij"
32273d9f13SBarry Smith #define MATMPIMAIJ         "mpimaij"
3349bd79ccSDebojyoti Ghosh #define MATKAIJ            "kaij"
3449bd79ccSDebojyoti Ghosh #define MATSEQKAIJ         "seqkaij"
3549bd79ccSDebojyoti Ghosh #define MATMPIKAIJ         "mpikaij"
36273d9f13SBarry Smith #define MATIS              "is"
375a11e1b2SBarry Smith #define MATAIJ             "aij"
38273d9f13SBarry Smith #define MATSEQAIJ          "seqaij"
39273d9f13SBarry Smith #define MATMPIAIJ          "mpiaij"
405a11e1b2SBarry Smith #define MATAIJCRL          "aijcrl"
415a11e1b2SBarry Smith #define MATSEQAIJCRL       "seqaijcrl"
425a11e1b2SBarry Smith #define MATMPIAIJCRL       "mpiaijcrl"
439ae82921SPaul Mullowney #define MATAIJCUSPARSE     "aijcusparse"
449ae82921SPaul Mullowney #define MATSEQAIJCUSPARSE  "seqaijcusparse"
459ae82921SPaul Mullowney #define MATMPIAIJCUSPARSE  "mpiaijcusparse"
468c3ff71bSJunchao Zhang #define MATAIJKOKKOS       "aijkokkos"
478c3ff71bSJunchao Zhang #define MATSEQAIJKOKKOS    "seqaijkokkos"
488c3ff71bSJunchao Zhang #define MATMPIAIJKOKKOS    "mpiaijkokkos"
49d67ff14aSKarl Rupp #define MATAIJVIENNACL     "aijviennacl"
50d67ff14aSKarl Rupp #define MATSEQAIJVIENNACL  "seqaijviennacl"
51d67ff14aSKarl Rupp #define MATMPIAIJVIENNACL  "mpiaijviennacl"
525a11e1b2SBarry Smith #define MATAIJPERM         "aijperm"
535a11e1b2SBarry Smith #define MATSEQAIJPERM      "seqaijperm"
545a11e1b2SBarry Smith #define MATMPIAIJPERM      "mpiaijperm"
554dfdc2d9SRichard Tran Mills #define MATAIJSELL         "aijsell"
564dfdc2d9SRichard Tran Mills #define MATSEQAIJSELL      "seqaijsell"
574dfdc2d9SRichard Tran Mills #define MATMPIAIJSELL      "mpiaijsell"
584a2a386eSRichard Tran Mills #define MATAIJMKL          "aijmkl"
594a2a386eSRichard Tran Mills #define MATSEQAIJMKL       "seqaijmkl"
604a2a386eSRichard Tran Mills #define MATMPIAIJMKL       "mpiaijmkl"
61b5b72c8aSIrina Sokolova #define MATBAIJMKL         "baijmkl"
62b5b72c8aSIrina Sokolova #define MATSEQBAIJMKL      "seqbaijmkl"
63b5b72c8aSIrina Sokolova #define MATMPIBAIJMKL      "mpibaijmkl"
64273d9f13SBarry Smith #define MATSHELL           "shell"
65c1fff1c6SRichard Tran Mills #define MATCENTERING       "centering"
665a11e1b2SBarry Smith #define MATDENSE           "dense"
67637a0070SStefano Zampini #define MATDENSECUDA       "densecuda"
68209238afSKris Buschelman #define MATSEQDENSE        "seqdense"
69bfc799aaSStefano Zampini #define MATSEQDENSECUDA    "seqdensecuda"
70273d9f13SBarry Smith #define MATMPIDENSE        "mpidense"
71637a0070SStefano Zampini #define MATMPIDENSECUDA    "mpidensecuda"
72db31f6deSJed Brown #define MATELEMENTAL       "elemental"
73d24d4204SJose E. Roman #define MATSCALAPACK       "scalapack"
745a11e1b2SBarry Smith #define MATBAIJ            "baij"
75273d9f13SBarry Smith #define MATSEQBAIJ         "seqbaij"
76273d9f13SBarry Smith #define MATMPIBAIJ         "mpibaij"
77273d9f13SBarry Smith #define MATMPIADJ          "mpiadj"
785a11e1b2SBarry Smith #define MATSBAIJ           "sbaij"
79273d9f13SBarry Smith #define MATSEQSBAIJ        "seqsbaij"
80273d9f13SBarry Smith #define MATMPISBAIJ        "mpisbaij"
81cebc7f6cSBarry Smith #define MATMFFD            "mffd"
82c8a8475eSBarry Smith #define MATNORMAL          "normal"
83c5e4d11fSDmitry Karpeev #define MATNORMALHERMITIAN "normalh"
84ab92ecdeSBarry Smith #define MATLRC             "lrc"
852a6744ebSBarry Smith #define MATSCATTER         "scatter"
86421e10b8SBarry Smith #define MATBLOCKMAT        "blockmat"
87793850ffSBarry Smith #define MATCOMPOSITE       "composite"
881f8c7532SHong Zhang #define MATFFT             "fft"
891f8c7532SHong Zhang #define MATFFTW            "fftw"
90e133240eSMatthew G Knepley #define MATSEQCUFFT        "seqcufft"
91557cca28SSatish Balay #define MATTRANSPOSEMAT    "transpose"
9272ca8751SBarry Smith #define MATSCHURCOMPLEMENT "schurcomplement"
931d6018f0SLisandro Dalcin #define MATPYTHON          "python"
9463c07aadSStefano Zampini #define MATHYPRE           "hypre"
95f91d8e95SBarry Smith #define MATHYPRESTRUCT     "hyprestruct"
96a9e6138eSGlenn Hammond #define MATHYPRESSTRUCT    "hypresstruct"
97ee1cef2cSJed Brown #define MATSUBMATRIX       "submatrix"
982c0dbf93SJed Brown #define MATLOCALREF        "localref"
99d8588912SDave May #define MATNEST            "nest"
100c094ef40SMatthew G. Knepley #define MATPREALLOCATOR    "preallocator"
101d4002b98SHong Zhang #define MATSELL            "sell"
102d4002b98SHong Zhang #define MATSEQSELL         "seqsell"
103d4002b98SHong Zhang #define MATMPISELL         "mpisell"
104a3b2e22bSHong Zhang #define MATDUMMY           "dummy"
105cd929ea3SAlp Dener #define MATLMVM            "lmvm"
10678e4361aSAlp Dener #define MATLMVMDFP         "lmvmdfp"
10778e4361aSAlp Dener #define MATLMVMBFGS        "lmvmbfgs"
10878e4361aSAlp Dener #define MATLMVMSR1         "lmvmsr1"
109864588a7SAlp Dener #define MATLMVMBROYDEN     "lmvmbroyden"
110864588a7SAlp Dener #define MATLMVMBADBROYDEN  "lmvmbadbroyden"
111864588a7SAlp Dener #define MATLMVMSYMBROYDEN  "lmvmsymbroyden"
112864588a7SAlp Dener #define MATLMVMSYMBADBROYDEN "lmvmsymbadbroyden"
113864588a7SAlp Dener #define MATLMVMDIAGBROYDEN   "lmvmdiagbroyden"
1143423f386SBarry Smith #define MATCONSTANTDIAGONAL  "constantdiagonal"
115c7a4214aSPierre Jolivet #define MATHTOOL           "htool"
11653022affSStefano Zampini #define MATH2OPUS          "h2opus"
117773941d6SBarry Smith 
11876bdecfbSBarry Smith /*J
1193ca39a21SBarry Smith     MatSolverType - String with the name of a PETSc matrix solver type.
1209989ab13SBarry Smith 
121c2b89b5dSBarry Smith     For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc
1229989ab13SBarry Smith 
1239989ab13SBarry Smith    Level: beginner
1249989ab13SBarry Smith 
1253f498edaSToby Isaac    Notes:  MATSOLVERUMFPACK, MATSOLVERCHOLMOD, MATSOLVERKLU, MATSOLVERSPQR form the SuiteSparse package for which you can use --download-suitesparse
126c7ccbb75SBarry Smith 
127db781477SPatrick Sanan .seealso: `MatGetFactor()`, `PCFactorSetMatSolverType()`, `PCFactorGetMatSolverType()`
12876bdecfbSBarry Smith J*/
129ea799195SBarry Smith typedef const char* MatSolverType;
1302692d6eeSBarry Smith #define MATSOLVERSUPERLU          "superlu"
1312692d6eeSBarry Smith #define MATSOLVERSUPERLU_DIST     "superlu_dist"
13208f5efcfSPieter Ghysels #define MATSOLVERSTRUMPACK        "strumpack"
1332692d6eeSBarry Smith #define MATSOLVERUMFPACK          "umfpack"
13420db9a53SJed Brown #define MATSOLVERCHOLMOD          "cholmod"
135d89f5e7aSBarry Smith #define MATSOLVERKLU              "klu"
136418810c4SBarry Smith #define MATSOLVERSPARSEELEMENTAL  "sparseelemental"
137d89f5e7aSBarry Smith #define MATSOLVERELEMENTAL        "elemental"
138d24d4204SJose E. Roman #define MATSOLVERSCALAPACK        "scalapack"
1392692d6eeSBarry Smith #define MATSOLVERESSL             "essl"
1402692d6eeSBarry Smith #define MATSOLVERLUSOL            "lusol"
1412692d6eeSBarry Smith #define MATSOLVERMUMPS            "mumps"
142d615f992SSatish Balay #define MATSOLVERMKL_PARDISO      "mkl_pardiso"
143d305a81bSVasiliy Kozyrev #define MATSOLVERMKL_CPARDISO     "mkl_cpardiso"
1442692d6eeSBarry Smith #define MATSOLVERPASTIX           "pastix"
1452692d6eeSBarry Smith #define MATSOLVERMATLAB           "matlab"
1462692d6eeSBarry Smith #define MATSOLVERPETSC            "petsc"
1472692d6eeSBarry Smith #define MATSOLVERBAS              "bas"
1489ae82921SPaul Mullowney #define MATSOLVERCUSPARSE         "cusparse"
149bddcd29dSMark Adams #define MATSOLVERCUSPARSEBAND     "cusparseband"
150bfc799aaSStefano Zampini #define MATSOLVERCUDA             "cuda"
151930e68a5SMark Adams #define MATSOLVERKOKKOS           "kokkos"
1528f7e8f9dSMark Adams #define MATSOLVERKOKKOSDEVICE     "kokkosdevice"
153a2fc1e05SToby Isaac #define MATSOLVERSPQR             "spqr"
154c0cdd4a1SDahai Guo 
155b24902e0SBarry Smith /*E
156b24902e0SBarry Smith     MatFactorType - indicates what type of factorization is requested
157b24902e0SBarry Smith 
158b24902e0SBarry Smith     Level: beginner
159b24902e0SBarry Smith 
160af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
161b24902e0SBarry Smith 
162db781477SPatrick Sanan .seealso: `MatSolverType`, `MatGetFactor()`, `MatGetFactorAvailable()`, `MatSolverTypeRegister()`
163b24902e0SBarry Smith E*/
1643f498edaSToby Isaac typedef enum {MAT_FACTOR_NONE, MAT_FACTOR_LU, MAT_FACTOR_CHOLESKY, MAT_FACTOR_ILU, MAT_FACTOR_ICC, MAT_FACTOR_ILUDT, MAT_FACTOR_QR, MAT_FACTOR_NUM_TYPES} MatFactorType;
165014dd563SJed Brown PETSC_EXTERN const char *const MatFactorTypes[];
166e92e720dSBarry Smith 
167ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactor(Mat,MatSolverType,MatFactorType,Mat*);
168ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat,MatSolverType,MatFactorType,PetscBool *);
169f73b0415SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetCanUseOrdering(Mat, PetscBool*);
1709fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatFactorGetCanUseOrdering() (since version 3.15)") static inline PetscErrorCode MatFactorGetUseOrdering(Mat A,PetscBool *b) {return MatFactorGetCanUseOrdering(A,b);}
171ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat,MatSolverType*);
172014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat,MatFactorType*);
1737abd51d3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat,MatFactorType);
1742430ea28SJose E. Roman PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatSolverFunction)(Mat,MatFactorType,Mat*);
1752430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType,MatType,MatFactorType,MatSolverFunction);
1762430ea28SJose E. Roman PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType,MatType,MatFactorType,PetscBool*,PetscBool*,MatSolverFunction*);
17725ef9dfeSBarry Smith typedef MatSolverType MatSolverPackage PETSC_DEPRECATED_TYPEDEF("Use MatSolverType (since version 3.9)");
1789fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatSolverTypeRegister() (since version 3.9)") static inline PetscErrorCode MatSolverPackageRegister(MatSolverType stype,MatType mtype,MatFactorType ftype,MatSolverFunction f)
179c19b563cSJed Brown { return MatSolverTypeRegister(stype,mtype,ftype,f); }
1809fbee547SJacob 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)
181c19b563cSJed Brown { return MatSolverTypeGet(stype,mtype,ftype,foundmtype,foundstype,f); }
1829989ab13SBarry Smith 
1834222ddf1SHong Zhang /*E
1844222ddf1SHong Zhang     MatProductType - indicates what type of matrix product is requested
1854222ddf1SHong Zhang 
1864222ddf1SHong Zhang     Level: beginner
1874222ddf1SHong Zhang 
188db781477SPatrick Sanan .seealso: `MatProductSetType()`
1894222ddf1SHong Zhang E*/
1906718818eSStefano Zampini typedef enum {MATPRODUCT_UNSPECIFIED=0,MATPRODUCT_AB,MATPRODUCT_AtB,MATPRODUCT_ABt,MATPRODUCT_PtAP,MATPRODUCT_RARt,MATPRODUCT_ABC} MatProductType;
191544a5e07SHong Zhang PETSC_EXTERN const char *const MatProductTypes[];
1924222ddf1SHong Zhang 
1934222ddf1SHong Zhang /*J
1944222ddf1SHong Zhang     MatProductAlgorithm - String with the name of an algorithm for a PETSc matrix product implementation
1954222ddf1SHong Zhang 
1964222ddf1SHong Zhang    Level: beginner
1974222ddf1SHong Zhang 
198db781477SPatrick Sanan .seealso: `MatSetType()`, `Mat`, `MatProductSetAlgorithm()`, `MatProductType`
1994222ddf1SHong Zhang J*/
2004222ddf1SHong Zhang typedef const char* MatProductAlgorithm;
2013e662e0bSHong Zhang #define MATPRODUCTALGORITHMDEFAULT "default"
2023e662e0bSHong Zhang #define MATPRODUCTALGORITHMSORTED "sorted"
2033e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLE "scalable"
2043e662e0bSHong Zhang #define MATPRODUCTALGORITHMSCALABLEFAST "scalable_fast"
2053e662e0bSHong Zhang #define MATPRODUCTALGORITHMHEAP "heap"
2063e662e0bSHong Zhang #define MATPRODUCTALGORITHMBHEAP "btheap"
2073e662e0bSHong Zhang #define MATPRODUCTALGORITHMLLCONDENSED "llcondensed"
2083e662e0bSHong Zhang #define MATPRODUCTALGORITHMROWMERGE "rowmerge"
2093e662e0bSHong Zhang #define MATPRODUCTALGORITHMOUTERPRODUCT "outerproduct"
2103e662e0bSHong Zhang #define MATPRODUCTALGORITHMATB "at*b"
2113e662e0bSHong Zhang #define MATPRODUCTALGORITHMRAP "rap"
2123e662e0bSHong Zhang #define MATPRODUCTALGORITHMNONSCALABLE "nonscalable"
2133e662e0bSHong Zhang #define MATPRODUCTALGORITHMSEQMPI "seqmpi"
2143e662e0bSHong Zhang #define MATPRODUCTALGORITHMBACKEND "backend"
2153e662e0bSHong Zhang #define MATPRODUCTALGORITHMOVERLAPPING "overlapping"
2163e662e0bSHong Zhang #define MATPRODUCTALGORITHMMERGED "merged"
2173e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCE "allatonce"
2183e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLATONCEMERGED "allatonce_merged"
2193e662e0bSHong Zhang #define MATPRODUCTALGORITHMALLGATHERV "allgatherv"
2203e662e0bSHong Zhang #define MATPRODUCTALGORITHMCYCLIC "cyclic"
2213e662e0bSHong Zhang #if defined(PETSC_HAVE_HYPRE)
2223e662e0bSHong Zhang #define MATPRODUCTALGORITHMHYPRE "hypre"
2233e662e0bSHong Zhang #endif
2244222ddf1SHong Zhang 
2254222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreate(Mat,Mat,Mat,Mat*);
2264222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductCreateWithMat(Mat,Mat,Mat,Mat);
2274222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetType(Mat,MatProductType);
2284222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetAlgorithm(Mat,MatProductAlgorithm);
2294222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFill(Mat,PetscReal);
2304222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSetFromOptions(Mat);
2314222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductSymbolic(Mat);
2324222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductNumeric(Mat);
2334222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatProductReplaceMats(Mat,Mat,Mat,Mat);
2344417c5e8SHong Zhang PETSC_EXTERN PetscErrorCode MatProductClear(Mat);
2356718818eSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductView(Mat,PetscViewer);
236c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetType(Mat,MatProductType*);
237c600787bSStefano Zampini PETSC_EXTERN PetscErrorCode MatProductGetMats(Mat,Mat*,Mat*,Mat*);
2384222ddf1SHong Zhang 
239c06d978dSMatthew Knepley /* Logging support */
2400700a824SBarry Smith #define    MAT_FILE_CLASSID 1211216    /* used to indicate matrices in binary files */
241014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_CLASSID;
242335efc43SPeter Brune PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID;
243014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID;
244014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID;
245014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID;
246014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID;
247014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID;
248014dd563SJed Brown PETSC_EXTERN PetscClassId MATMFFD_CLASSID;
249c06d978dSMatthew Knepley 
250ceb03754SKris Buschelman /*E
2517dae84e0SHong Zhang     MatReuse - Indicates if matrices obtained from a previous call to MatCreateSubMatrices(), MatCreateSubMatrix(), MatConvert() or several other functions
252cf37664fSBarry Smith      are to be reused to store the new matrix values.
253cf37664fSBarry Smith 
254cf37664fSBarry Smith $  MAT_INITIAL_MATRIX - create a new matrix
255cf37664fSBarry Smith $  MAT_REUSE_MATRIX - reuse the matrix created with a previous call that used MAT_INITIAL_MATRIX
256cf37664fSBarry Smith $  MAT_INPLACE_MATRIX - replace the first input matrix with the new matrix (not applicable to all functions)
257cf37664fSBarry 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)
258ceb03754SKris Buschelman 
259ceb03754SKris Buschelman     Level: beginner
260ceb03754SKris Buschelman 
261af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
262ceb03754SKris Buschelman 
263db781477SPatrick Sanan .seealso: `MatCreateSubMatrices()`, `MatCreateSubMatrix()`, `MatDestroyMatrices()`, `MatConvert()`
264ceb03754SKris Buschelman E*/
265511c6705SHong Zhang typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX,MAT_IGNORE_MATRIX,MAT_INPLACE_MATRIX} MatReuse;
266ceb03754SKris Buschelman 
2675494a064SHong Zhang /*E
2687dae84e0SHong Zhang     MatCreateSubMatrixOption - Indicates if matrices obtained from a call to MatCreateSubMatrices()
269446c23c1SPierre Jolivet      include the matrix values. Currently it is only used by MatGetSeqNonzeroStructure().
2705494a064SHong Zhang 
2715494a064SHong Zhang     Level: beginner
2725494a064SHong Zhang 
273db781477SPatrick Sanan .seealso: `MatGetSeqNonzeroStructure()`
2745494a064SHong Zhang E*/
2757dae84e0SHong Zhang typedef enum {MAT_DO_NOT_GET_VALUES,MAT_GET_VALUES} MatCreateSubMatrixOption;
2765494a064SHong Zhang 
277607a6623SBarry Smith PETSC_EXTERN PetscErrorCode MatInitializePackage(void);
278c06d978dSMatthew Knepley 
279014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm,Mat*);
280014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetSizes(Mat,PetscInt,PetscInt,PetscInt,PetscInt);
28119fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatSetType(Mat,MatType);
2820d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatGetVecType(Mat,VecType*);
2830d229a57SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetVecType(Mat,VecType);
284014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat);
285fe2efc57SMark PETSC_EXTERN PetscErrorCode MatViewFromOptions(Mat,PetscObject,const char[]);
286bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatRegister(const char[],PetscErrorCode(*)(Mat));
28723bebc0bSBarry Smith PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[],const char[],const char[]);
288014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat,const char[]);
28926cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOptionsPrefixFactor(Mat,const char[]);
29026cc229bSBarry Smith PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefixFactor(Mat,const char[]);
291014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat,const char[]);
292014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat,const char*[]);
29384d44b13SHong Zhang PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat,PetscBool);
294f69a0ea3SMatthew Knepley 
295140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatList;
296140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatColoringList;
297140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatPartitioningList;
29828988994SBarry Smith 
2993b224e63SBarry Smith /*E
300aa6c7ce3SBarry Smith     MatStructure - Indicates if two matrices have the same nonzero structure
3013b224e63SBarry Smith 
3023b224e63SBarry Smith     Level: beginner
3033b224e63SBarry Smith 
304531d0c6aSBarry Smith $  SAME_NONZERO_PATTERN  - the two matrices have identical nonzero patterns
305531d0c6aSBarry Smith $  DIFFERENT_NONZERO_PATTERN - the two matrices may have different nonzero patterns
306531d0c6aSBarry Smith $  SUBSET_NONZERO_PATTERN - the nonzero pattern of the second matrix is a subset of the nonzero pattern of the first matrix
307531d0c6aSBarry Smith $  UNKNOWN_NONZERO_PATTERN - there is no known relationship between the nonzero patterns. In this case the implementations may try to detect a relationship to optimize the operation
308531d0c6aSBarry Smith 
309531d0c6aSBarry Smith    Developer Notes:
310d60b7d5cSBarry Smith      Any additions/changes here MUST also be made in src/mat/f90-mod/petscmat.h
3113b224e63SBarry Smith 
312db781477SPatrick Sanan .seealso: `MatCopy()`, `MatAXPY()`, `MatAYPX()`
3133b224e63SBarry Smith E*/
314d60b7d5cSBarry Smith typedef enum {DIFFERENT_NONZERO_PATTERN,SUBSET_NONZERO_PATTERN,SAME_NONZERO_PATTERN,UNKNOWN_NONZERO_PATTERN} MatStructure;
315d60b7d5cSBarry Smith PETSC_EXTERN const char *const MatStructures[];
3163b224e63SBarry Smith 
3179779e05dSSatish Balay #if defined PETSC_HAVE_MKL_SPARSE
318ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
319ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
32080095d54SIrina Sokolova PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
321ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
32280095d54SIrina Sokolova #endif
323cd929ea3SAlp Dener 
324d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
325d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
326d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat,PetscInt,const PetscInt[]);
327d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
32880095d54SIrina Sokolova 
329014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*);
330014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*);
331014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
332014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
333014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat*);
3348f8f2f0dSBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
3356a3d2595SBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArray(Mat,const PetscScalar []);
336014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],PetscInt[],PetscInt[],PetscScalar[],Mat*);
3373b00a383SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm,Mat,Mat,const PetscInt[],Mat*);
3383b00a383SHong Zhang 
339014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
340014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
341014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat*);
3427e8381f9SStefano Zampini 
343e8729f6fSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSetPreallocationCOO(Mat,PetscCount,PetscInt[],PetscInt[]);
34482a78a4eSJed Brown PETSC_EXTERN PetscErrorCode MatSetPreallocationCOOLocal(Mat,PetscCount,PetscInt[],PetscInt[]);
3457e8381f9SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetValuesCOO(Mat,const PetscScalar[],InsertMode);
346d21a29f3SJed Brown 
347014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*);
348014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
349d21a29f3SJed Brown 
350014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
351014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat *);
35238f409ebSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
353014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
3544cce697cSJed Brown PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],const PetscInt[]);
355dfb205c3SBarry Smith 
356014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*);
357c1fff1c6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatCreateCentering(MPI_Comm,PetscInt,PetscInt,Mat*);
358014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat,Mat*);
359c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat,Mat*);
360986c4d72SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat,Mat,Vec,Mat,Mat*);
361267ca84cSJose E. Roman PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat,Mat*,Mat*,Vec*,Mat*);
362c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,ISLocalToGlobalMapping,ISLocalToGlobalMapping,Mat*);
363014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
364014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
365c0cdd4a1SDahai Guo 
366014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm,VecScatter,Mat*);
367014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat,VecScatter);
368014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat,VecScatter*);
369014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,Mat*);
370014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat,Mat);
371014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat);
3728c8613bfSJakub Kruzik typedef enum {MAT_COMPOSITE_MERGE_RIGHT,MAT_COMPOSITE_MERGE_LEFT} MatCompositeMergeType;
3738c8613bfSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat,MatCompositeMergeType);
374014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm,PetscInt,const Mat*,Mat*);
3756d7c1e57SBarry Smith typedef enum {MAT_COMPOSITE_ADDITIVE,MAT_COMPOSITE_MULTIPLICATIVE} MatCompositeType;
376014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat,MatCompositeType);
3776dbc55e5SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat,MatCompositeType*);
3783b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat,MatStructure);
3793b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat,MatStructure*);
3806d0add67SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat,PetscInt*);
3818b5c3584SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat,PetscInt,Mat*);
38203049c21SJunchao Zhang PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat,const PetscScalar*);
3836d7c1e57SBarry Smith 
38419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm,PetscInt,const PetscInt[],MatType,Mat*);
385014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm,PetscInt,const PetscInt[],Mat*);
386dedccee8SHong Zhang 
387014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat,Mat*);
3888060fb66Sstefano_zampini PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat,Mat*);
389d0de2241SAndrew Spott PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat,Mat*);
39006511a5cSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat,Mat*);
391fa80d070SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalGetMat(Mat,Mat*);
39265f45395SPierre Jolivet PETSC_EXTERN PetscErrorCode MatNormalHermitianGetMat(Mat,Mat*);
39354e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat,IS,IS,Mat*);
39454e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat,Mat,IS,IS);
395014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat,IS,IS,Mat*);
3963423f386SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar,Mat*);
3971472f72bSBarry Smith 
398978814f1SStefano Zampini #if defined(PETSC_HAVE_HYPRE)
399d975228cSstefano_zampini PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
400978814f1SStefano Zampini #endif
401978814f1SStefano Zampini 
402014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat,const char[]);
403ebead697SStefano Zampini PETSC_EXTERN PetscErrorCode MatPythonGetType(Mat,const char*[]);
4041d6018f0SLisandro Dalcin 
405846b4da1SFande Kong PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat);
406014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetUp(Mat);
407014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroy(Mat*);
408e56f5c9eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat,PetscObjectState*);
40921c89e3eSBarry Smith 
410014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatConjugate(Mat);
411014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRealPart(Mat);
412014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat);
413014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat,Mat*);
414014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetTrace(Mat,PetscScalar*);
415713ccfa9SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat,const PetscScalar **);
4160da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat,PetscInt,const PetscInt*,PetscScalar*);
417479a70c0SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat,Mat);
4188a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockEnvelope(Mat,MatReuse,Mat*);
41999cafbc1SBarry Smith 
4208ed539a5SBarry Smith /* ------------------------------------------------------------*/
421014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
4228a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetValuesIS(Mat,IS,IS,const PetscScalar[],InsertMode);
423014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
424014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat,PetscInt,const PetscScalar[]);
425014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat,PetscInt,const PetscScalar[]);
426014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat,PetscInt,PetscInt,PetscInt[],const PetscScalar[]);
42773a71a0fSBarry Smith PETSC_EXTERN PetscErrorCode MatSetRandom(Mat,PetscRandom);
42884cb2905SBarry Smith 
4292ef4de8bSBarry Smith /*S
4302ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
431*87497f52SBarry Smith         column of a matrix as indexed on an associated grid. These are arguments to `MatSetStencil()` and `MatSetBlockStencil()`
43262ef0227SBarry Smith 
43362ef0227SBarry 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).
434*87497f52SBarry 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.
43562ef0227SBarry Smith 
436*87497f52SBarry Smith    For stencil access to vectors see `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`.
437be479b30SJed Brown 
438*87497f52SBarry Smith    Fortran usage is different, see `MatSetValuesStencil()` for details.
4392ef4de8bSBarry Smith 
4402ef4de8bSBarry Smith    Level: beginner
4412ef4de8bSBarry Smith 
442db781477SPatrick Sanan .seealso: `MatSetValuesStencil()`, `MatSetStencil()`, `MatSetValuesBlockedStencil()`, `DMDAVecGetArray()`, `DMDAVecGetArrayF90()`
4432ef4de8bSBarry Smith S*/
444435da068SBarry Smith typedef struct {
445c1ac3661SBarry Smith   PetscInt k,j,i,c;
446435da068SBarry Smith } MatStencil;
4472ef4de8bSBarry Smith 
448014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
449014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
450014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt);
451435da068SBarry Smith 
452d91e6319SBarry Smith /*E
453*87497f52SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, for example in a solver, or if you plan
45462ef0227SBarry Smith      to continue to add or insert values to it
455d91e6319SBarry Smith 
456d91e6319SBarry Smith     Level: beginner
457d91e6319SBarry Smith 
458db781477SPatrick Sanan .seealso: `MatAssemblyBegin()`, `MatAssemblyEnd()`
459d91e6319SBarry Smith E*/
4606d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
461014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat,MatAssemblyType);
462014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat,MatAssemblyType);
463014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssembled(Mat,PetscBool *);
4644f9c727eSBarry Smith 
465d91e6319SBarry Smith /*E
466d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
467d91e6319SBarry Smith 
468d91e6319SBarry Smith     Level: beginner
469d91e6319SBarry Smith 
47095452b02SPatrick Sanan    Developer Notes:
47195452b02SPatrick Sanan    Entries that are negative need not be called collectively by all processes.
472382164b0SBarry Smith 
473*87497f52SBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
474*87497f52SBarry Smith 
475*87497f52SBarry Smith    Any additions/changes here must also be made in src/mat/interface/dlregismat.c in MatOptions[]
476*87497f52SBarry Smith 
477db781477SPatrick Sanan .seealso: `MatSetOption()`
478d91e6319SBarry Smith E*/
479c5e4d11fSDmitry Karpeev typedef enum {MAT_OPTION_MIN = -3,
480c5e4d11fSDmitry Karpeev               MAT_UNUSED_NONZERO_LOCATION_ERR = -2,
48192d4d306SBarry Smith               MAT_ROW_ORIENTED = -1,
482382164b0SBarry Smith               MAT_SYMMETRIC = 1,
483382164b0SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC = 2,
4848c78258cSHong Zhang               MAT_FORCE_DIAGONAL_ENTRIES = 3,
485382164b0SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES = 4,
486382164b0SBarry Smith               MAT_USE_HASH_TABLE = 5,
487382164b0SBarry Smith               MAT_KEEP_NONZERO_PATTERN = 6,
488382164b0SBarry Smith               MAT_IGNORE_ZERO_ENTRIES = 7,
489382164b0SBarry Smith               MAT_USE_INODES = 8,
490382164b0SBarry Smith               MAT_HERMITIAN = 9,
491382164b0SBarry Smith               MAT_SYMMETRY_ETERNAL = 10,
492c5e4d11fSDmitry Karpeev               MAT_NEW_NONZERO_LOCATION_ERR = 11,
493382164b0SBarry Smith               MAT_IGNORE_LOWER_TRIANGULAR = 12,
494382164b0SBarry Smith               MAT_ERROR_LOWER_TRIANGULAR = 13,
495382164b0SBarry Smith               MAT_GETROW_UPPERTRIANGULAR = 14,
496382164b0SBarry Smith               MAT_SPD = 15,
49792d4d306SBarry Smith               MAT_NO_OFF_PROC_ZERO_ROWS = 16,
49892d4d306SBarry Smith               MAT_NO_OFF_PROC_ENTRIES = 17,
49992d4d306SBarry Smith               MAT_NEW_NONZERO_LOCATIONS = 18,
500c5e4d11fSDmitry Karpeev               MAT_NEW_NONZERO_ALLOCATION_ERR = 19,
501c5e4d11fSDmitry Karpeev               MAT_SUBSET_OFF_PROC_ENTRIES = 20,
502c10200c1SHong Zhang               MAT_SUBMAT_SINGLEIS = 21,
503957cac9fSHong Zhang               MAT_STRUCTURE_ONLY = 22,
504071fcb05SBarry Smith               MAT_SORTED_FULL = 23,
5051a2c6b5cSJunchao Zhang               MAT_FORM_EXPLICIT_TRANSPOSE = 24,
506b94d7dedSBarry Smith               MAT_STRUCTURAL_SYMMETRY_ETERNAL = 25,
507b94d7dedSBarry Smith               MAT_SPD_ETERNAL = 26,
508b94d7dedSBarry Smith               MAT_OPTION_MAX = 27} MatOption;
509e057df02SPaul Mullowney 
5100f8fb01aSBarry Smith PETSC_EXTERN const char *const *MatOptions;
511014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOption(Mat,MatOption,PetscBool);
5127d68702bSBarry Smith PETSC_EXTERN PetscErrorCode MatGetOption(Mat,MatOption,PetscBool*);
513856afa8bSStefano Zampini PETSC_EXTERN PetscErrorCode MatPropagateSymmetryOptions(Mat,Mat);
51419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetType(Mat,MatType*);
51584cb2905SBarry Smith 
516014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]);
517014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
518014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
519014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat);
520014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat);
521014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat,Vec,PetscInt);
5228c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetArray(Mat,PetscScalar *[]);
5238f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayRead(Mat,const PetscScalar *[]);
524d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayWrite(Mat,PetscScalar *[]);
5258c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArray(Mat,PetscScalar *[]);
5268f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayRead(Mat,const PetscScalar *[]);
527d67d9f35SJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayWrite(Mat,PetscScalar *[]);
52821e72a00SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetMaxRowNonzeros(Mat,PetscInt*);
529bd04181cSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetValuesLocalFast(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
5304099cc6bSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetType(Mat,MatType);
531ad7e164aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatSeqAIJKron(Mat,Mat,MatReuse,Mat*);
532388d47a6SSatish Balay PETSC_EXTERN PetscErrorCode MatSeqAIJRegister(const char[],PetscErrorCode (*)(Mat,MatType,MatReuse,Mat *));
5334099cc6bSBarry Smith PETSC_EXTERN PetscFunctionList MatSeqAIJList;
534cda14afcSprj- PETSC_EXTERN PetscErrorCode MatSeqBAIJGetArray(Mat,PetscScalar *[]);
535cda14afcSprj- PETSC_EXTERN PetscErrorCode MatSeqBAIJRestoreArray(Mat,PetscScalar *[]);
5368397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJGetArray(Mat,PetscScalar *[]);
5378397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJRestoreArray(Mat,PetscScalar *[]);
5388c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArray(Mat,PetscScalar *[]);
5398c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArray(Mat,PetscScalar *[]);
540d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDensePlaceArray(Mat,const PetscScalar[]);
541d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseReplaceArray(Mat,const PetscScalar[]);
542d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseResetArray(Mat);
5438572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArrayRead(Mat,const PetscScalar *[]);
5448572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayRead(Mat,const PetscScalar *[]);
5456947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetArrayWrite(Mat,PetscScalar *[]);
5466947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayWrite(Mat,PetscScalar *[]);
547014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat,PetscInt *);
548014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat,PetscInt);
549014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat,PetscInt *,PetscInt *);
550014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat,PetscInt,PetscInt);
55133d57670SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizesFromMats(Mat,Mat,Mat);
5520da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetVariableBlockSizes(Mat,PetscInt,PetscInt*);
5530da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetVariableBlockSizes(Mat,PetscInt*,const PetscInt**);
5540da83c2eSBarry Smith 
55586aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat,PetscInt,PetscScalar*[]);
55686aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat,PetscScalar*[]);
5576947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVec(Mat,PetscInt,Vec*);
5586947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVec(Mat,PetscInt,Vec*);
5596947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecRead(Mat,PetscInt,Vec*);
5606947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecRead(Mat,PetscInt,Vec*);
5616947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseGetColumnVecWrite(Mat,PetscInt,Vec*);
5626947451fSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseRestoreColumnVecWrite(Mat,PetscInt,Vec*);
563a2748737SPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseGetSubMatrix(Mat,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
5645ea7661aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatDenseRestoreSubMatrix(Mat,Mat*);
5651620fd73SBarry Smith 
566014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMult(Mat,Vec,Vec);
567014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat,Vec,Vec);
568014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAdd(Mat,Vec,Vec,Vec);
569014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat,Vec,Vec);
570014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat,Vec,Vec);
571014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat,Mat,PetscReal,PetscBool *);
572014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat,Mat,PetscReal,PetscBool *);
573014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat,Vec,Vec,Vec);
574014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat,Vec,Vec,Vec);
575014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatSolve(Mat,Mat,Mat);
576bdc285e1SStefano Zampini PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat,Mat,Mat);
577eb3ef3b2SHong Zhang PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat,Mat,Mat);
578f9426fe0SMark Adams PETSC_EXTERN PetscErrorCode MatResidual(Mat,Vec,Vec,Vec);
579f5edf698SHong Zhang 
580d91e6319SBarry Smith /*E
581d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
582d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
583d91e6319SBarry Smith 
584d91e6319SBarry Smith     Level: beginner
585d91e6319SBarry Smith 
586af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
587d91e6319SBarry Smith 
588*87497f52SBarry Smith $   `MAT_DO_NOT_COPY_VALUES`    - Create a matrix using the same nonzero pattern as the original matrix,
5890018da39SRichard Tran Mills $                               with zeros for the numerical values.
590*87497f52SBarry Smith $   `MAT_COPY_VALUES`           - Create a matrix with the same nonzero pattern as the original matrix
5910018da39SRichard Tran Mills $                               and with the same numerical values.
592*87497f52SBarry Smith $   `MAT_SHARE_NONZERO_PATTERN` - Create a matrix that shares the nonzero structure with the previous matrix
5930018da39SRichard Tran Mills $                               and does not copy it, using zeros for the numerical values. The parent and
5940018da39SRichard Tran Mills $                               child matrices will share their index (i and j) arrays, and you cannot
5950018da39SRichard Tran Mills $                               insert new nonzero entries into either matrix.
5960018da39SRichard Tran Mills 
597*87497f52SBarry Smith   Note:
598*87497f52SBarry Smith   Many matrix types (including `MATSEQAIJ`) do not support the `MAT_SHARE_NONZERO_PATTERN` optimization; in
599*87497f52SBarry Smith   this case the behavior is as if `MAT_DO_NOT_COPY_VALUES` has been specified.
60070dcbbb9SBarry Smith 
601db781477SPatrick Sanan .seealso: `MatDuplicate()`
602d91e6319SBarry Smith E*/
60370dcbbb9SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES,MAT_SHARE_NONZERO_PATTERN} MatDuplicateOption;
6042e8a6d31SBarry Smith 
60519fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatConvert(Mat,MatType,MatReuse,Mat*);
606014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDuplicate(Mat,MatDuplicateOption,Mat*);
60794a9d846SBarry Smith 
608014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCopy(Mat,Mat,MatStructure);
609014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatView(Mat,PetscViewer);
610014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat,PetscReal,PetscBool *);
611014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat,PetscBool *);
612014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat,PetscReal,PetscBool *);
613014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat,PetscBool *,PetscBool *);
614014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat,PetscBool *,PetscBool *);
615b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetricKnown(Mat,PetscBool *,PetscBool*);
616b94d7dedSBarry Smith PETSC_EXTERN PetscErrorCode MatIsSPDKnown(Mat,PetscBool*,PetscBool*);
617014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat,PetscBool  *,PetscInt *);
618014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer);
6197b80b807SBarry Smith 
6201a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt*,const PetscInt *[],const PetscInt *[],PetscBool  *);
6211a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt *,const PetscInt *[],const PetscInt *[],PetscBool  *);
6221a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt*,const PetscInt *[],const PetscInt *[],PetscBool  *);
6231a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt *,const PetscInt *[],const PetscInt *[],PetscBool  *);
624d4fbbf0eSBarry Smith 
625d91e6319SBarry Smith /*S
626*87497f52SBarry Smith      MatInfo - Context of matrix information, used with `MatGetInfo()`
627d91e6319SBarry Smith 
628*87497f52SBarry Smith    In Fortran this is simply a double precision array of dimension `MAT_INFO_SIZE`
629d91e6319SBarry Smith 
630d91e6319SBarry Smith    Level: intermediate
631d91e6319SBarry Smith 
632db781477SPatrick Sanan .seealso: `MatGetInfo()`, `MatInfoType`
633d91e6319SBarry Smith S*/
6344e220ebcSLois Curfman McInnes typedef struct {
635b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
636b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
637b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
638b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
639b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
640b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
641b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
6424e220ebcSLois Curfman McInnes } MatInfo;
6434e220ebcSLois Curfman McInnes 
644d9274352SBarry Smith /*E
645d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
646d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
647d9274352SBarry Smith 
648d9274352SBarry Smith     Level: beginner
649d9274352SBarry Smith 
650af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
651d9274352SBarry Smith 
652db781477SPatrick Sanan .seealso: `MatGetInfo()`, `MatInfo`
653d9274352SBarry Smith E*/
6547b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
655014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInfo(Mat,MatInfoType,MatInfo*);
656014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat,Vec);
657014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat,Vec,PetscInt[]);
658014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat,Vec,PetscInt[]);
659014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat,Vec,PetscInt[]);
660014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat,Vec,PetscInt[]);
661014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat,Vec);
662014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTranspose(Mat,MatReuse,Mat*);
6637fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSymbolic(Mat,Mat*);
6647fb60732SBarry Smith PETSC_EXTERN PetscErrorCode MatTransposeSetPrecursor(Mat,Mat);
665014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat,MatReuse,Mat*);
666014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPermute(Mat,IS,IS,Mat*);
667014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat,Vec,Vec);
668014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat,Vec,InsertMode);
669a52676ecSHong Zhang 
670014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatEqual(Mat,Mat,PetscBool*);
671014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultEqual(Mat,Mat,PetscInt,PetscBool*);
672014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat,Mat,PetscInt,PetscBool*);
673014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat,Mat,PetscInt,PetscBool*);
674014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscBool*);
675e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeEqual(Mat,Mat,PetscInt,PetscBool*);
676e573050aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAddEqual(Mat,Mat,PetscInt,PetscBool*);
677a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat,Mat,Mat,PetscInt,PetscBool*);
678a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat,Mat,Mat,PetscInt,PetscBool*);
679cc48ffa7SToby Isaac PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat,Mat,Mat,PetscInt,PetscBool*);
6804222ddf1SHong Zhang PETSC_EXTERN PetscErrorCode MatPtAPMultEqual(Mat,Mat,Mat,PetscInt,PetscBool*);
681447fed29SStefano Zampini PETSC_EXTERN PetscErrorCode MatRARtMultEqual(Mat,Mat,Mat,PetscInt,PetscBool*);
68286919fd6SHong Zhang PETSC_EXTERN PetscErrorCode MatIsLinear(Mat,PetscInt,PetscBool*);
6837b80b807SBarry Smith 
684014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNorm(Mat,NormType,PetscReal*);
685014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat,NormType,PetscReal*);
686857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSums(Mat,PetscScalar*);
687857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsRealPart(Mat,PetscReal*);
688857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnSumsImaginaryPart(Mat,PetscReal*);
689857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeans(Mat,PetscScalar*);
690857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansRealPart(Mat,PetscReal*);
691857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnMeansImaginaryPart(Mat,PetscReal*);
692857cbf51SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetColumnReductions(Mat,PetscInt,PetscReal*);
693014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat);
6941b2b9847SBarry Smith PETSC_EXTERN PetscErrorCode MatSetInf(Mat);
695014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRows(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec);
696014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat,IS,PetscScalar,Vec,Vec);
697014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat,PetscInt,const MatStencil [],PetscScalar,Vec,Vec);
698014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat,PetscInt,const MatStencil[],PetscScalar,Vec,Vec);
699014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec);
700014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat,IS,PetscScalar,Vec,Vec);
7017b80b807SBarry Smith 
702014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSize(Mat,PetscInt*,PetscInt*);
703014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat,PetscInt*,PetscInt*);
704014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat,PetscInt*,PetscInt*);
705014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat,const PetscInt**);
706014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat,PetscInt*,PetscInt*);
707014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat,const PetscInt**);
708566876eaSJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat,IS*,IS*);
7095ef9f2a5SBarry Smith 
7107dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
7119fbee547SJacob 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[]) {return MatCreateSubMatrices(mat,n,irow,icol,scall,submat);}
7127dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
7139fbee547SJacob 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[]) {return MatCreateSubMatricesMPI(mat,n,irow,icol,scall,submat);}
714014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt,Mat *[]);
715df750dc8SHong Zhang PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt,Mat *[]);
7167dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat,IS,IS,MatReuse,Mat *);
7179fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatrix() (since version 3.8)") static inline PetscErrorCode MatGetSubMatrix(Mat mat,IS isrow,IS iscol,MatReuse cll,Mat *newmat) {return MatCreateSubMatrix(mat,isrow,iscol,cll,newmat);}
718014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat,IS,IS,Mat*);
719014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat,IS,IS,Mat*);
720014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat,Mat*);
721014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat*);
7227b80b807SBarry Smith 
723014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*);
724014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*);
725014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat,Mat);
726014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat,MatReuse,Mat*);
7278a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatAIJGetLocalMat(Mat,Mat*);
728014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*);
729ed502f03SStefano Zampini PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatMerge(Mat,MatReuse,IS*,Mat*);
730f2afee66SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJGetNumberNonzeros(Mat,PetscCount*);
731014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,Mat*);
732014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *,const PetscInt *[]);
7338efafbd8SBarry Smith 
734014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt);
735aa1e27eaSFande Kong PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat mat,PetscInt n,IS is[],PetscInt ov);
736d2b2a242SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat,PetscBool);
7377b80b807SBarry Smith 
738014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
73922440eb1SKris Buschelman 
7407bab7c10SHong Zhang PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat,Mat,Mat,MatReuse,PetscReal,Mat*);
7412df6c5c3SPatrick Farrell PETSC_EXTERN PetscErrorCode MatGalerkin(Mat,Mat,Mat,MatReuse,PetscReal,Mat*);
7427bab7c10SHong Zhang 
743014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*);
744014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARt(Mat,Mat,MatReuse,PetscReal,Mat*);
74522440eb1SKris Buschelman 
746014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
747014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat,Mat,MatReuse,PetscReal,Mat*);
748bc011b1eSHong Zhang 
749014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAXPY(Mat,PetscScalar,Mat,MatStructure);
750014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAYPX(Mat,PetscScalar,Mat,MatStructure);
7511c741599SHong Zhang 
752014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScale(Mat,PetscScalar);
753014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShift(Mat,PetscScalar);
7547b80b807SBarry Smith 
755014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping,ISLocalToGlobalMapping);
756014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping*,ISLocalToGlobalMapping*);
757a93ff8c4SPeter Brune PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat,PetscLayout*,PetscLayout*);
75881fa06acSBarry Smith PETSC_EXTERN PetscErrorCode MatSetLayouts(Mat,PetscLayout,PetscLayout);
759014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec);
760014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat,IS,PetscScalar,Vec,Vec);
761014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec);
762014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat,IS,PetscScalar,Vec,Vec);
763e265f6d6SPatrick Sanan PETSC_EXTERN PetscErrorCode MatGetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]);
764014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
765014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
766052efed2SBarry Smith 
767014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat,PetscInt,PetscInt);
768014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
76990f02eecSBarry Smith 
770014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolate(Mat,Vec,Vec);
771014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat,Vec,Vec,Vec);
772014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestrict(Mat,Vec,Vec);
77330b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolate(Mat,Mat,Mat*);
77430b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatInterpolateAdd(Mat,Mat,Mat,Mat*);
77530b0564aSStefano Zampini PETSC_EXTERN PetscErrorCode MatMatRestrict(Mat,Mat,Mat*);
7762a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat,Vec*,Vec*);
7779fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatCreateVecs() (since version 3.6)") static inline PetscErrorCode MatGetVecs(Mat mat,Vec *x,Vec *y) {return MatCreateVecs(mat,x,y);}
77853cd1579SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat,PetscInt,MPI_Comm,MatReuse,Mat*);
779014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat,MPI_Comm,MatReuse,Mat*);
780014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat,IS*);
7813a062f41SBarry Smith PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat,IS*);
7829c8f2541SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm,Mat,PetscInt,MatReuse,Mat*);
783bd481603SBarry Smith 
784bd481603SBarry Smith /*MC
7851620fd73SBarry Smith    MatSetValue - Set a single entry into a matrix.
7861620fd73SBarry Smith 
7871620fd73SBarry Smith    Not collective
7881620fd73SBarry Smith 
789a9834a7dSSatish Balay    Synopsis:
790a9834a7dSSatish Balay      #include <petscmat.h>
791a9834a7dSSatish Balay      PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode)
792a9834a7dSSatish Balay 
7931620fd73SBarry Smith    Input Parameters:
7941620fd73SBarry Smith +  m - the matrix
7951620fd73SBarry Smith .  row - the row location of the entry
7961620fd73SBarry Smith .  col - the column location of the entry
7971620fd73SBarry Smith .  value - the value to insert
798*87497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
7991620fd73SBarry Smith 
8001620fd73SBarry Smith    Notes:
801*87497f52SBarry Smith    For efficiency one should use `MatSetValues()` and set several values simultaneously.
8021620fd73SBarry Smith 
8031620fd73SBarry Smith    Level: beginner
8041620fd73SBarry Smith 
805db781477SPatrick Sanan .seealso: `MatGetValue()`, `MatSetValues()`, `MatSetValueLocal()`, `MatSetValuesLocal()`
8061620fd73SBarry Smith M*/
8079fbee547SJacob Faibussowitsch static inline PetscErrorCode MatSetValue(Mat v,PetscInt i,PetscInt j,PetscScalar va,InsertMode mode) {return MatSetValues(v,1,&i,1,&j,&va,mode);}
8081620fd73SBarry Smith 
809e5e5a7b5SPatrick Sanan /*@C
810e5e5a7b5SPatrick Sanan    MatGetValue - Gets a single value from a matrix
8111620fd73SBarry Smith 
812e5e5a7b5SPatrick Sanan    Not Collective; can only return a value owned by the given process
813e5e5a7b5SPatrick Sanan 
814e5e5a7b5SPatrick Sanan    Input Parameters:
815e5e5a7b5SPatrick Sanan +  mat - the matrix
816e5e5a7b5SPatrick Sanan .  row - the row location of the entry
817e5e5a7b5SPatrick Sanan -  col - the column location of the entry
818e5e5a7b5SPatrick Sanan 
819e5e5a7b5SPatrick Sanan    Output Parameter:
820e5e5a7b5SPatrick Sanan .  va - the value
821e5e5a7b5SPatrick Sanan 
822e5e5a7b5SPatrick Sanan    Notes:
823*87497f52SBarry Smith    For efficiency one should use `MatGetValues()` and get several values simultaneously.
824e5e5a7b5SPatrick Sanan 
825*87497f52SBarry Smith    See notes for `MatGetValues()`.
826e5e5a7b5SPatrick Sanan 
827e5e5a7b5SPatrick Sanan    Level: advanced
828e5e5a7b5SPatrick Sanan 
829db781477SPatrick Sanan .seealso: `MatSetValue()`, `MatGetValueLocal()`, `MatGetValues()`
830e5e5a7b5SPatrick Sanan @*/
8319fbee547SJacob Faibussowitsch static inline PetscErrorCode MatGetValue(Mat mat,PetscInt row,PetscInt col,PetscScalar *va) {return MatGetValues(mat,1,&row,1,&col,va);}
832e5e5a7b5SPatrick Sanan 
833e5e5a7b5SPatrick Sanan /*MC
834e5e5a7b5SPatrick Sanan    MatSetValueLocal - Inserts or adds a single value into a matrix,
835e5e5a7b5SPatrick Sanan    using a local numbering of the nodes.
836e5e5a7b5SPatrick Sanan 
837e5e5a7b5SPatrick Sanan    Not Collective
838e5e5a7b5SPatrick Sanan 
839e5e5a7b5SPatrick Sanan    Input Parameters:
840e5e5a7b5SPatrick Sanan +  m - the matrix
841e5e5a7b5SPatrick Sanan .  row - the row location of the entry
842e5e5a7b5SPatrick Sanan .  col - the column location of the entry
843e5e5a7b5SPatrick Sanan .  value - the value to insert
844*87497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
845e5e5a7b5SPatrick Sanan 
846e5e5a7b5SPatrick Sanan    Notes:
847*87497f52SBarry Smith    For efficiency one should use `MatSetValuesLocal()` and set several values simultaneously.
848e5e5a7b5SPatrick Sanan 
849*87497f52SBarry Smith    See notes for `MatSetValuesLocal()` for additional information on when and how this function can be used.
850e5e5a7b5SPatrick Sanan 
851e5e5a7b5SPatrick Sanan    Level: intermediate
852e5e5a7b5SPatrick Sanan 
853db781477SPatrick Sanan .seealso: `MatSetValue()`, `MatSetValuesLocal()`
854e5e5a7b5SPatrick Sanan M*/
8559fbee547SJacob Faibussowitsch static inline PetscErrorCode MatSetValueLocal(Mat v,PetscInt i,PetscInt j,PetscScalar va,InsertMode mode) {return MatSetValuesLocal(v,1,&i,1,&j,&va,mode);}
8561620fd73SBarry Smith 
8571620fd73SBarry Smith /*MC
858d0609cedSBarry Smith    MatPreallocateBegin - Begins the block of code that will count the number of nonzeros per
859bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
860bd481603SBarry Smith 
861bd481603SBarry Smith    Synopsis:
862aaa7dc30SBarry Smith    #include <petscmat.h>
863d0609cedSBarry Smith    PetscErrorCode MatPreallocateBegin(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
864bd481603SBarry Smith 
865d083f849SBarry Smith    Collective
866bd481603SBarry Smith 
867bd481603SBarry Smith    Input Parameters:
868bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
869859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
870859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
871bd481603SBarry Smith 
872bd481603SBarry Smith    Output Parameters:
873bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
874a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
875bd481603SBarry Smith 
876bd481603SBarry Smith    Level: intermediate
877bd481603SBarry Smith 
878bd481603SBarry Smith    Notes:
879d0609cedSBarry Smith     This is a macro that handles its own error checking, it does not return an error code.
880d0609cedSBarry Smith 
881a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
882bd481603SBarry Smith 
8831d73ed98SBarry Smith     Do not malloc or free dnz and onz, that is handled internally by these routines
884bd481603SBarry Smith 
885d0609cedSBarry Smith    Developer Notes:
8861620fd73SBarry Smith     This is a MACRO not a function because it has a leading { that is closed by PetscPreallocateFinalize().
8871620fd73SBarry Smith 
888db781477SPatrick Sanan .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
889db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
890bd481603SBarry Smith M*/
891d0609cedSBarry Smith #define MatPreallocateBegin(comm,nrows,ncols,dnz,onz)  do {                             \
8925f80ce2aSJacob Faibussowitsch   PetscInt __nrows = (nrows),__ncols = (ncols),__rstart,__start,__end = 0;                     \
8939566063dSJacob Faibussowitsch   PetscCall(PetscCalloc2(__nrows,&(dnz),__nrows,&(onz)));                                        \
8949566063dSJacob Faibussowitsch   PetscCallMPI(MPI_Scan(&__ncols,&__end,1,MPIU_INT,MPI_SUM,comm));                                \
8955f80ce2aSJacob Faibussowitsch   __start = __end - __ncols; (void)__start;                                                    \
8969566063dSJacob Faibussowitsch   PetscCallMPI(MPI_Scan(&__nrows,&__rstart,1,MPIU_INT,MPI_SUM,comm));                             \
8975f80ce2aSJacob Faibussowitsch   __rstart -= __nrows
8987c922b88SBarry Smith 
899d0609cedSBarry Smith #define MatPreallocateInitialize(...) PETSC_DEPRECATED_MACRO("GCC warning \"Use MatPreallocateBegin() (since version 3.18)\"") MatPreallocateBegin(__VA_ARGS__)
900d0609cedSBarry Smith 
901bd481603SBarry Smith /*MC
902bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
903bd481603SBarry Smith        inserted using a local number of the rows and columns
904bd481603SBarry Smith 
905bd481603SBarry Smith    Synopsis:
906aaa7dc30SBarry Smith    #include <petscmat.h>
907c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
908bd481603SBarry Smith 
909bd481603SBarry Smith    Not Collective
910bd481603SBarry Smith 
911bd481603SBarry Smith    Input Parameters:
912784ac674SJed Brown +  map - the row mapping from local numbering to global numbering
913bd481603SBarry Smith .  nrows - the number of rows indicated
9141d73ed98SBarry Smith .  rows - the indices of the rows
915784ac674SJed Brown .  cmap - the column mapping from local to global numbering
916bd481603SBarry Smith .  ncols - the number of columns in the matrix
917bd481603SBarry Smith .  cols - the columns indicated
918bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
919a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
920bd481603SBarry Smith 
921bd481603SBarry Smith    Level: intermediate
922bd481603SBarry Smith 
923bd481603SBarry Smith    Notes:
924a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
925bd481603SBarry Smith 
9261d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
927bd481603SBarry Smith 
928db781477SPatrick Sanan .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
929db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocalRemoveDups()`
930bd481603SBarry Smith M*/
93194bad497SJacob Faibussowitsch #define MatPreallocateSetLocal(rmap,nrows,rows,cmap,ncols,cols,dnz,onz)                        \
93294bad497SJacob Faibussowitsch   PetscMacroReturnStandard(                                                                    \
9339566063dSJacob Faibussowitsch     PetscCall(ISLocalToGlobalMappingApply(rmap,nrows,rows,rows));                                \
9349566063dSJacob Faibussowitsch     PetscCall(ISLocalToGlobalMappingApply(cmap,ncols,cols,cols));                                \
9359566063dSJacob Faibussowitsch     for (PetscInt __l=0;__l<nrows;__l++) PetscCall(MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz)); \
93694bad497SJacob Faibussowitsch   )
937c4f061fbSSatish Balay 
938bd481603SBarry Smith /*MC
939c1154cd5SBarry Smith    MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be
940c1154cd5SBarry Smith        inserted using a local number of the rows and columns. This version removes any duplicate columns in cols
941c1154cd5SBarry Smith 
942c1154cd5SBarry Smith    Synopsis:
943c1154cd5SBarry Smith    #include <petscmat.h>
944c1154cd5SBarry Smith    PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
945c1154cd5SBarry Smith 
946c1154cd5SBarry Smith    Not Collective
947c1154cd5SBarry Smith 
948c1154cd5SBarry Smith    Input Parameters:
949c1154cd5SBarry Smith +  map - the row mapping from local numbering to global numbering
950c1154cd5SBarry Smith .  nrows - the number of rows indicated
951c1154cd5SBarry Smith .  rows - the indices of the rows (these values are mapped to the global values)
952c1154cd5SBarry Smith .  cmap - the column mapping from local to global numbering
953c1154cd5SBarry Smith .  ncols - the number of columns in the matrix   (this value will be changed if duplicate columns are found)
954c1154cd5SBarry Smith .  cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed)
955c1154cd5SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
956a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
957c1154cd5SBarry Smith 
958c1154cd5SBarry Smith    Level: intermediate
959c1154cd5SBarry Smith 
960c1154cd5SBarry Smith    Notes:
961c1154cd5SBarry Smith     See Users-Manual: ch_performance for more details.
962c1154cd5SBarry Smith 
963c1154cd5SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
964c1154cd5SBarry Smith 
965db781477SPatrick Sanan .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
966db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
967c1154cd5SBarry Smith M*/
96894bad497SJacob Faibussowitsch #define MatPreallocateSetLocalRemoveDups(rmap,nrows,rows,cmap,ncols,cols,dnz,onz)              \
96994bad497SJacob Faibussowitsch   PetscMacroReturnStandard(                                                                    \
9709566063dSJacob Faibussowitsch     PetscCall(ISLocalToGlobalMappingApply(rmap,nrows,rows,rows));                                \
9719566063dSJacob Faibussowitsch     PetscCall(ISLocalToGlobalMappingApply(cmap,ncols,cols,cols));                                \
9729566063dSJacob Faibussowitsch     PetscCall(PetscSortRemoveDupsInt(&ncols,cols));                                              \
9739566063dSJacob Faibussowitsch     for (PetscInt __l=0;__l<nrows;__l++) PetscCall(MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz)); \
97494bad497SJacob Faibussowitsch   )
975c1154cd5SBarry Smith 
976c1154cd5SBarry Smith /*MC
977d6e23781SBarry Smith    MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
978bd481603SBarry Smith        inserted using a local number of the rows and columns
979bd481603SBarry Smith 
980bd481603SBarry Smith    Synopsis:
981aaa7dc30SBarry Smith    #include <petscmat.h>
982d6e23781SBarry Smith    PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
983d6e23781SBarry Smith 
984d6e23781SBarry Smith    Not Collective
985d6e23781SBarry Smith 
986d6e23781SBarry Smith    Input Parameters:
987d6e23781SBarry Smith +  map - the row mapping from local numbering to global numbering
988d6e23781SBarry Smith .  nrows - the number of rows indicated
989d6e23781SBarry Smith .  rows - the indices of the rows
990d6e23781SBarry Smith .  cmap - the column mapping from local to global numbering
991d6e23781SBarry Smith .  ncols - the number of columns in the matrix
992d6e23781SBarry Smith .  cols - the columns indicated
993d6e23781SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
994a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
995d6e23781SBarry Smith 
996d6e23781SBarry Smith    Level: intermediate
997d6e23781SBarry Smith 
998d6e23781SBarry Smith    Notes:
999d6e23781SBarry Smith     See Users-Manual: ch_performance for more details.
1000d6e23781SBarry Smith 
1001d6e23781SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
1002d6e23781SBarry Smith 
1003db781477SPatrick Sanan .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1004db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSymmetricSetLocalBlock()`
1005d6e23781SBarry Smith M*/
100694bad497SJacob Faibussowitsch #define MatPreallocateSetLocalBlock(rmap,nrows,rows,cmap,ncols,cols,dnz,onz)                   \
100794bad497SJacob Faibussowitsch   PetscMacroReturnStandard(                                                                    \
10089566063dSJacob Faibussowitsch     PetscCall(ISLocalToGlobalMappingApplyBlock(rmap,nrows,rows,rows));                           \
10099566063dSJacob Faibussowitsch     PetscCall(ISLocalToGlobalMappingApplyBlock(cmap,ncols,cols,cols));                           \
10109566063dSJacob Faibussowitsch     for (PetscInt __l=0;__l<nrows;__l++) PetscCall(MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz)); \
101194bad497SJacob Faibussowitsch   )
1012d6e23781SBarry Smith 
1013d6e23781SBarry Smith /*MC
1014d6e23781SBarry Smith    MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1015d6e23781SBarry Smith        inserted using a local number of the rows and columns
1016d6e23781SBarry Smith 
1017d6e23781SBarry Smith    Synopsis:
1018d6e23781SBarry Smith    #include <petscmat.h>
1019d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1020bd481603SBarry Smith 
1021bd481603SBarry Smith    Not Collective
1022bd481603SBarry Smith 
1023bd481603SBarry Smith    Input Parameters:
1024bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
1025bd481603SBarry Smith .  nrows - the number of rows indicated
10261d73ed98SBarry Smith .  rows - the indices of the rows
1027bd481603SBarry Smith .  ncols - the number of columns in the matrix
1028bd481603SBarry Smith .  cols - the columns indicated
1029bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1030a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1031bd481603SBarry Smith 
1032bd481603SBarry Smith    Level: intermediate
1033bd481603SBarry Smith 
1034bd481603SBarry Smith    Notes:
1035a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
1036bd481603SBarry Smith 
1037bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
1038bd481603SBarry Smith 
1039db781477SPatrick Sanan .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`
1040db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1041bd481603SBarry Smith M*/
104294bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetLocalBlock(map,nrows,rows,ncols,cols,dnz,onz)                \
104394bad497SJacob Faibussowitsch   PetscMacroReturnStandard(                                                                    \
10449566063dSJacob Faibussowitsch     PetscCall(ISLocalToGlobalMappingApplyBlock(map,nrows,rows,rows));                            \
10459566063dSJacob Faibussowitsch     PetscCall(ISLocalToGlobalMappingApplyBlock(map,ncols,cols,cols));                            \
10469566063dSJacob Faibussowitsch     for (PetscInt __l=0;__l<nrows;__l++) PetscCall(MatPreallocateSymmetricSetBlock((rows)[__l],ncols,cols,dnz,onz)); \
104794bad497SJacob Faibussowitsch   )
1048e83a5d19SLisandro Dalcin 
1049bd481603SBarry Smith /*MC
1050bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1051bd481603SBarry Smith        inserted using a local number of the rows and columns
1052bd481603SBarry Smith 
1053bd481603SBarry Smith    Synopsis:
1054aaa7dc30SBarry Smith    #include <petscmat.h>
1055c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1056bd481603SBarry Smith 
1057bd481603SBarry Smith    Not Collective
1058bd481603SBarry Smith 
1059bd481603SBarry Smith    Input Parameters:
106064075487SBarry Smith +  row - the row
1061bd481603SBarry Smith .  ncols - the number of columns in the matrix
1062a50f8bf6SHong Zhang -  cols - the columns indicated
1063a50f8bf6SHong Zhang 
1064a50f8bf6SHong Zhang    Output Parameters:
1065a50f8bf6SHong Zhang +  dnz - the array that will be passed to the matrix preallocation routines
1066a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1067bd481603SBarry Smith 
1068bd481603SBarry Smith    Level: intermediate
1069bd481603SBarry Smith 
1070bd481603SBarry Smith    Notes:
1071a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
1072bd481603SBarry Smith 
1073bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
1074bd481603SBarry Smith 
1075d0609cedSBarry Smith    This is a MACRO not a function because it uses variables declared in MatPreallocateBegin().
10761620fd73SBarry Smith 
1077db781477SPatrick Sanan .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`
1078db781477SPatrick Sanan           `MatPreallocateBegin()`, `MatPreallocateSetLocal()`
1079bd481603SBarry Smith M*/
108094bad497SJacob Faibussowitsch #define MatPreallocateSet(row,nc,cols,dnz,onz) PetscMacroReturnStandard(                       \
10812c71b3e2SJacob Faibussowitsch     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); \
10822c71b3e2SJacob Faibussowitsch     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); \
10835f80ce2aSJacob Faibussowitsch     for (PetscInt __i = 0; __i < nc; ++__i) {                                                  \
108464075487SBarry Smith       if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++;                \
1085a6042fd4SStefano Zampini       else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++;                           \
10867c922b88SBarry Smith     }                                                                                          \
108794bad497SJacob Faibussowitsch   )
10887c922b88SBarry Smith 
1089bd481603SBarry Smith /*MC
1090d6e23781SBarry Smith    MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
1091bd481603SBarry Smith        inserted using a local number of the rows and columns
1092bd481603SBarry Smith 
1093bd481603SBarry Smith    Synopsis:
1094aaa7dc30SBarry Smith    #include <petscmat.h>
1095d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
1096bd481603SBarry Smith 
1097bd481603SBarry Smith    Not Collective
1098bd481603SBarry Smith 
1099bd481603SBarry Smith    Input Parameters:
1100bd481603SBarry Smith +  nrows - the number of rows indicated
11011d73ed98SBarry Smith .  rows - the indices of the rows
1102bd481603SBarry Smith .  ncols - the number of columns in the matrix
1103bd481603SBarry Smith .  cols - the columns indicated
1104bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1105a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1106bd481603SBarry Smith 
1107bd481603SBarry Smith    Level: intermediate
1108bd481603SBarry Smith 
1109bd481603SBarry Smith    Notes:
1110a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
1111bd481603SBarry Smith 
1112bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
1113bd481603SBarry Smith 
1114d0609cedSBarry Smith    This is a MACRO not a function because it uses variables declared in MatPreallocateBegin().
11151620fd73SBarry Smith 
1116db781477SPatrick Sanan .seealso: `MatPreallocateEnd()`, `MatPreallocateSet()`, `MatPreallocateBegin()`,
1117db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`, `MatPreallocateSetLocal()`
1118bd481603SBarry Smith M*/
111994bad497SJacob Faibussowitsch #define MatPreallocateSymmetricSetBlock(row,nc,cols,dnz,onz)                                   \
112094bad497SJacob Faibussowitsch   PetscMacroReturnStandard(                                                                    \
11215f80ce2aSJacob Faibussowitsch     for (PetscInt __i=0; __i<nc; __i++) {                                                      \
1122d3d32019SBarry Smith       if (cols[__i] >= __end) onz[row - __rstart]++;                                           \
1123a6042fd4SStefano Zampini       else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++;       \
1124d3d32019SBarry Smith     }                                                                                          \
112594bad497SJacob Faibussowitsch   )
1126d3d32019SBarry Smith 
1127bd481603SBarry Smith /*MC
1128a6042fd4SStefano Zampini    MatPreallocateLocation -  An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists
112916371a99SBarry Smith 
113016371a99SBarry Smith    Synopsis:
1131aaa7dc30SBarry Smith    #include <petscmat.h>
113216371a99SBarry Smith    PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz)
113316371a99SBarry Smith 
113416371a99SBarry Smith    Not Collective
113516371a99SBarry Smith 
113616371a99SBarry Smith    Input Parameters:
1137a2b725a8SWilliam Gropp +  A - matrix
113816371a99SBarry Smith .  row - row where values exist (must be local to this process)
113916371a99SBarry Smith .  ncols - number of columns
114016371a99SBarry Smith .  cols - columns with nonzeros
114116371a99SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
1142a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
114316371a99SBarry Smith 
114416371a99SBarry Smith    Level: intermediate
114516371a99SBarry Smith 
114616371a99SBarry Smith    Notes:
1147a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
114816371a99SBarry Smith 
114916371a99SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
115016371a99SBarry Smith 
115116371a99SBarry Smith    This is a MACRO not a function because it uses a bunch of variables private to the MatPreallocation.... routines.
115216371a99SBarry Smith 
1153db781477SPatrick Sanan .seealso: `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1154db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
115516371a99SBarry Smith M*/
1156d0609cedSBarry 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))
115716371a99SBarry Smith 
115816371a99SBarry Smith /*MC
1159d0609cedSBarry Smith    MatPreallocateEnd - Ends the block of code that will count the number of nonzeros per
1160bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
1161bd481603SBarry Smith 
1162bd481603SBarry Smith    Synopsis:
1163aaa7dc30SBarry Smith    #include <petscmat.h>
1164d0609cedSBarry Smith    PetscErrorCode MatPreallocateEnd(PetscInt *dnz, PetscInt *onz)
1165bd481603SBarry Smith 
1166d083f849SBarry Smith    Collective
1167bd481603SBarry Smith 
1168bd481603SBarry Smith    Input Parameters:
116916371a99SBarry Smith +  dnz - the array that was be passed to the matrix preallocation routines
1170a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1171bd481603SBarry Smith 
1172bd481603SBarry Smith    Level: intermediate
1173bd481603SBarry Smith 
1174bd481603SBarry Smith    Notes:
1175d0609cedSBarry Smith     This is a macro that handles its own error checking, it does not return an error code.
1176d0609cedSBarry Smith 
1177a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
1178bd481603SBarry Smith 
1179d0609cedSBarry Smith     Do not malloc or free dnz and onz, that is handled internally by these routines
1180bd481603SBarry Smith 
1181d0609cedSBarry Smith    Developer Notes:
1182d0609cedSBarry Smith     This is a MACRO not a function because it closes the { started in MatPreallocateBegin().
11831620fd73SBarry Smith 
1184db781477SPatrick Sanan .seealso: `MatPreallocateBegin()`, `MatPreallocateSet()`, `MatPreallocateSymmetricSetBlock()`, `MatPreallocateSetLocal()`,
1185db781477SPatrick Sanan           `MatPreallocateSymmetricSetLocalBlock()`
1186bd481603SBarry Smith M*/
1187d0609cedSBarry Smith #define MatPreallocateEnd(dnz,onz) PetscCall(PetscFree2(dnz,onz));} while (0)
1188d0609cedSBarry Smith 
1189d0609cedSBarry Smith #define MatPreallocateFinalize(...) PETSC_DEPRECATED_MACRO("GCC warning \"Use MatPreallocateEnd() (since version 3.18)\"") MatPreallocateEnd(__VA_ARGS__)
11907c922b88SBarry Smith 
11917b80b807SBarry Smith /* Routines unique to particular data structures */
1192014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat,void *);
1193698d4c6aSKris Buschelman 
1194014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat,IS*,IS*);
1195014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *);
1196698d4c6aSKris Buschelman 
1197014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat,PetscInt[]);
1198014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat,PetscInt[]);
1199014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
1200014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
1201014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
1202014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*,PetscInt,PetscBool);
12037b80b807SBarry Smith 
1204a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4
1205a96a251dSBarry Smith 
1206014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
1207014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
1208014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]);
120919b08ed1SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetTotalPreallocation(Mat,PetscInt);
1210273d9f13SBarry Smith 
1211014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
1212014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
1213014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
1214014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat,const PetscInt [],const PetscInt [],const PetscScalar []);
1215014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
1216014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]);
1217014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
1218014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]);
1219b44e7856SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat,Mat*);
1220252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeqRankZero(Mat,Mat*);
1221014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat,PetscScalar[]);
1222014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat,PetscScalar[]);
12239230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,const PetscInt*[]);
12249230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,const PetscInt*[]);
1225014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat,Mat*);
1226273d9f13SBarry Smith 
122749a6ff4bSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat,PetscInt*);
1228ad16ce7aSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseSetLDA(Mat,PetscInt);
12299fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatDenseSetLDA() (since version 3.14)") static inline PetscErrorCode MatSeqDenseSetLDA(Mat A,PetscInt lda) {return MatDenseSetLDA(A,lda);}
1230014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat,Mat*);
12311b807ce4Svictorle 
1232621e819fSSatish Balay PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
1233621e819fSSatish Balay 
1234014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStoreValues(Mat);
1235014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat);
12362e8a6d31SBarry Smith 
1237014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat,IS*);
12387cfe41e4SPatrick Farrell PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat,IS*);
12397b80b807SBarry Smith /*
12407b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
124194b7f48cSBarry Smith   done through the KSP and PC interfaces.
12427b80b807SBarry Smith */
12437b80b807SBarry Smith 
124476bdecfbSBarry Smith /*J
12458f6c3df8SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering
1246d9274352SBarry Smith 
1247d9274352SBarry Smith    Level: beginner
1248d9274352SBarry Smith 
12492c7c0729SBarry Smith    Notes:
1250*87497f52SBarry Smith       If `MATORDERINGEXTERNAL` is used then PETSc does not compute an ordering and utilizes one built into the factorization package
12512c7c0729SBarry Smith 
1252db781477SPatrick Sanan .seealso: `MatGetOrdering()`
125376bdecfbSBarry Smith J*/
125419fd82e9SBarry Smith typedef const char* MatOrderingType;
12552692d6eeSBarry Smith #define MATORDERINGNATURAL        "natural"
12562692d6eeSBarry Smith #define MATORDERINGND             "nd"
12572692d6eeSBarry Smith #define MATORDERING1WD            "1wd"
12582692d6eeSBarry Smith #define MATORDERINGRCM            "rcm"
12592692d6eeSBarry Smith #define MATORDERINGQMD            "qmd"
12602692d6eeSBarry Smith #define MATORDERINGROWLENGTH      "rowlength"
1261510184a7SJed Brown #define MATORDERINGWBM            "wbm"
1262fc1bef75SJed Brown #define MATORDERINGSPECTRAL       "spectral"
1263312e372aSBarry Smith #define MATORDERINGAMD            "amd"            /* only works if UMFPACK is installed with PETSc */
1264048412efSPablo Brubeck #define MATORDERINGMETISND        "metisnd"        /* only works if METIS is installed with PETSc */
12659bd791bbSBarry 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 */
12662c7c0729SBarry Smith #define MATORDERINGEXTERNAL       "external"       /* uses an ordering type internal to the factorization package */
1267b12f92e5SBarry Smith 
126819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat,MatOrderingType,IS*,IS*);
1269140e18c1SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFunctionList*);
1270bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[],PetscErrorCode(*)(Mat,MatOrderingType,IS*,IS*));
1271140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatOrderingList;
1272d4fbbf0eSBarry Smith 
1273014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
1274fc1bef75SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat,PetscReal,PetscBool,Mat*);
1275a2ce50c7SBarry Smith 
12764ac6704cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetPreferredOrdering(Mat,MatFactorType,MatOrderingType*);
12774ac6704cSBarry Smith 
1278d91e6319SBarry Smith /*S
1279ec5066bdSBarry Smith     MatFactorShiftType - Numeric Shift for factorizations
1280d90ac83dSHong Zhang 
1281d90ac83dSHong Zhang    Level: beginner
1282d90ac83dSHong Zhang 
1283db781477SPatrick Sanan .seealso: `MatGetFactor()`
1284d90ac83dSHong Zhang S*/
1285d90ac83dSHong Zhang typedef enum {MAT_SHIFT_NONE,MAT_SHIFT_NONZERO,MAT_SHIFT_POSITIVE_DEFINITE,MAT_SHIFT_INBLOCKS} MatFactorShiftType;
12866a6fc655SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypes[];
12875e9742b9SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypesDetail[];
1288d90ac83dSHong Zhang 
1289d90ac83dSHong Zhang /*S
1290ec5066bdSBarry Smith     MatFactorError - indicates what type of error was generated in a matrix factorization
12919aa7eafdSHong Zhang 
12929aa7eafdSHong Zhang     Level: beginner
12939aa7eafdSHong Zhang 
1294*87497f52SBarry Smith     Developer Note:
129595452b02SPatrick Sanan     Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
129600e125f8SBarry Smith 
1297db781477SPatrick Sanan .seealso: `MatGetFactor()`
12989aa7eafdSHong Zhang S*/
12995cd7cf9dSHong Zhang typedef enum {MAT_FACTOR_NOERROR,MAT_FACTOR_STRUCT_ZEROPIVOT,MAT_FACTOR_NUMERIC_ZEROPIVOT,MAT_FACTOR_OUTMEMORY,MAT_FACTOR_OTHER} MatFactorError;
13009aa7eafdSHong Zhang 
130100e125f8SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat,MatFactorError*);
1302b8b68cfdSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat);
13037b6c816cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat,PetscReal*,PetscInt*);
130400e125f8SBarry Smith 
13059aa7eafdSHong Zhang /*S
1306422a814eSBarry Smith    MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization
1307b00f7748SHong Zhang 
1308*87497f52SBarry Smith    In Fortran these are simply double precision arrays of size `MAT_FACTORINFO_SIZE`, that is use
130961cad860SBarry Smith $     MatFactorInfo  info(MAT_FACTORINFO_SIZE)
1310b00f7748SHong Zhang 
131195452b02SPatrick Sanan    Notes:
1312*87497f52SBarry Smith     These are not usually directly used by users, instead use `PC` type of `PCLU`, `PCILU`, `PCCHOLESKY` or `PCICC`.
1313b00f7748SHong Zhang 
1314*87497f52SBarry Smith       You can use `MatFactorInfoInitialize()` to set default values.
131561cad860SBarry Smith 
1316b00f7748SHong Zhang    Level: developer
1317b00f7748SHong Zhang 
1318db781477SPatrick Sanan .seealso: `MatLUFactorSymbolic()`, `MatILUFactorSymbolic()`, `MatCholeskyFactorSymbolic()`, `MatICCFactorSymbolic()`, `MatICCFactor()`,
1319db781477SPatrick Sanan           `MatFactorInfoInitialize()`
1320b00f7748SHong Zhang 
1321b00f7748SHong Zhang S*/
1322b00f7748SHong Zhang typedef struct {
132315e8a5b3SHong Zhang   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
132485317021SBarry Smith   PetscReal     usedt;
132515e8a5b3SHong Zhang   PetscReal     dt;             /* drop tolerance */
1326b00f7748SHong Zhang   PetscReal     dtcol;          /* tolerance for pivoting */
132715e8a5b3SHong Zhang   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
132867e28bfeSBarry Smith   PetscReal     fill;           /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */
1329348344bbSBarry Smith   PetscReal     levels;         /* ICC/ILU(levels) */
1330bcd9e38bSBarry Smith   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
1331bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
133215e8a5b3SHong Zhang   PetscReal     zeropivot;      /* pivot is called zero if less than this */
1333f4db908eSBarry Smith   PetscReal     shifttype;      /* type of shift added to matrix factor to prevent zero pivots */
1334f4db908eSBarry Smith   PetscReal     shiftamount;     /* how large the shift is */
133515e8a5b3SHong Zhang } MatFactorInfo;
1336ffa6d0a5SLois Curfman McInnes 
1337014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo*);
13389a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat,IS,const MatFactorInfo*);
13399a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat,Mat,IS,const MatFactorInfo*);
13409a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat,Mat,const MatFactorInfo*);
13419a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactor(Mat,IS,IS,const MatFactorInfo*);
13429a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactor(Mat,IS,IS,const MatFactorInfo*);
13439a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat,Mat,IS,IS,const MatFactorInfo*);
13449a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat,Mat,IS,IS,const MatFactorInfo*);
13459a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat,Mat,IS,const MatFactorInfo*);
13469a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactor(Mat,IS,const MatFactorInfo*);
13479a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat,Mat,const MatFactorInfo*);
13483f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactor(Mat,IS,const MatFactorInfo*);
13493f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorSymbolic(Mat,Mat,IS,const MatFactorInfo*);
13503f498edaSToby Isaac PETSC_EXTERN PetscErrorCode MatQRFactorNumeric(Mat,Mat,const MatFactorInfo*);
1351014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*);
1352014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolve(Mat,Vec,Vec);
1353014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat,Vec,Vec);
1354014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat,Vec,Vec);
1355014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat,Vec,Vec,Vec);
1356014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat,Vec,Vec);
1357014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
1358014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolves(Mat,Vecs,Vecs);
13597c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat);
13607c2f51b8SStefano Zampini 
13617c2f51b8SStefano Zampini typedef enum {MAT_FACTOR_SCHUR_UNFACTORED, MAT_FACTOR_SCHUR_FACTORED, MAT_FACTOR_SCHUR_INVERTED} MatFactorSchurStatus;
13628e7ba810SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat,IS);
13637c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat,Mat*,MatFactorSchurStatus*);
13647c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat,Mat*,MatFactorSchurStatus);
13655a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat);
13667c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat,Mat*,MatFactorSchurStatus*);
13675a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat,Vec,Vec);
13685a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat,Vec,Vec);
13696dba178dSStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat);
1370bb5a7306SBarry Smith 
13718a9c020eSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqDenseInvert(Mat);
1372d91e6319SBarry Smith /*E
1373d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
1374bb1eb677SSatish Balay 
1375d91e6319SBarry Smith     Level: beginner
1376d91e6319SBarry Smith 
1377d9274352SBarry Smith    May be bitwise ORd together
1378d9274352SBarry Smith 
1379*87497f52SBarry Smith    Developer Notes:
1380af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
1381d91e6319SBarry Smith 
1382*87497f52SBarry Smith   `MatSORType` may be bitwise ORd together, so do not change the numerical values
13834e7234bfSBarry Smith 
1384db781477SPatrick Sanan .seealso: `MatSOR()`
1385d91e6319SBarry Smith E*/
1386ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
1387ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
1388ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
138984cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
1390014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSOR(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
13918ed539a5SBarry Smith 
13927086a01eSPeter Brune /*S
13937086a01eSPeter Brune      MatColoring - Object for managing the coloring of matrices.
13947086a01eSPeter Brune 
13957086a01eSPeter Brune    Level: beginner
13967086a01eSPeter Brune 
1397ec5066bdSBarry Smith     Notes:
1398*87497f52SBarry 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
1399*87497f52SBarry Smith        matrix comes from via `DMCreateColoring()`. In general using the mesh produces a more optimal coloring (fewer colors).
1400ec5066bdSBarry Smith 
1401*87497f52SBarry Smith        Once a coloring is available `MatFDColoringCreate()` creates an object that can be used to efficiently compute Jacobians using that coloring. This
1402ec5066bdSBarry Smith        same object can also be used to efficiently convert data created by Automatic Differentation tools to PETSc sparse matrices.
1403ec5066bdSBarry Smith 
1404db781477SPatrick Sanan .seealso: `MatFDColoringCreate()`, `MatColoringWeightType`, `ISColoring`, `MatFDColoring`, `DMCreateColoring()`, `MatColoringCreate()`, `MatOrdering`, `MatPartitioning`, `MatColoringType`
14057086a01eSPeter Brune S*/
1406d4db15c4SBarry Smith typedef struct _p_MatColoring* MatColoring;
1407d4db15c4SBarry Smith 
1408d4db15c4SBarry Smith /*J
1409d4db15c4SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring
1410d9274352SBarry Smith 
1411d9274352SBarry Smith    Level: beginner
1412d9274352SBarry Smith 
1413db781477SPatrick Sanan .seealso: `MatColoringSetType()`, `MatColoring`
141476bdecfbSBarry Smith J*/
141519fd82e9SBarry Smith typedef const  char*           MatColoringType;
14165567d71aSPeter Brune #define MATCOLORINGJP      "jp"
1417b9acb617SPeter Brune #define MATCOLORINGPOWER   "power"
14182692d6eeSBarry Smith #define MATCOLORINGNATURAL "natural"
14192692d6eeSBarry Smith #define MATCOLORINGSL      "sl"
14202692d6eeSBarry Smith #define MATCOLORINGLF      "lf"
14212692d6eeSBarry Smith #define MATCOLORINGID      "id"
14228121bdceSPeter Brune #define MATCOLORINGGREEDY  "greedy"
1423b12f92e5SBarry Smith 
14248ac6da0aSPeter Brune /*E
14258ac6da0aSPeter Brune    MatColoringWeightType - Type of weight scheme
14268ac6da0aSPeter Brune 
14278ac6da0aSPeter Brune     Not Collective
14288ac6da0aSPeter Brune 
1429*87497f52SBarry Smith +   `MAT_COLORING_RANDOM`  - Random weights
1430*87497f52SBarry Smith .   `MAT_COLORING_LEXICAL` - Lexical weighting based upon global numbering.
1431*87497f52SBarry Smith -   `MAT_COLORING_LF`      - Last-first weighting.
14328ac6da0aSPeter Brune 
14338ac6da0aSPeter Brune     Level: intermediate
14348ac6da0aSPeter Brune 
1435*87497f52SBarry Smith    Developer Note:
1436af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
1437ec5066bdSBarry Smith 
1438db781477SPatrick Sanan .seealso: `MatColoring`, `MatColoringCreate()`
14398ac6da0aSPeter Brune E*/
1440301c140bSPeter Brune typedef enum {MAT_COLORING_WEIGHT_RANDOM,MAT_COLORING_WEIGHT_LEXICAL,MAT_COLORING_WEIGHT_LF,MAT_COLORING_WEIGHT_SL} MatColoringWeightType;
14418ac6da0aSPeter Brune 
1442335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat,MatColoring*);
1443d7f2a307SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat,PetscInt,PetscInt*);
1444335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring*);
1445335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring,PetscViewer);
1446335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring,MatColoringType);
1447335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring);
1448335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring,PetscInt);
1449335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring,PetscInt*);
1450335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring,PetscInt);
1451335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring,PetscInt*);
1452335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring,ISColoring*);
1453335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[],PetscErrorCode(*)(MatColoring));
1454014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*);
14558ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring,MatColoringWeightType);
1456c29971fcSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring,PetscReal*,PetscInt*);
14578ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring,PetscReal **,PetscInt **lperm);
1458bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring,ISColoring);
14599fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatColoringTest() (since version 3.10)") static inline PetscErrorCode MatColoringTestValid(MatColoring matcoloring,ISColoring iscoloring) {return MatColoringTest(matcoloring,iscoloring);}
1460bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat,ISColoring);
1461639f9d9dSBarry Smith 
1462d9274352SBarry Smith /*S
1463*87497f52SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences with coloring
1464639f9d9dSBarry Smith 
1465d9274352SBarry Smith    Level: beginner
1466d9274352SBarry Smith 
1467ec5066bdSBarry Smith    Notes:
1468*87497f52SBarry Smith       This object is creating utilizing a coloring provided by the `MatColoring` object or `DMCreateColoring()`
1469ec5066bdSBarry Smith 
1470*87497f52SBarry Smith .seealso: `MatFDColoringCreate()`, `MatFDColoringSetFunction()`, `MatColoring`, `DMCreateColoring()`
1471d9274352SBarry Smith S*/
1472e2a1c21fSSatish Balay typedef struct _p_MatFDColoring* MatFDColoring;
1473639f9d9dSBarry Smith 
1474014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
1475014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring*);
1476014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring,PetscViewer);
1477014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*);
1478014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring,PetscErrorCode (**)(void),void**);
1479014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
1480014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring);
1481d1e9a80fSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat,MatFDColoring,Vec,void *);
1482014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring,Vec);
1483edaa7c33SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,const PetscInt*[]);
1484f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat,ISColoring,MatFDColoring);
1485f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring,PetscInt,PetscInt);
1486bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat,MatFDColoring,const PetscScalar*);
1487b1683b59SHong Zhang 
1488b1683b59SHong Zhang /*S
1489b9af6bddSHong Zhang      MatTransposeColoring - Object for computing a sparse matrix product C=A*B^T via coloring
1490b1683b59SHong Zhang 
1491b1683b59SHong Zhang    Level: beginner
1492b1683b59SHong Zhang 
1493db781477SPatrick Sanan .seealso: `MatTransposeColoringCreate()`
1494b1683b59SHong Zhang S*/
1495b9af6bddSHong Zhang typedef struct _p_MatTransposeColoring* MatTransposeColoring;
1496b1683b59SHong Zhang 
1497014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat,ISColoring,MatTransposeColoring *);
1498014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring,Mat,Mat);
1499014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring,Mat,Mat);
1500014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring*);
1501b1683b59SHong Zhang 
1502d9274352SBarry Smith /*S
1503d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
1504d9274352SBarry Smith 
1505d9274352SBarry Smith    Level: beginner
1506d9274352SBarry Smith 
1507*87497f52SBarry Smith    Note:
1508*87497f52SBarry Smith      There is also a `PetscPartitioner` object that provides the same functionality. It can utilize the `MatPartitioning` operations
1509*87497f52SBarry Smith      via `PetscPartitionerSetType`(p,`PETSCPARTITIONERMATPARTITIONING`)
1510ec5066bdSBarry Smith 
1511ec5066bdSBarry Smith    Developers Note:
1512ec5066bdSBarry Smith      It is an extra maintainance and documentation cost to have two objects with the same functionality.
1513ec5066bdSBarry Smith 
1514db781477SPatrick Sanan .seealso: `MatPartitioningCreate()`, `MatPartitioningType`, `MatColoring`, `MatGetOrdering()`
1515d9274352SBarry Smith S*/
151691e9ee9fSBarry Smith typedef struct _p_MatPartitioning* MatPartitioning;
1517d9274352SBarry Smith 
151876bdecfbSBarry Smith /*J
15198f6c3df8SBarry Smith     MatPartitioningType - String with the name of a PETSc matrix partitioning
1520d9274352SBarry Smith 
1521d9274352SBarry Smith    Level: beginner
15220d04baf8SBarry Smith dm
1523*87497f52SBarry Smith .seealso: `MatPartitioningCreate()`, `MatPartitioning`, `MatPartitioningSetType()`
152476bdecfbSBarry Smith J*/
152519fd82e9SBarry Smith typedef const char* MatPartitioningType;
15262692d6eeSBarry Smith #define MATPARTITIONINGCURRENT  "current"
1527aa1e27eaSFande Kong #define MATPARTITIONINGAVERAGE   "average"
15282692d6eeSBarry Smith #define MATPARTITIONINGSQUARE   "square"
15292692d6eeSBarry Smith #define MATPARTITIONINGPARMETIS "parmetis"
15302692d6eeSBarry Smith #define MATPARTITIONINGCHACO    "chaco"
15312692d6eeSBarry Smith #define MATPARTITIONINGPARTY    "party"
153250d91057SBarry Smith #define MATPARTITIONINGPTSCOTCH "ptscotch"
153388d2ac2bSFande Kong #define MATPARTITIONINGHIERARCH  "hierarch"
153471306c60Sjroman 
1535014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm,MatPartitioning*);
153619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning,MatPartitioningType);
1537014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning,PetscInt);
1538014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning,Mat);
1539252a1336SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetNumberVertexWeights(MatPartitioning,PetscInt);
1540014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]);
1541014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []);
1542ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningSetUseEdgeWeights(MatPartitioning,PetscBool);
1543ebf67979SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningGetUseEdgeWeights(MatPartitioning,PetscBool*);
1544014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning,IS*);
1545fdd1c351SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning,IS*);
1546668144dbSFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning,IS);
1547f3ad2dabSStefano Zampini PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning,IS*);
1548014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning*);
1549bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[],PetscErrorCode (*)(MatPartitioning));
1550014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning,PetscViewer);
1551fe2efc57SMark PETSC_EXTERN PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning,PetscObject,const char[]);
1552014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning);
155319fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
1554ca161407SBarry Smith 
155527538973SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part);
1556014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
1557014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *);
15580752156aSBarry Smith 
1559b6956c12SJose Roman typedef enum { MP_CHACO_MULTILEVEL=1,MP_CHACO_SPECTRAL=2,MP_CHACO_LINEAR=4,MP_CHACO_RANDOM=5,MP_CHACO_SCATTERED=6 } MPChacoGlobalType;
15606a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoGlobalTypes[];
1561b6956c12SJose Roman typedef enum { MP_CHACO_KERNIGHAN=1,MP_CHACO_NONE=2 } MPChacoLocalType;
15626a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoLocalTypes[];
1563b6956c12SJose Roman typedef enum { MP_CHACO_LANCZOS=0,MP_CHACO_RQI=1 } MPChacoEigenType;
15646a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoEigenTypes[];
1565b6956c12SJose Roman 
1566014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning,MPChacoGlobalType);
1567014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning,MPChacoGlobalType*);
1568014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning,MPChacoLocalType);
1569014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning,MPChacoLocalType*);
1570014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal);
1571014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType);
1572014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning,MPChacoEigenType*);
1573014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning,PetscReal);
1574014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning,PetscReal*);
1575014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning,PetscInt);
1576014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning,PetscInt*);
157771306c60Sjroman 
157871306c60Sjroman #define MP_PARTY_OPT "opt"
157971306c60Sjroman #define MP_PARTY_LIN "lin"
158071306c60Sjroman #define MP_PARTY_SCA "sca"
158171306c60Sjroman #define MP_PARTY_RAN "ran"
158271306c60Sjroman #define MP_PARTY_GBF "gbf"
158371306c60Sjroman #define MP_PARTY_GCF "gcf"
158471306c60Sjroman #define MP_PARTY_BUB "bub"
158571306c60Sjroman #define MP_PARTY_DEF "def"
1586014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning,const char*);
158771306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs"
158871306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
158971306c60Sjroman #define MP_PARTY_NONE "no"
1590014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning,const char*);
1591014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal);
1592014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning,PetscBool);
1593014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscBool);
159471306c60Sjroman 
1595b0ca845eSVaclav Hapla typedef enum { MP_PTSCOTCH_DEFAULT,MP_PTSCOTCH_QUALITY,MP_PTSCOTCH_SPEED,MP_PTSCOTCH_BALANCE,MP_PTSCOTCH_SAFETY,MP_PTSCOTCH_SCALABILITY } MPPTScotchStrategyType;
15966a6fc655SJed Brown PETSC_EXTERN const char *const MPPTScotchStrategyTypes[];
1597e0f1cffaSJose Roman 
1598014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning,PetscReal);
1599014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning,PetscReal*);
1600014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning,MPPTScotchStrategyType);
1601014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning,MPPTScotchStrategyType*);
160271306c60Sjroman 
1603b43b03e9SMark F. Adams /*
16046294fa2bSFande Kong  * hierarchical partitioning
16056294fa2bSFande Kong  */
16064e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning,IS*);
16074e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning,IS*);
16084e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning,PetscInt);
16094e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt);
16106294fa2bSFande Kong 
1611014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToVertexGraph(Mat,PetscInt,Mat*);
1612014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat,PetscInt,Mat*);
1613591294e4SBarry Smith 
16140752156aSBarry Smith /*
1615c786d857SStefano Zampini     If you add entries here you must also add them to src/mat/f90-mod/petscmat.h
1616c786d857SStefano Zampini     If any of the enum values are changed, also update dMatOps dict at src/binding/petsc4py/src/libpetsc4py/libpetsc4py.pyx
1617d4fbbf0eSBarry Smith */
16181c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
16191c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
16201c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
16211c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
16221c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
16237c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
16247c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
16251c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
16261c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
16277c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
16287c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
16291c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
16301c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
1631a714c06dSBarry Smith                MATOP_SOR=13,
16321c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
16331c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
16341c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
16351c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
16361c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
16371c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
16381c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
16391c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
1640d519adbfSMatthew Knepley                MATOP_SET_OPTION=22,
1641d519adbfSMatthew Knepley                MATOP_ZERO_ENTRIES=23,
1642d519adbfSMatthew Knepley                MATOP_ZERO_ROWS=24,
1643d519adbfSMatthew Knepley                MATOP_LUFACTOR_SYMBOLIC=25,
1644d519adbfSMatthew Knepley                MATOP_LUFACTOR_NUMERIC=26,
1645d519adbfSMatthew Knepley                MATOP_CHOLESKY_FACTOR_SYMBOLIC=27,
1646d519adbfSMatthew Knepley                MATOP_CHOLESKY_FACTOR_NUMERIC=28,
1647e5f2d425SStefano Zampini                MATOP_SETUP=29,
1648d519adbfSMatthew Knepley                MATOP_ILUFACTOR_SYMBOLIC=30,
1649d519adbfSMatthew Knepley                MATOP_ICCFACTOR_SYMBOLIC=31,
1650a5b7ff6bSBarry Smith                MATOP_GET_DIAGONAL_BLOCK=32,
1651e5f2d425SStefano Zampini                MATOP_SET_INF=33,
1652d519adbfSMatthew Knepley                MATOP_DUPLICATE=34,
1653d519adbfSMatthew Knepley                MATOP_FORWARD_SOLVE=35,
1654d519adbfSMatthew Knepley                MATOP_BACKWARD_SOLVE=36,
1655d519adbfSMatthew Knepley                MATOP_ILUFACTOR=37,
1656d519adbfSMatthew Knepley                MATOP_ICCFACTOR=38,
1657d519adbfSMatthew Knepley                MATOP_AXPY=39,
16587dae84e0SHong Zhang                MATOP_CREATE_SUBMATRICES=40,
1659d519adbfSMatthew Knepley                MATOP_INCREASE_OVERLAP=41,
1660d519adbfSMatthew Knepley                MATOP_GET_VALUES=42,
1661d519adbfSMatthew Knepley                MATOP_COPY=43,
1662d519adbfSMatthew Knepley                MATOP_GET_ROW_MAX=44,
1663d519adbfSMatthew Knepley                MATOP_SCALE=45,
1664d519adbfSMatthew Knepley                MATOP_SHIFT=46,
166535153367SBarry Smith                MATOP_DIAGONAL_SET=47,
16669d39f69dSJed Brown                MATOP_ZERO_ROWS_COLUMNS=48,
16679d39f69dSJed Brown                MATOP_SET_RANDOM=49,
1668d519adbfSMatthew Knepley                MATOP_GET_ROW_IJ=50,
1669d519adbfSMatthew Knepley                MATOP_RESTORE_ROW_IJ=51,
1670d519adbfSMatthew Knepley                MATOP_GET_COLUMN_IJ=52,
1671d519adbfSMatthew Knepley                MATOP_RESTORE_COLUMN_IJ=53,
1672d519adbfSMatthew Knepley                MATOP_FDCOLORING_CREATE=54,
1673d519adbfSMatthew Knepley                MATOP_COLORING_PATCH=55,
1674d519adbfSMatthew Knepley                MATOP_SET_UNFACTORED=56,
1675d519adbfSMatthew Knepley                MATOP_PERMUTE=57,
1676d519adbfSMatthew Knepley                MATOP_SET_VALUES_BLOCKED=58,
16777dae84e0SHong Zhang                MATOP_CREATE_SUBMATRIX=59,
1678d519adbfSMatthew Knepley                MATOP_DESTROY=60,
1679d519adbfSMatthew Knepley                MATOP_VIEW=61,
1680d519adbfSMatthew Knepley                MATOP_CONVERT_FROM=62,
1681e5f2d425SStefano Zampini                /* MATOP_PLACEHOLDER_63=63 */
16827bab7c10SHong Zhang                MATOP_MATMAT_MULT_SYMBOLIC=64,
16837bab7c10SHong Zhang                MATOP_MATMAT_MULT_NUMERIC=65,
1684d519adbfSMatthew Knepley                MATOP_SET_LOCAL_TO_GLOBAL_MAP=66,
1685d519adbfSMatthew Knepley                MATOP_SET_VALUES_LOCAL=67,
1686d519adbfSMatthew Knepley                MATOP_ZERO_ROWS_LOCAL=68,
1687d519adbfSMatthew Knepley                MATOP_GET_ROW_MAX_ABS=69,
1688d519adbfSMatthew Knepley                MATOP_GET_ROW_MIN_ABS=70,
1689d519adbfSMatthew Knepley                MATOP_CONVERT=71,
1690e5f2d425SStefano Zampini                MATOP_HAS_OPERATION=72,
16919d39f69dSJed Brown                /* MATOP_PLACEHOLDER_73=73, */
1692d519adbfSMatthew Knepley                MATOP_SET_VALUES_ADIFOR=74,
1693d519adbfSMatthew Knepley                MATOP_FD_COLORING_APPLY=75,
1694d519adbfSMatthew Knepley                MATOP_SET_FROM_OPTIONS=76,
1695e5f2d425SStefano Zampini                /* MATOP_PLACEHOLDER_77=77, */
1696e5f2d425SStefano Zampini                /* MATOP_PLACEHOLDER_78=78, */
16979d39f69dSJed Brown                MATOP_FIND_ZERO_DIAGONALS=79,
1698d519adbfSMatthew Knepley                MATOP_MULT_MULTIPLE=80,
1699d519adbfSMatthew Knepley                MATOP_SOLVE_MULTIPLE=81,
1700d519adbfSMatthew Knepley                MATOP_GET_INERTIA=82,
1701d519adbfSMatthew Knepley                MATOP_LOAD=83,
1702d519adbfSMatthew Knepley                MATOP_IS_SYMMETRIC=84,
1703d519adbfSMatthew Knepley                MATOP_IS_HERMITIAN=85,
1704d519adbfSMatthew Knepley                MATOP_IS_STRUCTURALLY_SYMMETRIC=86,
1705820469bcSHong Zhang                MATOP_SET_VALUES_BLOCKEDLOCAL=87,
1706b41ce5d5SBarry Smith                MATOP_CREATE_VECS=88,
1707e5f2d425SStefano Zampini                /* MATOP_PLACEHOLDER_89=89, */
1708d519adbfSMatthew Knepley                MATOP_MAT_MULT_SYMBOLIC=90,
1709d519adbfSMatthew Knepley                MATOP_MAT_MULT_NUMERIC=91,
1710e5f2d425SStefano Zampini                /* MATOP_PLACEHOLDER_92=92, */
1711d519adbfSMatthew Knepley                MATOP_PTAP_SYMBOLIC=93,
1712d519adbfSMatthew Knepley                MATOP_PTAP_NUMERIC=94,
1713e5f2d425SStefano Zampini                /* MATOP_PLACEHOLDER_95=95, */
1714bda6c4cbSBarry Smith                MATOP_MAT_TRANSPOSE_MULT_SYMBO=96,
1715bda6c4cbSBarry Smith                MATOP_MAT_TRANSPOSE_MULT_NUMER=97,
1716e5f2d425SStefano Zampini                MATOP_BIND_TO_CPU=98,
17177a3c3d58SStefano Zampini                MATOP_PRODUCTSETFROMOPTIONS=99,
17187a3c3d58SStefano Zampini                MATOP_PRODUCTSYMBOLIC=100,
17197a3c3d58SStefano Zampini                MATOP_PRODUCTNUMERIC=101,
1720d519adbfSMatthew Knepley                MATOP_CONJUGATE=102,
1721e5f2d425SStefano Zampini                MATOP_VIEW_NATIVE=103,
1722d519adbfSMatthew Knepley                MATOP_SET_VALUES_ROW=104,
1723d519adbfSMatthew Knepley                MATOP_REAL_PART=105,
1724bda6c4cbSBarry Smith                MATOP_IMAGINARY_PART=106,
1725bda6c4cbSBarry Smith                MATOP_GET_ROW_UPPER_TRIANGULAR=107,
1726bda6c4cbSBarry Smith                MATOP_RESTORE_ROW_UPPER_TRIANG=108,
1727bda6c4cbSBarry Smith                MATOP_MAT_SOLVE=109,
172829eadf9eSStefano Zampini                MATOP_MAT_SOLVE_TRANSPOSE=110,
1729d519adbfSMatthew Knepley                MATOP_GET_ROW_MIN=111,
17300e8d04f7SBarry Smith                MATOP_GET_COLUMN_VECTOR=112,
1731d519adbfSMatthew Knepley                MATOP_MISSING_DIAGONAL=113,
17320e8d04f7SBarry Smith                MATOP_GET_SEQ_NONZERO_STRUCTUR=114,
173389c6957cSBarry Smith                MATOP_CREATE=115,
173489c6957cSBarry Smith                MATOP_GET_GHOSTS=116,
17350e8d04f7SBarry Smith                MATOP_GET_LOCAL_SUB_MATRIX=117,
17360e8d04f7SBarry Smith                MATOP_RESTORE_LOCALSUB_MATRIX=118,
1737eeffb40dSHong Zhang                MATOP_MULT_DIAGONAL_BLOCK=119,
17380e8d04f7SBarry Smith                MATOP_HERMITIAN_TRANSPOSE=120,
17390e8d04f7SBarry Smith                MATOP_MULT_HERMITIAN_TRANSPOSE=121,
17400e8d04f7SBarry Smith                MATOP_MULT_HERMITIAN_TRANS_ADD=122,
17410e8d04f7SBarry Smith                MATOP_GET_MULTI_PROC_BLOCK=123,
17429d39f69dSJed Brown                MATOP_FIND_NONZERO_ROWS=124,
17430e8d04f7SBarry Smith                MATOP_GET_COLUMN_NORMS=125,
17449d39f69dSJed Brown                MATOP_INVERT_BLOCK_DIAGONAL=126,
1745e5f2d425SStefano Zampini                MATOP_INVERT_VBLOCK_DIAGONAL=127,
1746b41ce5d5SBarry Smith                MATOP_CREATE_SUB_MATRICES_MPI=128,
17472b8ad9a3SHong Zhang                MATOP_SET_VALUES_BATCH=129,
1748e5f2d425SStefano Zampini                /* MATOP_PLACEHOLDER_130=130, */
17490e8d04f7SBarry Smith                MATOP_TRANSPOSE_MAT_MULT_SYMBO=131,
1750e9b602ebSSatish Balay                MATOP_TRANSPOSE_MAT_MULT_NUMER=132,
17510e8d04f7SBarry Smith                MATOP_TRANSPOSE_COLORING_CREAT=133,
17520e8d04f7SBarry Smith                MATOP_TRANS_COLORING_APPLY_SPT=134,
17530e8d04f7SBarry Smith                MATOP_TRANS_COLORING_APPLY_DEN=135,
1754e5f2d425SStefano Zampini                /* MATOP_PLACEHOLDER_136=136, */
17550e8d04f7SBarry Smith                MATOP_RART_SYMBOLIC=137,
17560e8d04f7SBarry Smith                MATOP_RART_NUMERIC=138,
1757e09a3074SHong Zhang                MATOP_SET_BLOCK_SIZES=139,
1758f9426fe0SMark Adams                MATOP_AYPX=140,
17591919a2e2SJed Brown                MATOP_RESIDUAL=141,
17609c8f2541SHong Zhang                MATOP_FDCOLORING_SETUP=142,
1761e5f2d425SStefano Zampini                MATOP_FIND_OFFBLOCK_ENTRIES=143,
17622d033e1fSHong Zhang                MATOP_MPICONCATENATESEQ=144,
1763bb01b7b0SPatrick Sanan                MATOP_DESTROYSUBMATRICES=145,
1764e265f6d6SPatrick Sanan                MATOP_TRANSPOSE_SOLVE=146,
1765e265f6d6SPatrick Sanan                MATOP_GET_VALUES_LOCAL=147
1766fae171e0SBarry Smith              } MatOperation;
17670c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOperation(Mat,MatOperation,void(*)(void));
1768976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatGetOperation(Mat,MatOperation,void(**)(void));
1769976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatHasOperation(Mat,MatOperation,PetscBool*);
177094342113SStefano Zampini PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat,PetscBool*);
17719fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatProductClear() (since version 3.14)") static inline PetscErrorCode MatFreeIntermediateDataStructures(Mat A) {return MatProductClear(A);}
1772014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat,MatOperation,void(*)(void));
1773014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat,MatOperation,void(**)(void));
1774014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat,void*);
1775800f99ffSJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetContextDestroy(Mat,PetscErrorCode (*)(void*));
1776db77db73SJeremy L Thompson PETSC_EXTERN PetscErrorCode MatShellSetVecType(Mat,VecType);
1777f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat,PetscErrorCode (*)(void*,Vec,Vec),Vec,void*,PetscBool*);
1778f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat,PetscErrorCode (*)(void*,Vec,Vec),Vec,void*,PetscBool*);
17790c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat);
1780b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatShellSetMatProductOperation(Mat,MatProductType,PetscErrorCode (*)(Mat,Mat,Mat,void**),PetscErrorCode (*)(Mat,Mat,Mat,void*),PetscErrorCode (*)(void*),MatType,MatType);
1781b77ba244SStefano Zampini PETSC_EXTERN PetscErrorCode MatIsShell(Mat,PetscBool*);
1782112a2221SBarry Smith 
178390ace30eSBarry Smith /*
178490ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
178590ace30eSBarry Smith    stored in a universal format. By changing the format with
17866a9046bcSBarry Smith    PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will
178790ace30eSBarry Smith    be stored in a way natural for the matrix, for example dense matrices
178890ace30eSBarry Smith    would be stored as dense. Matrices stored this way may only be
1789f4403165SShri Abhyankar    read into matrices of the same type.
179090ace30eSBarry Smith */
179190ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
179290ace30eSBarry Smith 
1793014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
179475d48cdbSStefano Zampini 
17958546b261SStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat,MatType);
179675d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
179775d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat,PetscBool);
1798f03112d0SStefano Zampini PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat,PetscBool);
1799014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat,Mat*);
18003b3b1effSJed Brown PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat,Mat*);
1801014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat,Mat);
1802e432b41dSStefano Zampini PETSC_EXTERN PetscErrorCode MatISGetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping*,ISLocalToGlobalMapping*);
180325ef9dfeSBarry Smith PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use the MatConvert() interface (since version 3.10)") PetscErrorCode MatISGetMPIXAIJ(Mat,MatReuse,Mat*);
18041f4e1ec7SBarry Smith 
1805d9274352SBarry Smith /*S
1806d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
1807cb6b9846SMatthew Knepley          orthogonalizes the vector to a subspace
1808d9274352SBarry Smith 
1809f7a9e4ceSBarry Smith    Level: advanced
1810d9274352SBarry Smith 
1811*87497f52SBarry Smith .seealso: `MatNullSpaceCreate()`, `MatNullSpaceSetFunction()`, `MatGetNullSpace()`, `MatSetNullSpace()`
1812d9274352SBarry Smith S*/
181374637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
1814d9274352SBarry Smith 
1815014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm,PetscBool ,PetscInt,const Vec[],MatNullSpace*);
1816014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace,PetscErrorCode (*)(MatNullSpace,Vec,void*),void*);
1817014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace*);
1818d0195637SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace,Vec);
1819014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *);
18205fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *);
18215fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat,MatNullSpace);
1822014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat,MatNullSpace);
1823014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat,MatNullSpace);
1824014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat,MatNullSpace*);
1825014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace,Mat,PetscBool  *);
1826014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace,PetscViewer);
1827014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace,PetscBool*,PetscInt*,const Vec**);
1828014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec,MatNullSpace*);
182974637425SBarry Smith 
1830014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat,IS);
1831014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1832014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat,PetscInt *);
18333f1d51d7SBarry Smith 
1834014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat,PetscInt,Mat*);
1835014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat,PetscInt,Mat*);
1836014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat,Mat*);
1837c4f061fbSSatish Balay 
18380bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat,MatType,Mat*);
18390bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat,MatType,Mat*);
18400bacdadaSStefano Zampini 
18419fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatComputeOperator() (since version 3.12)") static inline PetscErrorCode MatComputeExplicitOperator(Mat A,Mat* B) { return MatComputeOperator(A,NULL,B); }
18429fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatComputeOperatorTranspose() (since version 3.12)") static inline PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A,Mat* B) { return MatComputeOperatorTranspose(A,NULL,B); }
1843b0a32e0cSBarry Smith 
184449bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat,PetscInt,PetscInt,const PetscScalar[],const PetscScalar[],Mat*);
184549bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat,Mat*);
1846a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat,PetscInt*,PetscInt*,PetscScalar**);
1847a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat,PetscInt*,PetscInt*,const PetscScalar**);
1848a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat,PetscScalar**);
1849a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat,const PetscScalar**);
1850a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat,PetscInt*,PetscInt*,PetscScalar**);
1851a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat,PetscInt*,PetscInt*,const PetscScalar**);
1852a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat,PetscScalar**);
1853a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat,const PetscScalar**);
1854dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat,Mat);
1855dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat,PetscInt,PetscInt,const PetscScalar[]);
1856dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat,PetscInt,PetscInt,const PetscScalar[]);
1857910cf402Sprj- PETSC_EXTERN PetscErrorCode MatKAIJGetScaledIdentity(Mat,PetscBool*);
185849bd79ccSDebojyoti Ghosh 
1859014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat,Vec);
186004f1ad80SBarry Smith 
1861014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
1862014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat,Vec,Vec);
1863014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat,PetscErrorCode(*)(void*,Vec,Vec),void*);
1864014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat,PetscErrorCode (*)(void*,PetscInt,Vec,PetscScalar*));
1865014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat,PetscErrorCode (*)(void*,Vec));
1866014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat,PetscScalar[],PetscInt);
1867014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat);
1868014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat,PetscReal);
1869014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat,PetscInt);
1870014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat,PetscScalar *);
1871014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat,const char[]);
1872014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void*,Vec,Vec,PetscScalar*);
1873014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat,PetscErrorCode (*)(void*,Vec,Vec,PetscScalar*),void*);
1874e884886fSBarry Smith 
18756370053bSBarry Smith /*S
18766370053bSBarry Smith     MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free
18776370053bSBarry Smith               Jacobian vector products
1878e884886fSBarry Smith 
187995452b02SPatrick Sanan     Notes:
1880*87497f52SBarry Smith     `MATMFFD` is a specific `MatType` which uses the `MatMFFD` data structure
18816370053bSBarry Smith 
1882*87497f52SBarry Smith     MatMFFD*() methods actually take the Mat as their first argument. Not a `MatMFFD` data structure
18836370053bSBarry Smith 
18846370053bSBarry Smith     Level: developer
18856370053bSBarry Smith 
1886db781477SPatrick Sanan .seealso: `MATMFFD`, `MatCreateMFFD()`, `MatMFFDSetFuction()`, `MatMFFDSetType()`, `MatMFFDRegister()`
18876370053bSBarry Smith S*/
1888e884886fSBarry Smith typedef struct _p_MatMFFD* MatMFFD;
1889e884886fSBarry Smith 
189076bdecfbSBarry Smith /*J
1891e884886fSBarry Smith     MatMFFDType - algorithm used to compute the h used in computing matrix-vector products via differencing of the function
1892e884886fSBarry Smith 
1893e884886fSBarry Smith    Level: beginner
1894e884886fSBarry Smith 
1895db781477SPatrick Sanan .seealso: `MatMFFDSetType()`, `MatMFFDRegister()`
189676bdecfbSBarry Smith J*/
189719fd82e9SBarry Smith typedef const char* MatMFFDType;
1898e884886fSBarry Smith #define MATMFFD_DS  "ds"
1899e884886fSBarry Smith #define MATMFFD_WP  "wp"
1900e884886fSBarry Smith 
190119fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat,MatMFFDType);
1902bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[],PetscErrorCode (*)(MatMFFD));
1903e884886fSBarry Smith 
1904014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat,PetscReal);
1905014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat,PetscBool);
1906e884886fSBarry Smith 
190761ab5df0SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring,MatMFFDType);
190861ab5df0SBarry Smith 
1909014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
1910014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
19117dbadf16SMatthew Knepley 
191253022affSStefano Zampini #ifdef PETSC_HAVE_H2OPUS
191353022affSStefano Zampini PETSC_EXTERN_TYPEDEF typedef PetscScalar (*MatH2OpusKernel)(PetscInt,PetscReal[],PetscReal[],void*);
191453022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromKernel(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscReal[],PetscBool,MatH2OpusKernel,void*,PetscReal,PetscInt,PetscInt,Mat*);
191553022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateH2OpusFromMat(Mat,PetscInt,const PetscReal[],PetscBool,PetscReal,PetscInt,PetscInt,PetscInt,PetscReal,Mat*);
191653022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetSamplingMat(Mat,Mat,PetscInt,PetscReal);
191753022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusOrthogonalize(Mat);
191853022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusCompress(Mat,PetscReal);
191953022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusSetNativeMult(Mat,PetscBool);
192053022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetNativeMult(Mat,PetscBool*);
192153022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusGetIndexMap(Mat,IS*);
192253022affSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusMapVec(Mat,PetscBool,Vec,Vec*);
1923300d917bSStefano Zampini PETSC_EXTERN PetscErrorCode MatH2OpusLowRankUpdate(Mat,Mat,Mat,PetscScalar);
1924a0d2e7d8SStefano Zampini #endif
1925a0d2e7d8SStefano Zampini 
1926c7a4214aSPierre Jolivet #ifdef PETSC_HAVE_HTOOL
192798e73e17SPierre Jolivet PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*MatHtoolKernel)(PetscInt,PetscInt,PetscInt,const PetscInt*,const PetscInt*,PetscScalar*,void*);
1928c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatCreateHtoolFromKernel(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscReal[],const PetscReal[],MatHtoolKernel,void*,Mat*);
1929c7a4214aSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolSetKernel(Mat,MatHtoolKernel,void*);
193098e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationSource(Mat,IS*);
193198e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolGetPermutationTarget(Mat,IS*);
193298e73e17SPierre Jolivet PETSC_EXTERN PetscErrorCode MatHtoolUsePermutation(Mat,PetscBool);
1933c7a4214aSPierre Jolivet /*E
1934*87497f52SBarry Smith      MatHtoolCompressorType - Indicates the type of compressor used by a `MATHTOOL`
1935c7a4214aSPierre Jolivet 
1936c7a4214aSPierre Jolivet    Level: beginner
1937c7a4214aSPierre Jolivet 
1938c7a4214aSPierre Jolivet     Values:
1939*87497f52SBarry Smith +   `MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA` (default) - symmetric partial adaptive cross approximation
1940*87497f52SBarry Smith .   `MAT_HTOOL_COMPRESSOR_FULL_ACA` - full adaptive cross approximation
1941*87497f52SBarry Smith -   `MAT_HTOOL_COMPRESSOR_SVD` - singular value decomposition
1942c7a4214aSPierre Jolivet 
1943db781477SPatrick Sanan .seealso: `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolClusteringType`
1944c7a4214aSPierre Jolivet E*/
1945c7a4214aSPierre Jolivet typedef enum { MAT_HTOOL_COMPRESSOR_SYMPARTIAL_ACA, MAT_HTOOL_COMPRESSOR_FULL_ACA, MAT_HTOOL_COMPRESSOR_SVD } MatHtoolCompressorType;
194698e73e17SPierre Jolivet /*E
1947*87497f52SBarry Smith      MatHtoolClusteringType - Indicates the type of clustering used by a `MATHTOOL`
194898e73e17SPierre Jolivet 
194998e73e17SPierre Jolivet    Level: beginner
195098e73e17SPierre Jolivet 
195198e73e17SPierre Jolivet     Values:
1952*87497f52SBarry Smith +   `MAT_HTOOL_CLUSTERING_PCA_REGULAR` (default) - axis computed via principle component analysis, split uniformly
1953*87497f52SBarry Smith .   `MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC` - axis computed via principle component analysis, split barycentrically
1954*87497f52SBarry Smith .   `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR` - axis along the largest extent of the bounding box, split uniformly
1955*87497f52SBarry Smith -   `MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC` - axis along the largest extent of the bounding box, split barycentrically
195698e73e17SPierre Jolivet 
195798e73e17SPierre Jolivet     Notes: higher-dimensional clustering is not yet supported in Htool, but once it is, one should add BOUNDING_BOX_{2,3} types
195898e73e17SPierre Jolivet 
1959db781477SPatrick Sanan .seealso: `MatCreateHtoolFromKernel()`, `MATHTOOL`, `MatHtoolCompressorType`
196098e73e17SPierre Jolivet E*/
196198e73e17SPierre Jolivet typedef enum { MAT_HTOOL_CLUSTERING_PCA_REGULAR, MAT_HTOOL_CLUSTERING_PCA_GEOMETRIC, MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_REGULAR, MAT_HTOOL_CLUSTERING_BOUNDING_BOX_1_GEOMETRIC } MatHtoolClusteringType;
1962c7a4214aSPierre Jolivet #endif
1963c7a4214aSPierre Jolivet 
196497969023SHong Zhang #ifdef PETSC_HAVE_MUMPS
1965014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat,PetscInt,PetscInt);
1966bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat,PetscInt,PetscInt*);
1967b9e9ea26SSatish Balay PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat,PetscInt,PetscReal);
1968bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat,PetscInt,PetscReal*);
1969bc6112feSHong Zhang 
1970ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat,PetscInt,PetscInt*);
1971ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat,PetscInt,PetscInt*);
1972ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat,PetscInt,PetscReal*);
1973ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat,PetscInt,PetscReal*);
197489a9c03aSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat,Mat);
19750e6b8875SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat,Mat);
197697969023SHong Zhang #endif
197723a5497aSJed Brown 
1978b500a6b7SJose David Bermeol #ifdef PETSC_HAVE_MKL_PARDISO
1979d615f992SSatish Balay PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat,PetscInt,PetscInt);
1980b500a6b7SJose David Bermeol #endif
1981b500a6b7SJose David Bermeol 
1982d305a81bSVasiliy Kozyrev #ifdef PETSC_HAVE_MKL_CPARDISO
1983d305a81bSVasiliy Kozyrev PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat,PetscInt,PetscInt);
1984d305a81bSVasiliy Kozyrev #endif
1985d305a81bSVasiliy Kozyrev 
1986d954db57SHong Zhang #ifdef PETSC_HAVE_SUPERLU
1987014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat,PetscReal);
1988d954db57SHong Zhang #endif
1989d954db57SHong Zhang 
1990fb785984SHong Zhang #ifdef PETSC_HAVE_SUPERLU_DIST
1991fb785984SHong Zhang PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat,PetscScalar*);
1992fb785984SHong Zhang #endif
1993fb785984SHong Zhang 
1994575704cbSPieter Ghysels #ifdef PETSC_HAVE_STRUMPACK
1995542aee0fSPieter Ghysels /*E
1996*87497f52SBarry Smith     MatSTRUMPACKReordering - sparsity reducing ordering to be used in `STRUMPACK`
1997542aee0fSPieter Ghysels 
1998542aee0fSPieter Ghysels     Level: intermediate
1999542aee0fSPieter Ghysels E*/
200034f43fa5SPieter Ghysels typedef enum {MAT_STRUMPACK_NATURAL=0,
200134f43fa5SPieter Ghysels               MAT_STRUMPACK_METIS=1,
200234f43fa5SPieter Ghysels               MAT_STRUMPACK_PARMETIS=2,
200334f43fa5SPieter Ghysels               MAT_STRUMPACK_SCOTCH=3,
200434f43fa5SPieter Ghysels               MAT_STRUMPACK_PTSCOTCH=4,
200534f43fa5SPieter Ghysels               MAT_STRUMPACK_RCM=5} MatSTRUMPACKReordering;
200634f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat,MatSTRUMPACKReordering);
2007575704cbSPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat,PetscBool);
200834f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSRelTol(Mat,PetscReal);
20099fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatSTRUMPACKSetHSSRelTol() (since version 3.9)") static inline PetscErrorCode MatSTRUMPACKSetHSSRelCompTol(Mat mat,PetscReal rtol) {return MatSTRUMPACKSetHSSRelTol(mat,rtol);}
201034f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSAbsTol(Mat,PetscReal);
201134f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSMinSepSize(Mat,PetscInt);
20129fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatSTRUMPACKSetHSSMinSepSize() (since version 3.9)") static inline PetscErrorCode MatSTRUMPACKSetHSSMinSize(Mat mat,PetscInt hssminsize) {return MatSTRUMPACKSetHSSMinSepSize(mat,hssminsize);}
201334f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSMaxRank(Mat,PetscInt);
2014a36bf211SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSLeafSize(Mat,PetscInt);
2015575704cbSPieter Ghysels #endif
2016575704cbSPieter Ghysels 
2017b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatBindToCPU(Mat,PetscBool);
20182216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode MatBoundToCPU(Mat,PetscBool*);
20199fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use MatBindToCPU (since v3.13)") static inline PetscErrorCode MatPinToCPU(Mat A,PetscBool flg) {return MatBindToCPU(A,flg);}
202065a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatSetBindingPropagates(Mat,PetscBool);
2021e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatGetBindingPropagates(Mat,PetscBool *);
2022e7e92044SBarry Smith 
2023042217e8SBarry Smith typedef struct _n_SplitCSRMat *PetscSplitCSRDataStructure;
2024042217e8SBarry Smith PETSC_EXTERN PetscErrorCode MatCUSPARSEGetDeviceMatWrite(Mat,PetscSplitCSRDataStructure*);
2025a587d139SMark 
2026a587d139SMark #ifdef PETSC_HAVE_KOKKOS_KERNELS
2027042217e8SBarry Smith PETSC_EXTERN PetscErrorCode MatKokkosGetDeviceMatWrite(Mat,PetscSplitCSRDataStructure*);
2028042217e8SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJKokkosSetDeviceMat(Mat,PetscSplitCSRDataStructure);
2029042217e8SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJKokkosGetDeviceMat(Mat,PetscSplitCSRDataStructure*);
2030a587d139SMark #endif
2031a587d139SMark 
2032aa372e3fSPaul Mullowney #ifdef PETSC_HAVE_CUDA
20333f9c0db1SPaul Mullowney /*E
2034e057df02SPaul Mullowney     MatCUSPARSEStorageFormat - indicates the storage format for CUSPARSE (GPU)
20352692e278SPaul Mullowney     matrices.
2036e057df02SPaul Mullowney 
2037e057df02SPaul Mullowney     Not Collective
2038e057df02SPaul Mullowney 
2039*87497f52SBarry Smith +   `MAT_CUSPARSE_CSR` - Compressed Sparse Row
2040*87497f52SBarry Smith .   `MAT_CUSPARSE_ELL` - Ellpack (requires CUDA 4.2 or later).
2041*87497f52SBarry Smith -   `MAT_CUSPARSE_HYB` - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later).
2042e057df02SPaul Mullowney 
2043e057df02SPaul Mullowney     Level: intermediate
2044e057df02SPaul Mullowney 
2045*87497f52SBarry Smith    Developer Note:
2046af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
2047e057df02SPaul Mullowney 
2048db781477SPatrick Sanan .seealso: `MatCUSPARSESetFormat()`, `MatCUSPARSEFormatOperation`
2049e057df02SPaul Mullowney E*/
2050e057df02SPaul Mullowney 
20513f9c0db1SPaul Mullowney typedef enum {MAT_CUSPARSE_CSR, MAT_CUSPARSE_ELL, MAT_CUSPARSE_HYB} MatCUSPARSEStorageFormat;
2052e057df02SPaul Mullowney 
2053e057df02SPaul Mullowney /* these will be strings associated with enumerated type defined above */
2054e057df02SPaul Mullowney PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[];
2055e057df02SPaul Mullowney 
20563f9c0db1SPaul Mullowney /*E
2057e057df02SPaul Mullowney     MatCUSPARSEFormatOperation - indicates the operation of CUSPARSE (GPU)
20582692e278SPaul Mullowney     matrices whose operation should use a particular storage format.
2059e057df02SPaul Mullowney 
2060e057df02SPaul Mullowney     Not Collective
2061e057df02SPaul Mullowney 
2062*87497f52SBarry Smith +   `MAT_CUSPARSE_MULT_DIAG` - sets the storage format for the diagonal matrix in the parallel MatMult
2063*87497f52SBarry Smith .   `MAT_CUSPARSE_MULT_OFFDIAG` - sets the storage format for the offdiagonal matrix in the parallel MatMult
2064*87497f52SBarry Smith .   `MAT_CUSPARSE_MULT` - sets the storage format for the entire matrix in the serial (single GPU) MatMult
2065*87497f52SBarry Smith -   `MAT_CUSPARSE_ALL` - sets the storage format for all CUSPARSE (GPU) matrices
2066e057df02SPaul Mullowney 
2067e057df02SPaul Mullowney     Level: intermediate
2068e057df02SPaul Mullowney 
2069db781477SPatrick Sanan .seealso: `MatCUSPARSESetFormat()`, `MatCUSPARSEStorageFormat`
2070e057df02SPaul Mullowney E*/
207136d62e41SPaul Mullowney typedef enum {MAT_CUSPARSE_MULT_DIAG, MAT_CUSPARSE_MULT_OFFDIAG, MAT_CUSPARSE_MULT, MAT_CUSPARSE_ALL} MatCUSPARSEFormatOperation;
2072e057df02SPaul Mullowney 
207310e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
207410e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
2075e057df02SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat,MatCUSPARSEFormatOperation,MatCUSPARSEStorageFormat);
2076365b711fSMark Adams PETSC_EXTERN PetscErrorCode MatCUSPARSESetUseCPUSolve(Mat,PetscBool);
2077e8d2b73aSMark Adams typedef struct Mat_SeqAIJCUSPARSETriFactors* Mat_SeqAIJCUSPARSETriFactors_p;
20785f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetIJ(Mat,PetscBool,const int**,const int**);
20795f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreIJ(Mat,PetscBool,const int**,const int**);
20805f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayRead(Mat,const PetscScalar**);
20815f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayRead(Mat,const PetscScalar**);
20825f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArrayWrite(Mat,PetscScalar**);
20835f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArrayWrite(Mat,PetscScalar**);
20845f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSEGetArray(Mat,PetscScalar**);
20855f101d05SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJCUSPARSERestoreArray(Mat,PetscScalar**);
2086637a0070SStefano Zampini 
2087637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateDenseCUDA(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*);
2088637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatCreateSeqDenseCUDA(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*);
2089637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatMPIDenseCUDASetPreallocation(Mat,PetscScalar[]);
2090637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqDenseCUDASetPreallocation(Mat,PetscScalar[]);
2091637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayWrite(Mat,PetscScalar**);
2092637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArrayRead(Mat,const PetscScalar**);
2093637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAGetArray(Mat,PetscScalar**);
2094637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayWrite(Mat,PetscScalar**);
2095637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArrayRead(Mat,const PetscScalar**);
2096637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDARestoreArray(Mat,PetscScalar**);
2097637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAPlaceArray(Mat,const PetscScalar*);
2098d5ea218eSStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAReplaceArray(Mat,const PetscScalar*);
2099637a0070SStefano Zampini PETSC_EXTERN PetscErrorCode MatDenseCUDAResetArray(Mat);
21003fa6b06aSMark Adams 
21019ae82921SPaul Mullowney #endif
21029ae82921SPaul Mullowney 
2103d67ff14aSKarl Rupp #if defined(PETSC_HAVE_VIENNACL)
2104d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
2105d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
2106d67ff14aSKarl Rupp #endif
2107d67ff14aSKarl Rupp 
210854efbe56SHong Zhang #if defined(PETSC_HAVE_FFTW)
2109014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat,Vec,Vec);
2110014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat,Vec,Vec);
21112a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat,Vec*,Vec*,Vec*);
211254efbe56SHong Zhang #endif
211354efbe56SHong Zhang 
2114d24d4204SJose E. Roman #if defined(PETSC_HAVE_SCALAPACK)
2115d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateScaLAPACK(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
2116d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKSetBlockSizes(Mat,PetscInt,PetscInt);
2117d24d4204SJose E. Roman PETSC_EXTERN PetscErrorCode MatScaLAPACKGetBlockSizes(Mat,PetscInt*,PetscInt*);
2118d24d4204SJose E. Roman #endif
2119d24d4204SJose E. Roman 
2120014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm,PetscInt,const IS[],PetscInt,const IS[],const Mat[],Mat*);
2121014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat,PetscInt*,PetscInt*);
2122014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat,IS[],IS[]);
2123014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat,IS[],IS[]);
2124014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat,PetscInt*,PetscInt*,Mat***);
2125014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat,PetscInt,PetscInt,Mat*);
212619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat,VecType);
2127014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat,PetscInt,const IS[],PetscInt,const IS[],const Mat[]);
2128014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat,PetscInt,PetscInt,Mat);
2129d8588912SDave May 
21304325cce7SMatthew G Knepley PETSC_EXTERN PetscErrorCode MatChop(Mat,PetscReal);
2131e0a58c10SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat,PetscReal,PetscInt*);
21324325cce7SMatthew G Knepley 
2133b541e6a4SDmitry Karpeev PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat,PetscInt,PetscInt*,IS**);
213453dd7562SDmitry Karpeev 
2135c094ef40SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat,PetscBool,Mat);
2136c094ef40SMatthew G. Knepley 
2137539c167fSBarry Smith PETSC_INTERN PetscErrorCode MatHeaderMerge(Mat,Mat*);
2138539c167fSBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat,Mat*);
21391a2c6b5cSJunchao Zhang 
21407ee59b9bSJunchao Zhang PETSC_EXTERN PetscErrorCode MatSeqAIJGetCSRAndMemType(Mat,const PetscInt**,const PetscInt**,PetscScalar**,PetscMemType*);
214172833a62Smarkadams4 
214272833a62Smarkadams4 PETSC_EXTERN PetscErrorCode MatCreateGraph(Mat,PetscBool,PetscBool,Mat*);
214372833a62Smarkadams4 PETSC_EXTERN PetscErrorCode MatFilter(Mat,PetscReal,Mat*);
214472833a62Smarkadams4 
214523a5497aSJed Brown #endif
2146