xref: /petsc/include/petscmat.h (revision be1d678a52e6eff2808b2fa31ae986cdbf03c9fe)
12eac72dbSBarry Smith /*
22eac72dbSBarry Smith      Include file for the matrix component of PETSc
32eac72dbSBarry Smith */
40a835dfdSSatish Balay #ifndef __PETSCMAT_H
50a835dfdSSatish Balay #define __PETSCMAT_H
60a835dfdSSatish Balay #include "petscvec.h"
7e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN
82eac72dbSBarry Smith 
9d9274352SBarry Smith /*S
10d9274352SBarry Smith      Mat - Abstract PETSc matrix object
112eac72dbSBarry Smith 
12d91e6319SBarry Smith    Level: beginner
13d91e6319SBarry Smith 
14d9274352SBarry Smith   Concepts: matrix; linear operator
15d9274352SBarry Smith 
16d9274352SBarry Smith .seealso:  MatCreate(), MatType, MatSetType()
17d9274352SBarry Smith S*/
18d9274352SBarry Smith typedef struct _p_Mat*           Mat;
19d9274352SBarry Smith 
20d9274352SBarry Smith /*E
21d9274352SBarry Smith     MatType - String with the name of a PETSc matrix or the creation function
22d9274352SBarry Smith        with an optional dynamic library name, for example
23d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:mymatcreate()
24d9274352SBarry Smith 
25d9274352SBarry Smith    Level: beginner
26d9274352SBarry Smith 
27d9274352SBarry Smith .seealso: MatSetType(), Mat
28d91e6319SBarry Smith E*/
29273d9f13SBarry Smith #define MATSAME            "same"
30273d9f13SBarry Smith #define MATSEQMAIJ         "seqmaij"
31273d9f13SBarry Smith #define MATMPIMAIJ         "mpimaij"
32209238afSKris Buschelman #define MATMAIJ            "maij"
33273d9f13SBarry Smith #define MATIS              "is"
34273d9f13SBarry Smith #define MATMPIROWBS        "mpirowbs"
35273d9f13SBarry Smith #define MATSEQAIJ          "seqaij"
36273d9f13SBarry Smith #define MATMPIAIJ          "mpiaij"
37209238afSKris Buschelman #define MATAIJ             "aij"
38273d9f13SBarry Smith #define MATSHELL           "shell"
39273d9f13SBarry Smith #define MATSEQBDIAG        "seqbdiag"
40273d9f13SBarry Smith #define MATMPIBDIAG        "mpibdiag"
41209238afSKris Buschelman #define MATBDIAG           "bdiag"
42209238afSKris Buschelman #define MATSEQDENSE        "seqdense"
43273d9f13SBarry Smith #define MATMPIDENSE        "mpidense"
44209238afSKris Buschelman #define MATDENSE           "dense"
45273d9f13SBarry Smith #define MATSEQBAIJ         "seqbaij"
46273d9f13SBarry Smith #define MATMPIBAIJ         "mpibaij"
47209238afSKris Buschelman #define MATBAIJ            "baij"
48273d9f13SBarry Smith #define MATMPIADJ          "mpiadj"
49273d9f13SBarry Smith #define MATSEQSBAIJ        "seqsbaij"
50273d9f13SBarry Smith #define MATMPISBAIJ        "mpisbaij"
51209238afSKris Buschelman #define MATSBAIJ           "sbaij"
52cebc7f6cSBarry Smith #define MATDAAD            "daad"
53cebc7f6cSBarry Smith #define MATMFFD            "mffd"
54c8a8475eSBarry Smith #define MATNORMAL          "normal"
55b3a1e11cSKris Buschelman #define MATSEQAIJSPOOLES   "seqaijspooles"
56d10c748bSKris Buschelman #define MATMPIAIJSPOOLES   "mpiaijspooles"
579abb65ffSKris Buschelman #define MATSEQSBAIJSPOOLES "seqsbaijspooles"
5822191285SKris Buschelman #define MATMPISBAIJSPOOLES "mpisbaijspooles"
59bb4d4166SHong Zhang #define MATAIJSPOOLES      "aijspooles"
60bb4d4166SHong Zhang #define MATSBAIJSPOOLES    "sbaijspooles"
6114b396bbSKris Buschelman #define MATSUPERLU         "superlu"
621d96aa28SKris Buschelman #define MATSUPERLU_DIST    "superlu_dist"
631677d0b8SKris Buschelman #define MATUMFPACK         "umfpack"
64e8aa55a4SKris Buschelman #define MATESSL            "essl"
654eb8e494SKris Buschelman #define MATLUSOL           "lusol"
66397b6df1SKris Buschelman #define MATAIJMUMPS        "aijmumps"
67397b6df1SKris Buschelman #define MATSBAIJMUMPS      "sbaijmumps"
688da957c5SKris Buschelman #define MATDSCPACK         "dscpack"
697065e2aaSKris Buschelman #define MATMATLAB          "matlab"
7049773a63SBarry Smith #define MatType char*
71d91e6319SBarry Smith 
72c06d978dSMatthew Knepley /* Logging support */
73552e946dSBarry Smith #define    MAT_FILE_COOKIE 1211216    /* used to indicate matrices in binary files */
74*be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MAT_COOKIE;
75*be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MATSNESMFCTX_COOKIE;
76*be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MAT_FDCOLORING_COOKIE;
77*be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MAT_PARTITIONING_COOKIE;
78*be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MAT_NULLSPACE_COOKIE;
796849ba73SBarry Smith extern PetscEvent  MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose;
806849ba73SBarry Smith extern PetscEvent  MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose;
816849ba73SBarry Smith extern PetscEvent  MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic;
826849ba73SBarry Smith extern PetscEvent  MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor;
836849ba73SBarry Smith extern PetscEvent  MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin;
846849ba73SBarry Smith extern PetscEvent  MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering;
856849ba73SBarry Smith extern PetscEvent  MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate;
866849ba73SBarry Smith extern PetscEvent  MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction;
87cb00f407SKris Buschelman extern PetscEvent  MAT_MatMult, MAT_MatMultSymbolic, MAT_MatMultNumeric;
88534c1384SKris Buschelman extern PetscEvent  MAT_PtAP, MAT_PtAPSymbolic, MAT_PtAPNumeric;
89bc011b1eSHong Zhang extern PetscEvent  MAT_MatMultTranspose, MAT_MatMultTransposeSymbolic, MAT_MatMultTransposeNumeric;
90c06d978dSMatthew Knepley 
91ceb03754SKris Buschelman /*E
92ceb03754SKris Buschelman     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
93ceb03754SKris Buschelman      or MatGetSubMatrix() are to be reused to store the new matrix values.
94ceb03754SKris Buschelman 
95ceb03754SKris Buschelman     Level: beginner
96ceb03754SKris Buschelman 
97ceb03754SKris Buschelman    Any additions/changes here MUST also be made in include/finclude/petscmat.h
98ceb03754SKris Buschelman 
99ceb03754SKris Buschelman .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
100ceb03754SKris Buschelman E*/
101ceb03754SKris Buschelman typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
102ceb03754SKris Buschelman 
103*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInitializePackage(char *);
104c06d978dSMatthew Knepley 
105*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreate(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
106*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetType(Mat,const MatType);
107*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetFromOptions(Mat);
108*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUpPreallocation(Mat);
109*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegisterAll(const char[]);
110*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat));
11130de9b25SBarry Smith 
11230de9b25SBarry Smith /*MC
11330de9b25SBarry Smith    MatRegisterDynamic - Adds a new matrix type
11430de9b25SBarry Smith 
11530de9b25SBarry Smith    Synopsis:
116c1ac3661SBarry Smith    PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat))
11730de9b25SBarry Smith 
11830de9b25SBarry Smith    Not Collective
11930de9b25SBarry Smith 
12030de9b25SBarry Smith    Input Parameters:
12130de9b25SBarry Smith +  name - name of a new user-defined matrix type
12230de9b25SBarry Smith .  path - path (either absolute or relative) the library containing this solver
12330de9b25SBarry Smith .  name_create - name of routine to create method context
12430de9b25SBarry Smith -  routine_create - routine to create method context
12530de9b25SBarry Smith 
12630de9b25SBarry Smith    Notes:
12730de9b25SBarry Smith    MatRegisterDynamic() may be called multiple times to add several user-defined solvers.
12830de9b25SBarry Smith 
12930de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
13030de9b25SBarry Smith    is ignored.
13130de9b25SBarry Smith 
13230de9b25SBarry Smith    Sample usage:
13330de9b25SBarry Smith .vb
13430de9b25SBarry Smith    MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a,
13530de9b25SBarry Smith                "MyMatCreate",MyMatCreate);
13630de9b25SBarry Smith .ve
13730de9b25SBarry Smith 
13830de9b25SBarry Smith    Then, your solver can be chosen with the procedural interface via
13930de9b25SBarry Smith $     MatSetType(Mat,"my_mat")
14030de9b25SBarry Smith    or at runtime via the option
14130de9b25SBarry Smith $     -mat_type my_mat
14230de9b25SBarry Smith 
14330de9b25SBarry Smith    Level: advanced
14430de9b25SBarry Smith 
145ab901514SBarry Smith    Notes: ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
14630de9b25SBarry Smith          If your function is not being put into a shared library then use VecRegister() instead
14730de9b25SBarry Smith 
14830de9b25SBarry Smith .keywords: Mat, register
14930de9b25SBarry Smith 
15030de9b25SBarry Smith .seealso: MatRegisterAll(), MatRegisterDestroy()
15130de9b25SBarry Smith 
15230de9b25SBarry Smith M*/
153273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
154273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
155273d9f13SBarry Smith #else
156273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
15730de9b25SBarry Smith #endif
15830de9b25SBarry Smith 
159273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled;
160b0a32e0cSBarry Smith extern PetscFList MatList;
16128988994SBarry Smith 
162*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*);
163*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*);
164*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
165*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
166*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
167*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
168*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
169*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
170*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
171*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*);
172*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
173*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
174*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*);
175*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*);
176*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateNormal(Mat,Mat*);
177*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroy(Mat);
17821c89e3eSBarry Smith 
179*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPrintHelp(Mat);
180*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetPetscMaps(Mat,PetscMap*,PetscMap*);
181ec0117caSBarry Smith 
1828ed539a5SBarry Smith /* ------------------------------------------------------------*/
183*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
184*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
18584cb2905SBarry Smith 
1862ef4de8bSBarry Smith /*S
1872ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
1882ef4de8bSBarry Smith         column of a matrix as index on an associated grid.
1892ef4de8bSBarry Smith 
1902ef4de8bSBarry Smith    Level: beginner
1912ef4de8bSBarry Smith 
1922ef4de8bSBarry Smith   Concepts: matrix; linear operator
1932ef4de8bSBarry Smith 
194d7bd93baSBarry Smith .seealso:  MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil()
1952ef4de8bSBarry Smith S*/
196435da068SBarry Smith typedef struct {
197c1ac3661SBarry Smith   PetscInt k,j,i,c;
198435da068SBarry Smith } MatStencil;
1992ef4de8bSBarry Smith 
200*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
201*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
202*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt);
203435da068SBarry Smith 
204*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetColoring(Mat,ISColoring);
205*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesAdic(Mat,void*);
206*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesAdifor(Mat,PetscInt,void*);
2073a7fca6bSBarry Smith 
208d91e6319SBarry Smith /*E
209d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
210d91e6319SBarry Smith      to continue to add values to it
211d91e6319SBarry Smith 
212d91e6319SBarry Smith     Level: beginner
213d91e6319SBarry Smith 
214d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
215d91e6319SBarry Smith E*/
2166d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
217*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssemblyBegin(Mat,MatAssemblyType);
218*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssemblyEnd(Mat,MatAssemblyType);
219*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssembled(Mat,PetscTruth*);
2204f9c727eSBarry Smith 
221*be1d678aSKris Buschelman extern PETSCMAT_DLLEXPORT PetscInt    MatSetValue_Row;
222*be1d678aSKris Buschelman extern PETSCMAT_DLLEXPORT PetscInt    MatSetValue_Column;
223*be1d678aSKris Buschelman extern PETSCMAT_DLLEXPORT PetscScalar MatSetValue_Value;
2241d73ed98SBarry Smith 
22530de9b25SBarry Smith /*MC
22630de9b25SBarry Smith    MatSetValue - Set a single entry into a matrix.
22730de9b25SBarry Smith 
22830de9b25SBarry Smith    Synopsis:
229c1ac3661SBarry Smith    PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode);
23030de9b25SBarry Smith 
23130de9b25SBarry Smith    Not collective
23230de9b25SBarry Smith 
23330de9b25SBarry Smith    Input Parameters:
23430de9b25SBarry Smith +  m - the matrix
23530de9b25SBarry Smith .  row - the row location of the entry
23630de9b25SBarry Smith .  col - the column location of the entry
23730de9b25SBarry Smith .  value - the value to insert
23830de9b25SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
23930de9b25SBarry Smith 
24030de9b25SBarry Smith    Notes:
24130de9b25SBarry Smith    For efficiency one should use MatSetValues() and set several or many
24230de9b25SBarry Smith    values simultaneously if possible.
24330de9b25SBarry Smith 
24430de9b25SBarry Smith    Level: beginner
24530de9b25SBarry Smith 
24630de9b25SBarry Smith .seealso: MatSetValues(), MatSetValueLocal()
24730de9b25SBarry Smith M*/
248b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
249f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
2501d73ed98SBarry Smith    MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
25130de9b25SBarry Smith 
252ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
253f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,0) || \
2541d73ed98SBarry Smith    MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va))
25530de9b25SBarry Smith 
256d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \
257f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
2581d73ed98SBarry Smith    MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
25930de9b25SBarry Smith 
260d91e6319SBarry Smith /*E
261d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
262d91e6319SBarry Smith 
263d91e6319SBarry Smith     Level: beginner
264d91e6319SBarry Smith 
2650a835dfdSSatish Balay    Any additions/changes here MUST also be made in include/finclude/petscmat.h
266d91e6319SBarry Smith 
267d91e6319SBarry Smith .seealso: MatSetOption()
268d91e6319SBarry Smith E*/
2696d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
2706d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
2716d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
2726ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
2736ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
2746ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
2756ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
2764787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
2777c922b88SBarry Smith               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
2782bad1931SBarry Smith               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
279efcf0fc3SBarry Smith               MAT_DO_NOT_USE_INODES=82,MAT_NOT_SYMMETRIC=83,MAT_HERMITIAN=84,
2809a4540c5SBarry Smith               MAT_NOT_STRUCTURALLY_SYMMETRIC=85,MAT_NOT_HERMITIAN=86,
281d487561eSHong Zhang               MAT_SYMMETRY_ETERNAL=87,MAT_NOT_SYMMETRY_ETERNAL=88,
282941593c8SHong Zhang               MAT_USE_COMPRESSEDROW=89,MAT_DO_NOT_USE_COMPRESSEDROW=90,
283941593c8SHong Zhang               MAT_IGNORE_LOWER_TRIANGULAR=91,MAT_ERROR_LOWER_TRIANGULAR=92} MatOption;
284*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetOption(Mat,MatOption);
285*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetType(Mat,MatType*);
28684cb2905SBarry Smith 
287*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]);
288*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
289*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
290*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
291*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
292*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumnVector(Mat,Vec,PetscInt);
293*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetArray(Mat,PetscScalar *[]);
294*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreArray(Mat,PetscScalar *[]);
295*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBlockSize(Mat,PetscInt *);
296*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetBlockSize(Mat,PetscInt);
2977b80b807SBarry Smith 
298*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMult(Mat,Vec,Vec);
299*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultAdd(Mat,Vec,Vec,Vec);
300*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTranspose(Mat,Vec,Vec);
301*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*);
302*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeAdd(Mat,Vec,Vec,Vec);
303*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultConstrained(Mat,Vec,Vec);
304*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeConstrained(Mat,Vec,Vec);
3052eac72dbSBarry Smith 
306d91e6319SBarry Smith /*E
307d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
308d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
309d91e6319SBarry Smith 
310d91e6319SBarry Smith     Level: beginner
311d91e6319SBarry Smith 
312d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
313d91e6319SBarry Smith 
314d91e6319SBarry Smith .seealso: MatDuplicate()
315d91e6319SBarry Smith E*/
3162e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
3172e8a6d31SBarry Smith 
318*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegister(const char[],const char[],const char[],PetscErrorCode (*)(Mat,MatType,MatReuse,Mat*));
319273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
320273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
321273d9f13SBarry Smith #else
322273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
323273d9f13SBarry Smith #endif
324*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegisterAll(const char[]);
325*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegisterDestroy(void);
326273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled;
327b0a32e0cSBarry Smith extern PetscFList MatConvertList;
328*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvert(Mat,const MatType,MatReuse,Mat*);
329*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDuplicate(Mat,MatDuplicateOption,Mat*);
33094a9d846SBarry Smith 
331d91e6319SBarry Smith /*E
332d91e6319SBarry Smith     MatStructure - Indicates if the matrix has the same nonzero structure
333d91e6319SBarry Smith 
334d91e6319SBarry Smith     Level: beginner
335d91e6319SBarry Smith 
336d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
337d91e6319SBarry Smith 
33894b7f48cSBarry Smith .seealso: MatCopy(), KSPSetOperators(), PCSetOperators()
339d91e6319SBarry Smith E*/
340c537a176SHong Zhang typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure;
341cb5b572fSBarry Smith 
342*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCopy(Mat,Mat,MatStructure);
343*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatView(Mat,PetscViewer);
344*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsSymmetric(Mat,PetscReal,PetscTruth*);
345*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsStructurallySymmetric(Mat,PetscTruth*);
346*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitian(Mat,PetscTruth*);
347*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*);
348*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitianKnown(Mat,PetscTruth*,PetscTruth*);
349*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLoad(PetscViewer,const MatType,Mat*);
3507b80b807SBarry Smith 
351*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
352*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
353*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
354*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
355d4fbbf0eSBarry Smith 
356d91e6319SBarry Smith /*S
357d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
358d91e6319SBarry Smith 
359d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
360d91e6319SBarry Smith 
361d91e6319SBarry Smith    Level: intermediate
362d91e6319SBarry Smith 
363d91e6319SBarry Smith   Concepts: matrix^nonzero information
364d91e6319SBarry Smith 
365d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
366d91e6319SBarry Smith S*/
3674e220ebcSLois Curfman McInnes typedef struct {
368b0a32e0cSBarry Smith   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
369b0a32e0cSBarry Smith   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
370b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
371b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
372b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
373b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
374b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
375b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
376b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
3774e220ebcSLois Curfman McInnes } MatInfo;
3784e220ebcSLois Curfman McInnes 
379d9274352SBarry Smith /*E
380d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
381d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
382d9274352SBarry Smith 
383d9274352SBarry Smith     Level: beginner
384d9274352SBarry Smith 
385d9274352SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
386d9274352SBarry Smith 
387d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
388d9274352SBarry Smith E*/
3897b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
390*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetInfo(Mat,MatInfoType,MatInfo*);
391*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatValid(Mat,PetscTruth*);
392*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetDiagonal(Mat,Vec);
393*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowMax(Mat,Vec);
394*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatTranspose(Mat,Mat*);
395*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPermute(Mat,IS,IS,Mat *);
396*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *);
397*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScale(Mat,Vec,Vec);
398*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalSet(Mat,Vec,InsertMode);
399*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatEqual(Mat,Mat,PetscTruth*);
400*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultEqual(Mat,Mat,PetscInt,PetscTruth*);
401*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultAddEqual(Mat,Mat,PetscInt,PetscTruth*);
402*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeEqual(Mat,Mat,PetscInt,PetscTruth*);
403*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscTruth*);
4047b80b807SBarry Smith 
405*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNorm(Mat,NormType,PetscReal *);
406*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroEntries(Mat);
407*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRows(Mat,IS,const PetscScalar*);
408*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroColumns(Mat,IS,const PetscScalar*);
4097b80b807SBarry Smith 
410*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatUseScaledForm(Mat,PetscTruth);
411*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScaleSystem(Mat,Vec,Vec);
412*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatUnScaleSystem(Mat,Vec,Vec);
4135ef9f2a5SBarry Smith 
414*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSize(Mat,PetscInt*,PetscInt*);
415*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalSize(Mat,PetscInt*,PetscInt*);
416*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOwnershipRange(Mat,PetscInt*,PetscInt*);
4177b80b807SBarry Smith 
418*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
419*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroyMatrices(PetscInt,Mat *[]);
420*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *);
421*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*);
422*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*);
423*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPISymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*);
424*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPINumeric(Mat,Mat);
425*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroy_MPIAIJ_SeqsToMPI(Mat);
426*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalMat(Mat,MatReuse,Mat*);
427*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*);
428*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*);
429*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBrowsOfAoCols(Mat,Mat,MatReuse,PetscInt**,PetscScalar**,Mat*);
4308efafbd8SBarry Smith 
431*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt);
4327b80b807SBarry Smith 
433*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
434*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*);
435*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultNumeric(Mat,Mat,Mat);
43622440eb1SKris Buschelman 
437*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*);
438*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*);
439*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAPNumeric(Mat,Mat,Mat);
44022440eb1SKris Buschelman 
441*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*);
442*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*);
443*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTransposeNumeric(Mat,Mat,Mat);
444bc011b1eSHong Zhang 
445*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAXPY(const PetscScalar *,Mat,Mat,MatStructure);
446*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAYPX(const PetscScalar *,Mat,Mat);
447*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCompress(Mat);
4481c741599SHong Zhang 
449*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScale(const PetscScalar *,Mat);
450*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShift(const PetscScalar *,Mat);
4517b80b807SBarry Smith 
452*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
453*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
454*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRowsLocal(Mat,IS,const PetscScalar*);
455*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
456*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
457052efed2SBarry Smith 
458*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStashSetInitialSize(Mat,PetscInt,PetscInt);
459*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
46090f02eecSBarry Smith 
461*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInterpolateAdd(Mat,Vec,Vec,Vec);
462*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInterpolate(Mat,Vec,Vec);
463*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestrict(Mat,Vec,Vec);
464*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetVecs(Mat,Vec*,Vec*);
465bd481603SBarry Smith 
466bd481603SBarry Smith /*MC
467bd481603SBarry Smith    MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per
468bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
469bd481603SBarry Smith 
470bd481603SBarry Smith    Synopsis:
471c1ac3661SBarry Smith    PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
472bd481603SBarry Smith 
473bd481603SBarry Smith    Collective on MPI_Comm
474bd481603SBarry Smith 
475bd481603SBarry Smith    Input Parameters:
476bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
477859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
478859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
479bd481603SBarry Smith 
480bd481603SBarry Smith    Output Parameters:
481bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
482bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
483bd481603SBarry Smith 
484bd481603SBarry Smith 
485bd481603SBarry Smith    Level: intermediate
486bd481603SBarry Smith 
487bd481603SBarry Smith    Notes:
488bd481603SBarry Smith    See the chapter in the users manual on performance for more details
489bd481603SBarry Smith 
4901d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
491bd481603SBarry Smith 
492bd481603SBarry Smith    Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices)
493bd481603SBarry Smith 
494bd481603SBarry Smith   Concepts: preallocation^Matrix
495bd481603SBarry Smith 
496bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
497bd481603SBarry Smith           MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal()
498bd481603SBarry Smith M*/
499c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
5007c922b88SBarry Smith { \
501c1ac3661SBarry Smith   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
502c1ac3661SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
503c1ac3661SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
504c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
505c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
5067c922b88SBarry Smith 
507bd481603SBarry Smith /*MC
508bd481603SBarry Smith    MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per
509bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
510bd481603SBarry Smith 
511bd481603SBarry Smith    Synopsis:
512c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
513bd481603SBarry Smith 
514bd481603SBarry Smith    Collective on MPI_Comm
515bd481603SBarry Smith 
516bd481603SBarry Smith    Input Parameters:
517bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
518859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
519859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
520bd481603SBarry Smith 
521bd481603SBarry Smith    Output Parameters:
522bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
523bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
524bd481603SBarry Smith 
525bd481603SBarry Smith 
526bd481603SBarry Smith    Level: intermediate
527bd481603SBarry Smith 
528bd481603SBarry Smith    Notes:
529bd481603SBarry Smith    See the chapter in the users manual on performance for more details
530bd481603SBarry Smith 
5311d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
532bd481603SBarry Smith 
533bd481603SBarry Smith   Concepts: preallocation^Matrix
534bd481603SBarry Smith 
535bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
536bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
537bd481603SBarry Smith M*/
538222b16d4SBarry Smith #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \
539222b16d4SBarry Smith { \
540c1ac3661SBarry Smith   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__end; \
541c1ac3661SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
542c1ac3661SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
543c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\
544c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
545222b16d4SBarry Smith 
546bd481603SBarry Smith /*MC
547bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
548bd481603SBarry Smith        inserted using a local number of the rows and columns
549bd481603SBarry Smith 
550bd481603SBarry Smith    Synopsis:
551c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
552bd481603SBarry Smith 
553bd481603SBarry Smith    Not Collective
554bd481603SBarry Smith 
555bd481603SBarry Smith    Input Parameters:
556bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
557bd481603SBarry Smith .  nrows - the number of rows indicated
5581d73ed98SBarry Smith .  rows - the indices of the rows
559bd481603SBarry Smith .  ncols - the number of columns in the matrix
560bd481603SBarry Smith .  cols - the columns indicated
561bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
562bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
563bd481603SBarry Smith 
564bd481603SBarry Smith 
565bd481603SBarry Smith    Level: intermediate
566bd481603SBarry Smith 
567bd481603SBarry Smith    Notes:
568bd481603SBarry Smith    See the chapter in the users manual on performance for more details
569bd481603SBarry Smith 
5701d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
571bd481603SBarry Smith 
572bd481603SBarry Smith   Concepts: preallocation^Matrix
573bd481603SBarry Smith 
574bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
575bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
576bd481603SBarry Smith M*/
577c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
578c4f061fbSSatish Balay {\
579c1ac3661SBarry Smith   PetscInt __l;\
580ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
581ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
582c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
583ef66eb69SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
584c4f061fbSSatish Balay   }\
585c4f061fbSSatish Balay }
586c4f061fbSSatish Balay 
587bd481603SBarry Smith /*MC
588bd481603SBarry Smith    MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
589bd481603SBarry Smith        inserted using a local number of the rows and columns
590bd481603SBarry Smith 
591bd481603SBarry Smith    Synopsis:
592c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
593bd481603SBarry Smith 
594bd481603SBarry Smith    Not Collective
595bd481603SBarry Smith 
596bd481603SBarry Smith    Input Parameters:
597bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
598bd481603SBarry Smith .  nrows - the number of rows indicated
5991d73ed98SBarry Smith .  rows - the indices of the rows
600bd481603SBarry Smith .  ncols - the number of columns in the matrix
601bd481603SBarry Smith .  cols - the columns indicated
602bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
603bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
604bd481603SBarry Smith 
605bd481603SBarry Smith 
606bd481603SBarry Smith    Level: intermediate
607bd481603SBarry Smith 
608bd481603SBarry Smith    Notes:
609bd481603SBarry Smith    See the chapter in the users manual on performance for more details
610bd481603SBarry Smith 
611bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
612bd481603SBarry Smith 
613bd481603SBarry Smith   Concepts: preallocation^Matrix
614bd481603SBarry Smith 
615bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
616bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
617bd481603SBarry Smith M*/
618d3d32019SBarry Smith #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
619d3d32019SBarry Smith {\
620c1ac3661SBarry Smith   PetscInt __l;\
621d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
622d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
623d3d32019SBarry Smith   for (__l=0;__l<nrows;__l++) {\
624d3d32019SBarry Smith     _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
625d3d32019SBarry Smith   }\
626d3d32019SBarry Smith }
627d3d32019SBarry Smith 
628bd481603SBarry Smith /*MC
629bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
630bd481603SBarry Smith        inserted using a local number of the rows and columns
631bd481603SBarry Smith 
632bd481603SBarry Smith    Synopsis:
633c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
634bd481603SBarry Smith 
635bd481603SBarry Smith    Not Collective
636bd481603SBarry Smith 
637bd481603SBarry Smith    Input Parameters:
638bd481603SBarry Smith +  nrows - the number of rows indicated
6391d73ed98SBarry Smith .  rows - the indices of the rows
640bd481603SBarry Smith .  ncols - the number of columns in the matrix
641a50f8bf6SHong Zhang -  cols - the columns indicated
642a50f8bf6SHong Zhang 
643a50f8bf6SHong Zhang    Output Parameters:
644a50f8bf6SHong Zhang +  dnz - the array that will be passed to the matrix preallocation routines
645bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
646bd481603SBarry Smith 
647bd481603SBarry Smith 
648bd481603SBarry Smith    Level: intermediate
649bd481603SBarry Smith 
650bd481603SBarry Smith    Notes:
651bd481603SBarry Smith    See the chapter in the users manual on performance for more details
652bd481603SBarry Smith 
653bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
654bd481603SBarry Smith 
655bd481603SBarry Smith   Concepts: preallocation^Matrix
656bd481603SBarry Smith 
657bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
658bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
659bd481603SBarry Smith M*/
660c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
661c1ac3661SBarry Smith { PetscInt __i; \
6627c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
6637c922b88SBarry Smith     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
6647c922b88SBarry Smith   }\
6657c922b88SBarry Smith   dnz[row - __rstart] = nc - onz[row - __rstart];\
6667c922b88SBarry Smith }
6677c922b88SBarry Smith 
668bd481603SBarry Smith /*MC
669bd481603SBarry Smith    MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
670bd481603SBarry Smith        inserted using a local number of the rows and columns
671bd481603SBarry Smith 
672bd481603SBarry Smith    Synopsis:
673c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
674bd481603SBarry Smith 
675bd481603SBarry Smith    Not Collective
676bd481603SBarry Smith 
677bd481603SBarry Smith    Input Parameters:
678bd481603SBarry Smith +  nrows - the number of rows indicated
6791d73ed98SBarry Smith .  rows - the indices of the rows
680bd481603SBarry Smith .  ncols - the number of columns in the matrix
681bd481603SBarry Smith .  cols - the columns indicated
682bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
683bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
684bd481603SBarry Smith 
685bd481603SBarry Smith 
686bd481603SBarry Smith    Level: intermediate
687bd481603SBarry Smith 
688bd481603SBarry Smith    Notes:
689bd481603SBarry Smith    See the chapter in the users manual on performance for more details
690bd481603SBarry Smith 
691bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
692bd481603SBarry Smith 
693bd481603SBarry Smith   Concepts: preallocation^Matrix
694bd481603SBarry Smith 
695bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
696bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
697bd481603SBarry Smith M*/
698d3d32019SBarry Smith #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\
699c1ac3661SBarry Smith { PetscInt __i; \
700d3d32019SBarry Smith   for (__i=0; __i<nc; __i++) {\
701d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
702d3d32019SBarry Smith     else if (cols[__i] >= row) dnz[row - __rstart]++;\
703d3d32019SBarry Smith   }\
704d3d32019SBarry Smith }
705d3d32019SBarry Smith 
706bd481603SBarry Smith /*MC
707bd481603SBarry Smith    MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per
708bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
709bd481603SBarry Smith 
710bd481603SBarry Smith    Synopsis:
711c1ac3661SBarry Smith    PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz)
712bd481603SBarry Smith 
713bd481603SBarry Smith    Collective on MPI_Comm
714bd481603SBarry Smith 
715bd481603SBarry Smith    Input Parameters:
716bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
717bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
718bd481603SBarry Smith 
719bd481603SBarry Smith 
720bd481603SBarry Smith    Level: intermediate
721bd481603SBarry Smith 
722bd481603SBarry Smith    Notes:
723bd481603SBarry Smith    See the chapter in the users manual on performance for more details
724bd481603SBarry Smith 
725bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
726bd481603SBarry Smith 
727bd481603SBarry Smith   Concepts: preallocation^Matrix
728bd481603SBarry Smith 
729bd481603SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
730bd481603SBarry Smith           MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal()
731bd481603SBarry Smith M*/
732ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);}
7337c922b88SBarry Smith 
734bd481603SBarry Smith 
735bd481603SBarry Smith 
7367b80b807SBarry Smith /* Routines unique to particular data structures */
737*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellGetContext(Mat,void **);
738435da068SBarry Smith 
739*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatBDiagGetData(Mat,PetscInt*,PetscInt*,PetscInt*[],PetscInt*[],PetscScalar***);
740698d4c6aSKris Buschelman 
741*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInodeAdjustForInodes(Mat,IS*,IS*);
742*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInodeGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *);
743698d4c6aSKris Buschelman 
744*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetColumnIndices(Mat,PetscInt[]);
745*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJSetColumnIndices(Mat,PetscInt[]);
746*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
7477b80b807SBarry Smith 
748*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
749*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
750*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]);
751*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDensePreallocation(Mat,PetscScalar[]);
752*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
753*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDenseSetPreallocation(Mat,PetscScalar[]);
754273d9f13SBarry Smith 
755*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
756*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
757*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
758*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]);
759*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
760*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIDensePreallocation(Mat,PetscScalar[]);
761*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
762*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]);
763*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIDenseSetPreallocation(Mat,PetscScalar[]);
764*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]);
765*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]);
766*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]);
767*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAdicSetLocalFunction(Mat,void (*)(void));
768273d9f13SBarry Smith 
769*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDenseSetLDA(Mat,PetscInt);
7701b807ce4Svictorle 
771*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStoreValues(Mat);
772*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRetrieveValues(Mat);
7732e8a6d31SBarry Smith 
774*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDAADSetCtx(Mat,void*);
7753a7fca6bSBarry Smith 
7767b80b807SBarry Smith /*
7777b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
77894b7f48cSBarry Smith   done through the KSP and PC interfaces.
7797b80b807SBarry Smith */
7807b80b807SBarry Smith 
781d9274352SBarry Smith /*E
782d9274352SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
783d9274352SBarry Smith        with an optional dynamic library name, for example
784d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
785d9274352SBarry Smith 
786d9274352SBarry Smith    Level: beginner
787d9274352SBarry Smith 
788d9274352SBarry Smith .seealso: MatGetOrdering()
789d9274352SBarry Smith E*/
79049773a63SBarry Smith #define MatOrderingType char*
791b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
792b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
793b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
794b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
795b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
796b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
79762152c8bSBarry Smith #define MATORDERING_DSC_ND    "dsc_nd"
79862152c8bSBarry Smith #define MATORDERING_DSC_MMD   "dsc_mmd"
79962152c8bSBarry Smith #define MATORDERING_DSC_MDF   "dsc_mdf"
800c06d978dSMatthew Knepley #define MATORDERING_CONSTRAINED "constrained"
801c06d978dSMatthew Knepley #define MATORDERING_IDENTITY  "identity"
802c06d978dSMatthew Knepley #define MATORDERING_REVERSE   "reverse"
803b12f92e5SBarry Smith 
804*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOrdering(Mat,const MatOrderingType,IS*,IS*);
805*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOrderingList(PetscFList *list);
806*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*));
80730de9b25SBarry Smith 
80830de9b25SBarry Smith /*MC
80930de9b25SBarry Smith    MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the
81030de9b25SBarry Smith                                matrix package.
81130de9b25SBarry Smith 
81230de9b25SBarry Smith    Synopsis:
813c1ac3661SBarry Smith    PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering))
81430de9b25SBarry Smith 
81530de9b25SBarry Smith    Not Collective
81630de9b25SBarry Smith 
81730de9b25SBarry Smith    Input Parameters:
81830de9b25SBarry Smith +  sname - name of ordering (for example MATORDERING_ND)
81930de9b25SBarry Smith .  path - location of library where creation routine is
82030de9b25SBarry Smith .  name - name of function that creates the ordering type,a string
82130de9b25SBarry Smith -  function - function pointer that creates the ordering
82230de9b25SBarry Smith 
82330de9b25SBarry Smith    Level: developer
82430de9b25SBarry Smith 
82530de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
82630de9b25SBarry Smith    is ignored.
82730de9b25SBarry Smith 
82830de9b25SBarry Smith    Sample usage:
82930de9b25SBarry Smith .vb
83030de9b25SBarry Smith    MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a,
83130de9b25SBarry Smith                "MyOrder",MyOrder);
83230de9b25SBarry Smith .ve
83330de9b25SBarry Smith 
83430de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
83530de9b25SBarry Smith $     MatOrderingSetType(part,"my_order)
83630de9b25SBarry Smith    or at runtime via the option
83730de9b25SBarry Smith $     -pc_ilu_mat_ordering_type my_order
83830de9b25SBarry Smith $     -pc_lu_mat_ordering_type my_order
83930de9b25SBarry Smith 
840ab901514SBarry Smith    ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
84130de9b25SBarry Smith 
84230de9b25SBarry Smith .keywords: matrix, ordering, register
84330de9b25SBarry Smith 
84430de9b25SBarry Smith .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll()
84530de9b25SBarry Smith M*/
846aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
847f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
848b12f92e5SBarry Smith #else
849f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
850b12f92e5SBarry Smith #endif
85130de9b25SBarry Smith 
852*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegisterDestroy(void);
853*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegisterAll(const char[]);
8542bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled;
855b0a32e0cSBarry Smith extern PetscFList MatOrderingList;
856d4fbbf0eSBarry Smith 
857*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
858a2ce50c7SBarry Smith 
859d91e6319SBarry Smith /*S
86015e8a5b3SHong Zhang    MatFactorInfo - Data based into the matrix factorization routines
861b00f7748SHong Zhang 
86215e8a5b3SHong Zhang    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE
863b00f7748SHong Zhang 
86415e8a5b3SHong Zhang    Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.
865b00f7748SHong Zhang 
866b00f7748SHong Zhang    Level: developer
867b00f7748SHong Zhang 
868d7d82daaSBarry Smith .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(),
869d7d82daaSBarry Smith           MatFactorInfoInitialize()
870b00f7748SHong Zhang 
871b00f7748SHong Zhang S*/
872b00f7748SHong Zhang typedef struct {
8730a29876aSHong Zhang   PetscReal     shiftnz;        /* scaling of identity added to matrix to prevent zero pivots */
8740a29876aSHong Zhang   PetscTruth    shiftpd;         /* if true, shift until positive pivots */
8752cea7109SBarry Smith   PetscReal     shift_fraction; /* record shift fraction taken */
87615e8a5b3SHong Zhang   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
87715e8a5b3SHong Zhang   PetscReal     dt;             /* drop tolerance */
878b00f7748SHong Zhang   PetscReal     dtcol;          /* tolerance for pivoting */
87915e8a5b3SHong Zhang   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
880f6275e2eSBarry Smith   PetscReal     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
881348344bbSBarry Smith   PetscReal     levels;         /* ICC/ILU(levels) */
882bcd9e38bSBarry Smith   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
883bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
88415e8a5b3SHong Zhang   PetscReal     zeropivot;      /* pivot is called zero if less than this */
88515e8a5b3SHong Zhang } MatFactorInfo;
886ffa6d0a5SLois Curfman McInnes 
887*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFactorInfoInitialize(MatFactorInfo*);
888*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactor(Mat,IS,MatFactorInfo*);
889*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
890*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactorNumeric(Mat,MatFactorInfo*,Mat*);
891*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactor(Mat,IS,IS,MatFactorInfo*);
892*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUFactor(Mat,IS,IS,MatFactorInfo*);
893*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
894*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
895*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
896*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatICCFactor(Mat,IS,MatFactorInfo*);
897*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactorNumeric(Mat,MatFactorInfo*,Mat*);
898*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUDTFactor(Mat,IS,IS,MatFactorInfo*,Mat *);
899*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*);
900*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolve(Mat,Vec,Vec);
901*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatForwardSolve(Mat,Vec,Vec);
902*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatBackwardSolve(Mat,Vec,Vec);
903*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveAdd(Mat,Vec,Vec,Vec);
904*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveTranspose(Mat,Vec,Vec);
905*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
906*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolves(Mat,Vecs,Vecs);
9078ed539a5SBarry Smith 
908*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUnfactored(Mat);
909bb5a7306SBarry Smith 
910d91e6319SBarry Smith /*E
911d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
912bb1eb677SSatish Balay 
913d91e6319SBarry Smith     Level: beginner
914d91e6319SBarry Smith 
915d9274352SBarry Smith    May be bitwise ORd together
916d9274352SBarry Smith 
917d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
918d91e6319SBarry Smith 
9194e7234bfSBarry Smith    MatSORType may be bitwise ORd together, so do not change the numbers
9204e7234bfSBarry Smith 
921a1d92eedSBarry Smith .seealso: MatRelax(), MatPBRelax()
922d91e6319SBarry Smith E*/
923ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
924ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
925ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
92684cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
927*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
928*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
9298ed539a5SBarry Smith 
930d4fbbf0eSBarry Smith /*
931639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
932639f9d9dSBarry Smith */
933b12f92e5SBarry Smith 
934d9274352SBarry Smith /*E
935d9274352SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
936d9274352SBarry Smith        with an optional dynamic library name, for example
937d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
938d9274352SBarry Smith 
939d9274352SBarry Smith    Level: beginner
940d9274352SBarry Smith 
941d9274352SBarry Smith .seealso: MatGetColoring()
942d9274352SBarry Smith E*/
94349773a63SBarry Smith #define MatColoringType char*
944b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
945b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
946b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
947b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
948b12f92e5SBarry Smith 
949*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColoring(Mat,const MatColoringType,ISColoring*);
950*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatColoringType,ISColoring *));
95130de9b25SBarry Smith 
95230de9b25SBarry Smith /*MC
95330de9b25SBarry Smith    MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the
95430de9b25SBarry Smith                                matrix package.
95530de9b25SBarry Smith 
95630de9b25SBarry Smith    Synopsis:
957c1ac3661SBarry Smith    PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring))
95830de9b25SBarry Smith 
95930de9b25SBarry Smith    Not Collective
96030de9b25SBarry Smith 
96130de9b25SBarry Smith    Input Parameters:
96230de9b25SBarry Smith +  sname - name of Coloring (for example MATCOLORING_SL)
96330de9b25SBarry Smith .  path - location of library where creation routine is
96430de9b25SBarry Smith .  name - name of function that creates the Coloring type, a string
96530de9b25SBarry Smith -  function - function pointer that creates the coloring
96630de9b25SBarry Smith 
96730de9b25SBarry Smith    Level: developer
96830de9b25SBarry Smith 
96930de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
97030de9b25SBarry Smith    is ignored.
97130de9b25SBarry Smith 
97230de9b25SBarry Smith    Sample usage:
97330de9b25SBarry Smith .vb
97430de9b25SBarry Smith    MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a,
97530de9b25SBarry Smith                "MyColor",MyColor);
97630de9b25SBarry Smith .ve
97730de9b25SBarry Smith 
97830de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
97930de9b25SBarry Smith $     MatColoringSetType(part,"my_color")
98030de9b25SBarry Smith    or at runtime via the option
98130de9b25SBarry Smith $     -mat_coloring_type my_color
98230de9b25SBarry Smith 
983ab901514SBarry Smith    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
98430de9b25SBarry Smith 
98530de9b25SBarry Smith .keywords: matrix, Coloring, register
98630de9b25SBarry Smith 
98730de9b25SBarry Smith .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll()
98830de9b25SBarry Smith M*/
989aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
990f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
991b12f92e5SBarry Smith #else
992f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
993b12f92e5SBarry Smith #endif
99430de9b25SBarry Smith 
9952bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled;
996f1144a30SSatish Balay 
997*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegisterAll(const char[]);
998*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegisterDestroy(void);
999*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*);
1000639f9d9dSBarry Smith 
1001d9274352SBarry Smith /*S
1002d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
1003d9274352SBarry Smith         and coloring
1004639f9d9dSBarry Smith 
1005d9274352SBarry Smith    Level: beginner
1006d9274352SBarry Smith 
1007d9274352SBarry Smith   Concepts: coloring, sparse Jacobian, finite differences
1008d9274352SBarry Smith 
1009d9274352SBarry Smith .seealso:  MatFDColoringCreate()
1010d9274352SBarry Smith S*/
1011e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
1012639f9d9dSBarry Smith 
1013*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
1014*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringDestroy(MatFDColoring);
1015*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringView(MatFDColoring,PetscViewer);
1016*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*);
1017*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
1018*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFrequency(MatFDColoring,PetscInt);
1019*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetFrequency(MatFDColoring,PetscInt*);
1020*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFromOptions(MatFDColoring);
1021*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
1022*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
1023*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetRecompute(MatFDColoring);
1024*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetF(MatFDColoring,Vec);
1025*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]);
1026639f9d9dSBarry Smith /*
10270752156aSBarry Smith     These routines are for partitioning matrices: currently used only
10283eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
10290752156aSBarry Smith */
1030ca161407SBarry Smith 
1031d9274352SBarry Smith /*S
1032d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
1033d9274352SBarry Smith 
1034d9274352SBarry Smith    Level: beginner
1035d9274352SBarry Smith 
1036d9274352SBarry Smith   Concepts: partitioning
1037d9274352SBarry Smith 
1038743a1026Svictorle .seealso:  MatPartitioningCreate(), MatPartitioningType
1039d9274352SBarry Smith S*/
104091e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
1041d9274352SBarry Smith 
1042d9274352SBarry Smith /*E
10435bc6e7ccSvictorle     MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function
1044d9274352SBarry Smith        with an optional dynamic library name, for example
1045d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
1046d9274352SBarry Smith 
1047d9274352SBarry Smith    Level: beginner
1048d9274352SBarry Smith 
1049b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning
1050d9274352SBarry Smith E*/
105149773a63SBarry Smith #define MatPartitioningType char*
10528ba1e511SMatthew Knepley #define MAT_PARTITIONING_CURRENT  "current"
1053c2ec2a73SHong Zhang #define MAT_PARTITIONING_SQUARE   "square"
10548ba1e511SMatthew Knepley #define MAT_PARTITIONING_PARMETIS "parmetis"
105571306c60Sjroman #define MAT_PARTITIONING_CHACO    "chaco"
105671306c60Sjroman #define MAT_PARTITIONING_JOSTLE   "jostle"
105771306c60Sjroman #define MAT_PARTITIONING_PARTY    "party"
105871306c60Sjroman #define MAT_PARTITIONING_SCOTCH   "scotch"
105971306c60Sjroman 
1060ca161407SBarry Smith 
1061*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningCreate(MPI_Comm,MatPartitioning*);
1062*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetType(MatPartitioning,const MatPartitioningType);
1063*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetNParts(MatPartitioning,PetscInt);
1064*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetAdjacency(MatPartitioning,Mat);
1065*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]);
1066*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []);
1067*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningApply(MatPartitioning,IS*);
1068*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningDestroy(MatPartitioning);
10692aabb6bbSBarry Smith 
1070*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning));
107130de9b25SBarry Smith 
107230de9b25SBarry Smith /*MC
107330de9b25SBarry Smith    MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the
107430de9b25SBarry Smith    matrix package.
107530de9b25SBarry Smith 
107630de9b25SBarry Smith    Synopsis:
1077c1ac3661SBarry Smith    PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning))
107830de9b25SBarry Smith 
107930de9b25SBarry Smith    Not Collective
108030de9b25SBarry Smith 
108130de9b25SBarry Smith    Input Parameters:
108230de9b25SBarry Smith +  sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis
108330de9b25SBarry Smith .  path - location of library where creation routine is
108430de9b25SBarry Smith .  name - name of function that creates the partitioning type, a string
108530de9b25SBarry Smith -  function - function pointer that creates the partitioning type
108630de9b25SBarry Smith 
108730de9b25SBarry Smith    Level: developer
108830de9b25SBarry Smith 
108930de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
109030de9b25SBarry Smith    is ignored.
109130de9b25SBarry Smith 
109230de9b25SBarry Smith    Sample usage:
109330de9b25SBarry Smith .vb
109430de9b25SBarry Smith    MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a,
109530de9b25SBarry Smith                "MyPartCreate",MyPartCreate);
109630de9b25SBarry Smith .ve
109730de9b25SBarry Smith 
109830de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
109930de9b25SBarry Smith $     MatPartitioningSetType(part,"my_part")
110030de9b25SBarry Smith    or at runtime via the option
110130de9b25SBarry Smith $     -mat_partitioning_type my_part
110230de9b25SBarry Smith 
1103ab901514SBarry Smith    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
110430de9b25SBarry Smith 
110530de9b25SBarry Smith .keywords: matrix, partitioning, register
110630de9b25SBarry Smith 
110730de9b25SBarry Smith .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll()
110830de9b25SBarry Smith M*/
1109aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1110f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
11112aabb6bbSBarry Smith #else
1112f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
11132aabb6bbSBarry Smith #endif
11142aabb6bbSBarry Smith 
11152bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled;
1116f1144a30SSatish Balay 
1117*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegisterAll(const char[]);
1118*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegisterDestroy(void);
11192bad1931SBarry Smith 
1120*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningView(MatPartitioning,PetscViewer);
1121*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetFromOptions(MatPartitioning);
1122*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
1123ca161407SBarry Smith 
1124*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
11250752156aSBarry Smith 
1126*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal);
1127*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningJostleSetCoarseSequential(MatPartitioning);
112871306c60Sjroman 
112971306c60Sjroman typedef enum { MP_CHACO_MULTILEVEL_KL, MP_CHACO_SPECTRAL, MP_CHACO_LINEAR,
113071306c60Sjroman     MP_CHACO_RANDOM, MP_CHACO_SCATTERED } MPChacoGlobalType;
1131*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
113271306c60Sjroman typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType;
1133*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1134*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal);
113571306c60Sjroman typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType;
1136*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType);
1137*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1138*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
113971306c60Sjroman 
114071306c60Sjroman #define MP_PARTY_OPT "opt"
114171306c60Sjroman #define MP_PARTY_LIN "lin"
114271306c60Sjroman #define MP_PARTY_SCA "sca"
114371306c60Sjroman #define MP_PARTY_RAN "ran"
114471306c60Sjroman #define MP_PARTY_GBF "gbf"
114571306c60Sjroman #define MP_PARTY_GCF "gcf"
114671306c60Sjroman #define MP_PARTY_BUB "bub"
114771306c60Sjroman #define MP_PARTY_DEF "def"
1148*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetGlobal(MatPartitioning, const char*);
114971306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs"
115071306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
115171306c60Sjroman #define MP_PARTY_NONE "no"
1152*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetLocal(MatPartitioning, const char*);
1153*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal);
1154*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetBipart(MatPartitioning,PetscTruth);
1155*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth);
115671306c60Sjroman 
115771306c60Sjroman typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType;
1158*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetArch(MatPartitioning,const char*);
1159*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetMultilevel(MatPartitioning);
1160*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType);
1161*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal);
1162*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetHostList(MatPartitioning,const char*);
116371306c60Sjroman typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType;
1164*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType);
1165*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetMapping(MatPartitioning);
1166*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetStrategy(MatPartitioning,char*);
116771306c60Sjroman 
11680752156aSBarry Smith /*
11690a835dfdSSatish Balay     If you add entries here you must also add them to finclude/petscmat.h
1170d4fbbf0eSBarry Smith */
11711c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
11721c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
11731c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
11741c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
11751c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
11767c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
11777c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
11781c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
11791c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
11807c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
11817c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
11821c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
11831c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
11841c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
11851c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
11861c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
11871c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
11881c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
11891c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
11901c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
11911c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
11921c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
11931c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
11941c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
11951c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
11961c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
11971c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
11981c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
11991c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
12001c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
1201d643ce63SMatthew Knepley                MATOP_SETUP_PREALLOCATION=30,
1202d643ce63SMatthew Knepley                MATOP_ILUFACTOR_SYMBOLIC=31,
1203d643ce63SMatthew Knepley                MATOP_ICCFACTOR_SYMBOLIC=32,
1204d643ce63SMatthew Knepley                MATOP_GET_ARRAY=33,
1205d643ce63SMatthew Knepley                MATOP_RESTORE_ARRAY=34,
1206d643ce63SMatthew Knepley                MATOP_DUPLCIATE=35,
1207d643ce63SMatthew Knepley                MATOP_FORWARD_SOLVE=36,
1208d643ce63SMatthew Knepley                MATOP_BACKWARD_SOLVE=37,
1209d643ce63SMatthew Knepley                MATOP_ILUFACTOR=38,
1210d643ce63SMatthew Knepley                MATOP_ICCFACTOR=39,
1211d643ce63SMatthew Knepley                MATOP_AXPY=40,
1212d643ce63SMatthew Knepley                MATOP_GET_SUBMATRICES=41,
1213d643ce63SMatthew Knepley                MATOP_INCREASE_OVERLAP=42,
1214d643ce63SMatthew Knepley                MATOP_GET_VALUES=43,
1215d643ce63SMatthew Knepley                MATOP_COPY=44,
1216d643ce63SMatthew Knepley                MATOP_PRINT_HELP=45,
1217d643ce63SMatthew Knepley                MATOP_SCALE=46,
1218d643ce63SMatthew Knepley                MATOP_SHIFT=47,
1219d643ce63SMatthew Knepley                MATOP_DIAGONAL_SHIFT=48,
1220d643ce63SMatthew Knepley                MATOP_ILUDT_FACTOR=49,
1221d643ce63SMatthew Knepley                MATOP_GET_BLOCK_SIZE=50,
1222d643ce63SMatthew Knepley                MATOP_GET_ROW_IJ=51,
1223d643ce63SMatthew Knepley                MATOP_RESTORE_ROW_IJ=52,
1224d643ce63SMatthew Knepley                MATOP_GET_COLUMN_IJ=53,
1225d643ce63SMatthew Knepley                MATOP_RESTORE_COLUMN_IJ=54,
1226d643ce63SMatthew Knepley                MATOP_FDCOLORING_CREATE=55,
1227d643ce63SMatthew Knepley                MATOP_COLORING_PATCH=56,
1228d643ce63SMatthew Knepley                MATOP_SET_UNFACTORED=57,
1229d643ce63SMatthew Knepley                MATOP_PERMUTE=58,
1230d643ce63SMatthew Knepley                MATOP_SET_VALUES_BLOCKED=59,
1231d643ce63SMatthew Knepley                MATOP_GET_SUBMATRIX=60,
1232d643ce63SMatthew Knepley                MATOP_DESTROY=61,
1233d643ce63SMatthew Knepley                MATOP_VIEW=62,
1234d643ce63SMatthew Knepley                MATOP_GET_MAPS=63,
1235d643ce63SMatthew Knepley                MATOP_USE_SCALED_FORM=64,
1236d643ce63SMatthew Knepley                MATOP_SCALE_SYSTEM=65,
1237d643ce63SMatthew Knepley                MATOP_UNSCALE_SYSTEM=66,
1238ba16a8cbSKris Buschelman                MATOP_SET_LOCAL_TO_GLOBAL_MAP=67,
1239d643ce63SMatthew Knepley                MATOP_SET_VALUES_LOCAL=68,
1240d643ce63SMatthew Knepley                MATOP_ZERO_ROWS_LOCAL=69,
1241d643ce63SMatthew Knepley                MATOP_GET_ROW_MAX=70,
1242d643ce63SMatthew Knepley                MATOP_CONVERT=71,
1243d643ce63SMatthew Knepley                MATOP_SET_COLORING=72,
1244d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIC=73,
1245d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIFOR=74,
1246d643ce63SMatthew Knepley                MATOP_FD_COLORING_APPLY=75,
1247d643ce63SMatthew Knepley                MATOP_SET_FROM_OPTIONS=76,
1248ba16a8cbSKris Buschelman                MATOP_MULT_CON=77,
1249ba16a8cbSKris Buschelman                MATOP_MULT_TRANSPOSE_CON=78,
1250ba16a8cbSKris Buschelman                MATOP_ILU_FACTOR_SYMBOLIC_CON=79,
1251d643ce63SMatthew Knepley                MATOP_PERMUTE_SPARSIFY=80,
1252d643ce63SMatthew Knepley                MATOP_MULT_MULTIPLE=81,
125341acf15aSKris Buschelman                MATOP_SOLVE_MULTIPLE=82,
125441acf15aSKris Buschelman                MATOP_GET_INERTIA=83,
125541acf15aSKris Buschelman                MATOP_LOAD=84,
125641acf15aSKris Buschelman                MATOP_IS_SYMMETRIC=85,
125741acf15aSKris Buschelman                MATOP_IS_HERMITIAN=86,
125841acf15aSKris Buschelman                MATOP_IS_STRUCTURALLY_SYMMETRIC=87,
125941acf15aSKris Buschelman                MATOP_PB_RELAX=88,
126041acf15aSKris Buschelman                MATOP_GET_VECS=89,
126141acf15aSKris Buschelman                MATOP_MAT_MULT=90,
126241acf15aSKris Buschelman                MATOP_MAT_MULT_SYMBOLIC=91,
126341acf15aSKris Buschelman                MATOP_MAT_MULT_NUMERIC=92,
126441acf15aSKris Buschelman                MATOP_PTAP=93,
126541acf15aSKris Buschelman                MATOP_PTAP_SYMBOLIC=94,
1266bc011b1eSHong Zhang                MATOP_PTAP_NUMERIC=95,
1267bc011b1eSHong Zhang                MATOP_MAT_MULTTRANSPOSE=96,
1268bc011b1eSHong Zhang                MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97,
12697ba1a0bfSKris Buschelman                MATOP_MAT_MULTTRANSPOSE_NUMERIC=98,
12707ba1a0bfSKris Buschelman                MATOP_PTAP_SYMBOLIC_SEQAIJ=99,
12717ba1a0bfSKris Buschelman                MATOP_PTAP_NUMERIC_SEQAIJ=100,
12727ba1a0bfSKris Buschelman                MATOP_PTAP_SYMBOLIC_MPIAIJ=101,
12737ba1a0bfSKris Buschelman                MATOP_PTAP_NUMERIC_MPIAIJ=102
1274fae171e0SBarry Smith              } MatOperation;
1275*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatHasOperation(Mat,MatOperation,PetscTruth*);
1276*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellSetOperation(Mat,MatOperation,void(*)(void));
1277*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellGetOperation(Mat,MatOperation,void(**)(void));
1278*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellSetContext(Mat,void*);
1279112a2221SBarry Smith 
128090ace30eSBarry Smith /*
128190ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
128290ace30eSBarry Smith  stored in a universal format. By changing the format with
1283fb9695e5SSatish Balay  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
128490ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
128590ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
128690ace30eSBarry Smith  read into matrices of the same time.
128790ace30eSBarry Smith */
128890ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
128990ace30eSBarry Smith 
1290*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
1291*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIRowbsGetColor(Mat,ISColoring *);
1292860d1616SSatish Balay 
1293*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatISGetLocalMat(Mat,Mat*);
12941f4e1ec7SBarry Smith 
1295d9274352SBarry Smith /*S
1296d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
1297d9274352SBarry Smith          orthogonalizes the vector to a subsapce
1298d9274352SBarry Smith 
1299f7a9e4ceSBarry Smith    Level: advanced
1300d9274352SBarry Smith 
1301d9274352SBarry Smith   Concepts: matrix; linear operator, null space
1302d9274352SBarry Smith 
13036e1639daSBarry Smith   Users manual sections:
13046e1639daSBarry Smith .   sec_singular
13056e1639daSBarry Smith 
1306d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
1307d9274352SBarry Smith S*/
130874637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
1309d9274352SBarry Smith 
1310*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*);
1311*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceDestroy(MatNullSpace);
1312*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
1313*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceAttach(Mat,MatNullSpace);
1314*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceTest(MatNullSpace,Mat);
131574637425SBarry Smith 
1316*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatReorderingSeqSBAIJ(Mat,IS);
1317*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1318*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqSBAIJSetColumnIndices(Mat,PetscInt *);
1319273d9f13SBarry Smith 
13203f1d51d7SBarry Smith 
1321*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMAIJ(Mat,PetscInt,Mat*);
1322*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMAIJRedimension(Mat,PetscInt,Mat*);
1323*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMAIJGetAIJ(Mat,Mat*);
1324c4f061fbSSatish Balay 
1325*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatComputeExplicitOperator(Mat,Mat*);
1326b0a32e0cSBarry Smith 
1327*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScaleLocal(Mat,Vec);
132804f1ad80SBarry Smith 
1329*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
1330*be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
13317dbadf16SMatthew Knepley 
1332e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
13332eac72dbSBarry Smith #endif
1334