xref: /petsc/include/petscmat.h (revision a96a251defc07734f733d1abf27b5765e87fdc8b)
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 */
74be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MAT_COOKIE;
75be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MAT_FDCOLORING_COOKIE;
76be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MAT_PARTITIONING_COOKIE;
77be1d678aSKris Buschelman extern PetscCookie PETSCMAT_DLLEXPORT MAT_NULLSPACE_COOKIE;
786849ba73SBarry Smith extern PetscEvent  MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose;
796849ba73SBarry Smith extern PetscEvent  MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose;
806849ba73SBarry Smith extern PetscEvent  MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic;
816849ba73SBarry Smith extern PetscEvent  MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor;
826849ba73SBarry Smith extern PetscEvent  MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin;
836849ba73SBarry Smith extern PetscEvent  MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering;
846849ba73SBarry Smith extern PetscEvent  MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate;
856849ba73SBarry Smith extern PetscEvent  MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction;
86cb00f407SKris Buschelman extern PetscEvent  MAT_MatMult, MAT_MatMultSymbolic, MAT_MatMultNumeric;
87534c1384SKris Buschelman extern PetscEvent  MAT_PtAP, MAT_PtAPSymbolic, MAT_PtAPNumeric;
88bc011b1eSHong Zhang extern PetscEvent  MAT_MatMultTranspose, MAT_MatMultTransposeSymbolic, MAT_MatMultTransposeNumeric;
89c06d978dSMatthew Knepley 
90ceb03754SKris Buschelman /*E
91ceb03754SKris Buschelman     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
92ceb03754SKris Buschelman      or MatGetSubMatrix() are to be reused to store the new matrix values.
93ceb03754SKris Buschelman 
94ceb03754SKris Buschelman     Level: beginner
95ceb03754SKris Buschelman 
96ceb03754SKris Buschelman    Any additions/changes here MUST also be made in include/finclude/petscmat.h
97ceb03754SKris Buschelman 
98ceb03754SKris Buschelman .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
99ceb03754SKris Buschelman E*/
100ceb03754SKris Buschelman typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
101ceb03754SKris Buschelman 
102be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInitializePackage(char *);
103c06d978dSMatthew Knepley 
104be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreate(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
105be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetType(Mat,const MatType);
106be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetFromOptions(Mat);
107be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUpPreallocation(Mat);
108be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegisterAll(const char[]);
109be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat));
11030de9b25SBarry Smith 
11130de9b25SBarry Smith /*MC
11230de9b25SBarry Smith    MatRegisterDynamic - Adds a new matrix type
11330de9b25SBarry Smith 
11430de9b25SBarry Smith    Synopsis:
115c1ac3661SBarry Smith    PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat))
11630de9b25SBarry Smith 
11730de9b25SBarry Smith    Not Collective
11830de9b25SBarry Smith 
11930de9b25SBarry Smith    Input Parameters:
12030de9b25SBarry Smith +  name - name of a new user-defined matrix type
12130de9b25SBarry Smith .  path - path (either absolute or relative) the library containing this solver
12230de9b25SBarry Smith .  name_create - name of routine to create method context
12330de9b25SBarry Smith -  routine_create - routine to create method context
12430de9b25SBarry Smith 
12530de9b25SBarry Smith    Notes:
12630de9b25SBarry Smith    MatRegisterDynamic() may be called multiple times to add several user-defined solvers.
12730de9b25SBarry Smith 
12830de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
12930de9b25SBarry Smith    is ignored.
13030de9b25SBarry Smith 
13130de9b25SBarry Smith    Sample usage:
13230de9b25SBarry Smith .vb
13330de9b25SBarry Smith    MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a,
13430de9b25SBarry Smith                "MyMatCreate",MyMatCreate);
13530de9b25SBarry Smith .ve
13630de9b25SBarry Smith 
13730de9b25SBarry Smith    Then, your solver can be chosen with the procedural interface via
13830de9b25SBarry Smith $     MatSetType(Mat,"my_mat")
13930de9b25SBarry Smith    or at runtime via the option
14030de9b25SBarry Smith $     -mat_type my_mat
14130de9b25SBarry Smith 
14230de9b25SBarry Smith    Level: advanced
14330de9b25SBarry Smith 
144ab901514SBarry Smith    Notes: ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
14530de9b25SBarry Smith          If your function is not being put into a shared library then use VecRegister() instead
14630de9b25SBarry Smith 
14730de9b25SBarry Smith .keywords: Mat, register
14830de9b25SBarry Smith 
14930de9b25SBarry Smith .seealso: MatRegisterAll(), MatRegisterDestroy()
15030de9b25SBarry Smith 
15130de9b25SBarry Smith M*/
152273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
153273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
154273d9f13SBarry Smith #else
155273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
15630de9b25SBarry Smith #endif
15730de9b25SBarry Smith 
158273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled;
159b0a32e0cSBarry Smith extern PetscFList MatList;
16028988994SBarry Smith 
161be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*);
162be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*);
163be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
164be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
165be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
166be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
167be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
168be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
169be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
170be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*);
171be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
172be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
173be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*);
174be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*);
175be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateNormal(Mat,Mat*);
176be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroy(Mat);
17721c89e3eSBarry Smith 
178be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPrintHelp(Mat);
179be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetPetscMaps(Mat,PetscMap*,PetscMap*);
180ec0117caSBarry Smith 
1818ed539a5SBarry Smith /* ------------------------------------------------------------*/
182be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
183be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
18484cb2905SBarry Smith 
1852ef4de8bSBarry Smith /*S
1862ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
1872ef4de8bSBarry Smith         column of a matrix as index on an associated grid.
1882ef4de8bSBarry Smith 
1892ef4de8bSBarry Smith    Level: beginner
1902ef4de8bSBarry Smith 
1912ef4de8bSBarry Smith   Concepts: matrix; linear operator
1922ef4de8bSBarry Smith 
193d7bd93baSBarry Smith .seealso:  MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil()
1942ef4de8bSBarry Smith S*/
195435da068SBarry Smith typedef struct {
196c1ac3661SBarry Smith   PetscInt k,j,i,c;
197435da068SBarry Smith } MatStencil;
1982ef4de8bSBarry Smith 
199be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
200be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
201be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt);
202435da068SBarry Smith 
203be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetColoring(Mat,ISColoring);
204be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesAdic(Mat,void*);
205be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesAdifor(Mat,PetscInt,void*);
2063a7fca6bSBarry Smith 
207d91e6319SBarry Smith /*E
208d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
209d91e6319SBarry Smith      to continue to add values to it
210d91e6319SBarry Smith 
211d91e6319SBarry Smith     Level: beginner
212d91e6319SBarry Smith 
213d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
214d91e6319SBarry Smith E*/
2156d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
216be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssemblyBegin(Mat,MatAssemblyType);
217be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssemblyEnd(Mat,MatAssemblyType);
218be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssembled(Mat,PetscTruth*);
2194f9c727eSBarry Smith 
220be1d678aSKris Buschelman extern PETSCMAT_DLLEXPORT PetscInt    MatSetValue_Row;
221be1d678aSKris Buschelman extern PETSCMAT_DLLEXPORT PetscInt    MatSetValue_Column;
222be1d678aSKris Buschelman extern PETSCMAT_DLLEXPORT PetscScalar MatSetValue_Value;
2231d73ed98SBarry Smith 
22430de9b25SBarry Smith /*MC
22530de9b25SBarry Smith    MatSetValue - Set a single entry into a matrix.
22630de9b25SBarry Smith 
22730de9b25SBarry Smith    Synopsis:
228c1ac3661SBarry Smith    PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode);
22930de9b25SBarry Smith 
23030de9b25SBarry Smith    Not collective
23130de9b25SBarry Smith 
23230de9b25SBarry Smith    Input Parameters:
23330de9b25SBarry Smith +  m - the matrix
23430de9b25SBarry Smith .  row - the row location of the entry
23530de9b25SBarry Smith .  col - the column location of the entry
23630de9b25SBarry Smith .  value - the value to insert
23730de9b25SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
23830de9b25SBarry Smith 
23930de9b25SBarry Smith    Notes:
24030de9b25SBarry Smith    For efficiency one should use MatSetValues() and set several or many
24130de9b25SBarry Smith    values simultaneously if possible.
24230de9b25SBarry Smith 
24330de9b25SBarry Smith    Level: beginner
24430de9b25SBarry Smith 
24530de9b25SBarry Smith .seealso: MatSetValues(), MatSetValueLocal()
24630de9b25SBarry Smith M*/
247b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
248f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
2491d73ed98SBarry Smith    MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
25030de9b25SBarry Smith 
251ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
252f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,0) || \
2531d73ed98SBarry Smith    MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va))
25430de9b25SBarry Smith 
255d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \
256f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
2571d73ed98SBarry Smith    MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
25830de9b25SBarry Smith 
259d91e6319SBarry Smith /*E
260d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
261d91e6319SBarry Smith 
262d91e6319SBarry Smith     Level: beginner
263d91e6319SBarry Smith 
2640a835dfdSSatish Balay    Any additions/changes here MUST also be made in include/finclude/petscmat.h
265d91e6319SBarry Smith 
266d91e6319SBarry Smith .seealso: MatSetOption()
267d91e6319SBarry Smith E*/
2686d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
2696d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
2706d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
2716ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
2726ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
2736ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
2746ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
2754787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
2767c922b88SBarry Smith               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
2772bad1931SBarry Smith               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
278efcf0fc3SBarry Smith               MAT_DO_NOT_USE_INODES=82,MAT_NOT_SYMMETRIC=83,MAT_HERMITIAN=84,
2799a4540c5SBarry Smith               MAT_NOT_STRUCTURALLY_SYMMETRIC=85,MAT_NOT_HERMITIAN=86,
280d487561eSHong Zhang               MAT_SYMMETRY_ETERNAL=87,MAT_NOT_SYMMETRY_ETERNAL=88,
281941593c8SHong Zhang               MAT_USE_COMPRESSEDROW=89,MAT_DO_NOT_USE_COMPRESSEDROW=90,
282941593c8SHong Zhang               MAT_IGNORE_LOWER_TRIANGULAR=91,MAT_ERROR_LOWER_TRIANGULAR=92} MatOption;
283be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetOption(Mat,MatOption);
284be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetType(Mat,MatType*);
28584cb2905SBarry Smith 
286be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]);
287be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
288be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
289be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
290be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
291be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumnVector(Mat,Vec,PetscInt);
292be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetArray(Mat,PetscScalar *[]);
293be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreArray(Mat,PetscScalar *[]);
294be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBlockSize(Mat,PetscInt *);
295be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetBlockSize(Mat,PetscInt);
2967b80b807SBarry Smith 
297be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMult(Mat,Vec,Vec);
298be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultAdd(Mat,Vec,Vec,Vec);
299be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTranspose(Mat,Vec,Vec);
300be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*);
301be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeAdd(Mat,Vec,Vec,Vec);
302be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultConstrained(Mat,Vec,Vec);
303be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeConstrained(Mat,Vec,Vec);
3042eac72dbSBarry Smith 
305d91e6319SBarry Smith /*E
306d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
307d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
308d91e6319SBarry Smith 
309d91e6319SBarry Smith     Level: beginner
310d91e6319SBarry Smith 
311d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
312d91e6319SBarry Smith 
313d91e6319SBarry Smith .seealso: MatDuplicate()
314d91e6319SBarry Smith E*/
3152e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
3162e8a6d31SBarry Smith 
317be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegister(const char[],const char[],const char[],PetscErrorCode (*)(Mat,MatType,MatReuse,Mat*));
318273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
319273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
320273d9f13SBarry Smith #else
321273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
322273d9f13SBarry Smith #endif
323be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegisterAll(const char[]);
324be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegisterDestroy(void);
325273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled;
326b0a32e0cSBarry Smith extern PetscFList MatConvertList;
327be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvert(Mat,const MatType,MatReuse,Mat*);
328be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDuplicate(Mat,MatDuplicateOption,Mat*);
32994a9d846SBarry Smith 
330d91e6319SBarry Smith /*E
331d91e6319SBarry Smith     MatStructure - Indicates if the matrix has the same nonzero structure
332d91e6319SBarry Smith 
333d91e6319SBarry Smith     Level: beginner
334d91e6319SBarry Smith 
335d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
336d91e6319SBarry Smith 
33794b7f48cSBarry Smith .seealso: MatCopy(), KSPSetOperators(), PCSetOperators()
338d91e6319SBarry Smith E*/
339c537a176SHong Zhang typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure;
340cb5b572fSBarry Smith 
341be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCopy(Mat,Mat,MatStructure);
342be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatView(Mat,PetscViewer);
343be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsSymmetric(Mat,PetscReal,PetscTruth*);
344be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsStructurallySymmetric(Mat,PetscTruth*);
345be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitian(Mat,PetscTruth*);
346be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*);
347be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitianKnown(Mat,PetscTruth*,PetscTruth*);
348be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLoad(PetscViewer,const MatType,Mat*);
3497b80b807SBarry Smith 
350be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
351be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
352be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
353be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
354d4fbbf0eSBarry Smith 
355d91e6319SBarry Smith /*S
356d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
357d91e6319SBarry Smith 
358d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
359d91e6319SBarry Smith 
360d91e6319SBarry Smith    Level: intermediate
361d91e6319SBarry Smith 
362d91e6319SBarry Smith   Concepts: matrix^nonzero information
363d91e6319SBarry Smith 
364d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
365d91e6319SBarry Smith S*/
3664e220ebcSLois Curfman McInnes typedef struct {
367b0a32e0cSBarry Smith   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
368b0a32e0cSBarry Smith   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
369b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
370b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
371b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
372b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
373b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
374b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
375b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
3764e220ebcSLois Curfman McInnes } MatInfo;
3774e220ebcSLois Curfman McInnes 
378d9274352SBarry Smith /*E
379d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
380d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
381d9274352SBarry Smith 
382d9274352SBarry Smith     Level: beginner
383d9274352SBarry Smith 
384d9274352SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
385d9274352SBarry Smith 
386d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
387d9274352SBarry Smith E*/
3887b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
389be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetInfo(Mat,MatInfoType,MatInfo*);
390be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatValid(Mat,PetscTruth*);
391be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetDiagonal(Mat,Vec);
392be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowMax(Mat,Vec);
393be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatTranspose(Mat,Mat*);
394be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPermute(Mat,IS,IS,Mat *);
395be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *);
396be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScale(Mat,Vec,Vec);
397be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalSet(Mat,Vec,InsertMode);
398be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatEqual(Mat,Mat,PetscTruth*);
399be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultEqual(Mat,Mat,PetscInt,PetscTruth*);
400be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultAddEqual(Mat,Mat,PetscInt,PetscTruth*);
401be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeEqual(Mat,Mat,PetscInt,PetscTruth*);
402be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscTruth*);
4037b80b807SBarry Smith 
404be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNorm(Mat,NormType,PetscReal *);
405be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroEntries(Mat);
406be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRows(Mat,IS,const PetscScalar*);
407be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroColumns(Mat,IS,const PetscScalar*);
4087b80b807SBarry Smith 
409be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatUseScaledForm(Mat,PetscTruth);
410be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScaleSystem(Mat,Vec,Vec);
411be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatUnScaleSystem(Mat,Vec,Vec);
4125ef9f2a5SBarry Smith 
413be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSize(Mat,PetscInt*,PetscInt*);
414be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalSize(Mat,PetscInt*,PetscInt*);
415be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOwnershipRange(Mat,PetscInt*,PetscInt*);
4167b80b807SBarry Smith 
417be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
418be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroyMatrices(PetscInt,Mat *[]);
419be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *);
420be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*);
421be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*);
422be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPISymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*);
423be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPINumeric(Mat,Mat);
424be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroy_MPIAIJ_SeqsToMPI(Mat);
425be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalMat(Mat,MatReuse,Mat*);
426be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*);
427be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*);
428be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBrowsOfAoCols(Mat,Mat,MatReuse,PetscInt**,PetscScalar**,Mat*);
4298efafbd8SBarry Smith 
430be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt);
4317b80b807SBarry Smith 
432be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
433be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*);
434be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultNumeric(Mat,Mat,Mat);
43522440eb1SKris Buschelman 
436be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*);
437be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*);
438be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAPNumeric(Mat,Mat,Mat);
43922440eb1SKris Buschelman 
440be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*);
441be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*);
442be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTransposeNumeric(Mat,Mat,Mat);
443bc011b1eSHong Zhang 
444be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAXPY(const PetscScalar *,Mat,Mat,MatStructure);
445be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAYPX(const PetscScalar *,Mat,Mat);
446be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCompress(Mat);
4471c741599SHong Zhang 
448be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScale(const PetscScalar *,Mat);
449be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShift(const PetscScalar *,Mat);
4507b80b807SBarry Smith 
451be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
452be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
453be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRowsLocal(Mat,IS,const PetscScalar*);
454be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
455be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
456052efed2SBarry Smith 
457be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStashSetInitialSize(Mat,PetscInt,PetscInt);
458be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
45990f02eecSBarry Smith 
460be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInterpolateAdd(Mat,Vec,Vec,Vec);
461be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInterpolate(Mat,Vec,Vec);
462be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestrict(Mat,Vec,Vec);
463be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetVecs(Mat,Vec*,Vec*);
464bd481603SBarry Smith 
465bd481603SBarry Smith /*MC
466bd481603SBarry Smith    MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per
467bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
468bd481603SBarry Smith 
469bd481603SBarry Smith    Synopsis:
470c1ac3661SBarry Smith    PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
471bd481603SBarry Smith 
472bd481603SBarry Smith    Collective on MPI_Comm
473bd481603SBarry Smith 
474bd481603SBarry Smith    Input Parameters:
475bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
476859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
477859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
478bd481603SBarry Smith 
479bd481603SBarry Smith    Output Parameters:
480bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
481bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
482bd481603SBarry Smith 
483bd481603SBarry Smith 
484bd481603SBarry Smith    Level: intermediate
485bd481603SBarry Smith 
486bd481603SBarry Smith    Notes:
487bd481603SBarry Smith    See the chapter in the users manual on performance for more details
488bd481603SBarry Smith 
4891d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
490bd481603SBarry Smith 
491bd481603SBarry Smith    Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices)
492bd481603SBarry Smith 
493bd481603SBarry Smith   Concepts: preallocation^Matrix
494bd481603SBarry Smith 
495bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
496bd481603SBarry Smith           MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal()
497bd481603SBarry Smith M*/
498c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
4997c922b88SBarry Smith { \
500c1ac3661SBarry Smith   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
501c1ac3661SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
502c1ac3661SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
503c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
504c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
5057c922b88SBarry Smith 
506bd481603SBarry Smith /*MC
507bd481603SBarry Smith    MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per
508bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
509bd481603SBarry Smith 
510bd481603SBarry Smith    Synopsis:
511c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
512bd481603SBarry Smith 
513bd481603SBarry Smith    Collective on MPI_Comm
514bd481603SBarry Smith 
515bd481603SBarry Smith    Input Parameters:
516bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
517859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
518859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
519bd481603SBarry Smith 
520bd481603SBarry Smith    Output Parameters:
521bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
522bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
523bd481603SBarry Smith 
524bd481603SBarry Smith 
525bd481603SBarry Smith    Level: intermediate
526bd481603SBarry Smith 
527bd481603SBarry Smith    Notes:
528bd481603SBarry Smith    See the chapter in the users manual on performance for more details
529bd481603SBarry Smith 
5301d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
531bd481603SBarry Smith 
532bd481603SBarry Smith   Concepts: preallocation^Matrix
533bd481603SBarry Smith 
534bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
535bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
536bd481603SBarry Smith M*/
537222b16d4SBarry Smith #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \
538222b16d4SBarry Smith { \
539c1ac3661SBarry Smith   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__end; \
540c1ac3661SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
541c1ac3661SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
542c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\
543c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
544222b16d4SBarry Smith 
545bd481603SBarry Smith /*MC
546bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
547bd481603SBarry Smith        inserted using a local number of the rows and columns
548bd481603SBarry Smith 
549bd481603SBarry Smith    Synopsis:
550c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
551bd481603SBarry Smith 
552bd481603SBarry Smith    Not Collective
553bd481603SBarry Smith 
554bd481603SBarry Smith    Input Parameters:
555bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
556bd481603SBarry Smith .  nrows - the number of rows indicated
5571d73ed98SBarry Smith .  rows - the indices of the rows
558bd481603SBarry Smith .  ncols - the number of columns in the matrix
559bd481603SBarry Smith .  cols - the columns indicated
560bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
561bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
562bd481603SBarry Smith 
563bd481603SBarry Smith 
564bd481603SBarry Smith    Level: intermediate
565bd481603SBarry Smith 
566bd481603SBarry Smith    Notes:
567bd481603SBarry Smith    See the chapter in the users manual on performance for more details
568bd481603SBarry Smith 
5691d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
570bd481603SBarry Smith 
571bd481603SBarry Smith   Concepts: preallocation^Matrix
572bd481603SBarry Smith 
573bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
574bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
575bd481603SBarry Smith M*/
576c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
577c4f061fbSSatish Balay {\
578c1ac3661SBarry Smith   PetscInt __l;\
579ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
580ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
581c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
582ef66eb69SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
583c4f061fbSSatish Balay   }\
584c4f061fbSSatish Balay }
585c4f061fbSSatish Balay 
586bd481603SBarry Smith /*MC
587bd481603SBarry Smith    MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
588bd481603SBarry Smith        inserted using a local number of the rows and columns
589bd481603SBarry Smith 
590bd481603SBarry Smith    Synopsis:
591c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
592bd481603SBarry Smith 
593bd481603SBarry Smith    Not Collective
594bd481603SBarry Smith 
595bd481603SBarry Smith    Input Parameters:
596bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
597bd481603SBarry Smith .  nrows - the number of rows indicated
5981d73ed98SBarry Smith .  rows - the indices of the rows
599bd481603SBarry Smith .  ncols - the number of columns in the matrix
600bd481603SBarry Smith .  cols - the columns indicated
601bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
602bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
603bd481603SBarry Smith 
604bd481603SBarry Smith 
605bd481603SBarry Smith    Level: intermediate
606bd481603SBarry Smith 
607bd481603SBarry Smith    Notes:
608bd481603SBarry Smith    See the chapter in the users manual on performance for more details
609bd481603SBarry Smith 
610bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
611bd481603SBarry Smith 
612bd481603SBarry Smith   Concepts: preallocation^Matrix
613bd481603SBarry Smith 
614bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
615bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
616bd481603SBarry Smith M*/
617d3d32019SBarry Smith #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
618d3d32019SBarry Smith {\
619c1ac3661SBarry Smith   PetscInt __l;\
620d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
621d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
622d3d32019SBarry Smith   for (__l=0;__l<nrows;__l++) {\
623d3d32019SBarry Smith     _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
624d3d32019SBarry Smith   }\
625d3d32019SBarry Smith }
626d3d32019SBarry Smith 
627bd481603SBarry Smith /*MC
628bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
629bd481603SBarry Smith        inserted using a local number of the rows and columns
630bd481603SBarry Smith 
631bd481603SBarry Smith    Synopsis:
632c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
633bd481603SBarry Smith 
634bd481603SBarry Smith    Not Collective
635bd481603SBarry Smith 
636bd481603SBarry Smith    Input Parameters:
637bd481603SBarry Smith +  nrows - the number of rows indicated
6381d73ed98SBarry Smith .  rows - the indices of the rows
639bd481603SBarry Smith .  ncols - the number of columns in the matrix
640a50f8bf6SHong Zhang -  cols - the columns indicated
641a50f8bf6SHong Zhang 
642a50f8bf6SHong Zhang    Output Parameters:
643a50f8bf6SHong Zhang +  dnz - the array that will be passed to the matrix preallocation routines
644bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
645bd481603SBarry Smith 
646bd481603SBarry Smith 
647bd481603SBarry Smith    Level: intermediate
648bd481603SBarry Smith 
649bd481603SBarry Smith    Notes:
650bd481603SBarry Smith    See the chapter in the users manual on performance for more details
651bd481603SBarry Smith 
652bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
653bd481603SBarry Smith 
654bd481603SBarry Smith   Concepts: preallocation^Matrix
655bd481603SBarry Smith 
656bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
657bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
658bd481603SBarry Smith M*/
659c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
660c1ac3661SBarry Smith { PetscInt __i; \
6617c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
6627c922b88SBarry Smith     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
6637c922b88SBarry Smith   }\
6647c922b88SBarry Smith   dnz[row - __rstart] = nc - onz[row - __rstart];\
6657c922b88SBarry Smith }
6667c922b88SBarry Smith 
667bd481603SBarry Smith /*MC
668bd481603SBarry Smith    MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
669bd481603SBarry Smith        inserted using a local number of the rows and columns
670bd481603SBarry Smith 
671bd481603SBarry Smith    Synopsis:
672c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
673bd481603SBarry Smith 
674bd481603SBarry Smith    Not Collective
675bd481603SBarry Smith 
676bd481603SBarry Smith    Input Parameters:
677bd481603SBarry Smith +  nrows - the number of rows indicated
6781d73ed98SBarry Smith .  rows - the indices of the rows
679bd481603SBarry Smith .  ncols - the number of columns in the matrix
680bd481603SBarry Smith .  cols - the columns indicated
681bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
682bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
683bd481603SBarry Smith 
684bd481603SBarry Smith 
685bd481603SBarry Smith    Level: intermediate
686bd481603SBarry Smith 
687bd481603SBarry Smith    Notes:
688bd481603SBarry Smith    See the chapter in the users manual on performance for more details
689bd481603SBarry Smith 
690bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
691bd481603SBarry Smith 
692bd481603SBarry Smith   Concepts: preallocation^Matrix
693bd481603SBarry Smith 
694bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
695bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
696bd481603SBarry Smith M*/
697d3d32019SBarry Smith #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\
698c1ac3661SBarry Smith { PetscInt __i; \
699d3d32019SBarry Smith   for (__i=0; __i<nc; __i++) {\
700d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
701d3d32019SBarry Smith     else if (cols[__i] >= row) dnz[row - __rstart]++;\
702d3d32019SBarry Smith   }\
703d3d32019SBarry Smith }
704d3d32019SBarry Smith 
705bd481603SBarry Smith /*MC
706bd481603SBarry Smith    MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per
707bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
708bd481603SBarry Smith 
709bd481603SBarry Smith    Synopsis:
710c1ac3661SBarry Smith    PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz)
711bd481603SBarry Smith 
712bd481603SBarry Smith    Collective on MPI_Comm
713bd481603SBarry Smith 
714bd481603SBarry Smith    Input Parameters:
715bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
716bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
717bd481603SBarry Smith 
718bd481603SBarry Smith 
719bd481603SBarry Smith    Level: intermediate
720bd481603SBarry Smith 
721bd481603SBarry Smith    Notes:
722bd481603SBarry Smith    See the chapter in the users manual on performance for more details
723bd481603SBarry Smith 
724bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
725bd481603SBarry Smith 
726bd481603SBarry Smith   Concepts: preallocation^Matrix
727bd481603SBarry Smith 
728bd481603SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
729bd481603SBarry Smith           MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal()
730bd481603SBarry Smith M*/
731ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);}
7327c922b88SBarry Smith 
733bd481603SBarry Smith 
734bd481603SBarry Smith 
7357b80b807SBarry Smith /* Routines unique to particular data structures */
736be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellGetContext(Mat,void **);
737435da068SBarry Smith 
738be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatBDiagGetData(Mat,PetscInt*,PetscInt*,PetscInt*[],PetscInt*[],PetscScalar***);
739698d4c6aSKris Buschelman 
740be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInodeAdjustForInodes(Mat,IS*,IS*);
741be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInodeGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *);
742698d4c6aSKris Buschelman 
743be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetColumnIndices(Mat,PetscInt[]);
744be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJSetColumnIndices(Mat,PetscInt[]);
745be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
7467b80b807SBarry Smith 
747*a96a251dSBarry Smith #define MAT_SKIP_ALLOCATION -4
748*a96a251dSBarry Smith 
749be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
750be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
751be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]);
752be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDensePreallocation(Mat,PetscScalar[]);
753be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
754be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDenseSetPreallocation(Mat,PetscScalar[]);
755273d9f13SBarry Smith 
756be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
757be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
758be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
759be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]);
760be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
761be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIDensePreallocation(Mat,PetscScalar[]);
762be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
763be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]);
764be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIDenseSetPreallocation(Mat,PetscScalar[]);
765be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]);
766be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]);
767be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]);
768be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAdicSetLocalFunction(Mat,void (*)(void));
769273d9f13SBarry Smith 
770be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDenseSetLDA(Mat,PetscInt);
7711b807ce4Svictorle 
772be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStoreValues(Mat);
773be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRetrieveValues(Mat);
7742e8a6d31SBarry Smith 
775be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDAADSetCtx(Mat,void*);
7763a7fca6bSBarry Smith 
7777b80b807SBarry Smith /*
7787b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
77994b7f48cSBarry Smith   done through the KSP and PC interfaces.
7807b80b807SBarry Smith */
7817b80b807SBarry Smith 
782d9274352SBarry Smith /*E
783d9274352SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
784d9274352SBarry Smith        with an optional dynamic library name, for example
785d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
786d9274352SBarry Smith 
787d9274352SBarry Smith    Level: beginner
788d9274352SBarry Smith 
789d9274352SBarry Smith .seealso: MatGetOrdering()
790d9274352SBarry Smith E*/
79149773a63SBarry Smith #define MatOrderingType char*
792b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
793b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
794b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
795b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
796b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
797b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
79862152c8bSBarry Smith #define MATORDERING_DSC_ND    "dsc_nd"
79962152c8bSBarry Smith #define MATORDERING_DSC_MMD   "dsc_mmd"
80062152c8bSBarry Smith #define MATORDERING_DSC_MDF   "dsc_mdf"
801c06d978dSMatthew Knepley #define MATORDERING_CONSTRAINED "constrained"
802c06d978dSMatthew Knepley #define MATORDERING_IDENTITY  "identity"
803c06d978dSMatthew Knepley #define MATORDERING_REVERSE   "reverse"
804b12f92e5SBarry Smith 
805be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOrdering(Mat,const MatOrderingType,IS*,IS*);
806be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOrderingList(PetscFList *list);
807be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*));
80830de9b25SBarry Smith 
80930de9b25SBarry Smith /*MC
81030de9b25SBarry Smith    MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the
81130de9b25SBarry Smith                                matrix package.
81230de9b25SBarry Smith 
81330de9b25SBarry Smith    Synopsis:
814c1ac3661SBarry Smith    PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering))
81530de9b25SBarry Smith 
81630de9b25SBarry Smith    Not Collective
81730de9b25SBarry Smith 
81830de9b25SBarry Smith    Input Parameters:
81930de9b25SBarry Smith +  sname - name of ordering (for example MATORDERING_ND)
82030de9b25SBarry Smith .  path - location of library where creation routine is
82130de9b25SBarry Smith .  name - name of function that creates the ordering type,a string
82230de9b25SBarry Smith -  function - function pointer that creates the ordering
82330de9b25SBarry Smith 
82430de9b25SBarry Smith    Level: developer
82530de9b25SBarry Smith 
82630de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
82730de9b25SBarry Smith    is ignored.
82830de9b25SBarry Smith 
82930de9b25SBarry Smith    Sample usage:
83030de9b25SBarry Smith .vb
83130de9b25SBarry Smith    MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a,
83230de9b25SBarry Smith                "MyOrder",MyOrder);
83330de9b25SBarry Smith .ve
83430de9b25SBarry Smith 
83530de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
83630de9b25SBarry Smith $     MatOrderingSetType(part,"my_order)
83730de9b25SBarry Smith    or at runtime via the option
83830de9b25SBarry Smith $     -pc_ilu_mat_ordering_type my_order
83930de9b25SBarry Smith $     -pc_lu_mat_ordering_type my_order
84030de9b25SBarry Smith 
841ab901514SBarry Smith    ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
84230de9b25SBarry Smith 
84330de9b25SBarry Smith .keywords: matrix, ordering, register
84430de9b25SBarry Smith 
84530de9b25SBarry Smith .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll()
84630de9b25SBarry Smith M*/
847aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
848f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
849b12f92e5SBarry Smith #else
850f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
851b12f92e5SBarry Smith #endif
85230de9b25SBarry Smith 
853be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegisterDestroy(void);
854be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegisterAll(const char[]);
8552bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled;
856b0a32e0cSBarry Smith extern PetscFList MatOrderingList;
857d4fbbf0eSBarry Smith 
858be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
859a2ce50c7SBarry Smith 
860d91e6319SBarry Smith /*S
86115e8a5b3SHong Zhang    MatFactorInfo - Data based into the matrix factorization routines
862b00f7748SHong Zhang 
86315e8a5b3SHong Zhang    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE
864b00f7748SHong Zhang 
86515e8a5b3SHong Zhang    Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.
866b00f7748SHong Zhang 
867b00f7748SHong Zhang    Level: developer
868b00f7748SHong Zhang 
869d7d82daaSBarry Smith .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(),
870d7d82daaSBarry Smith           MatFactorInfoInitialize()
871b00f7748SHong Zhang 
872b00f7748SHong Zhang S*/
873b00f7748SHong Zhang typedef struct {
8740a29876aSHong Zhang   PetscReal     shiftnz;        /* scaling of identity added to matrix to prevent zero pivots */
8750a29876aSHong Zhang   PetscTruth    shiftpd;         /* if true, shift until positive pivots */
8762cea7109SBarry Smith   PetscReal     shift_fraction; /* record shift fraction taken */
87715e8a5b3SHong Zhang   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
87815e8a5b3SHong Zhang   PetscReal     dt;             /* drop tolerance */
879b00f7748SHong Zhang   PetscReal     dtcol;          /* tolerance for pivoting */
88015e8a5b3SHong Zhang   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
881f6275e2eSBarry Smith   PetscReal     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
882348344bbSBarry Smith   PetscReal     levels;         /* ICC/ILU(levels) */
883bcd9e38bSBarry Smith   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
884bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
88515e8a5b3SHong Zhang   PetscReal     zeropivot;      /* pivot is called zero if less than this */
88615e8a5b3SHong Zhang } MatFactorInfo;
887ffa6d0a5SLois Curfman McInnes 
888be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFactorInfoInitialize(MatFactorInfo*);
889be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactor(Mat,IS,MatFactorInfo*);
890be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
891be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactorNumeric(Mat,MatFactorInfo*,Mat*);
892be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactor(Mat,IS,IS,MatFactorInfo*);
893be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUFactor(Mat,IS,IS,MatFactorInfo*);
894be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
895be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
896be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
897be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatICCFactor(Mat,IS,MatFactorInfo*);
898be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactorNumeric(Mat,MatFactorInfo*,Mat*);
899be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUDTFactor(Mat,IS,IS,MatFactorInfo*,Mat *);
900be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*);
901be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolve(Mat,Vec,Vec);
902be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatForwardSolve(Mat,Vec,Vec);
903be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatBackwardSolve(Mat,Vec,Vec);
904be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveAdd(Mat,Vec,Vec,Vec);
905be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveTranspose(Mat,Vec,Vec);
906be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
907be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolves(Mat,Vecs,Vecs);
9088ed539a5SBarry Smith 
909be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUnfactored(Mat);
910bb5a7306SBarry Smith 
911d91e6319SBarry Smith /*E
912d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
913bb1eb677SSatish Balay 
914d91e6319SBarry Smith     Level: beginner
915d91e6319SBarry Smith 
916d9274352SBarry Smith    May be bitwise ORd together
917d9274352SBarry Smith 
918d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
919d91e6319SBarry Smith 
9204e7234bfSBarry Smith    MatSORType may be bitwise ORd together, so do not change the numbers
9214e7234bfSBarry Smith 
922a1d92eedSBarry Smith .seealso: MatRelax(), MatPBRelax()
923d91e6319SBarry Smith E*/
924ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
925ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
926ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
92784cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
928be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
929be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
9308ed539a5SBarry Smith 
931d4fbbf0eSBarry Smith /*
932639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
933639f9d9dSBarry Smith */
934b12f92e5SBarry Smith 
935d9274352SBarry Smith /*E
936d9274352SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
937d9274352SBarry Smith        with an optional dynamic library name, for example
938d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
939d9274352SBarry Smith 
940d9274352SBarry Smith    Level: beginner
941d9274352SBarry Smith 
942d9274352SBarry Smith .seealso: MatGetColoring()
943d9274352SBarry Smith E*/
94449773a63SBarry Smith #define MatColoringType char*
945b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
946b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
947b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
948b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
949b12f92e5SBarry Smith 
950be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColoring(Mat,const MatColoringType,ISColoring*);
951be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatColoringType,ISColoring *));
95230de9b25SBarry Smith 
95330de9b25SBarry Smith /*MC
95430de9b25SBarry Smith    MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the
95530de9b25SBarry Smith                                matrix package.
95630de9b25SBarry Smith 
95730de9b25SBarry Smith    Synopsis:
958c1ac3661SBarry Smith    PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring))
95930de9b25SBarry Smith 
96030de9b25SBarry Smith    Not Collective
96130de9b25SBarry Smith 
96230de9b25SBarry Smith    Input Parameters:
96330de9b25SBarry Smith +  sname - name of Coloring (for example MATCOLORING_SL)
96430de9b25SBarry Smith .  path - location of library where creation routine is
96530de9b25SBarry Smith .  name - name of function that creates the Coloring type, a string
96630de9b25SBarry Smith -  function - function pointer that creates the coloring
96730de9b25SBarry Smith 
96830de9b25SBarry Smith    Level: developer
96930de9b25SBarry Smith 
97030de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
97130de9b25SBarry Smith    is ignored.
97230de9b25SBarry Smith 
97330de9b25SBarry Smith    Sample usage:
97430de9b25SBarry Smith .vb
97530de9b25SBarry Smith    MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a,
97630de9b25SBarry Smith                "MyColor",MyColor);
97730de9b25SBarry Smith .ve
97830de9b25SBarry Smith 
97930de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
98030de9b25SBarry Smith $     MatColoringSetType(part,"my_color")
98130de9b25SBarry Smith    or at runtime via the option
98230de9b25SBarry Smith $     -mat_coloring_type my_color
98330de9b25SBarry Smith 
984ab901514SBarry Smith    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
98530de9b25SBarry Smith 
98630de9b25SBarry Smith .keywords: matrix, Coloring, register
98730de9b25SBarry Smith 
98830de9b25SBarry Smith .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll()
98930de9b25SBarry Smith M*/
990aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
991f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
992b12f92e5SBarry Smith #else
993f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
994b12f92e5SBarry Smith #endif
99530de9b25SBarry Smith 
9962bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled;
997f1144a30SSatish Balay 
998be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegisterAll(const char[]);
999be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegisterDestroy(void);
1000be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*);
1001639f9d9dSBarry Smith 
1002d9274352SBarry Smith /*S
1003d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
1004d9274352SBarry Smith         and coloring
1005639f9d9dSBarry Smith 
1006d9274352SBarry Smith    Level: beginner
1007d9274352SBarry Smith 
1008d9274352SBarry Smith   Concepts: coloring, sparse Jacobian, finite differences
1009d9274352SBarry Smith 
1010d9274352SBarry Smith .seealso:  MatFDColoringCreate()
1011d9274352SBarry Smith S*/
1012e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
1013639f9d9dSBarry Smith 
1014be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
1015be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringDestroy(MatFDColoring);
1016be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringView(MatFDColoring,PetscViewer);
1017be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*);
1018be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
1019be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFrequency(MatFDColoring,PetscInt);
1020be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetFrequency(MatFDColoring,PetscInt*);
1021be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFromOptions(MatFDColoring);
1022be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
1023be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
1024be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetRecompute(MatFDColoring);
1025be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetF(MatFDColoring,Vec);
1026be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]);
1027639f9d9dSBarry Smith /*
10280752156aSBarry Smith     These routines are for partitioning matrices: currently used only
10293eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
10300752156aSBarry Smith */
1031ca161407SBarry Smith 
1032d9274352SBarry Smith /*S
1033d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
1034d9274352SBarry Smith 
1035d9274352SBarry Smith    Level: beginner
1036d9274352SBarry Smith 
1037d9274352SBarry Smith   Concepts: partitioning
1038d9274352SBarry Smith 
1039743a1026Svictorle .seealso:  MatPartitioningCreate(), MatPartitioningType
1040d9274352SBarry Smith S*/
104191e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
1042d9274352SBarry Smith 
1043d9274352SBarry Smith /*E
10445bc6e7ccSvictorle     MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function
1045d9274352SBarry Smith        with an optional dynamic library name, for example
1046d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
1047d9274352SBarry Smith 
1048d9274352SBarry Smith    Level: beginner
1049d9274352SBarry Smith 
1050b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning
1051d9274352SBarry Smith E*/
105249773a63SBarry Smith #define MatPartitioningType char*
10538ba1e511SMatthew Knepley #define MAT_PARTITIONING_CURRENT  "current"
1054c2ec2a73SHong Zhang #define MAT_PARTITIONING_SQUARE   "square"
10558ba1e511SMatthew Knepley #define MAT_PARTITIONING_PARMETIS "parmetis"
105671306c60Sjroman #define MAT_PARTITIONING_CHACO    "chaco"
105771306c60Sjroman #define MAT_PARTITIONING_JOSTLE   "jostle"
105871306c60Sjroman #define MAT_PARTITIONING_PARTY    "party"
105971306c60Sjroman #define MAT_PARTITIONING_SCOTCH   "scotch"
106071306c60Sjroman 
1061ca161407SBarry Smith 
1062be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningCreate(MPI_Comm,MatPartitioning*);
1063be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetType(MatPartitioning,const MatPartitioningType);
1064be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetNParts(MatPartitioning,PetscInt);
1065be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetAdjacency(MatPartitioning,Mat);
1066be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]);
1067be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []);
1068be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningApply(MatPartitioning,IS*);
1069be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningDestroy(MatPartitioning);
10702aabb6bbSBarry Smith 
1071be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning));
107230de9b25SBarry Smith 
107330de9b25SBarry Smith /*MC
107430de9b25SBarry Smith    MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the
107530de9b25SBarry Smith    matrix package.
107630de9b25SBarry Smith 
107730de9b25SBarry Smith    Synopsis:
1078c1ac3661SBarry Smith    PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning))
107930de9b25SBarry Smith 
108030de9b25SBarry Smith    Not Collective
108130de9b25SBarry Smith 
108230de9b25SBarry Smith    Input Parameters:
108330de9b25SBarry Smith +  sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis
108430de9b25SBarry Smith .  path - location of library where creation routine is
108530de9b25SBarry Smith .  name - name of function that creates the partitioning type, a string
108630de9b25SBarry Smith -  function - function pointer that creates the partitioning type
108730de9b25SBarry Smith 
108830de9b25SBarry Smith    Level: developer
108930de9b25SBarry Smith 
109030de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
109130de9b25SBarry Smith    is ignored.
109230de9b25SBarry Smith 
109330de9b25SBarry Smith    Sample usage:
109430de9b25SBarry Smith .vb
109530de9b25SBarry Smith    MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a,
109630de9b25SBarry Smith                "MyPartCreate",MyPartCreate);
109730de9b25SBarry Smith .ve
109830de9b25SBarry Smith 
109930de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
110030de9b25SBarry Smith $     MatPartitioningSetType(part,"my_part")
110130de9b25SBarry Smith    or at runtime via the option
110230de9b25SBarry Smith $     -mat_partitioning_type my_part
110330de9b25SBarry Smith 
1104ab901514SBarry Smith    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
110530de9b25SBarry Smith 
110630de9b25SBarry Smith .keywords: matrix, partitioning, register
110730de9b25SBarry Smith 
110830de9b25SBarry Smith .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll()
110930de9b25SBarry Smith M*/
1110aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1111f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
11122aabb6bbSBarry Smith #else
1113f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
11142aabb6bbSBarry Smith #endif
11152aabb6bbSBarry Smith 
11162bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled;
1117f1144a30SSatish Balay 
1118be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegisterAll(const char[]);
1119be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegisterDestroy(void);
11202bad1931SBarry Smith 
1121be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningView(MatPartitioning,PetscViewer);
1122be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetFromOptions(MatPartitioning);
1123be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
1124ca161407SBarry Smith 
1125be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
11260752156aSBarry Smith 
1127be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal);
1128be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningJostleSetCoarseSequential(MatPartitioning);
112971306c60Sjroman 
113071306c60Sjroman typedef enum { MP_CHACO_MULTILEVEL_KL, MP_CHACO_SPECTRAL, MP_CHACO_LINEAR,
113171306c60Sjroman     MP_CHACO_RANDOM, MP_CHACO_SCATTERED } MPChacoGlobalType;
1132be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
113371306c60Sjroman typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType;
1134be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1135be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal);
113671306c60Sjroman typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType;
1137be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType);
1138be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1139be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
114071306c60Sjroman 
114171306c60Sjroman #define MP_PARTY_OPT "opt"
114271306c60Sjroman #define MP_PARTY_LIN "lin"
114371306c60Sjroman #define MP_PARTY_SCA "sca"
114471306c60Sjroman #define MP_PARTY_RAN "ran"
114571306c60Sjroman #define MP_PARTY_GBF "gbf"
114671306c60Sjroman #define MP_PARTY_GCF "gcf"
114771306c60Sjroman #define MP_PARTY_BUB "bub"
114871306c60Sjroman #define MP_PARTY_DEF "def"
1149be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetGlobal(MatPartitioning, const char*);
115071306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs"
115171306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
115271306c60Sjroman #define MP_PARTY_NONE "no"
1153be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetLocal(MatPartitioning, const char*);
1154be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal);
1155be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetBipart(MatPartitioning,PetscTruth);
1156be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth);
115771306c60Sjroman 
115871306c60Sjroman typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType;
1159be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetArch(MatPartitioning,const char*);
1160be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetMultilevel(MatPartitioning);
1161be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType);
1162be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal);
1163be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetHostList(MatPartitioning,const char*);
116471306c60Sjroman typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType;
1165be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType);
1166be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetMapping(MatPartitioning);
1167be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetStrategy(MatPartitioning,char*);
116871306c60Sjroman 
11690752156aSBarry Smith /*
11700a835dfdSSatish Balay     If you add entries here you must also add them to finclude/petscmat.h
1171d4fbbf0eSBarry Smith */
11721c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
11731c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
11741c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
11751c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
11761c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
11777c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
11787c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
11791c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
11801c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
11817c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
11827c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
11831c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
11841c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
11851c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
11861c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
11871c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
11881c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
11891c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
11901c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
11911c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
11921c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
11931c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
11941c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
11951c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
11961c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
11971c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
11981c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
11991c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
12001c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
12011c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
1202d643ce63SMatthew Knepley                MATOP_SETUP_PREALLOCATION=30,
1203d643ce63SMatthew Knepley                MATOP_ILUFACTOR_SYMBOLIC=31,
1204d643ce63SMatthew Knepley                MATOP_ICCFACTOR_SYMBOLIC=32,
1205d643ce63SMatthew Knepley                MATOP_GET_ARRAY=33,
1206d643ce63SMatthew Knepley                MATOP_RESTORE_ARRAY=34,
1207d643ce63SMatthew Knepley                MATOP_DUPLCIATE=35,
1208d643ce63SMatthew Knepley                MATOP_FORWARD_SOLVE=36,
1209d643ce63SMatthew Knepley                MATOP_BACKWARD_SOLVE=37,
1210d643ce63SMatthew Knepley                MATOP_ILUFACTOR=38,
1211d643ce63SMatthew Knepley                MATOP_ICCFACTOR=39,
1212d643ce63SMatthew Knepley                MATOP_AXPY=40,
1213d643ce63SMatthew Knepley                MATOP_GET_SUBMATRICES=41,
1214d643ce63SMatthew Knepley                MATOP_INCREASE_OVERLAP=42,
1215d643ce63SMatthew Knepley                MATOP_GET_VALUES=43,
1216d643ce63SMatthew Knepley                MATOP_COPY=44,
1217d643ce63SMatthew Knepley                MATOP_PRINT_HELP=45,
1218d643ce63SMatthew Knepley                MATOP_SCALE=46,
1219d643ce63SMatthew Knepley                MATOP_SHIFT=47,
1220d643ce63SMatthew Knepley                MATOP_DIAGONAL_SHIFT=48,
1221d643ce63SMatthew Knepley                MATOP_ILUDT_FACTOR=49,
1222d643ce63SMatthew Knepley                MATOP_GET_BLOCK_SIZE=50,
1223d643ce63SMatthew Knepley                MATOP_GET_ROW_IJ=51,
1224d643ce63SMatthew Knepley                MATOP_RESTORE_ROW_IJ=52,
1225d643ce63SMatthew Knepley                MATOP_GET_COLUMN_IJ=53,
1226d643ce63SMatthew Knepley                MATOP_RESTORE_COLUMN_IJ=54,
1227d643ce63SMatthew Knepley                MATOP_FDCOLORING_CREATE=55,
1228d643ce63SMatthew Knepley                MATOP_COLORING_PATCH=56,
1229d643ce63SMatthew Knepley                MATOP_SET_UNFACTORED=57,
1230d643ce63SMatthew Knepley                MATOP_PERMUTE=58,
1231d643ce63SMatthew Knepley                MATOP_SET_VALUES_BLOCKED=59,
1232d643ce63SMatthew Knepley                MATOP_GET_SUBMATRIX=60,
1233d643ce63SMatthew Knepley                MATOP_DESTROY=61,
1234d643ce63SMatthew Knepley                MATOP_VIEW=62,
1235d643ce63SMatthew Knepley                MATOP_GET_MAPS=63,
1236d643ce63SMatthew Knepley                MATOP_USE_SCALED_FORM=64,
1237d643ce63SMatthew Knepley                MATOP_SCALE_SYSTEM=65,
1238d643ce63SMatthew Knepley                MATOP_UNSCALE_SYSTEM=66,
1239ba16a8cbSKris Buschelman                MATOP_SET_LOCAL_TO_GLOBAL_MAP=67,
1240d643ce63SMatthew Knepley                MATOP_SET_VALUES_LOCAL=68,
1241d643ce63SMatthew Knepley                MATOP_ZERO_ROWS_LOCAL=69,
1242d643ce63SMatthew Knepley                MATOP_GET_ROW_MAX=70,
1243d643ce63SMatthew Knepley                MATOP_CONVERT=71,
1244d643ce63SMatthew Knepley                MATOP_SET_COLORING=72,
1245d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIC=73,
1246d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIFOR=74,
1247d643ce63SMatthew Knepley                MATOP_FD_COLORING_APPLY=75,
1248d643ce63SMatthew Knepley                MATOP_SET_FROM_OPTIONS=76,
1249ba16a8cbSKris Buschelman                MATOP_MULT_CON=77,
1250ba16a8cbSKris Buschelman                MATOP_MULT_TRANSPOSE_CON=78,
1251ba16a8cbSKris Buschelman                MATOP_ILU_FACTOR_SYMBOLIC_CON=79,
1252d643ce63SMatthew Knepley                MATOP_PERMUTE_SPARSIFY=80,
1253d643ce63SMatthew Knepley                MATOP_MULT_MULTIPLE=81,
125441acf15aSKris Buschelman                MATOP_SOLVE_MULTIPLE=82,
125541acf15aSKris Buschelman                MATOP_GET_INERTIA=83,
125641acf15aSKris Buschelman                MATOP_LOAD=84,
125741acf15aSKris Buschelman                MATOP_IS_SYMMETRIC=85,
125841acf15aSKris Buschelman                MATOP_IS_HERMITIAN=86,
125941acf15aSKris Buschelman                MATOP_IS_STRUCTURALLY_SYMMETRIC=87,
126041acf15aSKris Buschelman                MATOP_PB_RELAX=88,
126141acf15aSKris Buschelman                MATOP_GET_VECS=89,
126241acf15aSKris Buschelman                MATOP_MAT_MULT=90,
126341acf15aSKris Buschelman                MATOP_MAT_MULT_SYMBOLIC=91,
126441acf15aSKris Buschelman                MATOP_MAT_MULT_NUMERIC=92,
126541acf15aSKris Buschelman                MATOP_PTAP=93,
126641acf15aSKris Buschelman                MATOP_PTAP_SYMBOLIC=94,
1267bc011b1eSHong Zhang                MATOP_PTAP_NUMERIC=95,
1268bc011b1eSHong Zhang                MATOP_MAT_MULTTRANSPOSE=96,
1269bc011b1eSHong Zhang                MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97,
12707ba1a0bfSKris Buschelman                MATOP_MAT_MULTTRANSPOSE_NUMERIC=98,
12717ba1a0bfSKris Buschelman                MATOP_PTAP_SYMBOLIC_SEQAIJ=99,
12727ba1a0bfSKris Buschelman                MATOP_PTAP_NUMERIC_SEQAIJ=100,
12737ba1a0bfSKris Buschelman                MATOP_PTAP_SYMBOLIC_MPIAIJ=101,
12747ba1a0bfSKris Buschelman                MATOP_PTAP_NUMERIC_MPIAIJ=102
1275fae171e0SBarry Smith              } MatOperation;
1276be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatHasOperation(Mat,MatOperation,PetscTruth*);
1277be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellSetOperation(Mat,MatOperation,void(*)(void));
1278be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellGetOperation(Mat,MatOperation,void(**)(void));
1279be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellSetContext(Mat,void*);
1280112a2221SBarry Smith 
128190ace30eSBarry Smith /*
128290ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
128390ace30eSBarry Smith  stored in a universal format. By changing the format with
1284fb9695e5SSatish Balay  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
128590ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
128690ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
128790ace30eSBarry Smith  read into matrices of the same time.
128890ace30eSBarry Smith */
128990ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
129090ace30eSBarry Smith 
1291be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
1292be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIRowbsGetColor(Mat,ISColoring *);
1293860d1616SSatish Balay 
1294be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatISGetLocalMat(Mat,Mat*);
12951f4e1ec7SBarry Smith 
1296d9274352SBarry Smith /*S
1297d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
1298d9274352SBarry Smith          orthogonalizes the vector to a subsapce
1299d9274352SBarry Smith 
1300f7a9e4ceSBarry Smith    Level: advanced
1301d9274352SBarry Smith 
1302d9274352SBarry Smith   Concepts: matrix; linear operator, null space
1303d9274352SBarry Smith 
13046e1639daSBarry Smith   Users manual sections:
13056e1639daSBarry Smith .   sec_singular
13066e1639daSBarry Smith 
1307d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
1308d9274352SBarry Smith S*/
130974637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
1310d9274352SBarry Smith 
1311be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*);
1312be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceDestroy(MatNullSpace);
1313be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
1314be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceAttach(Mat,MatNullSpace);
1315be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceTest(MatNullSpace,Mat);
131674637425SBarry Smith 
1317be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatReorderingSeqSBAIJ(Mat,IS);
1318be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1319be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqSBAIJSetColumnIndices(Mat,PetscInt *);
132046129b97SKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJInvertBlockDiagonal(Mat);
13213f1d51d7SBarry Smith 
1322be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMAIJ(Mat,PetscInt,Mat*);
1323be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMAIJRedimension(Mat,PetscInt,Mat*);
1324be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMAIJGetAIJ(Mat,Mat*);
1325c4f061fbSSatish Balay 
1326be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatComputeExplicitOperator(Mat,Mat*);
1327b0a32e0cSBarry Smith 
1328be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScaleLocal(Mat,Vec);
132904f1ad80SBarry Smith 
1330be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
1331be1d678aSKris Buschelman EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
13327dbadf16SMatthew Knepley 
1333e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
13342eac72dbSBarry Smith #endif
1335