xref: /petsc/include/petscmat.h (revision 8f1ea47ad061ce8c76f1cbfac9f6b11906423d51)
12eac72dbSBarry Smith /*
22eac72dbSBarry Smith      Include file for the matrix component of PETSc
32eac72dbSBarry Smith */
426bd1501SBarry Smith #ifndef PETSCMAT_H
526bd1501SBarry Smith #define PETSCMAT_H
62c8e378dSBarry Smith #include <petscvec.h>
72eac72dbSBarry Smith 
8d9274352SBarry Smith /*S
98f6c3df8SBarry Smith      Mat - Abstract PETSc matrix object used to manage all linear operators in PETSc, even those without
108f6c3df8SBarry Smith            an explicit sparse representation (such as matrix-free operators)
112eac72dbSBarry Smith 
12d91e6319SBarry Smith    Level: beginner
13d91e6319SBarry Smith 
148f6c3df8SBarry Smith .seealso:  MatCreate(), MatType, MatSetType(), MatDestroy()
15d9274352SBarry Smith S*/
16d9274352SBarry Smith typedef struct _p_Mat*           Mat;
17d9274352SBarry Smith 
1876bdecfbSBarry Smith /*J
198f6c3df8SBarry Smith     MatType - String with the name of a PETSc matrix type
20d9274352SBarry Smith 
21d9274352SBarry Smith    Level: beginner
22d9274352SBarry Smith 
233ca39a21SBarry Smith .seealso: MatSetType(), Mat, MatSolverType, MatRegister()
2476bdecfbSBarry Smith J*/
2519fd82e9SBarry Smith typedef const char* MatType;
26273d9f13SBarry Smith #define MATSAME            "same"
275a11e1b2SBarry Smith #define MATMAIJ            "maij"
28273d9f13SBarry Smith #define MATSEQMAIJ         "seqmaij"
29273d9f13SBarry Smith #define MATMPIMAIJ         "mpimaij"
3049bd79ccSDebojyoti Ghosh #define MATKAIJ            "kaij"
3149bd79ccSDebojyoti Ghosh #define MATSEQKAIJ         "seqkaij"
3249bd79ccSDebojyoti Ghosh #define MATMPIKAIJ         "mpikaij"
33273d9f13SBarry Smith #define MATIS              "is"
345a11e1b2SBarry Smith #define MATAIJ             "aij"
35273d9f13SBarry Smith #define MATSEQAIJ          "seqaij"
36273d9f13SBarry Smith #define MATMPIAIJ          "mpiaij"
375a11e1b2SBarry Smith #define MATAIJCRL          "aijcrl"
385a11e1b2SBarry Smith #define MATSEQAIJCRL       "seqaijcrl"
395a11e1b2SBarry Smith #define MATMPIAIJCRL       "mpiaijcrl"
409ae82921SPaul Mullowney #define MATAIJCUSPARSE     "aijcusparse"
419ae82921SPaul Mullowney #define MATSEQAIJCUSPARSE  "seqaijcusparse"
429ae82921SPaul Mullowney #define MATMPIAIJCUSPARSE  "mpiaijcusparse"
43d67ff14aSKarl Rupp #define MATAIJVIENNACL     "aijviennacl"
44d67ff14aSKarl Rupp #define MATSEQAIJVIENNACL  "seqaijviennacl"
45d67ff14aSKarl Rupp #define MATMPIAIJVIENNACL  "mpiaijviennacl"
465a11e1b2SBarry Smith #define MATAIJPERM         "aijperm"
475a11e1b2SBarry Smith #define MATSEQAIJPERM      "seqaijperm"
485a11e1b2SBarry Smith #define MATMPIAIJPERM      "mpiaijperm"
494dfdc2d9SRichard Tran Mills #define MATAIJSELL         "aijsell"
504dfdc2d9SRichard Tran Mills #define MATSEQAIJSELL      "seqaijsell"
514dfdc2d9SRichard Tran Mills #define MATMPIAIJSELL      "mpiaijsell"
524a2a386eSRichard Tran Mills #define MATAIJMKL          "aijmkl"
534a2a386eSRichard Tran Mills #define MATSEQAIJMKL       "seqaijmkl"
544a2a386eSRichard Tran Mills #define MATMPIAIJMKL       "mpiaijmkl"
55b5b72c8aSIrina Sokolova #define MATBAIJMKL         "baijmkl"
56b5b72c8aSIrina Sokolova #define MATSEQBAIJMKL      "seqbaijmkl"
57b5b72c8aSIrina Sokolova #define MATMPIBAIJMKL      "mpibaijmkl"
58273d9f13SBarry Smith #define MATSHELL           "shell"
595a11e1b2SBarry Smith #define MATDENSE           "dense"
60209238afSKris Buschelman #define MATSEQDENSE        "seqdense"
61bfc799aaSStefano Zampini #define MATSEQDENSECUDA    "seqdensecuda"
62273d9f13SBarry Smith #define MATMPIDENSE        "mpidense"
63db31f6deSJed Brown #define MATELEMENTAL       "elemental"
645a11e1b2SBarry Smith #define MATBAIJ            "baij"
65273d9f13SBarry Smith #define MATSEQBAIJ         "seqbaij"
66273d9f13SBarry Smith #define MATMPIBAIJ         "mpibaij"
67273d9f13SBarry Smith #define MATMPIADJ          "mpiadj"
685a11e1b2SBarry Smith #define MATSBAIJ           "sbaij"
69273d9f13SBarry Smith #define MATSEQSBAIJ        "seqsbaij"
70273d9f13SBarry Smith #define MATMPISBAIJ        "mpisbaij"
71cebc7f6cSBarry Smith #define MATDAAD            "daad"
72cebc7f6cSBarry Smith #define MATMFFD            "mffd"
73c8a8475eSBarry Smith #define MATNORMAL          "normal"
74c5e4d11fSDmitry Karpeev #define MATNORMALHERMITIAN "normalh"
75ab92ecdeSBarry Smith #define MATLRC             "lrc"
762a6744ebSBarry Smith #define MATSCATTER         "scatter"
77421e10b8SBarry Smith #define MATBLOCKMAT        "blockmat"
78793850ffSBarry Smith #define MATCOMPOSITE       "composite"
791f8c7532SHong Zhang #define MATFFT             "fft"
801f8c7532SHong Zhang #define MATFFTW            "fftw"
81e133240eSMatthew G Knepley #define MATSEQCUFFT        "seqcufft"
82557cca28SSatish Balay #define MATTRANSPOSEMAT    "transpose"
8372ca8751SBarry Smith #define MATSCHURCOMPLEMENT "schurcomplement"
841d6018f0SLisandro Dalcin #define MATPYTHON          "python"
8563c07aadSStefano Zampini #define MATHYPRE           "hypre"
86f91d8e95SBarry Smith #define MATHYPRESTRUCT     "hyprestruct"
87a9e6138eSGlenn Hammond #define MATHYPRESSTRUCT    "hypresstruct"
88ee1cef2cSJed Brown #define MATSUBMATRIX       "submatrix"
892c0dbf93SJed Brown #define MATLOCALREF        "localref"
90d8588912SDave May #define MATNEST            "nest"
91c094ef40SMatthew G. Knepley #define MATPREALLOCATOR    "preallocator"
92d4002b98SHong Zhang #define MATSELL            "sell"
93d4002b98SHong Zhang #define MATSEQSELL         "seqsell"
94d4002b98SHong Zhang #define MATMPISELL         "mpisell"
95a3b2e22bSHong Zhang #define MATDUMMY           "dummy"
96cd929ea3SAlp Dener #define MATLMVM            "lmvm"
9778e4361aSAlp Dener #define MATLMVMDFP         "lmvmdfp"
9878e4361aSAlp Dener #define MATLMVMBFGS        "lmvmbfgs"
9978e4361aSAlp Dener #define MATLMVMSR1         "lmvmsr1"
10078e4361aSAlp Dener #define MATLMVMBRDN        "lmvmbrdn"
10178e4361aSAlp Dener #define MATLMVMBADBRDN     "lmvmbadbrdn"
10278e4361aSAlp Dener #define MATLMVMSYMBRDN     "lmvmsymbrdn"
10318ad3407SAlp Dener #define MATLMVMSYMBADBRDN  "lmvmsymbadbrdn"
10450b47da0SAdam Denchfield #define MATLMVMDIAGBRDN    "lmvmdiagbrdn"
1053423f386SBarry Smith #define MATCONSTANTDIAGONAL "constantdiagonal"
106773941d6SBarry Smith 
10776bdecfbSBarry Smith /*J
1083ca39a21SBarry Smith     MatSolverType - String with the name of a PETSc matrix solver type.
1099989ab13SBarry Smith 
110c2b89b5dSBarry Smith     For example: "petsc" indicates what PETSc provides, "superlu_dist" the parallel SuperLU_DIST package etc
1119989ab13SBarry Smith 
1129989ab13SBarry Smith    Level: beginner
1139989ab13SBarry Smith 
114c7ccbb75SBarry Smith    Notes:  MATSOLVERUMFPACK, MATSOLVERCHOLMOD, MATSOLVERKLU form the SuiteSparse package for which you can use --download-suitesparse
115c7ccbb75SBarry Smith 
116b198fc33SVáclav Hapla .seealso: MatGetFactor(), PCFactorSetMatSolverType(), PCFactorGetMatSolverType()
11776bdecfbSBarry Smith J*/
118ea799195SBarry Smith typedef const char* MatSolverType;
1192692d6eeSBarry Smith #define MATSOLVERSUPERLU          "superlu"
1202692d6eeSBarry Smith #define MATSOLVERSUPERLU_DIST     "superlu_dist"
12108f5efcfSPieter Ghysels #define MATSOLVERSTRUMPACK        "strumpack"
1222692d6eeSBarry Smith #define MATSOLVERUMFPACK          "umfpack"
12320db9a53SJed Brown #define MATSOLVERCHOLMOD          "cholmod"
124d89f5e7aSBarry Smith #define MATSOLVERKLU              "klu"
125418810c4SBarry Smith #define MATSOLVERSPARSEELEMENTAL  "sparseelemental"
126d89f5e7aSBarry Smith #define MATSOLVERELEMENTAL        "elemental"
1272692d6eeSBarry Smith #define MATSOLVERESSL             "essl"
1282692d6eeSBarry Smith #define MATSOLVERLUSOL            "lusol"
1292692d6eeSBarry Smith #define MATSOLVERMUMPS            "mumps"
130d615f992SSatish Balay #define MATSOLVERMKL_PARDISO      "mkl_pardiso"
131d305a81bSVasiliy Kozyrev #define MATSOLVERMKL_CPARDISO     "mkl_cpardiso"
1322692d6eeSBarry Smith #define MATSOLVERPASTIX           "pastix"
1332692d6eeSBarry Smith #define MATSOLVERMATLAB           "matlab"
1342692d6eeSBarry Smith #define MATSOLVERPETSC            "petsc"
1352692d6eeSBarry Smith #define MATSOLVERBAS              "bas"
1369ae82921SPaul Mullowney #define MATSOLVERCUSPARSE         "cusparse"
137bfc799aaSStefano Zampini #define MATSOLVERCUDA             "cuda"
138c0cdd4a1SDahai Guo 
139b24902e0SBarry Smith /*E
140b24902e0SBarry Smith     MatFactorType - indicates what type of factorization is requested
141b24902e0SBarry Smith 
142b24902e0SBarry Smith     Level: beginner
143b24902e0SBarry Smith 
144af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
145b24902e0SBarry Smith 
1463ca39a21SBarry Smith .seealso: MatSolverType, MatGetFactor()
147b24902e0SBarry Smith E*/
148552a653fSAlp Dener typedef enum {MAT_FACTOR_NONE, MAT_FACTOR_LU, MAT_FACTOR_CHOLESKY, MAT_FACTOR_ILU, MAT_FACTOR_ICC,MAT_FACTOR_ILUDT} MatFactorType;
149014dd563SJed Brown PETSC_EXTERN const char *const MatFactorTypes[];
150e92e720dSBarry Smith 
151ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactor(Mat,MatSolverType,MatFactorType,Mat*);
152ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat,MatSolverType,MatFactorType,PetscBool *);
153ea799195SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetSolverType(Mat,MatSolverType*);
154014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat,MatFactorType*);
1557abd51d3SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatSetFactorType(Mat,MatFactorType);
156fd9d3c67SJed Brown PETSC_EXTERN PetscErrorCode MatSolverTypeRegister(MatSolverType,MatType,MatFactorType,PetscErrorCode(*)(Mat,MatFactorType,Mat*));
157fd9d3c67SJed Brown PETSC_EXTERN PetscErrorCode MatSolverTypeGet(MatSolverType,MatType,MatFactorType,PetscBool*,PetscBool*,PetscErrorCode (**)(Mat,MatFactorType,Mat*));
15825ef9dfeSBarry Smith typedef MatSolverType MatSolverPackage PETSC_DEPRECATED_TYPEDEF("Use MatSolverType (since version 3.9)");
15925ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatSolverTypeRegister() (since version 3.9)") PETSC_STATIC_INLINE PetscErrorCode MatSolverPackageRegister(MatSolverType stype,MatType mtype,MatFactorType ftype,PetscErrorCode(*f)(Mat,MatFactorType,Mat*))
160c19b563cSJed Brown { return MatSolverTypeRegister(stype,mtype,ftype,f); }
16125ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatSolverTypeGet() (since version 3.9)") PETSC_STATIC_INLINE PetscErrorCode MatSolverPackageGet(MatSolverType stype,MatType mtype,MatFactorType ftype,PetscBool *foundmtype,PetscBool *foundstype,PetscErrorCode(**f)(Mat,MatFactorType,Mat*))
162c19b563cSJed Brown { return MatSolverTypeGet(stype,mtype,ftype,foundmtype,foundstype,f); }
1639989ab13SBarry Smith 
164c06d978dSMatthew Knepley /* Logging support */
1650700a824SBarry Smith #define    MAT_FILE_CLASSID 1211216    /* used to indicate matrices in binary files */
166014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_CLASSID;
167335efc43SPeter Brune PETSC_EXTERN PetscClassId MAT_COLORING_CLASSID;
168014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID;
169014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID;
170014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID;
171014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID;
172014dd563SJed Brown PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID;
173014dd563SJed Brown PETSC_EXTERN PetscClassId MATMFFD_CLASSID;
174c06d978dSMatthew Knepley 
175ceb03754SKris Buschelman /*E
1767dae84e0SHong Zhang     MatReuse - Indicates if matrices obtained from a previous call to MatCreateSubMatrices(), MatCreateSubMatrix(), MatConvert() or several other functions
177cf37664fSBarry Smith      are to be reused to store the new matrix values.
178cf37664fSBarry Smith 
179cf37664fSBarry Smith $  MAT_INITIAL_MATRIX - create a new matrix
180cf37664fSBarry Smith $  MAT_REUSE_MATRIX - reuse the matrix created with a previous call that used MAT_INITIAL_MATRIX
181cf37664fSBarry Smith $  MAT_INPLACE_MATRIX - replace the first input matrix with the new matrix (not applicable to all functions)
182cf37664fSBarry 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)
183ceb03754SKris Buschelman 
184ceb03754SKris Buschelman     Level: beginner
185ceb03754SKris Buschelman 
186af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
187ceb03754SKris Buschelman 
1887dae84e0SHong Zhang .seealso: MatCreateSubMatrices(), MatCreateSubMatrix(), MatDestroyMatrices(), MatConvert()
189ceb03754SKris Buschelman E*/
190511c6705SHong Zhang typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX,MAT_IGNORE_MATRIX,MAT_INPLACE_MATRIX} MatReuse;
191ceb03754SKris Buschelman 
1925494a064SHong Zhang /*E
1937dae84e0SHong Zhang     MatCreateSubMatrixOption - Indicates if matrices obtained from a call to MatCreateSubMatrices()
194829201f2SHong Zhang      include the matrix values. Currently it is only used by MatGetSeqNonzerostructure().
1955494a064SHong Zhang 
1965494a064SHong Zhang     Level: beginner
1975494a064SHong Zhang 
198829201f2SHong Zhang .seealso: MatGetSeqNonzerostructure()
1995494a064SHong Zhang E*/
2007dae84e0SHong Zhang typedef enum {MAT_DO_NOT_GET_VALUES,MAT_GET_VALUES} MatCreateSubMatrixOption;
2015494a064SHong Zhang 
202607a6623SBarry Smith PETSC_EXTERN PetscErrorCode MatInitializePackage(void);
203c06d978dSMatthew Knepley 
204014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm,Mat*);
205014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetSizes(Mat,PetscInt,PetscInt,PetscInt,PetscInt);
20619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatSetType(Mat,MatType);
207014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat);
208685405a1SBarry Smith PETSC_STATIC_INLINE PetscErrorCode MatViewFromOptions(Mat A,PetscObject obj,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,obj,name);}
209bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatRegister(const char[],PetscErrorCode(*)(Mat));
21023bebc0bSBarry Smith PETSC_EXTERN PetscErrorCode MatRegisterRootName(const char[],const char[],const char[]);
211014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat,const char[]);
212014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat,const char[]);
213014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat,const char*[]);
21484d44b13SHong Zhang PETSC_EXTERN PetscErrorCode MatSetErrorIfFailure(Mat,PetscBool);
215f69a0ea3SMatthew Knepley 
216140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatList;
217140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatColoringList;
218140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatPartitioningList;
21928988994SBarry Smith 
2203b224e63SBarry Smith /*E
221aa6c7ce3SBarry Smith     MatStructure - Indicates if two matrices have the same nonzero structure
2223b224e63SBarry Smith 
2233b224e63SBarry Smith     Level: beginner
2243b224e63SBarry Smith 
225af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
2263b224e63SBarry Smith 
227aa6c7ce3SBarry Smith .seealso: MatCopy(), MatAXPY()
2283b224e63SBarry Smith E*/
229aa6c7ce3SBarry Smith typedef enum {DIFFERENT_NONZERO_PATTERN,SUBSET_NONZERO_PATTERN,SAME_NONZERO_PATTERN} MatStructure;
2303b224e63SBarry Smith 
2319779e05dSSatish Balay #if defined PETSC_HAVE_MKL_SPARSE
232ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqAIJMKL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
233ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateMPIAIJMKL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
23480095d54SIrina Sokolova PETSC_EXTERN PetscErrorCode MatCreateBAIJMKL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
235ddee360bSSatish Balay PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJMKL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
23680095d54SIrina Sokolova #endif
237cd929ea3SAlp Dener 
238d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSeqSELL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
239d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSELL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
240d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatSeqSELLSetPreallocation(Mat,PetscInt,const PetscInt[]);
241d4002b98SHong Zhang PETSC_EXTERN PetscErrorCode MatMPISELLSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
24280095d54SIrina Sokolova 
243014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*);
244014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*);
245014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
246014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
247014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat *);
2488f8f2f0dSBarry Smith PETSC_EXTERN PetscErrorCode MatUpdateMPIAIJWithArrays(Mat,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
249014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],PetscInt[],PetscInt[],PetscScalar[],Mat*);
2503b00a383SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSeqAIJ(MPI_Comm,Mat,Mat,const PetscInt[],Mat*);
2513b00a383SHong Zhang 
252014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
253014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
254014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat*);
255d21a29f3SJed Brown 
256014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*);
257014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
258d21a29f3SJed Brown 
259014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
260014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat *);
26138f409ebSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
262014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
2634cce697cSJed Brown PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],const PetscInt[]);
264dfb205c3SBarry Smith 
265014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*);
266014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat,Mat*);
267c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateNormalHermitian(Mat,Mat*);
268986c4d72SJose E. Roman PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat,Mat,Vec,Mat,Mat*);
269267ca84cSJose E. Roman PETSC_EXTERN PetscErrorCode MatLRCGetMats(Mat,Mat*,Mat*,Vec*,Mat*);
270c5e4d11fSDmitry Karpeev PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,ISLocalToGlobalMapping,ISLocalToGlobalMapping,Mat*);
271014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
272014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
273c0cdd4a1SDahai Guo 
274014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm,VecScatter,Mat*);
275014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat,VecScatter);
276014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat,VecScatter*);
277014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,Mat*);
278014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat,Mat);
279014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat);
2808c8613bfSJakub Kruzik typedef enum {MAT_COMPOSITE_MERGE_RIGHT,MAT_COMPOSITE_MERGE_LEFT} MatCompositeMergeType;
2818c8613bfSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMergeType(Mat,MatCompositeMergeType);
282014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm,PetscInt,const Mat*,Mat*);
2836d7c1e57SBarry Smith typedef enum {MAT_COMPOSITE_ADDITIVE,MAT_COMPOSITE_MULTIPLICATIVE} MatCompositeType;
284014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat,MatCompositeType);
2856dbc55e5SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetType(Mat,MatCompositeType*);
2863b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeSetMatStructure(Mat,MatStructure);
2873b35acafSJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMatStructure(Mat,MatStructure*);
2886d0add67SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetNumberMat(Mat,PetscInt*);
2898b5c3584SJakub Kruzik PETSC_EXTERN PetscErrorCode MatCompositeGetMat(Mat,PetscInt,Mat*);
29003049c21SJunchao Zhang PETSC_EXTERN PetscErrorCode MatCompositeSetScalings(Mat,const PetscScalar*);
2916d7c1e57SBarry Smith 
29219fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm,PetscInt,const PetscInt[],MatType,Mat*);
293014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm,PetscInt,const PetscInt[],Mat*);
294dedccee8SHong Zhang 
295014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat,Mat*);
2968060fb66Sstefano_zampini PETSC_EXTERN PetscErrorCode MatTransposeGetMat(Mat,Mat*);
297d0de2241SAndrew Spott PETSC_EXTERN PetscErrorCode MatCreateHermitianTranspose(Mat,Mat*);
29806511a5cSPierre Jolivet PETSC_EXTERN PetscErrorCode MatHermitianTransposeGetMat(Mat,Mat*);
29954e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrixVirtual(Mat,IS,IS,Mat*);
30054e05e6cSHong Zhang PETSC_EXTERN PetscErrorCode MatSubMatrixVirtualUpdate(Mat,Mat,IS,IS);
301014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat,IS,IS,Mat*);
3023423f386SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateConstantDiagonal(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar,Mat*);
3031472f72bSBarry Smith 
304978814f1SStefano Zampini #if defined(PETSC_HAVE_HYPRE)
305d975228cSstefano_zampini PETSC_EXTERN PetscErrorCode MatHYPRESetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
306978814f1SStefano Zampini #endif
307978814f1SStefano Zampini 
308014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat,const char[]);
3091d6018f0SLisandro Dalcin 
310846b4da1SFande Kong PETSC_EXTERN PetscErrorCode MatResetPreallocation(Mat);
311014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetUp(Mat);
312014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroy(Mat*);
313e56f5c9eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetNonzeroState(Mat,PetscObjectState*);
31421c89e3eSBarry Smith 
315014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatConjugate(Mat);
316014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRealPart(Mat);
317014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat);
318014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat,Mat*);
319014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetTrace(Mat,PetscScalar*);
320713ccfa9SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat,const PetscScalar **);
3210da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatInvertVariableBlockDiagonal(Mat,PetscInt,const PetscInt*,PetscScalar*);
322479a70c0SJed Brown PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonalMat(Mat,Mat);
32399cafbc1SBarry Smith 
3248ed539a5SBarry Smith /* ------------------------------------------------------------*/
325014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
326014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
327014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat,PetscInt,const PetscScalar[]);
328014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat,PetscInt,const PetscScalar[]);
329014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat,PetscInt,PetscInt,PetscInt[],const PetscScalar[]);
33073a71a0fSBarry Smith PETSC_EXTERN PetscErrorCode MatSetRandom(Mat,PetscRandom);
33184cb2905SBarry Smith 
3322ef4de8bSBarry Smith /*S
3332ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
33462ef0227SBarry Smith         column of a matrix as indexed on an associated grid. These are arguments to MatSetStencil() and MatSetBlockStencil()
33562ef0227SBarry Smith 
33662ef0227SBarry 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).
33762ef0227SBarry 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.
33862ef0227SBarry Smith 
33962ef0227SBarry Smith    For stencil access to vectors see DMDAVecGetArray(), DMDAVecGetArrayF90().
340be479b30SJed Brown 
341be479b30SJed Brown    Fortran usage is different, see MatSetValuesStencil() for details.
3422ef4de8bSBarry Smith 
3432ef4de8bSBarry Smith    Level: beginner
3442ef4de8bSBarry Smith 
34562ef0227SBarry Smith .seealso:  MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockedStencil(), DMDAVecGetArray(), DMDAVecGetArrayF90()
3462ef4de8bSBarry Smith S*/
347435da068SBarry Smith typedef struct {
348c1ac3661SBarry Smith   PetscInt k,j,i,c;
349435da068SBarry Smith } MatStencil;
3502ef4de8bSBarry Smith 
351014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
352014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
353014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt);
354435da068SBarry Smith 
355d91e6319SBarry Smith /*E
356d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
35762ef0227SBarry Smith      to continue to add or insert values to it
358d91e6319SBarry Smith 
359d91e6319SBarry Smith     Level: beginner
360d91e6319SBarry Smith 
361d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
362d91e6319SBarry Smith E*/
3636d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
364014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat,MatAssemblyType);
365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat,MatAssemblyType);
366014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAssembled(Mat,PetscBool *);
3674f9c727eSBarry Smith 
3681d73ed98SBarry Smith 
36930de9b25SBarry Smith 
370d91e6319SBarry Smith /*E
371d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
372d91e6319SBarry Smith 
373d91e6319SBarry Smith     Level: beginner
374d91e6319SBarry Smith 
375af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
3760f8fb01aSBarry Smith    Any additions/changes here must also be made in src/mat/interface/dlregismat.c in MatOptions[]
377d91e6319SBarry Smith 
37895452b02SPatrick Sanan    Developer Notes:
37995452b02SPatrick Sanan     Entries that are negative need not be called collectively by all processes.
380382164b0SBarry Smith 
381d91e6319SBarry Smith .seealso: MatSetOption()
382d91e6319SBarry Smith E*/
383c5e4d11fSDmitry Karpeev typedef enum {MAT_OPTION_MIN = -3,
384c5e4d11fSDmitry Karpeev               MAT_UNUSED_NONZERO_LOCATION_ERR = -2,
38592d4d306SBarry Smith               MAT_ROW_ORIENTED = -1,
386382164b0SBarry Smith               MAT_SYMMETRIC = 1,
387382164b0SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC = 2,
388382164b0SBarry Smith               MAT_NEW_DIAGONALS = 3,
389382164b0SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES = 4,
390382164b0SBarry Smith               MAT_USE_HASH_TABLE = 5,
391382164b0SBarry Smith               MAT_KEEP_NONZERO_PATTERN = 6,
392382164b0SBarry Smith               MAT_IGNORE_ZERO_ENTRIES = 7,
393382164b0SBarry Smith               MAT_USE_INODES = 8,
394382164b0SBarry Smith               MAT_HERMITIAN = 9,
395382164b0SBarry Smith               MAT_SYMMETRY_ETERNAL = 10,
396c5e4d11fSDmitry Karpeev               MAT_NEW_NONZERO_LOCATION_ERR = 11,
397382164b0SBarry Smith               MAT_IGNORE_LOWER_TRIANGULAR = 12,
398382164b0SBarry Smith               MAT_ERROR_LOWER_TRIANGULAR = 13,
399382164b0SBarry Smith               MAT_GETROW_UPPERTRIANGULAR = 14,
400382164b0SBarry Smith               MAT_SPD = 15,
40192d4d306SBarry Smith               MAT_NO_OFF_PROC_ZERO_ROWS = 16,
40292d4d306SBarry Smith               MAT_NO_OFF_PROC_ENTRIES = 17,
40392d4d306SBarry Smith               MAT_NEW_NONZERO_LOCATIONS = 18,
404c5e4d11fSDmitry Karpeev               MAT_NEW_NONZERO_ALLOCATION_ERR = 19,
405c5e4d11fSDmitry Karpeev               MAT_SUBSET_OFF_PROC_ENTRIES = 20,
406c10200c1SHong Zhang               MAT_SUBMAT_SINGLEIS = 21,
407957cac9fSHong Zhang               MAT_STRUCTURE_ONLY = 22,
408071fcb05SBarry Smith               MAT_SORTED_FULL = 23,
409071fcb05SBarry Smith               MAT_OPTION_MAX = 24} MatOption;
410e057df02SPaul Mullowney 
4110f8fb01aSBarry Smith PETSC_EXTERN const char *const *MatOptions;
412014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetOption(Mat,MatOption,PetscBool);
4137d68702bSBarry Smith PETSC_EXTERN PetscErrorCode MatGetOption(Mat,MatOption,PetscBool*);
41419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetType(Mat,MatType*);
41584cb2905SBarry Smith 
416014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]);
417014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
418014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
419014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat);
420014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat);
421014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat,Vec,PetscInt);
4228c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetArray(Mat,PetscScalar *[]);
423*8f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJGetArrayRead(Mat,const PetscScalar *[]);
4248c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArray(Mat,PetscScalar *[]);
425*8f1ea47aSStefano Zampini PETSC_EXTERN PetscErrorCode MatSeqAIJRestoreArrayRead(Mat,const PetscScalar *[]);
42621e72a00SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJGetMaxRowNonzeros(Mat,PetscInt*);
427bd04181cSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetValuesLocalFast(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
4284099cc6bSBarry Smith PETSC_EXTERN PetscErrorCode MatSeqAIJSetType(Mat,MatType);
429388d47a6SSatish Balay PETSC_EXTERN PetscErrorCode MatSeqAIJRegister(const char[],PetscErrorCode (*)(Mat,MatType,MatReuse,Mat *));
4304099cc6bSBarry Smith PETSC_EXTERN PetscFunctionList MatSeqAIJList;
4318397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJGetArray(Mat,PetscScalar *[]);
4328397e458SBarry Smith PETSC_EXTERN PetscErrorCode MatSeqSBAIJRestoreArray(Mat,PetscScalar *[]);
4338c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArray(Mat,PetscScalar *[]);
4348c778c55SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArray(Mat,PetscScalar *[]);
435d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDensePlaceArray(Mat,const PetscScalar[]);
436d3042a70SBarry Smith PETSC_EXTERN PetscErrorCode MatDenseResetArray(Mat);
4378572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetArrayRead(Mat,const PetscScalar *[]);
4388572280aSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseRestoreArrayRead(Mat,const PetscScalar *[]);
439014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat,PetscInt *);
440014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat,PetscInt);
441014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat,PetscInt *,PetscInt *);
442014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat,PetscInt,PetscInt);
44333d57670SJed Brown PETSC_EXTERN PetscErrorCode MatSetBlockSizesFromMats(Mat,Mat,Mat);
4440da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetVariableBlockSizes(Mat,PetscInt,PetscInt*);
4450da83c2eSBarry Smith PETSC_EXTERN PetscErrorCode MatGetVariableBlockSizes(Mat,PetscInt*,const PetscInt**);
4460da83c2eSBarry Smith 
44786aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseGetColumn(Mat,PetscInt,PetscScalar *[]);
44886aefd0dSHong Zhang PETSC_EXTERN PetscErrorCode MatDenseRestoreColumn(Mat,PetscScalar *[]);
4491620fd73SBarry Smith 
450014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMult(Mat,Vec,Vec);
451014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat,Vec,Vec);
452014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAdd(Mat,Vec,Vec,Vec);
453014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat,Vec,Vec);
454014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat,Vec,Vec);
455014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat,Mat,PetscReal,PetscBool *);
456014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat,Mat,PetscReal,PetscBool *);
457014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat,Vec,Vec,Vec);
458014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat,Vec,Vec,Vec);
459014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultConstrained(Mat,Vec,Vec);
460014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeConstrained(Mat,Vec,Vec);
461014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatSolve(Mat,Mat,Mat);
462bdc285e1SStefano Zampini PETSC_EXTERN PetscErrorCode MatMatSolveTranspose(Mat,Mat,Mat);
463eb3ef3b2SHong Zhang PETSC_EXTERN PetscErrorCode MatMatTransposeSolve(Mat,Mat,Mat);
464f9426fe0SMark Adams PETSC_EXTERN PetscErrorCode MatResidual(Mat,Vec,Vec,Vec);
465f5edf698SHong Zhang 
466d91e6319SBarry Smith /*E
467d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
468d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
469d91e6319SBarry Smith 
470d91e6319SBarry Smith     Level: beginner
471d91e6319SBarry Smith 
472af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
473d91e6319SBarry Smith 
4740018da39SRichard Tran Mills $   MAT_DO_NOT_COPY_VALUES    - Create a matrix using the same nonzero pattern as the original matrix,
4750018da39SRichard Tran Mills $                               with zeros for the numerical values.
4760018da39SRichard Tran Mills $   MAT_COPY_VALUES           - Create a matrix with the same nonzero pattern as the original matrix
4770018da39SRichard Tran Mills $                               and with the same numerical values.
4780018da39SRichard Tran Mills $   MAT_SHARE_NONZERO_PATTERN - Create a matrix that shares the nonzero structure with the previous matrix
4790018da39SRichard Tran Mills $                               and does not copy it, using zeros for the numerical values. The parent and
4800018da39SRichard Tran Mills $                               child matrices will share their index (i and j) arrays, and you cannot
4810018da39SRichard Tran Mills $                               insert new nonzero entries into either matrix.
4820018da39SRichard Tran Mills 
48395452b02SPatrick Sanan Notes:
48495452b02SPatrick Sanan     Many matrix types (including SeqAIJ) do not support the MAT_SHARE_NONZERO_PATTERN optimization; in
4850018da39SRichard Tran Mills this case the behavior is as if MAT_DO_NOT_COPY_VALUES has been specified.
48670dcbbb9SBarry Smith 
487d91e6319SBarry Smith .seealso: MatDuplicate()
488d91e6319SBarry Smith E*/
48970dcbbb9SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES,MAT_SHARE_NONZERO_PATTERN} MatDuplicateOption;
4902e8a6d31SBarry Smith 
49119fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatConvert(Mat,MatType,MatReuse,Mat*);
492014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDuplicate(Mat,MatDuplicateOption,Mat*);
49394a9d846SBarry Smith 
494cb5b572fSBarry Smith 
495014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCopy(Mat,Mat,MatStructure);
496014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatView(Mat,PetscViewer);
497014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat,PetscReal,PetscBool *);
498014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat,PetscBool *);
499014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat,PetscReal,PetscBool *);
500014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat,PetscBool *,PetscBool *);
501014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat,PetscBool *,PetscBool *);
502014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat,PetscBool  *,PetscInt *);
503014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer);
5047b80b807SBarry Smith 
5051a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt*,const PetscInt *[],const PetscInt *[],PetscBool  *);
5061a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt *,const PetscInt *[],const PetscInt *[],PetscBool  *);
5071a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt*,const PetscInt *[],const PetscInt *[],PetscBool  *);
5081a83f524SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt *,const PetscInt *[],const PetscInt *[],PetscBool  *);
509d4fbbf0eSBarry Smith 
510d91e6319SBarry Smith /*S
511d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
512d91e6319SBarry Smith 
513d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
514d91e6319SBarry Smith 
515d91e6319SBarry Smith    Level: intermediate
516d91e6319SBarry Smith 
517d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
518d91e6319SBarry Smith S*/
5194e220ebcSLois Curfman McInnes typedef struct {
520b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
521b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
522b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
523b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
524b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
525b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
526b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
5274e220ebcSLois Curfman McInnes } MatInfo;
5284e220ebcSLois Curfman McInnes 
529d9274352SBarry Smith /*E
530d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
531d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
532d9274352SBarry Smith 
533d9274352SBarry Smith     Level: beginner
534d9274352SBarry Smith 
535af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
536d9274352SBarry Smith 
537d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
538d9274352SBarry Smith E*/
5397b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
540014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInfo(Mat,MatInfoType,MatInfo*);
541014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat,Vec);
542014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat,Vec,PetscInt[]);
543014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat,Vec,PetscInt[]);
544014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat,Vec,PetscInt[]);
545014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat,Vec,PetscInt[]);
546014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat,Vec);
547014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTranspose(Mat,MatReuse,Mat*);
548014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat,MatReuse,Mat*);
549014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPermute(Mat,IS,IS,Mat*);
550014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat,Vec,Vec);
551014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat,Vec,InsertMode);
552a52676ecSHong Zhang 
553014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatEqual(Mat,Mat,PetscBool*);
554014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultEqual(Mat,Mat,PetscInt,PetscBool*);
555014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat,Mat,PetscInt,PetscBool*);
556014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat,Mat,PetscInt,PetscBool*);
557014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscBool*);
558a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatMatMultEqual(Mat,Mat,Mat,PetscInt,PetscBool*);
559a52676ecSHong Zhang PETSC_EXTERN PetscErrorCode MatTransposeMatMultEqual(Mat,Mat,Mat,PetscInt,PetscBool*);
560cc48ffa7SToby Isaac PETSC_EXTERN PetscErrorCode MatMatTransposeMultEqual(Mat,Mat,Mat,PetscInt,PetscBool*);
56186919fd6SHong Zhang PETSC_EXTERN PetscErrorCode MatIsLinear(Mat,PetscInt,PetscBool*);
5627b80b807SBarry Smith 
563014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNorm(Mat,NormType,PetscReal*);
564014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat,NormType,PetscReal*);
565014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat);
566014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRows(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec);
567014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat,IS,PetscScalar,Vec,Vec);
568014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat,PetscInt,const MatStencil [],PetscScalar,Vec,Vec);
569014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat,PetscInt,const MatStencil[],PetscScalar,Vec,Vec);
570014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec);
571014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat,IS,PetscScalar,Vec,Vec);
5727b80b807SBarry Smith 
573014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSize(Mat,PetscInt*,PetscInt*);
574014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat,PetscInt*,PetscInt*);
575014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat,PetscInt*,PetscInt*);
576014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat,const PetscInt**);
577014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat,PetscInt*,PetscInt*);
578014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat,const PetscInt**);
579566876eaSJed Brown PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat,IS*,IS*);
5805ef9f2a5SBarry Smith 
5817dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
58225ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatrices() (since version 3.8)") PETSC_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);}
5837dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatricesMPI(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
58425ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatricesMPI() (since version 3.8)") PETSC_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);}
585014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt,Mat *[]);
586df750dc8SHong Zhang PETSC_EXTERN PetscErrorCode MatDestroySubMatrices(PetscInt,Mat *[]);
5877dae84e0SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat,IS,IS,MatReuse,Mat *);
58825ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatCreateSubMatrix() (since version 3.8)") PETSC_STATIC_INLINE PetscErrorCode MatGetSubMatrix(Mat mat,IS isrow,IS iscol,MatReuse cll,Mat *newmat) {return MatCreateSubMatrix(mat,isrow,iscol,cll,newmat);}
589014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat,IS,IS,Mat*);
590014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat,IS,IS,Mat*);
591014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat,Mat*);
592014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat*);
5937b80b807SBarry Smith 
594014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*);
595014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*);
596014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat,Mat);
597014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat,MatReuse,Mat*);
598014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*);
599014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,Mat*);
600014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *,const PetscInt *[]);
6018efafbd8SBarry Smith 
602014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt);
603aa1e27eaSFande Kong PETSC_EXTERN PetscErrorCode MatIncreaseOverlapSplit(Mat mat,PetscInt n,IS is[],PetscInt ov);
604d2b2a242SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAIJSetUseScalableIncreaseOverlap(Mat,PetscBool);
6057b80b807SBarry Smith 
606014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
607014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*);
608014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatMultNumeric(Mat,Mat,Mat);
60922440eb1SKris Buschelman 
6107bab7c10SHong Zhang PETSC_EXTERN PetscErrorCode MatMatMatMult(Mat,Mat,Mat,MatReuse,PetscReal,Mat*);
6112df6c5c3SPatrick Farrell PETSC_EXTERN PetscErrorCode MatGalerkin(Mat,Mat,Mat,MatReuse,PetscReal,Mat*);
6127bab7c10SHong Zhang 
613014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*);
614014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*);
615014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPtAPNumeric(Mat,Mat,Mat);
616014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARt(Mat,Mat,MatReuse,PetscReal,Mat*);
617014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARtSymbolic(Mat,Mat,PetscReal,Mat*);
618014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRARtNumeric(Mat,Mat,Mat);
61922440eb1SKris Buschelman 
620014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
621014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposetMatMultSymbolic(Mat,Mat,PetscReal,Mat*);
622014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposetMatMultNumeric(Mat,Mat,Mat);
623014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat,Mat,MatReuse,PetscReal,Mat*);
624014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMultSymbolic(Mat,Mat,PetscReal,Mat*);
625014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMatTransposeMultNumeric(Mat,Mat,Mat);
626bc011b1eSHong Zhang 
627014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAXPY(Mat,PetscScalar,Mat,MatStructure);
628014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatAYPX(Mat,PetscScalar,Mat,MatStructure);
6291c741599SHong Zhang 
630014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatScale(Mat,PetscScalar);
631014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShift(Mat,PetscScalar);
6327b80b807SBarry Smith 
633014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping,ISLocalToGlobalMapping);
634014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping*,ISLocalToGlobalMapping*);
635a93ff8c4SPeter Brune PETSC_EXTERN PetscErrorCode MatGetLayouts(Mat,PetscLayout*,PetscLayout*);
636014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec);
637014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat,IS,PetscScalar,Vec,Vec);
638014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec);
639014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat,IS,PetscScalar,Vec,Vec);
640014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
641014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
642052efed2SBarry Smith 
643014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat,PetscInt,PetscInt);
644014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
64590f02eecSBarry Smith 
646014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolate(Mat,Vec,Vec);
647014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat,Vec,Vec,Vec);
648014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRestrict(Mat,Vec,Vec);
6492a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecs(Mat,Vec*,Vec*);
65025ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatCreateVecs() (since version 3.6)") PETSC_STATIC_INLINE PetscErrorCode MatGetVecs(Mat mat,Vec *x,Vec *y) {return MatCreateVecs(mat,x,y);}
65153cd1579SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateRedundantMatrix(Mat,PetscInt,MPI_Comm,MatReuse,Mat*);
652014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat,MPI_Comm,MatReuse,Mat*);
653014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat,IS*);
6543a062f41SBarry Smith PETSC_EXTERN PetscErrorCode MatFindOffBlockDiagonalEntries(Mat,IS*);
6559c8f2541SHong Zhang PETSC_EXTERN PetscErrorCode MatCreateMPIMatConcatenateSeqMat(MPI_Comm,Mat,PetscInt,MatReuse,Mat*);
656bd481603SBarry Smith 
657bd481603SBarry Smith /*MC
6581620fd73SBarry Smith    MatSetValue - Set a single entry into a matrix.
6591620fd73SBarry Smith 
6601620fd73SBarry Smith    Not collective
6611620fd73SBarry Smith 
662a9834a7dSSatish Balay    Synopsis:
663a9834a7dSSatish Balay      #include <petscmat.h>
664a9834a7dSSatish Balay      PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode)
665a9834a7dSSatish Balay 
6661620fd73SBarry Smith    Input Parameters:
6671620fd73SBarry Smith +  m - the matrix
6681620fd73SBarry Smith .  row - the row location of the entry
6691620fd73SBarry Smith .  col - the column location of the entry
6701620fd73SBarry Smith .  value - the value to insert
6711620fd73SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
6721620fd73SBarry Smith 
6731620fd73SBarry Smith    Notes:
6741620fd73SBarry Smith    For efficiency one should use MatSetValues() and set several or many
6751620fd73SBarry Smith    values simultaneously if possible.
6761620fd73SBarry Smith 
6771620fd73SBarry Smith    Level: beginner
6781620fd73SBarry Smith 
6791620fd73SBarry Smith .seealso: MatSetValues(), MatSetValueLocal()
6801620fd73SBarry Smith M*/
6811620fd73SBarry Smith PETSC_STATIC_INLINE PetscErrorCode MatSetValue(Mat v,PetscInt i,PetscInt j,PetscScalar va,InsertMode mode) {return MatSetValues(v,1,&i,1,&j,&va,mode);}
6821620fd73SBarry Smith 
6831620fd73SBarry Smith PETSC_STATIC_INLINE PetscErrorCode MatGetValue(Mat v,PetscInt i,PetscInt j,PetscScalar *va) {return MatGetValues(v,1,&i,1,&j,va);}
6841620fd73SBarry Smith 
6851620fd73SBarry Smith PETSC_STATIC_INLINE PetscErrorCode MatSetValueLocal(Mat v,PetscInt i,PetscInt j,PetscScalar va,InsertMode mode) {return MatSetValuesLocal(v,1,&i,1,&j,&va,mode);}
6861620fd73SBarry Smith 
6871620fd73SBarry Smith /*MC
6880d2a7ff2SSatish Balay    MatPreallocateInitialize - Begins the block of code that will count the number of nonzeros per
689bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
690bd481603SBarry Smith 
691bd481603SBarry Smith    Synopsis:
692aaa7dc30SBarry Smith    #include <petscmat.h>
693c1ac3661SBarry Smith    PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
694bd481603SBarry Smith 
695d083f849SBarry Smith    Collective
696bd481603SBarry Smith 
697bd481603SBarry Smith    Input Parameters:
698bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
699859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
700859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
701bd481603SBarry Smith 
702bd481603SBarry Smith    Output Parameters:
703bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
704a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
705bd481603SBarry Smith 
706bd481603SBarry Smith    Level: intermediate
707bd481603SBarry Smith 
708bd481603SBarry Smith    Notes:
709a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
710bd481603SBarry Smith 
7111d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
712bd481603SBarry Smith 
7131620fd73SBarry Smith    This is a MACRO not a function because it has a leading { that is closed by PetscPreallocateFinalize().
7141620fd73SBarry Smith 
715d6e23781SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSetBlock(), MatPreallocateSetLocal(),
716de25e9cbSPierre Jolivet           MatPreallocateSymmetricSetLocalBlock()
717bd481603SBarry Smith M*/
718c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
719e83a5d19SLisandro Dalcin do { \
720a6042fd4SStefano Zampini   PetscErrorCode _4_ierr; PetscInt __nrows = (nrows),__ncols = (ncols),__rstart,__start,__end; \
7217282cfc1SLisandro Dalcin   _4_ierr = PetscCalloc2((size_t)__nrows,&dnz,(size_t)__nrows,&onz);CHKERRQ(_4_ierr); \
7221795a4d1SJed Brown   __start = 0; __end = __start;                                         \
723a6042fd4SStefano Zampini   _4_ierr = MPI_Scan(&__ncols,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ncols;\
724e83a5d19SLisandro Dalcin   _4_ierr = MPI_Scan(&__nrows,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __nrows; \
725e83a5d19SLisandro Dalcin   do { } while(0)
7267c922b88SBarry Smith 
727bd481603SBarry Smith /*MC
728bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
729bd481603SBarry Smith        inserted using a local number of the rows and columns
730bd481603SBarry Smith 
731bd481603SBarry Smith    Synopsis:
732aaa7dc30SBarry Smith    #include <petscmat.h>
733c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
734bd481603SBarry Smith 
735bd481603SBarry Smith    Not Collective
736bd481603SBarry Smith 
737bd481603SBarry Smith    Input Parameters:
738784ac674SJed Brown +  map - the row mapping from local numbering to global numbering
739bd481603SBarry Smith .  nrows - the number of rows indicated
7401d73ed98SBarry Smith .  rows - the indices of the rows
741784ac674SJed Brown .  cmap - the column mapping from local to global numbering
742bd481603SBarry Smith .  ncols - the number of columns in the matrix
743bd481603SBarry Smith .  cols - the columns indicated
744bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
745a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
746bd481603SBarry Smith 
747bd481603SBarry Smith    Level: intermediate
748bd481603SBarry Smith 
749bd481603SBarry Smith    Notes:
750a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
751bd481603SBarry Smith 
7521d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
753bd481603SBarry Smith 
754a6042fd4SStefano Zampini .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSetBlock()
755c1154cd5SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocalBlock(), MatPreallocateSetLocalRemoveDups()
756bd481603SBarry Smith M*/
757784ac674SJed Brown #define MatPreallocateSetLocal(rmap,nrows,rows,cmap,ncols,cols,dnz,onz) 0; \
758e83a5d19SLisandro Dalcin do {\
759c1ac3661SBarry Smith   PetscInt __l;\
760784ac674SJed Brown   _4_ierr = ISLocalToGlobalMappingApply(rmap,nrows,rows,rows);CHKERRQ(_4_ierr);\
761784ac674SJed Brown   _4_ierr = ISLocalToGlobalMappingApply(cmap,ncols,cols,cols);CHKERRQ(_4_ierr);\
762c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
763ef66eb69SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
764c4f061fbSSatish Balay   }\
765e83a5d19SLisandro Dalcin  } while (0)
766c4f061fbSSatish Balay 
767bd481603SBarry Smith /*MC
768c1154cd5SBarry Smith    MatPreallocateSetLocalRemoveDups - Indicates the locations (rows and columns) in the matrix where nonzeros will be
769c1154cd5SBarry Smith        inserted using a local number of the rows and columns. This version removes any duplicate columns in cols
770c1154cd5SBarry Smith 
771c1154cd5SBarry Smith    Synopsis:
772c1154cd5SBarry Smith    #include <petscmat.h>
773c1154cd5SBarry Smith    PetscErrorCode MatPreallocateSetLocalRemoveDups(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
774c1154cd5SBarry Smith 
775c1154cd5SBarry Smith    Not Collective
776c1154cd5SBarry Smith 
777c1154cd5SBarry Smith    Input Parameters:
778c1154cd5SBarry Smith +  map - the row mapping from local numbering to global numbering
779c1154cd5SBarry Smith .  nrows - the number of rows indicated
780c1154cd5SBarry Smith .  rows - the indices of the rows (these values are mapped to the global values)
781c1154cd5SBarry Smith .  cmap - the column mapping from local to global numbering
782c1154cd5SBarry Smith .  ncols - the number of columns in the matrix   (this value will be changed if duplicate columns are found)
783c1154cd5SBarry Smith .  cols - the columns indicated (these values are mapped to the global values, they are then sorted and duplicates removed)
784c1154cd5SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
785a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
786c1154cd5SBarry Smith 
787c1154cd5SBarry Smith    Level: intermediate
788c1154cd5SBarry Smith 
789c1154cd5SBarry Smith    Notes:
790c1154cd5SBarry Smith     See Users-Manual: ch_performance for more details.
791c1154cd5SBarry Smith 
792c1154cd5SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
793c1154cd5SBarry Smith 
794a6042fd4SStefano Zampini .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSetBlock()
795c1154cd5SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocalBlock(), MatPreallocateSetLocal()
796c1154cd5SBarry Smith M*/
797c1154cd5SBarry Smith #define MatPreallocateSetLocalRemoveDups(rmap,nrows,rows,cmap,ncols,cols,dnz,onz) 0; \
798e83a5d19SLisandro Dalcin do {\
799c1154cd5SBarry Smith   PetscInt __l;\
800c1154cd5SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(rmap,nrows,rows,rows);CHKERRQ(_4_ierr);\
801c1154cd5SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(cmap,ncols,cols,cols);CHKERRQ(_4_ierr);\
802c1154cd5SBarry Smith   _4_ierr = PetscSortRemoveDupsInt(&ncols,cols);CHKERRQ(_4_ierr);\
803c1154cd5SBarry Smith   for (__l=0;__l<nrows;__l++) {\
804c1154cd5SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
805c1154cd5SBarry Smith   }\
806e83a5d19SLisandro Dalcin  } while (0)
807c1154cd5SBarry Smith 
808c1154cd5SBarry Smith /*MC
809d6e23781SBarry Smith    MatPreallocateSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
810bd481603SBarry Smith        inserted using a local number of the rows and columns
811bd481603SBarry Smith 
812bd481603SBarry Smith    Synopsis:
813aaa7dc30SBarry Smith    #include <petscmat.h>
814d6e23781SBarry Smith    PetscErrorCode MatPreallocateSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
815d6e23781SBarry Smith 
816d6e23781SBarry Smith    Not Collective
817d6e23781SBarry Smith 
818d6e23781SBarry Smith    Input Parameters:
819d6e23781SBarry Smith +  map - the row mapping from local numbering to global numbering
820d6e23781SBarry Smith .  nrows - the number of rows indicated
821d6e23781SBarry Smith .  rows - the indices of the rows
822d6e23781SBarry Smith .  cmap - the column mapping from local to global numbering
823d6e23781SBarry Smith .  ncols - the number of columns in the matrix
824d6e23781SBarry Smith .  cols - the columns indicated
825d6e23781SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
826a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
827d6e23781SBarry Smith 
828d6e23781SBarry Smith    Level: intermediate
829d6e23781SBarry Smith 
830d6e23781SBarry Smith    Notes:
831d6e23781SBarry Smith     See Users-Manual: ch_performance for more details.
832d6e23781SBarry Smith 
833d6e23781SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
834d6e23781SBarry Smith 
835a6042fd4SStefano Zampini .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSetBlock()
836d6e23781SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocalBlock()
837d6e23781SBarry Smith M*/
838d6e23781SBarry Smith #define MatPreallocateSetLocalBlock(rmap,nrows,rows,cmap,ncols,cols,dnz,onz) 0; \
839e83a5d19SLisandro Dalcin do {\
840d6e23781SBarry Smith   PetscInt __l;\
841d6e23781SBarry Smith   _4_ierr = ISLocalToGlobalMappingApplyBlock(rmap,nrows,rows,rows);CHKERRQ(_4_ierr);\
842d6e23781SBarry Smith   _4_ierr = ISLocalToGlobalMappingApplyBlock(cmap,ncols,cols,cols);CHKERRQ(_4_ierr);\
843d6e23781SBarry Smith   for (__l=0;__l<nrows;__l++) {\
844d6e23781SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
845d6e23781SBarry Smith   }\
846e83a5d19SLisandro Dalcin } while (0)
847d6e23781SBarry Smith 
848d6e23781SBarry Smith /*MC
849d6e23781SBarry Smith    MatPreallocateSymmetricSetLocalBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
850d6e23781SBarry Smith        inserted using a local number of the rows and columns
851d6e23781SBarry Smith 
852d6e23781SBarry Smith    Synopsis:
853d6e23781SBarry Smith    #include <petscmat.h>
854d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetLocalBlock(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
855bd481603SBarry Smith 
856bd481603SBarry Smith    Not Collective
857bd481603SBarry Smith 
858bd481603SBarry Smith    Input Parameters:
859bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
860bd481603SBarry Smith .  nrows - the number of rows indicated
8611d73ed98SBarry Smith .  rows - the indices of the rows
862bd481603SBarry Smith .  ncols - the number of columns in the matrix
863bd481603SBarry Smith .  cols - the columns indicated
864bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
865a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
866bd481603SBarry Smith 
867bd481603SBarry Smith    Level: intermediate
868bd481603SBarry Smith 
869bd481603SBarry Smith    Notes:
870a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
871bd481603SBarry Smith 
872bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
873bd481603SBarry Smith 
874a6042fd4SStefano Zampini .seealso: MatPreallocateFinalize(), MatPreallocateSet()
875d6e23781SBarry Smith           MatPreallocateInitialize(),  MatPreallocateSetLocal()
876bd481603SBarry Smith M*/
877d6e23781SBarry Smith #define MatPreallocateSymmetricSetLocalBlock(map,nrows,rows,ncols,cols,dnz,onz) 0;\
878e83a5d19SLisandro Dalcin do {\
879c1ac3661SBarry Smith   PetscInt __l;\
880d6e23781SBarry Smith   _4_ierr = ISLocalToGlobalMappingApplyBlock(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
881d6e23781SBarry Smith   _4_ierr = ISLocalToGlobalMappingApplyBlock(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
882d3d32019SBarry Smith   for (__l=0;__l<nrows;__l++) {\
883d6e23781SBarry Smith     _4_ierr = MatPreallocateSymmetricSetBlock((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
884d3d32019SBarry Smith   }\
885e83a5d19SLisandro Dalcin } while (0)
886e83a5d19SLisandro Dalcin 
887bd481603SBarry Smith /*MC
888bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
889bd481603SBarry Smith        inserted using a local number of the rows and columns
890bd481603SBarry Smith 
891bd481603SBarry Smith    Synopsis:
892aaa7dc30SBarry Smith    #include <petscmat.h>
893c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
894bd481603SBarry Smith 
895bd481603SBarry Smith    Not Collective
896bd481603SBarry Smith 
897bd481603SBarry Smith    Input Parameters:
89864075487SBarry Smith +  row - the row
899bd481603SBarry Smith .  ncols - the number of columns in the matrix
900a50f8bf6SHong Zhang -  cols - the columns indicated
901a50f8bf6SHong Zhang 
902a50f8bf6SHong Zhang    Output Parameters:
903a50f8bf6SHong Zhang +  dnz - the array that will be passed to the matrix preallocation routines
904a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
905bd481603SBarry Smith 
906bd481603SBarry Smith    Level: intermediate
907bd481603SBarry Smith 
908bd481603SBarry Smith    Notes:
909a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
910bd481603SBarry Smith 
911bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
912bd481603SBarry Smith 
9131620fd73SBarry Smith    This is a MACRO not a function because it uses variables declared in MatPreallocateInitialize().
9141620fd73SBarry Smith 
915a6042fd4SStefano Zampini .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSetBlock()
916d6e23781SBarry Smith           MatPreallocateInitialize(), MatPreallocateSetLocal()
917bd481603SBarry Smith M*/
918c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
919e83a5d19SLisandro Dalcin do { PetscInt __i; \
920e32f2f54SBarry Smith   if (row < __rstart) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Trying to set preallocation for row %D less than first local row %D",row,__rstart);\
921e32f2f54SBarry Smith   if (row >= __rstart+__nrows) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Trying to set preallocation for row %D greater than last local row %D",row,__rstart+__nrows-1);\
9227c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
92364075487SBarry Smith     if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \
924a6042fd4SStefano Zampini     else if (dnz[row - __rstart] < __ncols) dnz[row - __rstart]++;\
9257c922b88SBarry Smith   }\
926e83a5d19SLisandro Dalcin } while (0)
9277c922b88SBarry Smith 
928bd481603SBarry Smith /*MC
929d6e23781SBarry Smith    MatPreallocateSymmetricSetBlock - Indicates the locations (rows and columns) in the matrix where nonzeros will be
930bd481603SBarry Smith        inserted using a local number of the rows and columns
931bd481603SBarry Smith 
932bd481603SBarry Smith    Synopsis:
933aaa7dc30SBarry Smith    #include <petscmat.h>
934d6e23781SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetBlock(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
935bd481603SBarry Smith 
936bd481603SBarry Smith    Not Collective
937bd481603SBarry Smith 
938bd481603SBarry Smith    Input Parameters:
939bd481603SBarry Smith +  nrows - the number of rows indicated
9401d73ed98SBarry Smith .  rows - the indices of the rows
941bd481603SBarry Smith .  ncols - the number of columns in the matrix
942bd481603SBarry Smith .  cols - the columns indicated
943bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
944a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
945bd481603SBarry Smith 
946bd481603SBarry Smith    Level: intermediate
947bd481603SBarry Smith 
948bd481603SBarry Smith    Notes:
949a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
950bd481603SBarry Smith 
951bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
952bd481603SBarry Smith 
9531620fd73SBarry Smith    This is a MACRO not a function because it uses variables declared in MatPreallocateInitialize().
9541620fd73SBarry Smith 
955d6e23781SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(),  MatPreallocateInitialize(),
956a6042fd4SStefano Zampini           MatPreallocateSymmetricSetLocalBlock(), MatPreallocateSetLocal()
957bd481603SBarry Smith M*/
958d6e23781SBarry Smith #define MatPreallocateSymmetricSetBlock(row,nc,cols,dnz,onz) 0;\
959e83a5d19SLisandro Dalcin do { PetscInt __i; \
960d3d32019SBarry Smith   for (__i=0; __i<nc; __i++) {\
961d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
962a6042fd4SStefano Zampini     else if (cols[__i] >= row && dnz[row - __rstart] < __ncols) dnz[row - __rstart]++;\
963d3d32019SBarry Smith   }\
964e83a5d19SLisandro Dalcin } while (0)
965d3d32019SBarry Smith 
966bd481603SBarry Smith /*MC
967a6042fd4SStefano Zampini    MatPreallocateLocation -  An alternative to MatPreallocateSet() that puts the nonzero locations into the matrix if it exists
96816371a99SBarry Smith 
96916371a99SBarry Smith    Synopsis:
970aaa7dc30SBarry Smith    #include <petscmat.h>
97116371a99SBarry Smith    PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz)
97216371a99SBarry Smith 
97316371a99SBarry Smith    Not Collective
97416371a99SBarry Smith 
97516371a99SBarry Smith    Input Parameters:
976a2b725a8SWilliam Gropp +  A - matrix
97716371a99SBarry Smith .  row - row where values exist (must be local to this process)
97816371a99SBarry Smith .  ncols - number of columns
97916371a99SBarry Smith .  cols - columns with nonzeros
98016371a99SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
981a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
98216371a99SBarry Smith 
98316371a99SBarry Smith    Level: intermediate
98416371a99SBarry Smith 
98516371a99SBarry Smith    Notes:
986a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
98716371a99SBarry Smith 
98816371a99SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
98916371a99SBarry Smith 
99016371a99SBarry Smith    This is a MACRO not a function because it uses a bunch of variables private to the MatPreallocation.... routines.
99116371a99SBarry Smith 
992d6e23781SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSetBlock(), MatPreallocateSetLocal(),
993d6e23781SBarry Smith           MatPreallocateSymmetricSetLocalBlock()
99416371a99SBarry Smith M*/
995e83a5d19SLisandro Dalcin #define MatPreallocateLocation(A,row,ncols,cols,dnz,onz) 0; do {if (A) {ierr = MatSetValues(A,1,&row,ncols,cols,NULL,INSERT_VALUES);CHKERRQ(ierr);} else {ierr =  MatPreallocateSet(row,ncols,cols,dnz,onz);CHKERRQ(ierr);}} while(0)
99616371a99SBarry Smith 
99716371a99SBarry Smith 
99816371a99SBarry Smith /*MC
9990d2a7ff2SSatish Balay    MatPreallocateFinalize - Ends the block of code that will count the number of nonzeros per
1000bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
1001bd481603SBarry Smith 
1002bd481603SBarry Smith    Synopsis:
1003aaa7dc30SBarry Smith    #include <petscmat.h>
1004c1ac3661SBarry Smith    PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz)
1005bd481603SBarry Smith 
1006d083f849SBarry Smith    Collective
1007bd481603SBarry Smith 
1008bd481603SBarry Smith    Input Parameters:
100916371a99SBarry Smith +  dnz - the array that was be passed to the matrix preallocation routines
1010a6042fd4SStefano Zampini -  onz - the other array passed to the matrix preallocation routines
1011bd481603SBarry Smith 
1012bd481603SBarry Smith    Level: intermediate
1013bd481603SBarry Smith 
1014bd481603SBarry Smith    Notes:
1015a7f22e61SSatish Balay     See Users-Manual: ch_performance for more details.
1016bd481603SBarry Smith 
1017bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
1018bd481603SBarry Smith 
10191620fd73SBarry Smith    This is a MACRO not a function because it closes the { started in MatPreallocateInitialize().
10201620fd73SBarry Smith 
1021d6e23781SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSetBlock(), MatPreallocateSetLocal(),
1022d6e23781SBarry Smith           MatPreallocateSymmetricSetLocalBlock()
1023bd481603SBarry Smith M*/
1024e83a5d19SLisandro Dalcin #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree2(dnz,onz);CHKERRQ(_4_ierr);} while(0)
10257c922b88SBarry Smith 
10267b80b807SBarry Smith /* Routines unique to particular data structures */
1027014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat,void *);
1028698d4c6aSKris Buschelman 
1029014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat,IS*,IS*);
1030014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *);
1031698d4c6aSKris Buschelman 
1032014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat,PetscInt[]);
1033014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat,PetscInt[]);
1034014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
1035014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
1036014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
1037014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*,PetscInt,PetscBool);
10387b80b807SBarry Smith 
1039a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4
1040a96a251dSBarry Smith 
1041014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
1042014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
1043014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]);
1044273d9f13SBarry Smith 
1045014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
1046014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
1047014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
1048014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat,const PetscInt [],const PetscInt [],const PetscScalar []);
1049014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
1050014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]);
1051014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
1052014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]);
1053b44e7856SBarry Smith PETSC_EXTERN PetscErrorCode MatMPIAdjToSeq(Mat,Mat*);
1054014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat,PetscScalar[]);
1055014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat,PetscScalar[]);
10569230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,const PetscInt*[]);
10579230625dSJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,const PetscInt*[]);
1058014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat,Mat*);
1059273d9f13SBarry Smith 
1060014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqDenseSetLDA(Mat,PetscInt);
106149a6ff4bSBarry Smith PETSC_EXTERN PetscErrorCode MatDenseGetLDA(Mat,PetscInt*);
1062014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat,Mat*);
10631b807ce4Svictorle 
1064621e819fSSatish Balay PETSC_EXTERN PetscErrorCode MatBlockMatSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
1065621e819fSSatish Balay 
1066014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatStoreValues(Mat);
1067014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat);
10682e8a6d31SBarry Smith 
1069014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDAADSetCtx(Mat,void*);
10703a7fca6bSBarry Smith 
1071014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat,IS*);
10727cfe41e4SPatrick Farrell PETSC_EXTERN PetscErrorCode MatFindZeroRows(Mat,IS*);
10737b80b807SBarry Smith /*
10747b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
107594b7f48cSBarry Smith   done through the KSP and PC interfaces.
10767b80b807SBarry Smith */
10777b80b807SBarry Smith 
107876bdecfbSBarry Smith /*J
10798f6c3df8SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering
1080d9274352SBarry Smith 
1081d9274352SBarry Smith    Level: beginner
1082d9274352SBarry Smith 
1083d9274352SBarry Smith .seealso: MatGetOrdering()
108476bdecfbSBarry Smith J*/
108519fd82e9SBarry Smith typedef const char* MatOrderingType;
10862692d6eeSBarry Smith #define MATORDERINGNATURAL     "natural"
10872692d6eeSBarry Smith #define MATORDERINGND          "nd"
10882692d6eeSBarry Smith #define MATORDERING1WD         "1wd"
10892692d6eeSBarry Smith #define MATORDERINGRCM         "rcm"
10902692d6eeSBarry Smith #define MATORDERINGQMD         "qmd"
10912692d6eeSBarry Smith #define MATORDERINGROWLENGTH   "rowlength"
1092510184a7SJed Brown #define MATORDERINGWBM         "wbm"
1093fc1bef75SJed Brown #define MATORDERINGSPECTRAL    "spectral"
1094312e372aSBarry Smith #define MATORDERINGAMD         "amd"            /* only works if UMFPACK is installed with PETSc */
1095b12f92e5SBarry Smith 
109619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat,MatOrderingType,IS*,IS*);
1097140e18c1SBarry Smith PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFunctionList*);
1098bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[],PetscErrorCode(*)(Mat,MatOrderingType,IS*,IS*));
1099140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList MatOrderingList;
1100d4fbbf0eSBarry Smith 
1101014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
1102fc1bef75SJed Brown PETSC_EXTERN PetscErrorCode MatCreateLaplacian(Mat,PetscReal,PetscBool,Mat*);
1103a2ce50c7SBarry Smith 
1104d91e6319SBarry Smith /*S
1105d90ac83dSHong Zhang     MatFactorShiftType - Numeric Shift.
1106d90ac83dSHong Zhang 
1107d90ac83dSHong Zhang    Level: beginner
1108d90ac83dSHong Zhang 
1109d90ac83dSHong Zhang S*/
1110d90ac83dSHong Zhang typedef enum {MAT_SHIFT_NONE,MAT_SHIFT_NONZERO,MAT_SHIFT_POSITIVE_DEFINITE,MAT_SHIFT_INBLOCKS} MatFactorShiftType;
11116a6fc655SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypes[];
11125e9742b9SJed Brown PETSC_EXTERN const char *const MatFactorShiftTypesDetail[];
1113d90ac83dSHong Zhang 
1114d90ac83dSHong Zhang /*S
11159aa7eafdSHong Zhang     MatFactorError - indicates what type of error in matrix factor
11169aa7eafdSHong Zhang 
11179aa7eafdSHong Zhang     Level: beginner
11189aa7eafdSHong Zhang 
111995452b02SPatrick Sanan     Developer Notes:
112095452b02SPatrick Sanan     Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
112100e125f8SBarry Smith 
112200e125f8SBarry Smith .seealso: MatGetFactor()
11239aa7eafdSHong Zhang S*/
11245cd7cf9dSHong Zhang typedef enum {MAT_FACTOR_NOERROR,MAT_FACTOR_STRUCT_ZEROPIVOT,MAT_FACTOR_NUMERIC_ZEROPIVOT,MAT_FACTOR_OUTMEMORY,MAT_FACTOR_OTHER} MatFactorError;
11259aa7eafdSHong Zhang 
112600e125f8SBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetError(Mat,MatFactorError*);
1127b8b68cfdSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorClearError(Mat);
11287b6c816cSBarry Smith PETSC_EXTERN PetscErrorCode MatFactorGetErrorZeroPivot(Mat,PetscReal*,PetscInt*);
112900e125f8SBarry Smith 
11309aa7eafdSHong Zhang /*S
1131422a814eSBarry Smith    MatFactorInfo - Data passed into the matrix factorization routines, and information about the resulting factorization
1132b00f7748SHong Zhang 
113361cad860SBarry Smith    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE, that is use
113461cad860SBarry Smith $     MatFactorInfo  info(MAT_FACTORINFO_SIZE)
1135b00f7748SHong Zhang 
113695452b02SPatrick Sanan    Notes:
113795452b02SPatrick Sanan     These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.
1138b00f7748SHong Zhang 
113961cad860SBarry Smith       You can use MatFactorInfoInitialize() to set default values.
114061cad860SBarry Smith 
1141b00f7748SHong Zhang    Level: developer
1142b00f7748SHong Zhang 
1143d7d82daaSBarry Smith .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(),
1144d7d82daaSBarry Smith           MatFactorInfoInitialize()
1145b00f7748SHong Zhang 
1146b00f7748SHong Zhang S*/
1147b00f7748SHong Zhang typedef struct {
114815e8a5b3SHong Zhang   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
114985317021SBarry Smith   PetscReal     usedt;
115015e8a5b3SHong Zhang   PetscReal     dt;             /* drop tolerance */
1151b00f7748SHong Zhang   PetscReal     dtcol;          /* tolerance for pivoting */
115215e8a5b3SHong Zhang   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
115367e28bfeSBarry Smith   PetscReal     fill;           /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */
1154348344bbSBarry Smith   PetscReal     levels;         /* ICC/ILU(levels) */
1155bcd9e38bSBarry Smith   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
1156bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
115715e8a5b3SHong Zhang   PetscReal     zeropivot;      /* pivot is called zero if less than this */
1158f4db908eSBarry Smith   PetscReal     shifttype;      /* type of shift added to matrix factor to prevent zero pivots */
1159f4db908eSBarry Smith   PetscReal     shiftamount;     /* how large the shift is */
116015e8a5b3SHong Zhang } MatFactorInfo;
1161ffa6d0a5SLois Curfman McInnes 
1162014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo*);
11639a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat,IS,const MatFactorInfo*);
11649a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat,Mat,IS,const MatFactorInfo*);
11659a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat,Mat,const MatFactorInfo*);
11669a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactor(Mat,IS,IS,const MatFactorInfo*);
11679a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactor(Mat,IS,IS,const MatFactorInfo*);
11689a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat,Mat,IS,IS,const MatFactorInfo*);
11699a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat,Mat,IS,IS,const MatFactorInfo*);
11709a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat,Mat,IS,const MatFactorInfo*);
11719a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatICCFactor(Mat,IS,const MatFactorInfo*);
11729a625307SHong Zhang PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat,Mat,const MatFactorInfo*);
1173014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*);
1174014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolve(Mat,Vec,Vec);
1175014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat,Vec,Vec);
1176014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat,Vec,Vec);
1177014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat,Vec,Vec,Vec);
1178014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat,Vec,Vec);
1179014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
1180014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSolves(Mat,Vecs,Vecs);
11817c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat);
11827c2f51b8SStefano Zampini 
11837c2f51b8SStefano Zampini typedef enum {MAT_FACTOR_SCHUR_UNFACTORED, MAT_FACTOR_SCHUR_FACTORED, MAT_FACTOR_SCHUR_INVERTED} MatFactorSchurStatus;
11848e7ba810SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSetSchurIS(Mat,IS);
11857c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorGetSchurComplement(Mat,Mat*,MatFactorSchurStatus*);
11867c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorRestoreSchurComplement(Mat,Mat*,MatFactorSchurStatus);
11875a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorInvertSchurComplement(Mat);
11887c2f51b8SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorCreateSchurComplement(Mat,Mat*,MatFactorSchurStatus*);
11895a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplement(Mat,Vec,Vec);
11905a05ddb0SStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorSolveSchurComplementTranspose(Mat,Vec,Vec);
11916dba178dSStefano Zampini PETSC_EXTERN PetscErrorCode MatFactorFactorizeSchurComplement(Mat);
1192bb5a7306SBarry Smith 
1193d91e6319SBarry Smith /*E
1194d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
1195bb1eb677SSatish Balay 
1196d91e6319SBarry Smith     Level: beginner
1197d91e6319SBarry Smith 
1198d9274352SBarry Smith    May be bitwise ORd together
1199d9274352SBarry Smith 
1200af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
1201d91e6319SBarry Smith 
12024e7234bfSBarry Smith    MatSORType may be bitwise ORd together, so do not change the numbers
12034e7234bfSBarry Smith 
120441f059aeSBarry Smith .seealso: MatSOR()
1205d91e6319SBarry Smith E*/
1206ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
1207ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
1208ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
120984cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
1210014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSOR(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
12118ed539a5SBarry Smith 
1212d4fbbf0eSBarry Smith /*
1213639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
1214639f9d9dSBarry Smith */
1215b12f92e5SBarry Smith 
12167086a01eSPeter Brune /*S
12177086a01eSPeter Brune      MatColoring - Object for managing the coloring of matrices.
12187086a01eSPeter Brune 
12197086a01eSPeter Brune    Level: beginner
12207086a01eSPeter Brune 
12217086a01eSPeter Brune .seealso:  MatFDColoringCreate() ISColoring MatFDColoring
12227086a01eSPeter Brune S*/
12237086a01eSPeter Brune typedef struct _p_MatColoring* MatColoring;
122476bdecfbSBarry Smith /*J
12258f6c3df8SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring
1226d9274352SBarry Smith 
1227d9274352SBarry Smith    Level: beginner
1228d9274352SBarry Smith 
12297086a01eSPeter Brune .seealso: MatColoringSetType(), MatColoring
123076bdecfbSBarry Smith J*/
12317086a01eSPeter Brune 
123219fd82e9SBarry Smith typedef const  char*           MatColoringType;
12335567d71aSPeter Brune #define MATCOLORINGJP      "jp"
1234b9acb617SPeter Brune #define MATCOLORINGPOWER   "power"
12352692d6eeSBarry Smith #define MATCOLORINGNATURAL "natural"
12362692d6eeSBarry Smith #define MATCOLORINGSL      "sl"
12372692d6eeSBarry Smith #define MATCOLORINGLF      "lf"
12382692d6eeSBarry Smith #define MATCOLORINGID      "id"
12398121bdceSPeter Brune #define MATCOLORINGGREEDY  "greedy"
1240b12f92e5SBarry Smith 
12418ac6da0aSPeter Brune /*E
12428ac6da0aSPeter Brune    MatColoringWeightType - Type of weight scheme
12438ac6da0aSPeter Brune 
12448ac6da0aSPeter Brune     Not Collective
12458ac6da0aSPeter Brune 
12468ac6da0aSPeter Brune +   MAT_COLORING_RANDOM  - Random weights
12478ac6da0aSPeter Brune .   MAT_COLORING_LEXICAL - Lexical weighting based upon global numbering.
12488ac6da0aSPeter Brune -   MAT_COLORING_LF      - Last-first weighting.
12498ac6da0aSPeter Brune 
12508ac6da0aSPeter Brune     Level: intermediate
12518ac6da0aSPeter Brune 
1252af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
12538ac6da0aSPeter Brune E*/
1254301c140bSPeter Brune typedef enum {MAT_COLORING_WEIGHT_RANDOM,MAT_COLORING_WEIGHT_LEXICAL,MAT_COLORING_WEIGHT_LF,MAT_COLORING_WEIGHT_SL} MatColoringWeightType;
12558ac6da0aSPeter Brune 
1256335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreate(Mat,MatColoring*);
1257d7f2a307SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDegrees(Mat,PetscInt,PetscInt*);
1258335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringDestroy(MatColoring*);
1259335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringView(MatColoring,PetscViewer);
1260335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetType(MatColoring,MatColoringType);
1261335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetFromOptions(MatColoring);
1262335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetDistance(MatColoring,PetscInt);
1263335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetDistance(MatColoring,PetscInt*);
1264335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetMaxColors(MatColoring,PetscInt);
1265335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringGetMaxColors(MatColoring,PetscInt*);
1266335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringApply(MatColoring,ISColoring*);
1267335efc43SPeter Brune PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[],PetscErrorCode(*)(MatColoring));
1268014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*);
12698ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeightType(MatColoring,MatColoringWeightType);
1270c29971fcSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringSetWeights(MatColoring,PetscReal*,PetscInt*);
12718ac6da0aSPeter Brune PETSC_EXTERN PetscErrorCode MatColoringCreateWeights(MatColoring,PetscReal **,PetscInt **lperm);
1272bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatColoringTest(MatColoring,ISColoring);
127325ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatColoringTest() (since version 3.10)") PETSC_STATIC_INLINE PetscErrorCode MatColoringTestValid(MatColoring matcoloring,ISColoring iscoloring) {return MatColoringTest(matcoloring,iscoloring);}
1274bc76d17bSHong Zhang PETSC_EXTERN PetscErrorCode MatISColoringTest(Mat,ISColoring);
1275639f9d9dSBarry Smith 
1276d9274352SBarry Smith /*S
1277d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
1278d9274352SBarry Smith         and coloring
1279639f9d9dSBarry Smith 
1280d9274352SBarry Smith    Level: beginner
1281d9274352SBarry Smith 
1282d9274352SBarry Smith .seealso:  MatFDColoringCreate()
1283d9274352SBarry Smith S*/
1284e2a1c21fSSatish Balay typedef struct _p_MatFDColoring* MatFDColoring;
1285639f9d9dSBarry Smith 
1286014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
1287014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring*);
1288014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring,PetscViewer);
1289014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*);
1290014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring,PetscErrorCode (**)(void),void**);
1291014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
1292014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring);
1293d1e9a80fSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat,MatFDColoring,Vec,void *);
1294014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring,Vec);
1295edaa7c33SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,const PetscInt*[]);
1296f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetUp(Mat,ISColoring,MatFDColoring);
1297f86b9fbaSHong Zhang PETSC_EXTERN PetscErrorCode MatFDColoringSetBlockSize(MatFDColoring,PetscInt,PetscInt);
1298bdaf1daeSBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetValues(Mat,MatFDColoring,const PetscScalar*);
1299b1683b59SHong Zhang 
1300b1683b59SHong Zhang /*S
1301b9af6bddSHong Zhang      MatTransposeColoring - Object for computing a sparse matrix product C=A*B^T via coloring
1302b1683b59SHong Zhang 
1303b1683b59SHong Zhang    Level: beginner
1304b1683b59SHong Zhang 
1305b9af6bddSHong Zhang .seealso:  MatTransposeColoringCreate()
1306b1683b59SHong Zhang S*/
1307b9af6bddSHong Zhang typedef struct _p_MatTransposeColoring* MatTransposeColoring;
1308b1683b59SHong Zhang 
1309014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat,ISColoring,MatTransposeColoring *);
1310014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring,Mat,Mat);
1311014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring,Mat,Mat);
1312014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring*);
1313b1683b59SHong Zhang 
1314639f9d9dSBarry Smith /*
13150752156aSBarry Smith     These routines are for partitioning matrices: currently used only
13163eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
13170752156aSBarry Smith */
1318ca161407SBarry Smith 
1319d9274352SBarry Smith /*S
1320d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
1321d9274352SBarry Smith 
1322d9274352SBarry Smith    Level: beginner
1323d9274352SBarry Smith 
1324743a1026Svictorle .seealso:  MatPartitioningCreate(), MatPartitioningType
1325d9274352SBarry Smith S*/
132691e9ee9fSBarry Smith typedef struct _p_MatPartitioning* MatPartitioning;
1327d9274352SBarry Smith 
132876bdecfbSBarry Smith /*J
13298f6c3df8SBarry Smith     MatPartitioningType - String with the name of a PETSc matrix partitioning
1330d9274352SBarry Smith 
1331d9274352SBarry Smith    Level: beginner
13320d04baf8SBarry Smith dm
1333b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning
133476bdecfbSBarry Smith J*/
133519fd82e9SBarry Smith typedef const char* MatPartitioningType;
13362692d6eeSBarry Smith #define MATPARTITIONINGCURRENT  "current"
1337aa1e27eaSFande Kong #define MATPARTITIONINGAVERAGE   "average"
13382692d6eeSBarry Smith #define MATPARTITIONINGSQUARE   "square"
13392692d6eeSBarry Smith #define MATPARTITIONINGPARMETIS "parmetis"
13402692d6eeSBarry Smith #define MATPARTITIONINGCHACO    "chaco"
13412692d6eeSBarry Smith #define MATPARTITIONINGPARTY    "party"
134250d91057SBarry Smith #define MATPARTITIONINGPTSCOTCH "ptscotch"
134388d2ac2bSFande Kong #define MATPARTITIONINGHIERARCH  "hierarch"
134471306c60Sjroman 
1345ca161407SBarry Smith 
1346014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm,MatPartitioning*);
134719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning,MatPartitioningType);
1348014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning,PetscInt);
1349014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning,Mat);
1350014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]);
1351014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []);
1352014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning,IS*);
1353fdd1c351SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningImprove(MatPartitioning,IS*);
1354668144dbSFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningViewImbalance(MatPartitioning,IS);
1355f3ad2dabSStefano Zampini PETSC_EXTERN PetscErrorCode MatPartitioningApplyND(MatPartitioning,IS*);
1356014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning*);
13572aabb6bbSBarry Smith 
1358bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[],PetscErrorCode (*)(MatPartitioning));
135930de9b25SBarry Smith 
1360f1144a30SSatish Balay 
13612bad1931SBarry Smith 
1362014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning,PetscViewer);
1363854f7285SStefano Zampini PETSC_STATIC_INLINE PetscErrorCode MatPartitioningViewFromOptions(MatPartitioning A,PetscObject B,const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,B,name);}
1364854f7285SStefano Zampini 
1365014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning);
136619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
1367ca161407SBarry Smith 
136827538973SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetRepartition(MatPartitioning part);
1369014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
1370014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *);
13710752156aSBarry Smith 
1372b6956c12SJose Roman typedef enum { MP_CHACO_MULTILEVEL=1,MP_CHACO_SPECTRAL=2,MP_CHACO_LINEAR=4,MP_CHACO_RANDOM=5,MP_CHACO_SCATTERED=6 } MPChacoGlobalType;
13736a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoGlobalTypes[];
1374b6956c12SJose Roman typedef enum { MP_CHACO_KERNIGHAN=1,MP_CHACO_NONE=2 } MPChacoLocalType;
13756a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoLocalTypes[];
1376b6956c12SJose Roman typedef enum { MP_CHACO_LANCZOS=0,MP_CHACO_RQI=1 } MPChacoEigenType;
13776a6fc655SJed Brown PETSC_EXTERN const char *const MPChacoEigenTypes[];
1378b6956c12SJose Roman 
1379014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning,MPChacoGlobalType);
1380014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning,MPChacoGlobalType*);
1381014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning,MPChacoLocalType);
1382014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning,MPChacoLocalType*);
1383014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal);
1384014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType);
1385014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning,MPChacoEigenType*);
1386014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning,PetscReal);
1387014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning,PetscReal*);
1388014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning,PetscInt);
1389014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning,PetscInt*);
139071306c60Sjroman 
139171306c60Sjroman #define MP_PARTY_OPT "opt"
139271306c60Sjroman #define MP_PARTY_LIN "lin"
139371306c60Sjroman #define MP_PARTY_SCA "sca"
139471306c60Sjroman #define MP_PARTY_RAN "ran"
139571306c60Sjroman #define MP_PARTY_GBF "gbf"
139671306c60Sjroman #define MP_PARTY_GCF "gcf"
139771306c60Sjroman #define MP_PARTY_BUB "bub"
139871306c60Sjroman #define MP_PARTY_DEF "def"
1399014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning,const char*);
140071306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs"
140171306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
140271306c60Sjroman #define MP_PARTY_NONE "no"
1403014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning,const char*);
1404014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal);
1405014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning,PetscBool);
1406014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscBool);
140771306c60Sjroman 
1408b0ca845eSVaclav Hapla typedef enum { MP_PTSCOTCH_DEFAULT,MP_PTSCOTCH_QUALITY,MP_PTSCOTCH_SPEED,MP_PTSCOTCH_BALANCE,MP_PTSCOTCH_SAFETY,MP_PTSCOTCH_SCALABILITY } MPPTScotchStrategyType;
14096a6fc655SJed Brown PETSC_EXTERN const char *const MPPTScotchStrategyTypes[];
1410e0f1cffaSJose Roman 
1411014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning,PetscReal);
1412014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning,PetscReal*);
1413014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning,MPPTScotchStrategyType);
1414014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning,MPPTScotchStrategyType*);
141571306c60Sjroman 
1416b43b03e9SMark F. Adams /*
14176294fa2bSFande Kong  * hierarchical partitioning
14186294fa2bSFande Kong  */
14194e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetFineparts(MatPartitioning,IS*);
14204e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalGetCoarseparts(MatPartitioning,IS*);
14214e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNcoarseparts(MatPartitioning,PetscInt);
14224e713f55SFande Kong PETSC_EXTERN PetscErrorCode MatPartitioningHierarchicalSetNfineparts(MatPartitioning, PetscInt);
14236294fa2bSFande Kong 
1424014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToVertexGraph(Mat,PetscInt,Mat*);
1425014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat,PetscInt,Mat*);
1426591294e4SBarry Smith 
14270752156aSBarry Smith /*
1428af0996ceSBarry Smith     If you add entries here you must also add them to petsc/finclude/petscmat.h
1429d4fbbf0eSBarry Smith */
14301c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
14311c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
14321c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
14331c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
14341c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
14357c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
14367c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
14371c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
14381c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
14397c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
14407c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
14411c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
14421c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
1443a714c06dSBarry Smith                MATOP_SOR=13,
14441c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
14451c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
14461c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
14471c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
14481c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
14491c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
14501c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
14511c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
1452d519adbfSMatthew Knepley                MATOP_SET_OPTION=22,
1453d519adbfSMatthew Knepley                MATOP_ZERO_ENTRIES=23,
1454d519adbfSMatthew Knepley                MATOP_ZERO_ROWS=24,
1455d519adbfSMatthew Knepley                MATOP_LUFACTOR_SYMBOLIC=25,
1456d519adbfSMatthew Knepley                MATOP_LUFACTOR_NUMERIC=26,
1457d519adbfSMatthew Knepley                MATOP_CHOLESKY_FACTOR_SYMBOLIC=27,
1458d519adbfSMatthew Knepley                MATOP_CHOLESKY_FACTOR_NUMERIC=28,
1459d519adbfSMatthew Knepley                MATOP_SETUP_PREALLOCATION=29,
1460d519adbfSMatthew Knepley                MATOP_ILUFACTOR_SYMBOLIC=30,
1461d519adbfSMatthew Knepley                MATOP_ICCFACTOR_SYMBOLIC=31,
1462a5b7ff6bSBarry Smith                MATOP_GET_DIAGONAL_BLOCK=32,
1463dd4011a9SHong Zhang                MATOP_FREE_INTER_STRUCT=33,
1464d519adbfSMatthew Knepley                MATOP_DUPLICATE=34,
1465d519adbfSMatthew Knepley                MATOP_FORWARD_SOLVE=35,
1466d519adbfSMatthew Knepley                MATOP_BACKWARD_SOLVE=36,
1467d519adbfSMatthew Knepley                MATOP_ILUFACTOR=37,
1468d519adbfSMatthew Knepley                MATOP_ICCFACTOR=38,
1469d519adbfSMatthew Knepley                MATOP_AXPY=39,
14707dae84e0SHong Zhang                MATOP_CREATE_SUBMATRICES=40,
1471d519adbfSMatthew Knepley                MATOP_INCREASE_OVERLAP=41,
1472d519adbfSMatthew Knepley                MATOP_GET_VALUES=42,
1473d519adbfSMatthew Knepley                MATOP_COPY=43,
1474d519adbfSMatthew Knepley                MATOP_GET_ROW_MAX=44,
1475d519adbfSMatthew Knepley                MATOP_SCALE=45,
1476d519adbfSMatthew Knepley                MATOP_SHIFT=46,
147735153367SBarry Smith                MATOP_DIAGONAL_SET=47,
14789d39f69dSJed Brown                MATOP_ZERO_ROWS_COLUMNS=48,
14799d39f69dSJed Brown                MATOP_SET_RANDOM=49,
1480d519adbfSMatthew Knepley                MATOP_GET_ROW_IJ=50,
1481d519adbfSMatthew Knepley                MATOP_RESTORE_ROW_IJ=51,
1482d519adbfSMatthew Knepley                MATOP_GET_COLUMN_IJ=52,
1483d519adbfSMatthew Knepley                MATOP_RESTORE_COLUMN_IJ=53,
1484d519adbfSMatthew Knepley                MATOP_FDCOLORING_CREATE=54,
1485d519adbfSMatthew Knepley                MATOP_COLORING_PATCH=55,
1486d519adbfSMatthew Knepley                MATOP_SET_UNFACTORED=56,
1487d519adbfSMatthew Knepley                MATOP_PERMUTE=57,
1488d519adbfSMatthew Knepley                MATOP_SET_VALUES_BLOCKED=58,
14897dae84e0SHong Zhang                MATOP_CREATE_SUBMATRIX=59,
1490d519adbfSMatthew Knepley                MATOP_DESTROY=60,
1491d519adbfSMatthew Knepley                MATOP_VIEW=61,
1492d519adbfSMatthew Knepley                MATOP_CONVERT_FROM=62,
14937bab7c10SHong Zhang                MATOP_MATMAT_MULT=63,
14947bab7c10SHong Zhang                MATOP_MATMAT_MULT_SYMBOLIC=64,
14957bab7c10SHong Zhang                MATOP_MATMAT_MULT_NUMERIC=65,
1496d519adbfSMatthew Knepley                MATOP_SET_LOCAL_TO_GLOBAL_MAP=66,
1497d519adbfSMatthew Knepley                MATOP_SET_VALUES_LOCAL=67,
1498d519adbfSMatthew Knepley                MATOP_ZERO_ROWS_LOCAL=68,
1499d519adbfSMatthew Knepley                MATOP_GET_ROW_MAX_ABS=69,
1500d519adbfSMatthew Knepley                MATOP_GET_ROW_MIN_ABS=70,
1501d519adbfSMatthew Knepley                MATOP_CONVERT=71,
1502d519adbfSMatthew Knepley                MATOP_SET_COLORING=72,
15039d39f69dSJed Brown                /* MATOP_PLACEHOLDER_73=73, */
1504d519adbfSMatthew Knepley                MATOP_SET_VALUES_ADIFOR=74,
1505d519adbfSMatthew Knepley                MATOP_FD_COLORING_APPLY=75,
1506d519adbfSMatthew Knepley                MATOP_SET_FROM_OPTIONS=76,
1507bda6c4cbSBarry Smith                MATOP_MULT_CONSTRAINED=77,
1508bda6c4cbSBarry Smith                MATOP_MULT_TRANSPOSE_CONSTRAIN=78,
15099d39f69dSJed Brown                MATOP_FIND_ZERO_DIAGONALS=79,
1510d519adbfSMatthew Knepley                MATOP_MULT_MULTIPLE=80,
1511d519adbfSMatthew Knepley                MATOP_SOLVE_MULTIPLE=81,
1512d519adbfSMatthew Knepley                MATOP_GET_INERTIA=82,
1513d519adbfSMatthew Knepley                MATOP_LOAD=83,
1514d519adbfSMatthew Knepley                MATOP_IS_SYMMETRIC=84,
1515d519adbfSMatthew Knepley                MATOP_IS_HERMITIAN=85,
1516d519adbfSMatthew Knepley                MATOP_IS_STRUCTURALLY_SYMMETRIC=86,
1517820469bcSHong Zhang                MATOP_SET_VALUES_BLOCKEDLOCAL=87,
1518b41ce5d5SBarry Smith                MATOP_CREATE_VECS=88,
1519d519adbfSMatthew Knepley                MATOP_MAT_MULT=89,
1520d519adbfSMatthew Knepley                MATOP_MAT_MULT_SYMBOLIC=90,
1521d519adbfSMatthew Knepley                MATOP_MAT_MULT_NUMERIC=91,
1522d519adbfSMatthew Knepley                MATOP_PTAP=92,
1523d519adbfSMatthew Knepley                MATOP_PTAP_SYMBOLIC=93,
1524d519adbfSMatthew Knepley                MATOP_PTAP_NUMERIC=94,
1525bda6c4cbSBarry Smith                MATOP_MAT_TRANSPOSE_MULT=95,
1526bda6c4cbSBarry Smith                MATOP_MAT_TRANSPOSE_MULT_SYMBO=96,
1527bda6c4cbSBarry Smith                MATOP_MAT_TRANSPOSE_MULT_NUMER=97,
15289d39f69dSJed Brown                /* MATOP_PLACEHOLDER_98=98, */
15299d39f69dSJed Brown                /* MATOP_PLACEHOLDER_99=99, */
15309d39f69dSJed Brown                /* MATOP_PLACEHOLDER_100=100, */
15319d39f69dSJed Brown                /* MATOP_PLACEHOLDER_101=101, */
1532d519adbfSMatthew Knepley                MATOP_CONJUGATE=102,
15339d39f69dSJed Brown                /* MATOP_PLACEHOLDER_103=103, */
1534d519adbfSMatthew Knepley                MATOP_SET_VALUES_ROW=104,
1535d519adbfSMatthew Knepley                MATOP_REAL_PART=105,
1536bda6c4cbSBarry Smith                MATOP_IMAGINARY_PART=106,
1537bda6c4cbSBarry Smith                MATOP_GET_ROW_UPPER_TRIANGULAR=107,
1538bda6c4cbSBarry Smith                MATOP_RESTORE_ROW_UPPER_TRIANG=108,
1539bda6c4cbSBarry Smith                MATOP_MAT_SOLVE=109,
154029eadf9eSStefano Zampini                MATOP_MAT_SOLVE_TRANSPOSE=110,
1541d519adbfSMatthew Knepley                MATOP_GET_ROW_MIN=111,
15420e8d04f7SBarry Smith                MATOP_GET_COLUMN_VECTOR=112,
1543d519adbfSMatthew Knepley                MATOP_MISSING_DIAGONAL=113,
15440e8d04f7SBarry Smith                MATOP_GET_SEQ_NONZERO_STRUCTUR=114,
154589c6957cSBarry Smith                MATOP_CREATE=115,
154689c6957cSBarry Smith                MATOP_GET_GHOSTS=116,
15470e8d04f7SBarry Smith                MATOP_GET_LOCAL_SUB_MATRIX=117,
15480e8d04f7SBarry Smith                MATOP_RESTORE_LOCALSUB_MATRIX=118,
1549eeffb40dSHong Zhang                MATOP_MULT_DIAGONAL_BLOCK=119,
15500e8d04f7SBarry Smith                MATOP_HERMITIAN_TRANSPOSE=120,
15510e8d04f7SBarry Smith                MATOP_MULT_HERMITIAN_TRANSPOSE=121,
15520e8d04f7SBarry Smith                MATOP_MULT_HERMITIAN_TRANS_ADD=122,
15530e8d04f7SBarry Smith                MATOP_GET_MULTI_PROC_BLOCK=123,
15549d39f69dSJed Brown                MATOP_FIND_NONZERO_ROWS=124,
15550e8d04f7SBarry Smith                MATOP_GET_COLUMN_NORMS=125,
15569d39f69dSJed Brown                MATOP_INVERT_BLOCK_DIAGONAL=126,
15579d39f69dSJed Brown                /* MATOP_PLACEHOLDER_127=127, */
1558b41ce5d5SBarry Smith                MATOP_CREATE_SUB_MATRICES_MPI=128,
15592b8ad9a3SHong Zhang                MATOP_SET_VALUES_BATCH=129,
15600e8d04f7SBarry Smith                MATOP_TRANSPOSE_MAT_MULT=130,
15610e8d04f7SBarry Smith                MATOP_TRANSPOSE_MAT_MULT_SYMBO=131,
1562e9b602ebSSatish Balay                MATOP_TRANSPOSE_MAT_MULT_NUMER=132,
15630e8d04f7SBarry Smith                MATOP_TRANSPOSE_COLORING_CREAT=133,
15640e8d04f7SBarry Smith                MATOP_TRANS_COLORING_APPLY_SPT=134,
15650e8d04f7SBarry Smith                MATOP_TRANS_COLORING_APPLY_DEN=135,
15660e8d04f7SBarry Smith                MATOP_RART=136,
15670e8d04f7SBarry Smith                MATOP_RART_SYMBOLIC=137,
15680e8d04f7SBarry Smith                MATOP_RART_NUMERIC=138,
1569e09a3074SHong Zhang                MATOP_SET_BLOCK_SIZES=139,
1570f9426fe0SMark Adams                MATOP_AYPX=140,
15711919a2e2SJed Brown                MATOP_RESIDUAL=141,
15729c8f2541SHong Zhang                MATOP_FDCOLORING_SETUP=142,
15732d033e1fSHong Zhang                MATOP_MPICONCATENATESEQ=144,
15742d033e1fSHong Zhang                MATOP_DESTROYSUBMATRICES=145
1575fae171e0SBarry Smith              } MatOperation;
15760c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatSetOperation(Mat,MatOperation,void(*)(void));
1577976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatGetOperation(Mat,MatOperation,void(**)(void));
1578976e8c5aSLisandro Dalcin PETSC_EXTERN PetscErrorCode MatHasOperation(Mat,MatOperation,PetscBool *);
157994342113SStefano Zampini PETSC_EXTERN PetscErrorCode MatHasCongruentLayouts(Mat,PetscBool *);
1580dd4011a9SHong Zhang PETSC_EXTERN PetscErrorCode MatFreeIntermediateDataStructures(Mat);
1581976e8c5aSLisandro Dalcin 
1582014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat,MatOperation,void(*)(void));
1583014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat,MatOperation,void(**)(void));
1584014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat,void*);
1585f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMult(Mat,PetscErrorCode (*)(void*,Vec,Vec),Vec,void*,PetscBool*);
1586f3b1f45cSBarry Smith PETSC_EXTERN PetscErrorCode MatShellTestMultTranspose(Mat,PetscErrorCode (*)(void*,Vec,Vec),Vec,void*,PetscBool*);
15870c0fd78eSBarry Smith PETSC_EXTERN PetscErrorCode MatShellSetManageScalingShifts(Mat);
1588112a2221SBarry Smith 
158990ace30eSBarry Smith /*
159090ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
159190ace30eSBarry Smith    stored in a universal format. By changing the format with
15926a9046bcSBarry Smith    PetscViewerPushFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will
159390ace30eSBarry Smith    be stored in a way natural for the matrix, for example dense matrices
159490ace30eSBarry Smith    would be stored as dense. Matrices stored this way may only be
1595f4403165SShri Abhyankar    read into matrices of the same type.
159690ace30eSBarry Smith */
159790ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
159890ace30eSBarry Smith 
1599014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
160075d48cdbSStefano Zampini 
16018546b261SStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetLocalMatType(Mat,MatType);
160275d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
160375d48cdbSStefano Zampini PETSC_EXTERN PetscErrorCode MatISStoreL2L(Mat,PetscBool);
1604f03112d0SStefano Zampini PETSC_EXTERN PetscErrorCode MatISFixLocalEmpty(Mat,PetscBool);
1605014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat,Mat*);
16063b3b1effSJed Brown PETSC_EXTERN PetscErrorCode MatISRestoreLocalMat(Mat,Mat*);
1607014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat,Mat);
160825ef9dfeSBarry Smith PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use the MatConvert() interface (since version 3.10)") PetscErrorCode MatISGetMPIXAIJ(Mat,MatReuse,Mat*);
16091f4e1ec7SBarry Smith 
1610d9274352SBarry Smith /*S
1611d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
1612d9274352SBarry Smith          orthogonalizes the vector to a subsapce
1613d9274352SBarry Smith 
1614f7a9e4ceSBarry Smith    Level: advanced
1615d9274352SBarry Smith 
16166e1639daSBarry Smith   Users manual sections:
16176e1639daSBarry Smith .   sec_singular
16186e1639daSBarry Smith 
1619d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
1620d9274352SBarry Smith S*/
162174637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
1622d9274352SBarry Smith 
1623014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm,PetscBool ,PetscInt,const Vec[],MatNullSpace*);
1624014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace,PetscErrorCode (*)(MatNullSpace,Vec,void*),void*);
1625014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace*);
1626d0195637SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace,Vec);
1627014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *);
16285fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatGetTransposeNullSpace(Mat, MatNullSpace *);
16295fa7ec2dSBarry Smith PETSC_EXTERN PetscErrorCode MatSetTransposeNullSpace(Mat,MatNullSpace);
1630014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat,MatNullSpace);
1631014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat,MatNullSpace);
1632014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat,MatNullSpace*);
1633014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace,Mat,PetscBool  *);
1634014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace,PetscViewer);
1635014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace,PetscBool*,PetscInt*,const Vec**);
1636014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec,MatNullSpace*);
163774637425SBarry Smith 
1638014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat,IS);
1639014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1640014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat,PetscInt *);
1641014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSeqBAIJInvertBlockDiagonal(Mat);
16423f1d51d7SBarry Smith 
1643014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat,PetscInt,Mat*);
1644014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat,PetscInt,Mat*);
1645014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat,Mat*);
1646c4f061fbSSatish Balay 
16470bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperator(Mat,MatType,Mat*);
16480bacdadaSStefano Zampini PETSC_EXTERN PetscErrorCode MatComputeOperatorTranspose(Mat,MatType,Mat*);
16490bacdadaSStefano Zampini 
165025ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatComputeOperator() (since version 3.12)") PETSC_STATIC_INLINE PetscErrorCode MatComputeExplicitOperator(Mat A,Mat* B) { return MatComputeOperator(A,NULL,B); }
165125ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatComputeOperatorTranspose() (since version 3.12)") PETSC_STATIC_INLINE PetscErrorCode MatComputeExplicitOperatorTranspose(Mat A,Mat* B) { return MatComputeOperatorTranspose(A,NULL,B); }
1652b0a32e0cSBarry Smith 
165349bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatCreateKAIJ(Mat,PetscInt,PetscInt,const PetscScalar[],const PetscScalar[],Mat*);
165449bd79ccSDebojyoti Ghosh PETSC_EXTERN PetscErrorCode MatKAIJGetAIJ(Mat,Mat*);
1655a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetS(Mat,PetscInt*,PetscInt*,PetscScalar**);
1656a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetSRead(Mat,PetscInt*,PetscInt*,const PetscScalar**);
1657a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreS(Mat,PetscScalar**);
1658a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreSRead(Mat,const PetscScalar**);
1659a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetT(Mat,PetscInt*,PetscInt*,PetscScalar**);
1660a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJGetTRead(Mat,PetscInt*,PetscInt*,const PetscScalar**);
1661a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreT(Mat,PetscScalar**);
1662a5b5c723SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJRestoreTRead(Mat,const PetscScalar**);
1663dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetAIJ(Mat,Mat);
1664dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetS(Mat,PetscInt,PetscInt,const PetscScalar []);
1665dbb4b592SRichard Tran Mills PETSC_EXTERN PetscErrorCode MatKAIJSetT(Mat,PetscInt,PetscInt,const PetscScalar []);
166649bd79ccSDebojyoti Ghosh 
1667014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat,Vec);
166804f1ad80SBarry Smith 
1669014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
1670014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat,Vec,Vec);
1671014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat,PetscErrorCode(*)(void*,Vec,Vec),void*);
1672014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat,PetscErrorCode (*)(void*,PetscInt,Vec,PetscScalar*));
1673014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat,PetscErrorCode (*)(void*,Vec));
1674014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat,PetscScalar[],PetscInt);
1675014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat);
1676014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat,PetscReal);
1677014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat,PetscInt);
1678014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat,PetscScalar *);
1679014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat,const char[]);
1680014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void*,Vec,Vec,PetscScalar*);
1681014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat,PetscErrorCode (*)(void*,Vec,Vec,PetscScalar*),void*);
1682e884886fSBarry Smith 
16836370053bSBarry Smith /*S
16846370053bSBarry Smith     MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free
16856370053bSBarry Smith               Jacobian vector products
1686e884886fSBarry Smith 
168795452b02SPatrick Sanan     Notes:
168895452b02SPatrick Sanan     MATMFFD is a specific MatType which uses the MatMFFD data structure
16896370053bSBarry Smith 
16906370053bSBarry Smith            MatMFFD*() methods actually take the Mat as their first argument. Not a MatMFFD data structure
16916370053bSBarry Smith 
16926370053bSBarry Smith     Level: developer
16936370053bSBarry Smith 
16946370053bSBarry Smith .seealso: MATMFFD, MatCreateMFFD(), MatMFFDSetFuction(), MatMFFDSetType(), MatMFFDRegister()
16956370053bSBarry Smith S*/
1696e884886fSBarry Smith typedef struct _p_MatMFFD* MatMFFD;
1697e884886fSBarry Smith 
169876bdecfbSBarry Smith /*J
1699e884886fSBarry Smith     MatMFFDType - algorithm used to compute the h used in computing matrix-vector products via differencing of the function
1700e884886fSBarry Smith 
1701e884886fSBarry Smith    Level: beginner
1702e884886fSBarry Smith 
1703e884886fSBarry Smith .seealso: MatMFFDSetType(), MatMFFDRegister()
170476bdecfbSBarry Smith J*/
170519fd82e9SBarry Smith typedef const char* MatMFFDType;
1706e884886fSBarry Smith #define MATMFFD_DS  "ds"
1707e884886fSBarry Smith #define MATMFFD_WP  "wp"
1708e884886fSBarry Smith 
170919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat,MatMFFDType);
1710bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[],PetscErrorCode (*)(MatMFFD));
1711e884886fSBarry Smith 
1712014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat,PetscReal);
1713014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat,PetscBool );
1714e884886fSBarry Smith 
171561ab5df0SBarry Smith PETSC_EXTERN PetscErrorCode MatFDColoringSetType(MatFDColoring,MatMFFDType);
171661ab5df0SBarry Smith 
1717014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
1718014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
17197dbadf16SMatthew Knepley 
172097969023SHong Zhang /*
172197969023SHong Zhang    PETSc interface to MUMPS
172297969023SHong Zhang */
172397969023SHong Zhang #ifdef PETSC_HAVE_MUMPS
1724014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat,PetscInt,PetscInt);
1725bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetIcntl(Mat,PetscInt,PetscInt*);
1726b9e9ea26SSatish Balay PETSC_EXTERN PetscErrorCode MatMumpsSetCntl(Mat,PetscInt,PetscReal);
1727bc6112feSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetCntl(Mat,PetscInt,PetscReal*);
1728bc6112feSHong Zhang 
1729ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfo(Mat,PetscInt,PetscInt*);
1730ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInfog(Mat,PetscInt,PetscInt*);
1731ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfo(Mat,PetscInt,PetscReal*);
1732ca810319SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetRinfog(Mat,PetscInt,PetscReal*);
173389a9c03aSHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverse(Mat,Mat);
17340e6b8875SHong Zhang PETSC_EXTERN PetscErrorCode MatMumpsGetInverseTranspose(Mat,Mat);
173597969023SHong Zhang #endif
173623a5497aSJed Brown 
1737d954db57SHong Zhang /*
1738d615f992SSatish Balay    PETSc interface to Mkl_Pardiso
1739b500a6b7SJose David Bermeol */
1740b500a6b7SJose David Bermeol #ifdef PETSC_HAVE_MKL_PARDISO
1741d615f992SSatish Balay PETSC_EXTERN PetscErrorCode MatMkl_PardisoSetCntl(Mat,PetscInt,PetscInt);
1742b500a6b7SJose David Bermeol #endif
1743b500a6b7SJose David Bermeol 
1744b500a6b7SJose David Bermeol /*
1745d305a81bSVasiliy Kozyrev    PETSc interface to Mkl_CPardiso
1746d305a81bSVasiliy Kozyrev */
1747d305a81bSVasiliy Kozyrev #ifdef PETSC_HAVE_MKL_CPARDISO
1748d305a81bSVasiliy Kozyrev PETSC_EXTERN PetscErrorCode MatMkl_CPardisoSetCntl(Mat,PetscInt,PetscInt);
1749d305a81bSVasiliy Kozyrev #endif
1750d305a81bSVasiliy Kozyrev 
1751d305a81bSVasiliy Kozyrev /*
1752d954db57SHong Zhang    PETSc interface to SUPERLU
1753d954db57SHong Zhang */
1754d954db57SHong Zhang #ifdef PETSC_HAVE_SUPERLU
1755014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat,PetscReal);
1756d954db57SHong Zhang #endif
1757d954db57SHong Zhang 
1758fb785984SHong Zhang /*
1759fb785984SHong Zhang    PETSc interface to SUPERLU_DIST
1760fb785984SHong Zhang */
1761fb785984SHong Zhang #ifdef PETSC_HAVE_SUPERLU_DIST
1762fb785984SHong Zhang PETSC_EXTERN PetscErrorCode MatSuperluDistGetDiagU(Mat,PetscScalar*);
1763fb785984SHong Zhang #endif
1764fb785984SHong Zhang 
1765575704cbSPieter Ghysels /*
1766575704cbSPieter Ghysels    PETSc interface to STRUMPACK
1767575704cbSPieter Ghysels */
1768575704cbSPieter Ghysels #ifdef PETSC_HAVE_STRUMPACK
1769542aee0fSPieter Ghysels /*E
1770542aee0fSPieter Ghysels     MatSTRUMPACKReordering - sparsity reducing ordering to be used in STRUMPACK
1771542aee0fSPieter Ghysels 
1772542aee0fSPieter Ghysels     Level: intermediate
1773542aee0fSPieter Ghysels E*/
177434f43fa5SPieter Ghysels typedef enum {MAT_STRUMPACK_NATURAL=0,
177534f43fa5SPieter Ghysels               MAT_STRUMPACK_METIS=1,
177634f43fa5SPieter Ghysels               MAT_STRUMPACK_PARMETIS=2,
177734f43fa5SPieter Ghysels               MAT_STRUMPACK_SCOTCH=3,
177834f43fa5SPieter Ghysels               MAT_STRUMPACK_PTSCOTCH=4,
177934f43fa5SPieter Ghysels               MAT_STRUMPACK_RCM=5} MatSTRUMPACKReordering;
178034f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetReordering(Mat,MatSTRUMPACKReordering);
1781575704cbSPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetColPerm(Mat,PetscBool);
178234f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSRelTol(Mat,PetscReal);
178325ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatSTRUMPACKSetHSSRelTol() (since version 3.9)") PETSC_STATIC_INLINE PetscErrorCode MatSTRUMPACKSetHSSRelCompTol(Mat mat,PetscReal rtol) {return MatSTRUMPACKSetHSSRelTol(mat,rtol);}
178434f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSAbsTol(Mat,PetscReal);
178534f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSMinSepSize(Mat,PetscInt);
178625ef9dfeSBarry Smith PETSC_DEPRECATED_FUNCTION("Use MatSTRUMPACKSetHSSMinSepSize() (since version 3.9)") PETSC_STATIC_INLINE PetscErrorCode MatSTRUMPACKSetHSSMinSize(Mat mat,PetscInt hssminsize) {return MatSTRUMPACKSetHSSMinSepSize(mat,hssminsize);}
178734f43fa5SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSMaxRank(Mat,PetscInt);
1788a36bf211SPieter Ghysels PETSC_EXTERN PetscErrorCode MatSTRUMPACKSetHSSLeafSize(Mat,PetscInt);
1789575704cbSPieter Ghysels #endif
1790575704cbSPieter Ghysels 
1791575704cbSPieter Ghysels 
1792e7e92044SBarry Smith PETSC_EXTERN PetscErrorCode MatPinToCPU(Mat,PetscBool);
1793e7e92044SBarry Smith 
1794aa372e3fSPaul Mullowney #ifdef PETSC_HAVE_CUDA
17953f9c0db1SPaul Mullowney /*E
1796e057df02SPaul Mullowney     MatCUSPARSEStorageFormat - indicates the storage format for CUSPARSE (GPU)
17972692e278SPaul Mullowney     matrices.
1798e057df02SPaul Mullowney 
1799e057df02SPaul Mullowney     Not Collective
1800e057df02SPaul Mullowney 
18018468deeeSKarl Rupp +   MAT_CUSPARSE_CSR - Compressed Sparse Row
18022692e278SPaul Mullowney .   MAT_CUSPARSE_ELL - Ellpack (requires CUDA 4.2 or later).
18032692e278SPaul Mullowney -   MAT_CUSPARSE_HYB - Hybrid, a combination of Ellpack and Coordinate format (requires CUDA 4.2 or later).
1804e057df02SPaul Mullowney 
1805e057df02SPaul Mullowney     Level: intermediate
1806e057df02SPaul Mullowney 
1807af0996ceSBarry Smith    Any additions/changes here MUST also be made in include/petsc/finclude/petscmat.h
1808e057df02SPaul Mullowney 
1809e057df02SPaul Mullowney .seealso: MatCUSPARSESetFormat(), MatCUSPARSEFormatOperation
1810e057df02SPaul Mullowney E*/
1811e057df02SPaul Mullowney 
18123f9c0db1SPaul Mullowney typedef enum {MAT_CUSPARSE_CSR, MAT_CUSPARSE_ELL, MAT_CUSPARSE_HYB} MatCUSPARSEStorageFormat;
1813e057df02SPaul Mullowney 
1814e057df02SPaul Mullowney /* these will be strings associated with enumerated type defined above */
1815e057df02SPaul Mullowney PETSC_EXTERN const char *const MatCUSPARSEStorageFormats[];
1816e057df02SPaul Mullowney 
18173f9c0db1SPaul Mullowney /*E
1818e057df02SPaul Mullowney     MatCUSPARSEFormatOperation - indicates the operation of CUSPARSE (GPU)
18192692e278SPaul Mullowney     matrices whose operation should use a particular storage format.
1820e057df02SPaul Mullowney 
1821e057df02SPaul Mullowney     Not Collective
1822e057df02SPaul Mullowney 
18238468deeeSKarl Rupp +   MAT_CUSPARSE_MULT_DIAG - sets the storage format for the diagonal matrix in the parallel MatMult
18248468deeeSKarl Rupp .   MAT_CUSPARSE_MULT_OFFDIAG - sets the storage format for the offdiagonal matrix in the parallel MatMult
18258468deeeSKarl Rupp .   MAT_CUSPARSE_MULT - sets the storage format for the entire matrix in the serial (single GPU) MatMult
18268468deeeSKarl Rupp -   MAT_CUSPARSE_ALL - sets the storage format for all CUSPARSE (GPU) matrices
1827e057df02SPaul Mullowney 
1828e057df02SPaul Mullowney     Level: intermediate
1829e057df02SPaul Mullowney 
1830e057df02SPaul Mullowney .seealso: MatCUSPARSESetFormat(), MatCUSPARSEStorageFormat
1831e057df02SPaul Mullowney E*/
183236d62e41SPaul Mullowney typedef enum {MAT_CUSPARSE_MULT_DIAG, MAT_CUSPARSE_MULT_OFFDIAG, MAT_CUSPARSE_MULT, MAT_CUSPARSE_ALL} MatCUSPARSEFormatOperation;
1833e057df02SPaul Mullowney 
183410e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSPARSE(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
183510e9db80SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCreateAIJCUSPARSE(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
1836e057df02SPaul Mullowney PETSC_EXTERN PetscErrorCode MatCUSPARSESetFormat(Mat,MatCUSPARSEFormatOperation,MatCUSPARSEStorageFormat);
18379ae82921SPaul Mullowney #endif
18389ae82921SPaul Mullowney 
1839d67ff14aSKarl Rupp #if defined(PETSC_HAVE_VIENNACL)
1840d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateSeqAIJViennaCL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
1841d67ff14aSKarl Rupp PETSC_EXTERN PetscErrorCode MatCreateAIJViennaCL(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
1842d67ff14aSKarl Rupp #endif
1843d67ff14aSKarl Rupp 
184454efbe56SHong Zhang /*
184554efbe56SHong Zhang    PETSc interface to FFTW
184654efbe56SHong Zhang */
184754efbe56SHong Zhang #if defined(PETSC_HAVE_FFTW)
1848014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat,Vec,Vec);
1849014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat,Vec,Vec);
18502a7a6963SBarry Smith PETSC_EXTERN PetscErrorCode MatCreateVecsFFTW(Mat,Vec*,Vec*,Vec*);
185154efbe56SHong Zhang #endif
185254efbe56SHong Zhang 
1853014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm,PetscInt,const IS[],PetscInt,const IS[],const Mat[],Mat*);
1854014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat,PetscInt*,PetscInt*);
1855014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat,IS[],IS[]);
1856014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat,IS[],IS[]);
1857014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat,PetscInt*,PetscInt*,Mat***);
1858014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat,PetscInt,PetscInt,Mat*);
185919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat,VecType);
1860014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat,PetscInt,const IS[],PetscInt,const IS[],const Mat[]);
1861014dd563SJed Brown PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat,PetscInt,PetscInt,Mat);
1862d8588912SDave May 
18634325cce7SMatthew G Knepley PETSC_EXTERN PetscErrorCode MatChop(Mat,PetscReal);
1864e0a58c10SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatComputeBandwidth(Mat,PetscReal,PetscInt*);
18654325cce7SMatthew G Knepley 
1866b541e6a4SDmitry Karpeev PETSC_EXTERN PetscErrorCode MatSubdomainsCreateCoalesce(Mat,PetscInt,PetscInt*,IS**);
186753dd7562SDmitry Karpeev 
1868c094ef40SMatthew G. Knepley PETSC_EXTERN PetscErrorCode MatPreallocatorPreallocate(Mat,PetscBool,Mat);
1869c094ef40SMatthew G. Knepley 
1870539c167fSBarry Smith PETSC_INTERN PetscErrorCode MatHeaderMerge(Mat,Mat*);
1871539c167fSBarry Smith PETSC_EXTERN PetscErrorCode MatHeaderReplace(Mat,Mat*);
1872539c167fSBarry Smith 
187323a5497aSJed Brown #endif
1874