xref: /petsc/include/petscmat.h (revision 941593c847bb92c54fe3ea55b33506f4fd829627)
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 */
746849ba73SBarry Smith extern PetscCookie MAT_COOKIE, MATSNESMFCTX_COOKIE, MAT_FDCOLORING_COOKIE, MAT_PARTITIONING_COOKIE, MAT_NULLSPACE_COOKIE;
756849ba73SBarry Smith extern PetscEvent  MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose;
766849ba73SBarry Smith extern PetscEvent  MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose;
776849ba73SBarry Smith extern PetscEvent  MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic;
786849ba73SBarry Smith extern PetscEvent  MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor;
796849ba73SBarry Smith extern PetscEvent  MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin;
806849ba73SBarry Smith extern PetscEvent  MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering;
816849ba73SBarry Smith extern PetscEvent  MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate;
826849ba73SBarry Smith extern PetscEvent  MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction;
83cb00f407SKris Buschelman extern PetscEvent  MAT_MatMult, MAT_MatMultSymbolic, MAT_MatMultNumeric;
84534c1384SKris Buschelman extern PetscEvent  MAT_PtAP, MAT_PtAPSymbolic, MAT_PtAPNumeric;
85bc011b1eSHong Zhang extern PetscEvent  MAT_MatMultTranspose, MAT_MatMultTransposeSymbolic, MAT_MatMultTransposeNumeric;
86c06d978dSMatthew Knepley 
87ceb03754SKris Buschelman /*E
88ceb03754SKris Buschelman     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
89ceb03754SKris Buschelman      or MatGetSubMatrix() are to be reused to store the new matrix values.
90ceb03754SKris Buschelman 
91ceb03754SKris Buschelman     Level: beginner
92ceb03754SKris Buschelman 
93ceb03754SKris Buschelman    Any additions/changes here MUST also be made in include/finclude/petscmat.h
94ceb03754SKris Buschelman 
95ceb03754SKris Buschelman .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
96ceb03754SKris Buschelman E*/
97ceb03754SKris Buschelman typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
98ceb03754SKris Buschelman 
99dfbe8321SBarry Smith EXTERN PetscErrorCode MatInitializePackage(char *);
100c06d978dSMatthew Knepley 
101c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreate(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
102dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetType(Mat,const MatType);
103dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetFromOptions(Mat);
104dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetUpPreallocation(Mat);
105dfbe8321SBarry Smith EXTERN PetscErrorCode MatRegisterAll(const char[]);
1066849ba73SBarry Smith EXTERN PetscErrorCode MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat));
10730de9b25SBarry Smith 
10830de9b25SBarry Smith /*MC
10930de9b25SBarry Smith    MatRegisterDynamic - Adds a new matrix type
11030de9b25SBarry Smith 
11130de9b25SBarry Smith    Synopsis:
112c1ac3661SBarry Smith    PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat))
11330de9b25SBarry Smith 
11430de9b25SBarry Smith    Not Collective
11530de9b25SBarry Smith 
11630de9b25SBarry Smith    Input Parameters:
11730de9b25SBarry Smith +  name - name of a new user-defined matrix type
11830de9b25SBarry Smith .  path - path (either absolute or relative) the library containing this solver
11930de9b25SBarry Smith .  name_create - name of routine to create method context
12030de9b25SBarry Smith -  routine_create - routine to create method context
12130de9b25SBarry Smith 
12230de9b25SBarry Smith    Notes:
12330de9b25SBarry Smith    MatRegisterDynamic() may be called multiple times to add several user-defined solvers.
12430de9b25SBarry Smith 
12530de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (routine_create)
12630de9b25SBarry Smith    is ignored.
12730de9b25SBarry Smith 
12830de9b25SBarry Smith    Sample usage:
12930de9b25SBarry Smith .vb
13030de9b25SBarry Smith    MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a,
13130de9b25SBarry Smith                "MyMatCreate",MyMatCreate);
13230de9b25SBarry Smith .ve
13330de9b25SBarry Smith 
13430de9b25SBarry Smith    Then, your solver can be chosen with the procedural interface via
13530de9b25SBarry Smith $     MatSetType(Mat,"my_mat")
13630de9b25SBarry Smith    or at runtime via the option
13730de9b25SBarry Smith $     -mat_type my_mat
13830de9b25SBarry Smith 
13930de9b25SBarry Smith    Level: advanced
14030de9b25SBarry Smith 
141ab901514SBarry Smith    Notes: ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
14230de9b25SBarry Smith          If your function is not being put into a shared library then use VecRegister() instead
14330de9b25SBarry Smith 
14430de9b25SBarry Smith .keywords: Mat, register
14530de9b25SBarry Smith 
14630de9b25SBarry Smith .seealso: MatRegisterAll(), MatRegisterDestroy()
14730de9b25SBarry Smith 
14830de9b25SBarry Smith M*/
149273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
150273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
151273d9f13SBarry Smith #else
152273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
15330de9b25SBarry Smith #endif
15430de9b25SBarry Smith 
155273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled;
156b0a32e0cSBarry Smith extern PetscFList MatList;
15728988994SBarry Smith 
158c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*);
159c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*);
160c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
161c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
162c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
163c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
164c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
165c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
166c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
167c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*);
168c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
169c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
170c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*);
171c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*);
172dfbe8321SBarry Smith EXTERN PetscErrorCode MatCreateNormal(Mat,Mat*);
173dfbe8321SBarry Smith EXTERN PetscErrorCode MatDestroy(Mat);
17421c89e3eSBarry Smith 
175dfbe8321SBarry Smith EXTERN PetscErrorCode MatPrintHelp(Mat);
176dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetPetscMaps(Mat,PetscMap*,PetscMap*);
177ec0117caSBarry Smith 
1788ed539a5SBarry Smith /* ------------------------------------------------------------*/
179c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
180c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
18184cb2905SBarry Smith 
1822ef4de8bSBarry Smith /*S
1832ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
1842ef4de8bSBarry Smith         column of a matrix as index on an associated grid.
1852ef4de8bSBarry Smith 
1862ef4de8bSBarry Smith    Level: beginner
1872ef4de8bSBarry Smith 
1882ef4de8bSBarry Smith   Concepts: matrix; linear operator
1892ef4de8bSBarry Smith 
190d7bd93baSBarry Smith .seealso:  MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil()
1912ef4de8bSBarry Smith S*/
192435da068SBarry Smith typedef struct {
193c1ac3661SBarry Smith   PetscInt k,j,i,c;
194435da068SBarry Smith } MatStencil;
1952ef4de8bSBarry Smith 
196c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
197c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
198c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt);
199435da068SBarry Smith 
200dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetColoring(Mat,ISColoring);
201dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetValuesAdic(Mat,void*);
202c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesAdifor(Mat,PetscInt,void*);
2033a7fca6bSBarry Smith 
204d91e6319SBarry Smith /*E
205d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
206d91e6319SBarry Smith      to continue to add values to it
207d91e6319SBarry Smith 
208d91e6319SBarry Smith     Level: beginner
209d91e6319SBarry Smith 
210d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
211d91e6319SBarry Smith E*/
2126d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
213dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssemblyBegin(Mat,MatAssemblyType);
214dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssemblyEnd(Mat,MatAssemblyType);
215dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssembled(Mat,PetscTruth*);
2164f9c727eSBarry Smith 
217c1ac3661SBarry Smith extern PetscInt    MatSetValue_Row, MatSetValue_Column;
2181d73ed98SBarry Smith extern PetscScalar MatSetValue_Value;
2191d73ed98SBarry Smith 
22030de9b25SBarry Smith /*MC
22130de9b25SBarry Smith    MatSetValue - Set a single entry into a matrix.
22230de9b25SBarry Smith 
22330de9b25SBarry Smith    Synopsis:
224c1ac3661SBarry Smith    PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode);
22530de9b25SBarry Smith 
22630de9b25SBarry Smith    Not collective
22730de9b25SBarry Smith 
22830de9b25SBarry Smith    Input Parameters:
22930de9b25SBarry Smith +  m - the matrix
23030de9b25SBarry Smith .  row - the row location of the entry
23130de9b25SBarry Smith .  col - the column location of the entry
23230de9b25SBarry Smith .  value - the value to insert
23330de9b25SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
23430de9b25SBarry Smith 
23530de9b25SBarry Smith    Notes:
23630de9b25SBarry Smith    For efficiency one should use MatSetValues() and set several or many
23730de9b25SBarry Smith    values simultaneously if possible.
23830de9b25SBarry Smith 
23930de9b25SBarry Smith    Level: beginner
24030de9b25SBarry Smith 
24130de9b25SBarry Smith .seealso: MatSetValues(), MatSetValueLocal()
24230de9b25SBarry Smith M*/
243b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
244f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
2451d73ed98SBarry Smith    MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
24630de9b25SBarry Smith 
247ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
248f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,0) || \
2491d73ed98SBarry Smith    MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va))
25030de9b25SBarry Smith 
251d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \
252f1144a30SSatish Balay   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
2531d73ed98SBarry Smith    MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
25430de9b25SBarry Smith 
255d91e6319SBarry Smith /*E
256d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
257d91e6319SBarry Smith 
258d91e6319SBarry Smith     Level: beginner
259d91e6319SBarry Smith 
2600a835dfdSSatish Balay    Any additions/changes here MUST also be made in include/finclude/petscmat.h
261d91e6319SBarry Smith 
262d91e6319SBarry Smith .seealso: MatSetOption()
263d91e6319SBarry Smith E*/
2646d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
2656d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
2666d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
2676ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
2686ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
2696ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
2706ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
2714787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
2727c922b88SBarry Smith               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
2732bad1931SBarry Smith               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
274efcf0fc3SBarry Smith               MAT_DO_NOT_USE_INODES=82,MAT_NOT_SYMMETRIC=83,MAT_HERMITIAN=84,
2759a4540c5SBarry Smith               MAT_NOT_STRUCTURALLY_SYMMETRIC=85,MAT_NOT_HERMITIAN=86,
276d487561eSHong Zhang               MAT_SYMMETRY_ETERNAL=87,MAT_NOT_SYMMETRY_ETERNAL=88,
277*941593c8SHong Zhang               MAT_USE_COMPRESSEDROW=89,MAT_DO_NOT_USE_COMPRESSEDROW=90,
278*941593c8SHong Zhang               MAT_IGNORE_LOWER_TRIANGULAR=91,MAT_ERROR_LOWER_TRIANGULAR=92} MatOption;
279dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetOption(Mat,MatOption);
280dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetType(Mat,MatType*);
28184cb2905SBarry Smith 
282c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]);
283c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
284c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
285ba8c8a56SBarry Smith EXTERN PetscErrorCode MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
286ba8c8a56SBarry Smith EXTERN PetscErrorCode MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
287c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetColumnVector(Mat,Vec,PetscInt);
288dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetArray(Mat,PetscScalar *[]);
289dfbe8321SBarry Smith EXTERN PetscErrorCode MatRestoreArray(Mat,PetscScalar *[]);
290c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetBlockSize(Mat,PetscInt *);
291521d7252SBarry Smith EXTERN PetscErrorCode MatSetBlockSize(Mat,PetscInt);
2927b80b807SBarry Smith 
293dfbe8321SBarry Smith EXTERN PetscErrorCode MatMult(Mat,Vec,Vec);
294dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultAdd(Mat,Vec,Vec,Vec);
295dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTranspose(Mat,Vec,Vec);
296dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*);
297dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTransposeAdd(Mat,Vec,Vec,Vec);
298dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultConstrained(Mat,Vec,Vec);
299dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTransposeConstrained(Mat,Vec,Vec);
3002eac72dbSBarry Smith 
301d91e6319SBarry Smith /*E
302d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
303d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
304d91e6319SBarry Smith 
305d91e6319SBarry Smith     Level: beginner
306d91e6319SBarry Smith 
307d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
308d91e6319SBarry Smith 
309d91e6319SBarry Smith .seealso: MatDuplicate()
310d91e6319SBarry Smith E*/
3112e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
3122e8a6d31SBarry Smith 
313ceb03754SKris Buschelman EXTERN PetscErrorCode MatConvertRegister(const char[],const char[],const char[],PetscErrorCode (*)(Mat,MatType,MatReuse,Mat*));
314273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
315273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
316273d9f13SBarry Smith #else
317273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
318273d9f13SBarry Smith #endif
319dfbe8321SBarry Smith EXTERN PetscErrorCode        MatConvertRegisterAll(const char[]);
320dfbe8321SBarry Smith EXTERN PetscErrorCode        MatConvertRegisterDestroy(void);
321273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled;
322b0a32e0cSBarry Smith extern PetscFList MatConvertList;
323ceb03754SKris Buschelman EXTERN PetscErrorCode        MatConvert(Mat,const MatType,MatReuse,Mat*);
324dfbe8321SBarry Smith EXTERN PetscErrorCode        MatDuplicate(Mat,MatDuplicateOption,Mat*);
32594a9d846SBarry Smith 
326d91e6319SBarry Smith /*E
327d91e6319SBarry Smith     MatStructure - Indicates if the matrix has the same nonzero structure
328d91e6319SBarry Smith 
329d91e6319SBarry Smith     Level: beginner
330d91e6319SBarry Smith 
331d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
332d91e6319SBarry Smith 
33394b7f48cSBarry Smith .seealso: MatCopy(), KSPSetOperators(), PCSetOperators()
334d91e6319SBarry Smith E*/
335c537a176SHong Zhang typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure;
336cb5b572fSBarry Smith 
337dfbe8321SBarry Smith EXTERN PetscErrorCode MatCopy(Mat,Mat,MatStructure);
338dfbe8321SBarry Smith EXTERN PetscErrorCode MatView(Mat,PetscViewer);
339dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsSymmetric(Mat,PetscReal,PetscTruth*);
340781832ceSBarry Smith EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat,PetscTruth*);
3419ede4d1fSHong Zhang EXTERN PetscErrorCode MatIsHermitian(Mat,PetscTruth*);
342dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*);
343e10ebe35SBarry Smith EXTERN PetscErrorCode MatIsHermitianKnown(Mat,PetscTruth*,PetscTruth*);
344dfbe8321SBarry Smith EXTERN PetscErrorCode MatLoad(PetscViewer,const MatType,Mat*);
3457b80b807SBarry Smith 
346c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
347c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
348c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
349c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
350d4fbbf0eSBarry Smith 
351d91e6319SBarry Smith /*S
352d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
353d91e6319SBarry Smith 
354d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
355d91e6319SBarry Smith 
356d91e6319SBarry Smith    Level: intermediate
357d91e6319SBarry Smith 
358d91e6319SBarry Smith   Concepts: matrix^nonzero information
359d91e6319SBarry Smith 
360d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
361d91e6319SBarry Smith S*/
3624e220ebcSLois Curfman McInnes typedef struct {
363b0a32e0cSBarry Smith   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
364b0a32e0cSBarry Smith   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
365b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
366b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
367b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
368b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
369b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
370b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
371b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
3724e220ebcSLois Curfman McInnes } MatInfo;
3734e220ebcSLois Curfman McInnes 
374d9274352SBarry Smith /*E
375d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
376d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
377d9274352SBarry Smith 
378d9274352SBarry Smith     Level: beginner
379d9274352SBarry Smith 
380d9274352SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
381d9274352SBarry Smith 
382d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
383d9274352SBarry Smith E*/
3847b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
385dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetInfo(Mat,MatInfoType,MatInfo*);
386dfbe8321SBarry Smith EXTERN PetscErrorCode MatValid(Mat,PetscTruth*);
387dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetDiagonal(Mat,Vec);
388dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetRowMax(Mat,Vec);
389dfbe8321SBarry Smith EXTERN PetscErrorCode MatTranspose(Mat,Mat*);
390dfbe8321SBarry Smith EXTERN PetscErrorCode MatPermute(Mat,IS,IS,Mat *);
391c1ac3661SBarry Smith EXTERN PetscErrorCode MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *);
392dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalScale(Mat,Vec,Vec);
393dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalSet(Mat,Vec,InsertMode);
394dfbe8321SBarry Smith EXTERN PetscErrorCode MatEqual(Mat,Mat,PetscTruth*);
395237a5486SHong Zhang EXTERN PetscErrorCode MatMultEqual(Mat,Mat,PetscInt,PetscTruth*);
396237a5486SHong Zhang EXTERN PetscErrorCode MatMultAddEqual(Mat,Mat,PetscInt,PetscTruth*);
39763879571SHong Zhang EXTERN PetscErrorCode MatMultTransposeEqual(Mat,Mat,PetscInt,PetscTruth*);
39863879571SHong Zhang EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscTruth*);
3997b80b807SBarry Smith 
400dfbe8321SBarry Smith EXTERN PetscErrorCode MatNorm(Mat,NormType,PetscReal *);
401dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroEntries(Mat);
402dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroRows(Mat,IS,const PetscScalar*);
403dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroColumns(Mat,IS,const PetscScalar*);
4047b80b807SBarry Smith 
405dfbe8321SBarry Smith EXTERN PetscErrorCode MatUseScaledForm(Mat,PetscTruth);
406dfbe8321SBarry Smith EXTERN PetscErrorCode MatScaleSystem(Mat,Vec,Vec);
407dfbe8321SBarry Smith EXTERN PetscErrorCode MatUnScaleSystem(Mat,Vec,Vec);
4085ef9f2a5SBarry Smith 
409c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSize(Mat,PetscInt*,PetscInt*);
410c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetLocalSize(Mat,PetscInt*,PetscInt*);
411c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetOwnershipRange(Mat,PetscInt*,PetscInt*);
4127b80b807SBarry Smith 
413c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
414c1ac3661SBarry Smith EXTERN PetscErrorCode MatDestroyMatrices(PetscInt,Mat *[]);
415c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *);
4160e36024fSHong Zhang EXTERN PetscErrorCode MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*);
4170e36024fSHong Zhang EXTERN PetscErrorCode MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*);
418a61c8c0fSHong Zhang EXTERN PetscErrorCode MatMerge_SeqsToMPISymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*);
419a61c8c0fSHong Zhang EXTERN PetscErrorCode MatMerge_SeqsToMPINumeric(Mat,Mat);
4200febcb4bSHong Zhang EXTERN PetscErrorCode MatDestroy_MPIAIJ_SeqsToMPI(Mat);
42132fba14fSHong Zhang EXTERN PetscErrorCode MatGetLocalMat(Mat,MatReuse,Mat*);
42232fba14fSHong Zhang EXTERN PetscErrorCode MatGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*);
42325616d81SHong Zhang EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*);
424a6b2eed2SHong Zhang EXTERN PetscErrorCode MatGetBrowsOfAoCols(Mat,Mat,MatReuse,PetscInt**,PetscScalar**,Mat*);
4258efafbd8SBarry Smith 
426c1ac3661SBarry Smith EXTERN PetscErrorCode MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt);
4277b80b807SBarry Smith 
428dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
429dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*);
430dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMultNumeric(Mat,Mat,Mat);
43122440eb1SKris Buschelman 
432dfbe8321SBarry Smith EXTERN PetscErrorCode MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*);
43322440eb1SKris Buschelman EXTERN PetscErrorCode MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*);
43422440eb1SKris Buschelman EXTERN PetscErrorCode MatPtAPNumeric(Mat,Mat,Mat);
43522440eb1SKris Buschelman 
436bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*);
437bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*);
438bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTransposeNumeric(Mat,Mat,Mat);
439bc011b1eSHong Zhang 
440dfbe8321SBarry Smith EXTERN PetscErrorCode MatAXPY(const PetscScalar *,Mat,Mat,MatStructure);
441dfbe8321SBarry Smith EXTERN PetscErrorCode MatAYPX(const PetscScalar *,Mat,Mat);
442dfbe8321SBarry Smith EXTERN PetscErrorCode MatCompress(Mat);
4431c741599SHong Zhang 
444dfbe8321SBarry Smith EXTERN PetscErrorCode MatScale(const PetscScalar *,Mat);
445dfbe8321SBarry Smith EXTERN PetscErrorCode MatShift(const PetscScalar *,Mat);
4467b80b807SBarry Smith 
447dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
448dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
449dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroRowsLocal(Mat,IS,const PetscScalar*);
450c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
451c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
452052efed2SBarry Smith 
453c1ac3661SBarry Smith EXTERN PetscErrorCode MatStashSetInitialSize(Mat,PetscInt,PetscInt);
454c1ac3661SBarry Smith EXTERN PetscErrorCode MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
45590f02eecSBarry Smith 
456dfbe8321SBarry Smith EXTERN PetscErrorCode MatInterpolateAdd(Mat,Vec,Vec,Vec);
457dfbe8321SBarry Smith EXTERN PetscErrorCode MatInterpolate(Mat,Vec,Vec);
458dfbe8321SBarry Smith EXTERN PetscErrorCode MatRestrict(Mat,Vec,Vec);
459dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetVecs(Mat,Vec*,Vec*);
460bd481603SBarry Smith 
461bd481603SBarry Smith /*MC
462bd481603SBarry Smith    MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per
463bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
464bd481603SBarry Smith 
465bd481603SBarry Smith    Synopsis:
466c1ac3661SBarry Smith    PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
467bd481603SBarry Smith 
468bd481603SBarry Smith    Collective on MPI_Comm
469bd481603SBarry Smith 
470bd481603SBarry Smith    Input Parameters:
471bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
472859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
473859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
474bd481603SBarry Smith 
475bd481603SBarry Smith    Output Parameters:
476bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
477bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
478bd481603SBarry Smith 
479bd481603SBarry Smith 
480bd481603SBarry Smith    Level: intermediate
481bd481603SBarry Smith 
482bd481603SBarry Smith    Notes:
483bd481603SBarry Smith    See the chapter in the users manual on performance for more details
484bd481603SBarry Smith 
4851d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
486bd481603SBarry Smith 
487bd481603SBarry Smith    Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices)
488bd481603SBarry Smith 
489bd481603SBarry Smith   Concepts: preallocation^Matrix
490bd481603SBarry Smith 
491bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
492bd481603SBarry Smith           MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal()
493bd481603SBarry Smith M*/
494c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
4957c922b88SBarry Smith { \
496c1ac3661SBarry Smith   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
497c1ac3661SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
498c1ac3661SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
499c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
500c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
5017c922b88SBarry Smith 
502bd481603SBarry Smith /*MC
503bd481603SBarry Smith    MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per
504bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
505bd481603SBarry Smith 
506bd481603SBarry Smith    Synopsis:
507c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
508bd481603SBarry Smith 
509bd481603SBarry Smith    Collective on MPI_Comm
510bd481603SBarry Smith 
511bd481603SBarry Smith    Input Parameters:
512bd481603SBarry Smith +  comm - the communicator that will share the eventually allocated matrix
513859fcb39SBarry Smith .  nrows - the number of LOCAL rows in the matrix
514859fcb39SBarry Smith -  ncols - the number of LOCAL columns in the matrix
515bd481603SBarry Smith 
516bd481603SBarry Smith    Output Parameters:
517bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
518bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
519bd481603SBarry Smith 
520bd481603SBarry Smith 
521bd481603SBarry Smith    Level: intermediate
522bd481603SBarry Smith 
523bd481603SBarry Smith    Notes:
524bd481603SBarry Smith    See the chapter in the users manual on performance for more details
525bd481603SBarry Smith 
5261d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
527bd481603SBarry Smith 
528bd481603SBarry Smith   Concepts: preallocation^Matrix
529bd481603SBarry Smith 
530bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
531bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
532bd481603SBarry Smith M*/
533222b16d4SBarry Smith #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \
534222b16d4SBarry Smith { \
535c1ac3661SBarry Smith   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__end; \
536c1ac3661SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
537c1ac3661SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
538c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\
539c1ac3661SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
540222b16d4SBarry Smith 
541bd481603SBarry Smith /*MC
542bd481603SBarry Smith    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
543bd481603SBarry Smith        inserted using a local number of the rows and columns
544bd481603SBarry Smith 
545bd481603SBarry Smith    Synopsis:
546c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
547bd481603SBarry Smith 
548bd481603SBarry Smith    Not Collective
549bd481603SBarry Smith 
550bd481603SBarry Smith    Input Parameters:
551bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
552bd481603SBarry Smith .  nrows - the number of rows indicated
5531d73ed98SBarry Smith .  rows - the indices of the rows
554bd481603SBarry Smith .  ncols - the number of columns in the matrix
555bd481603SBarry Smith .  cols - the columns indicated
556bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
557bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
558bd481603SBarry Smith 
559bd481603SBarry Smith 
560bd481603SBarry Smith    Level: intermediate
561bd481603SBarry Smith 
562bd481603SBarry Smith    Notes:
563bd481603SBarry Smith    See the chapter in the users manual on performance for more details
564bd481603SBarry Smith 
5651d73ed98SBarry Smith    Do not malloc or free dnz and onz, that is handled internally by these routines
566bd481603SBarry Smith 
567bd481603SBarry Smith   Concepts: preallocation^Matrix
568bd481603SBarry Smith 
569bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
570bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
571bd481603SBarry Smith M*/
572c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
573c4f061fbSSatish Balay {\
574c1ac3661SBarry Smith   PetscInt __l;\
575ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
576ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
577c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
578ef66eb69SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
579c4f061fbSSatish Balay   }\
580c4f061fbSSatish Balay }
581c4f061fbSSatish Balay 
582bd481603SBarry Smith /*MC
583bd481603SBarry Smith    MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
584bd481603SBarry Smith        inserted using a local number of the rows and columns
585bd481603SBarry Smith 
586bd481603SBarry Smith    Synopsis:
587c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
588bd481603SBarry Smith 
589bd481603SBarry Smith    Not Collective
590bd481603SBarry Smith 
591bd481603SBarry Smith    Input Parameters:
592bd481603SBarry Smith +  map - the mapping between local numbering and global numbering
593bd481603SBarry Smith .  nrows - the number of rows indicated
5941d73ed98SBarry Smith .  rows - the indices of the rows
595bd481603SBarry Smith .  ncols - the number of columns in the matrix
596bd481603SBarry Smith .  cols - the columns indicated
597bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
598bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
599bd481603SBarry Smith 
600bd481603SBarry Smith 
601bd481603SBarry Smith    Level: intermediate
602bd481603SBarry Smith 
603bd481603SBarry Smith    Notes:
604bd481603SBarry Smith    See the chapter in the users manual on performance for more details
605bd481603SBarry Smith 
606bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
607bd481603SBarry Smith 
608bd481603SBarry Smith   Concepts: preallocation^Matrix
609bd481603SBarry Smith 
610bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
611bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
612bd481603SBarry Smith M*/
613d3d32019SBarry Smith #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
614d3d32019SBarry Smith {\
615c1ac3661SBarry Smith   PetscInt __l;\
616d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
617d3d32019SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
618d3d32019SBarry Smith   for (__l=0;__l<nrows;__l++) {\
619d3d32019SBarry Smith     _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
620d3d32019SBarry Smith   }\
621d3d32019SBarry Smith }
622d3d32019SBarry Smith 
623bd481603SBarry Smith /*MC
624bd481603SBarry Smith    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
625bd481603SBarry Smith        inserted using a local number of the rows and columns
626bd481603SBarry Smith 
627bd481603SBarry Smith    Synopsis:
628c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
629bd481603SBarry Smith 
630bd481603SBarry Smith    Not Collective
631bd481603SBarry Smith 
632bd481603SBarry Smith    Input Parameters:
633bd481603SBarry Smith +  nrows - the number of rows indicated
6341d73ed98SBarry Smith .  rows - the indices of the rows
635bd481603SBarry Smith .  ncols - the number of columns in the matrix
636a50f8bf6SHong Zhang -  cols - the columns indicated
637a50f8bf6SHong Zhang 
638a50f8bf6SHong Zhang    Output Parameters:
639a50f8bf6SHong Zhang +  dnz - the array that will be passed to the matrix preallocation routines
640bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
641bd481603SBarry Smith 
642bd481603SBarry Smith 
643bd481603SBarry Smith    Level: intermediate
644bd481603SBarry Smith 
645bd481603SBarry Smith    Notes:
646bd481603SBarry Smith    See the chapter in the users manual on performance for more details
647bd481603SBarry Smith 
648bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
649bd481603SBarry Smith 
650bd481603SBarry Smith   Concepts: preallocation^Matrix
651bd481603SBarry Smith 
652bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
653bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
654bd481603SBarry Smith M*/
655c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
656c1ac3661SBarry Smith { PetscInt __i; \
6577c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
6587c922b88SBarry Smith     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
6597c922b88SBarry Smith   }\
6607c922b88SBarry Smith   dnz[row - __rstart] = nc - onz[row - __rstart];\
6617c922b88SBarry Smith }
6627c922b88SBarry Smith 
663bd481603SBarry Smith /*MC
664bd481603SBarry Smith    MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
665bd481603SBarry Smith        inserted using a local number of the rows and columns
666bd481603SBarry Smith 
667bd481603SBarry Smith    Synopsis:
668c1ac3661SBarry Smith    PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
669bd481603SBarry Smith 
670bd481603SBarry Smith    Not Collective
671bd481603SBarry Smith 
672bd481603SBarry Smith    Input Parameters:
673bd481603SBarry Smith +  nrows - the number of rows indicated
6741d73ed98SBarry Smith .  rows - the indices of the rows
675bd481603SBarry Smith .  ncols - the number of columns in the matrix
676bd481603SBarry Smith .  cols - the columns indicated
677bd481603SBarry Smith .  dnz - the array that will be passed to the matrix preallocation routines
678bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
679bd481603SBarry Smith 
680bd481603SBarry Smith 
681bd481603SBarry Smith    Level: intermediate
682bd481603SBarry Smith 
683bd481603SBarry Smith    Notes:
684bd481603SBarry Smith    See the chapter in the users manual on performance for more details
685bd481603SBarry Smith 
686bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
687bd481603SBarry Smith 
688bd481603SBarry Smith   Concepts: preallocation^Matrix
689bd481603SBarry Smith 
690bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
691bd481603SBarry Smith           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
692bd481603SBarry Smith M*/
693d3d32019SBarry Smith #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\
694c1ac3661SBarry Smith { PetscInt __i; \
695d3d32019SBarry Smith   for (__i=0; __i<nc; __i++) {\
696d3d32019SBarry Smith     if (cols[__i] >= __end) onz[row - __rstart]++; \
697d3d32019SBarry Smith     else if (cols[__i] >= row) dnz[row - __rstart]++;\
698d3d32019SBarry Smith   }\
699d3d32019SBarry Smith }
700d3d32019SBarry Smith 
701bd481603SBarry Smith /*MC
702bd481603SBarry Smith    MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per
703bd481603SBarry Smith        row in a matrix providing the data that one can use to correctly preallocate the matrix.
704bd481603SBarry Smith 
705bd481603SBarry Smith    Synopsis:
706c1ac3661SBarry Smith    PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz)
707bd481603SBarry Smith 
708bd481603SBarry Smith    Collective on MPI_Comm
709bd481603SBarry Smith 
710bd481603SBarry Smith    Input Parameters:
711bd481603SBarry Smith +  dnz - the array that will be passed to the matrix preallocation routines
712bd481603SBarry Smith -  ozn - the other array passed to the matrix preallocation routines
713bd481603SBarry Smith 
714bd481603SBarry Smith 
715bd481603SBarry Smith    Level: intermediate
716bd481603SBarry Smith 
717bd481603SBarry Smith    Notes:
718bd481603SBarry Smith    See the chapter in the users manual on performance for more details
719bd481603SBarry Smith 
720bd481603SBarry Smith    Do not malloc or free dnz and onz that is handled internally by these routines
721bd481603SBarry Smith 
722bd481603SBarry Smith   Concepts: preallocation^Matrix
723bd481603SBarry Smith 
724bd481603SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
725bd481603SBarry Smith           MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal()
726bd481603SBarry Smith M*/
727ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);}
7287c922b88SBarry Smith 
729bd481603SBarry Smith 
730bd481603SBarry Smith 
7317b80b807SBarry Smith /* Routines unique to particular data structures */
732dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellGetContext(Mat,void **);
733435da068SBarry Smith 
734c1ac3661SBarry Smith EXTERN PetscErrorCode MatBDiagGetData(Mat,PetscInt*,PetscInt*,PetscInt*[],PetscInt*[],PetscScalar***);
735c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat,PetscInt[]);
736c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat,PetscInt[]);
737c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
7387b80b807SBarry Smith 
739c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
740c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
741c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]);
742dfbe8321SBarry Smith EXTERN PetscErrorCode MatSeqDensePreallocation(Mat,PetscScalar[]);
743c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
744dfbe8321SBarry Smith EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat,PetscScalar[]);
745273d9f13SBarry Smith 
746c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
747c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
748c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
749ccd8e176SBarry Smith EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]);
750aac34f13SBarry Smith EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
751dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIDensePreallocation(Mat,PetscScalar[]);
752c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
753c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]);
754dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat,PetscScalar[]);
755c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]);
756c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]);
757c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]);
758dfbe8321SBarry Smith EXTERN PetscErrorCode MatAdicSetLocalFunction(Mat,void (*)(void));
759273d9f13SBarry Smith 
760c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqDenseSetLDA(Mat,PetscInt);
7611b807ce4Svictorle 
762dfbe8321SBarry Smith EXTERN PetscErrorCode MatStoreValues(Mat);
763dfbe8321SBarry Smith EXTERN PetscErrorCode MatRetrieveValues(Mat);
7642e8a6d31SBarry Smith 
765dfbe8321SBarry Smith EXTERN PetscErrorCode MatDAADSetCtx(Mat,void*);
7663a7fca6bSBarry Smith 
7677b80b807SBarry Smith /*
7687b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
76994b7f48cSBarry Smith   done through the KSP and PC interfaces.
7707b80b807SBarry Smith */
7717b80b807SBarry Smith 
772d9274352SBarry Smith /*E
773d9274352SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
774d9274352SBarry Smith        with an optional dynamic library name, for example
775d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
776d9274352SBarry Smith 
777d9274352SBarry Smith    Level: beginner
778d9274352SBarry Smith 
779d9274352SBarry Smith .seealso: MatGetOrdering()
780d9274352SBarry Smith E*/
78149773a63SBarry Smith #define MatOrderingType char*
782b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
783b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
784b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
785b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
786b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
787b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
78862152c8bSBarry Smith #define MATORDERING_DSC_ND    "dsc_nd"
78962152c8bSBarry Smith #define MATORDERING_DSC_MMD   "dsc_mmd"
79062152c8bSBarry Smith #define MATORDERING_DSC_MDF   "dsc_mdf"
791c06d978dSMatthew Knepley #define MATORDERING_CONSTRAINED "constrained"
792c06d978dSMatthew Knepley #define MATORDERING_IDENTITY  "identity"
793c06d978dSMatthew Knepley #define MATORDERING_REVERSE   "reverse"
794b12f92e5SBarry Smith 
795dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetOrdering(Mat,const MatOrderingType,IS*,IS*);
7966849ba73SBarry Smith EXTERN PetscErrorCode MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*));
79730de9b25SBarry Smith 
79830de9b25SBarry Smith /*MC
79930de9b25SBarry Smith    MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the
80030de9b25SBarry Smith                                matrix package.
80130de9b25SBarry Smith 
80230de9b25SBarry Smith    Synopsis:
803c1ac3661SBarry Smith    PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering))
80430de9b25SBarry Smith 
80530de9b25SBarry Smith    Not Collective
80630de9b25SBarry Smith 
80730de9b25SBarry Smith    Input Parameters:
80830de9b25SBarry Smith +  sname - name of ordering (for example MATORDERING_ND)
80930de9b25SBarry Smith .  path - location of library where creation routine is
81030de9b25SBarry Smith .  name - name of function that creates the ordering type,a string
81130de9b25SBarry Smith -  function - function pointer that creates the ordering
81230de9b25SBarry Smith 
81330de9b25SBarry Smith    Level: developer
81430de9b25SBarry Smith 
81530de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
81630de9b25SBarry Smith    is ignored.
81730de9b25SBarry Smith 
81830de9b25SBarry Smith    Sample usage:
81930de9b25SBarry Smith .vb
82030de9b25SBarry Smith    MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a,
82130de9b25SBarry Smith                "MyOrder",MyOrder);
82230de9b25SBarry Smith .ve
82330de9b25SBarry Smith 
82430de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
82530de9b25SBarry Smith $     MatOrderingSetType(part,"my_order)
82630de9b25SBarry Smith    or at runtime via the option
82730de9b25SBarry Smith $     -pc_ilu_mat_ordering_type my_order
82830de9b25SBarry Smith $     -pc_lu_mat_ordering_type my_order
82930de9b25SBarry Smith 
830ab901514SBarry Smith    ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
83130de9b25SBarry Smith 
83230de9b25SBarry Smith .keywords: matrix, ordering, register
83330de9b25SBarry Smith 
83430de9b25SBarry Smith .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll()
83530de9b25SBarry Smith M*/
836aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
837f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
838b12f92e5SBarry Smith #else
839f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
840b12f92e5SBarry Smith #endif
84130de9b25SBarry Smith 
842dfbe8321SBarry Smith EXTERN PetscErrorCode        MatOrderingRegisterDestroy(void);
843dfbe8321SBarry Smith EXTERN PetscErrorCode        MatOrderingRegisterAll(const char[]);
8442bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled;
845b0a32e0cSBarry Smith extern PetscFList MatOrderingList;
846d4fbbf0eSBarry Smith 
847dfbe8321SBarry Smith EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
848a2ce50c7SBarry Smith 
849d91e6319SBarry Smith /*S
85015e8a5b3SHong Zhang    MatFactorInfo - Data based into the matrix factorization routines
851b00f7748SHong Zhang 
85215e8a5b3SHong Zhang    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE
853b00f7748SHong Zhang 
85415e8a5b3SHong Zhang    Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.
855b00f7748SHong Zhang 
856b00f7748SHong Zhang    Level: developer
857b00f7748SHong Zhang 
858d7d82daaSBarry Smith .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(),
859d7d82daaSBarry Smith           MatFactorInfoInitialize()
860b00f7748SHong Zhang 
861b00f7748SHong Zhang S*/
862b00f7748SHong Zhang typedef struct {
8630a29876aSHong Zhang   PetscReal     shiftnz;        /* scaling of identity added to matrix to prevent zero pivots */
8640a29876aSHong Zhang   PetscTruth    shiftpd;         /* if true, shift until positive pivots */
8652cea7109SBarry Smith   PetscReal     shift_fraction; /* record shift fraction taken */
86615e8a5b3SHong Zhang   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
86715e8a5b3SHong Zhang   PetscReal     dt;             /* drop tolerance */
868b00f7748SHong Zhang   PetscReal     dtcol;          /* tolerance for pivoting */
86915e8a5b3SHong Zhang   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
870f6275e2eSBarry Smith   PetscReal     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
871348344bbSBarry Smith   PetscReal     levels;         /* ICC/ILU(levels) */
872bcd9e38bSBarry Smith   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
873bcd9e38bSBarry Smith                                    factorization may be faster if do not pivot */
87415e8a5b3SHong Zhang   PetscReal     zeropivot;      /* pivot is called zero if less than this */
87515e8a5b3SHong Zhang } MatFactorInfo;
876ffa6d0a5SLois Curfman McInnes 
877d7d82daaSBarry Smith EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo*);
878dfbe8321SBarry Smith EXTERN PetscErrorCode MatCholeskyFactor(Mat,IS,MatFactorInfo*);
879dfbe8321SBarry Smith EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
880af281ebdSHong Zhang EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat,MatFactorInfo*,Mat*);
881dfbe8321SBarry Smith EXTERN PetscErrorCode MatLUFactor(Mat,IS,IS,MatFactorInfo*);
882dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUFactor(Mat,IS,IS,MatFactorInfo*);
883dfbe8321SBarry Smith EXTERN PetscErrorCode MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
884dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
885dfbe8321SBarry Smith EXTERN PetscErrorCode MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
886dfbe8321SBarry Smith EXTERN PetscErrorCode MatICCFactor(Mat,IS,MatFactorInfo*);
887af281ebdSHong Zhang EXTERN PetscErrorCode MatLUFactorNumeric(Mat,MatFactorInfo*,Mat*);
888dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *);
889c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*);
890dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolve(Mat,Vec,Vec);
891dfbe8321SBarry Smith EXTERN PetscErrorCode MatForwardSolve(Mat,Vec,Vec);
892dfbe8321SBarry Smith EXTERN PetscErrorCode MatBackwardSolve(Mat,Vec,Vec);
893dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveAdd(Mat,Vec,Vec,Vec);
894dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveTranspose(Mat,Vec,Vec);
895dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
896dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolves(Mat,Vecs,Vecs);
8978ed539a5SBarry Smith 
898dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetUnfactored(Mat);
899bb5a7306SBarry Smith 
900d91e6319SBarry Smith /*E
901d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
902bb1eb677SSatish Balay 
903d91e6319SBarry Smith     Level: beginner
904d91e6319SBarry Smith 
905d9274352SBarry Smith    May be bitwise ORd together
906d9274352SBarry Smith 
907d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
908d91e6319SBarry Smith 
9094e7234bfSBarry Smith    MatSORType may be bitwise ORd together, so do not change the numbers
9104e7234bfSBarry Smith 
911a1d92eedSBarry Smith .seealso: MatRelax(), MatPBRelax()
912d91e6319SBarry Smith E*/
913ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
914ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
915ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
91684cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
917c1ac3661SBarry Smith EXTERN PetscErrorCode MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
918c1ac3661SBarry Smith EXTERN PetscErrorCode MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
9198ed539a5SBarry Smith 
920d4fbbf0eSBarry Smith /*
921639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
922639f9d9dSBarry Smith */
923b12f92e5SBarry Smith 
924d9274352SBarry Smith /*E
925d9274352SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
926d9274352SBarry Smith        with an optional dynamic library name, for example
927d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
928d9274352SBarry Smith 
929d9274352SBarry Smith    Level: beginner
930d9274352SBarry Smith 
931d9274352SBarry Smith .seealso: MatGetColoring()
932d9274352SBarry Smith E*/
93349773a63SBarry Smith #define MatColoringType char*
934b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
935b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
936b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
937b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
938b12f92e5SBarry Smith 
939dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetColoring(Mat,const MatColoringType,ISColoring*);
9406849ba73SBarry Smith EXTERN PetscErrorCode MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatColoringType,ISColoring *));
94130de9b25SBarry Smith 
94230de9b25SBarry Smith /*MC
94330de9b25SBarry Smith    MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the
94430de9b25SBarry Smith                                matrix package.
94530de9b25SBarry Smith 
94630de9b25SBarry Smith    Synopsis:
947c1ac3661SBarry Smith    PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring))
94830de9b25SBarry Smith 
94930de9b25SBarry Smith    Not Collective
95030de9b25SBarry Smith 
95130de9b25SBarry Smith    Input Parameters:
95230de9b25SBarry Smith +  sname - name of Coloring (for example MATCOLORING_SL)
95330de9b25SBarry Smith .  path - location of library where creation routine is
95430de9b25SBarry Smith .  name - name of function that creates the Coloring type, a string
95530de9b25SBarry Smith -  function - function pointer that creates the coloring
95630de9b25SBarry Smith 
95730de9b25SBarry Smith    Level: developer
95830de9b25SBarry Smith 
95930de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
96030de9b25SBarry Smith    is ignored.
96130de9b25SBarry Smith 
96230de9b25SBarry Smith    Sample usage:
96330de9b25SBarry Smith .vb
96430de9b25SBarry Smith    MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a,
96530de9b25SBarry Smith                "MyColor",MyColor);
96630de9b25SBarry Smith .ve
96730de9b25SBarry Smith 
96830de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
96930de9b25SBarry Smith $     MatColoringSetType(part,"my_color")
97030de9b25SBarry Smith    or at runtime via the option
97130de9b25SBarry Smith $     -mat_coloring_type my_color
97230de9b25SBarry Smith 
973ab901514SBarry Smith    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
97430de9b25SBarry Smith 
97530de9b25SBarry Smith .keywords: matrix, Coloring, register
97630de9b25SBarry Smith 
97730de9b25SBarry Smith .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll()
97830de9b25SBarry Smith M*/
979aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
980f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
981b12f92e5SBarry Smith #else
982f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
983b12f92e5SBarry Smith #endif
98430de9b25SBarry Smith 
9852bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled;
986f1144a30SSatish Balay 
987f1144a30SSatish Balay EXTERN PetscErrorCode        MatColoringRegisterAll(const char[]);
988dfbe8321SBarry Smith EXTERN PetscErrorCode        MatColoringRegisterDestroy(void);
989c1ac3661SBarry Smith EXTERN PetscErrorCode        MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*);
990639f9d9dSBarry Smith 
991d9274352SBarry Smith /*S
992d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
993d9274352SBarry Smith         and coloring
994639f9d9dSBarry Smith 
995d9274352SBarry Smith    Level: beginner
996d9274352SBarry Smith 
997d9274352SBarry Smith   Concepts: coloring, sparse Jacobian, finite differences
998d9274352SBarry Smith 
999d9274352SBarry Smith .seealso:  MatFDColoringCreate()
1000d9274352SBarry Smith S*/
1001e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
1002639f9d9dSBarry Smith 
1003dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
1004dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring);
1005dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringView(MatFDColoring,PetscViewer);
10066849ba73SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*);
1007dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
1008c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFrequency(MatFDColoring,PetscInt);
1009c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringGetFrequency(MatFDColoring,PetscInt*);
1010dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring);
1011dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
1012dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
1013dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetRecompute(MatFDColoring);
1014dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring,Vec);
1015c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]);
1016639f9d9dSBarry Smith /*
10170752156aSBarry Smith     These routines are for partitioning matrices: currently used only
10183eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
10190752156aSBarry Smith */
1020ca161407SBarry Smith 
1021d9274352SBarry Smith /*S
1022d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
1023d9274352SBarry Smith 
1024d9274352SBarry Smith    Level: beginner
1025d9274352SBarry Smith 
1026d9274352SBarry Smith   Concepts: partitioning
1027d9274352SBarry Smith 
1028743a1026Svictorle .seealso:  MatPartitioningCreate(), MatPartitioningType
1029d9274352SBarry Smith S*/
103091e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
1031d9274352SBarry Smith 
1032d9274352SBarry Smith /*E
10335bc6e7ccSvictorle     MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function
1034d9274352SBarry Smith        with an optional dynamic library name, for example
1035d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
1036d9274352SBarry Smith 
1037d9274352SBarry Smith    Level: beginner
1038d9274352SBarry Smith 
1039b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning
1040d9274352SBarry Smith E*/
104149773a63SBarry Smith #define MatPartitioningType char*
10428ba1e511SMatthew Knepley #define MAT_PARTITIONING_CURRENT  "current"
1043c2ec2a73SHong Zhang #define MAT_PARTITIONING_SQUARE   "square"
10448ba1e511SMatthew Knepley #define MAT_PARTITIONING_PARMETIS "parmetis"
104571306c60Sjroman #define MAT_PARTITIONING_CHACO    "chaco"
104671306c60Sjroman #define MAT_PARTITIONING_JOSTLE   "jostle"
104771306c60Sjroman #define MAT_PARTITIONING_PARTY    "party"
104871306c60Sjroman #define MAT_PARTITIONING_SCOTCH   "scotch"
104971306c60Sjroman 
1050ca161407SBarry Smith 
1051dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm,MatPartitioning*);
1052dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning,const MatPartitioningType);
1053c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning,PetscInt);
1054dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning,Mat);
1055c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]);
1056dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []);
1057dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning,IS*);
1058dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning);
10592aabb6bbSBarry Smith 
10606849ba73SBarry Smith EXTERN PetscErrorCode MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning));
106130de9b25SBarry Smith 
106230de9b25SBarry Smith /*MC
106330de9b25SBarry Smith    MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the
106430de9b25SBarry Smith    matrix package.
106530de9b25SBarry Smith 
106630de9b25SBarry Smith    Synopsis:
1067c1ac3661SBarry Smith    PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning))
106830de9b25SBarry Smith 
106930de9b25SBarry Smith    Not Collective
107030de9b25SBarry Smith 
107130de9b25SBarry Smith    Input Parameters:
107230de9b25SBarry Smith +  sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis
107330de9b25SBarry Smith .  path - location of library where creation routine is
107430de9b25SBarry Smith .  name - name of function that creates the partitioning type, a string
107530de9b25SBarry Smith -  function - function pointer that creates the partitioning type
107630de9b25SBarry Smith 
107730de9b25SBarry Smith    Level: developer
107830de9b25SBarry Smith 
107930de9b25SBarry Smith    If dynamic libraries are used, then the fourth input argument (function)
108030de9b25SBarry Smith    is ignored.
108130de9b25SBarry Smith 
108230de9b25SBarry Smith    Sample usage:
108330de9b25SBarry Smith .vb
108430de9b25SBarry Smith    MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a,
108530de9b25SBarry Smith                "MyPartCreate",MyPartCreate);
108630de9b25SBarry Smith .ve
108730de9b25SBarry Smith 
108830de9b25SBarry Smith    Then, your partitioner can be chosen with the procedural interface via
108930de9b25SBarry Smith $     MatPartitioningSetType(part,"my_part")
109030de9b25SBarry Smith    or at runtime via the option
109130de9b25SBarry Smith $     -mat_partitioning_type my_part
109230de9b25SBarry Smith 
1093ab901514SBarry Smith    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
109430de9b25SBarry Smith 
109530de9b25SBarry Smith .keywords: matrix, partitioning, register
109630de9b25SBarry Smith 
109730de9b25SBarry Smith .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll()
109830de9b25SBarry Smith M*/
1099aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1100f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
11012aabb6bbSBarry Smith #else
1102f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
11032aabb6bbSBarry Smith #endif
11042aabb6bbSBarry Smith 
11052bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled;
1106f1144a30SSatish Balay 
1107f1144a30SSatish Balay EXTERN PetscErrorCode MatPartitioningRegisterAll(const char[]);
1108dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningRegisterDestroy(void);
11092bad1931SBarry Smith 
1110dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningView(MatPartitioning,PetscViewer);
1111dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning);
1112dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
1113ca161407SBarry Smith 
1114dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
11150752156aSBarry Smith 
1116dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal);
1117dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningJostleSetCoarseSequential(MatPartitioning);
111871306c60Sjroman 
111971306c60Sjroman typedef enum { MP_CHACO_MULTILEVEL_KL, MP_CHACO_SPECTRAL, MP_CHACO_LINEAR,
112071306c60Sjroman     MP_CHACO_RANDOM, MP_CHACO_SCATTERED } MPChacoGlobalType;
1121dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
112271306c60Sjroman typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType;
1123dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1124dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal);
112571306c60Sjroman typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType;
1126dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType);
1127dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1128c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
112971306c60Sjroman 
113071306c60Sjroman #define MP_PARTY_OPT "opt"
113171306c60Sjroman #define MP_PARTY_LIN "lin"
113271306c60Sjroman #define MP_PARTY_SCA "sca"
113371306c60Sjroman #define MP_PARTY_RAN "ran"
113471306c60Sjroman #define MP_PARTY_GBF "gbf"
113571306c60Sjroman #define MP_PARTY_GCF "gcf"
113671306c60Sjroman #define MP_PARTY_BUB "bub"
113771306c60Sjroman #define MP_PARTY_DEF "def"
1138dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char*);
113971306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs"
114071306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl"
114171306c60Sjroman #define MP_PARTY_NONE "no"
1142dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char*);
1143dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal);
1144dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning,PetscTruth);
1145dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth);
114671306c60Sjroman 
114771306c60Sjroman typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType;
1148dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetArch(MatPartitioning,const char*);
1149dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetMultilevel(MatPartitioning);
1150dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType);
1151dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal);
1152dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetHostList(MatPartitioning,const char*);
115371306c60Sjroman typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType;
1154dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType);
1155dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetMapping(MatPartitioning);
1156dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetStrategy(MatPartitioning,char*);
115771306c60Sjroman 
11580752156aSBarry Smith /*
11590a835dfdSSatish Balay     If you add entries here you must also add them to finclude/petscmat.h
1160d4fbbf0eSBarry Smith */
11611c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
11621c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
11631c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
11641c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
11651c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
11667c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
11677c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
11681c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
11691c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
11707c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
11717c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
11721c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
11731c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
11741c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
11751c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
11761c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
11771c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
11781c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
11791c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
11801c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
11811c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
11821c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
11831c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
11841c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
11851c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
11861c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
11871c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
11881c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
11891c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
11901c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
1191d643ce63SMatthew Knepley                MATOP_SETUP_PREALLOCATION=30,
1192d643ce63SMatthew Knepley                MATOP_ILUFACTOR_SYMBOLIC=31,
1193d643ce63SMatthew Knepley                MATOP_ICCFACTOR_SYMBOLIC=32,
1194d643ce63SMatthew Knepley                MATOP_GET_ARRAY=33,
1195d643ce63SMatthew Knepley                MATOP_RESTORE_ARRAY=34,
1196d643ce63SMatthew Knepley                MATOP_DUPLCIATE=35,
1197d643ce63SMatthew Knepley                MATOP_FORWARD_SOLVE=36,
1198d643ce63SMatthew Knepley                MATOP_BACKWARD_SOLVE=37,
1199d643ce63SMatthew Knepley                MATOP_ILUFACTOR=38,
1200d643ce63SMatthew Knepley                MATOP_ICCFACTOR=39,
1201d643ce63SMatthew Knepley                MATOP_AXPY=40,
1202d643ce63SMatthew Knepley                MATOP_GET_SUBMATRICES=41,
1203d643ce63SMatthew Knepley                MATOP_INCREASE_OVERLAP=42,
1204d643ce63SMatthew Knepley                MATOP_GET_VALUES=43,
1205d643ce63SMatthew Knepley                MATOP_COPY=44,
1206d643ce63SMatthew Knepley                MATOP_PRINT_HELP=45,
1207d643ce63SMatthew Knepley                MATOP_SCALE=46,
1208d643ce63SMatthew Knepley                MATOP_SHIFT=47,
1209d643ce63SMatthew Knepley                MATOP_DIAGONAL_SHIFT=48,
1210d643ce63SMatthew Knepley                MATOP_ILUDT_FACTOR=49,
1211d643ce63SMatthew Knepley                MATOP_GET_BLOCK_SIZE=50,
1212d643ce63SMatthew Knepley                MATOP_GET_ROW_IJ=51,
1213d643ce63SMatthew Knepley                MATOP_RESTORE_ROW_IJ=52,
1214d643ce63SMatthew Knepley                MATOP_GET_COLUMN_IJ=53,
1215d643ce63SMatthew Knepley                MATOP_RESTORE_COLUMN_IJ=54,
1216d643ce63SMatthew Knepley                MATOP_FDCOLORING_CREATE=55,
1217d643ce63SMatthew Knepley                MATOP_COLORING_PATCH=56,
1218d643ce63SMatthew Knepley                MATOP_SET_UNFACTORED=57,
1219d643ce63SMatthew Knepley                MATOP_PERMUTE=58,
1220d643ce63SMatthew Knepley                MATOP_SET_VALUES_BLOCKED=59,
1221d643ce63SMatthew Knepley                MATOP_GET_SUBMATRIX=60,
1222d643ce63SMatthew Knepley                MATOP_DESTROY=61,
1223d643ce63SMatthew Knepley                MATOP_VIEW=62,
1224d643ce63SMatthew Knepley                MATOP_GET_MAPS=63,
1225d643ce63SMatthew Knepley                MATOP_USE_SCALED_FORM=64,
1226d643ce63SMatthew Knepley                MATOP_SCALE_SYSTEM=65,
1227d643ce63SMatthew Knepley                MATOP_UNSCALE_SYSTEM=66,
1228ba16a8cbSKris Buschelman                MATOP_SET_LOCAL_TO_GLOBAL_MAP=67,
1229d643ce63SMatthew Knepley                MATOP_SET_VALUES_LOCAL=68,
1230d643ce63SMatthew Knepley                MATOP_ZERO_ROWS_LOCAL=69,
1231d643ce63SMatthew Knepley                MATOP_GET_ROW_MAX=70,
1232d643ce63SMatthew Knepley                MATOP_CONVERT=71,
1233d643ce63SMatthew Knepley                MATOP_SET_COLORING=72,
1234d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIC=73,
1235d643ce63SMatthew Knepley                MATOP_SET_VALUES_ADIFOR=74,
1236d643ce63SMatthew Knepley                MATOP_FD_COLORING_APPLY=75,
1237d643ce63SMatthew Knepley                MATOP_SET_FROM_OPTIONS=76,
1238ba16a8cbSKris Buschelman                MATOP_MULT_CON=77,
1239ba16a8cbSKris Buschelman                MATOP_MULT_TRANSPOSE_CON=78,
1240ba16a8cbSKris Buschelman                MATOP_ILU_FACTOR_SYMBOLIC_CON=79,
1241d643ce63SMatthew Knepley                MATOP_PERMUTE_SPARSIFY=80,
1242d643ce63SMatthew Knepley                MATOP_MULT_MULTIPLE=81,
124341acf15aSKris Buschelman                MATOP_SOLVE_MULTIPLE=82,
124441acf15aSKris Buschelman                MATOP_GET_INERTIA=83,
124541acf15aSKris Buschelman                MATOP_LOAD=84,
124641acf15aSKris Buschelman                MATOP_IS_SYMMETRIC=85,
124741acf15aSKris Buschelman                MATOP_IS_HERMITIAN=86,
124841acf15aSKris Buschelman                MATOP_IS_STRUCTURALLY_SYMMETRIC=87,
124941acf15aSKris Buschelman                MATOP_PB_RELAX=88,
125041acf15aSKris Buschelman                MATOP_GET_VECS=89,
125141acf15aSKris Buschelman                MATOP_MAT_MULT=90,
125241acf15aSKris Buschelman                MATOP_MAT_MULT_SYMBOLIC=91,
125341acf15aSKris Buschelman                MATOP_MAT_MULT_NUMERIC=92,
125441acf15aSKris Buschelman                MATOP_PTAP=93,
125541acf15aSKris Buschelman                MATOP_PTAP_SYMBOLIC=94,
1256bc011b1eSHong Zhang                MATOP_PTAP_NUMERIC=95,
1257bc011b1eSHong Zhang                MATOP_MAT_MULTTRANSPOSE=96,
1258bc011b1eSHong Zhang                MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97,
12597ba1a0bfSKris Buschelman                MATOP_MAT_MULTTRANSPOSE_NUMERIC=98,
12607ba1a0bfSKris Buschelman                MATOP_PTAP_SYMBOLIC_SEQAIJ=99,
12617ba1a0bfSKris Buschelman                MATOP_PTAP_NUMERIC_SEQAIJ=100,
12627ba1a0bfSKris Buschelman                MATOP_PTAP_SYMBOLIC_MPIAIJ=101,
12637ba1a0bfSKris Buschelman                MATOP_PTAP_NUMERIC_MPIAIJ=102
1264fae171e0SBarry Smith              } MatOperation;
1265dfbe8321SBarry Smith EXTERN PetscErrorCode MatHasOperation(Mat,MatOperation,PetscTruth*);
1266dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellSetOperation(Mat,MatOperation,void(*)(void));
1267dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellGetOperation(Mat,MatOperation,void(**)(void));
1268dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellSetContext(Mat,void*);
1269112a2221SBarry Smith 
127090ace30eSBarry Smith /*
127190ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
127290ace30eSBarry Smith  stored in a universal format. By changing the format with
1273fb9695e5SSatish Balay  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
127490ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
127590ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
127690ace30eSBarry Smith  read into matrices of the same time.
127790ace30eSBarry Smith */
127890ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
127990ace30eSBarry Smith 
1280dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
1281c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *);
1282dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIRowbsGetColor(Mat,ISColoring *);
1283860d1616SSatish Balay 
1284dfbe8321SBarry Smith EXTERN PetscErrorCode MatISGetLocalMat(Mat,Mat*);
12851f4e1ec7SBarry Smith 
1286d9274352SBarry Smith /*S
1287d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
1288d9274352SBarry Smith          orthogonalizes the vector to a subsapce
1289d9274352SBarry Smith 
1290f7a9e4ceSBarry Smith    Level: advanced
1291d9274352SBarry Smith 
1292d9274352SBarry Smith   Concepts: matrix; linear operator, null space
1293d9274352SBarry Smith 
12946e1639daSBarry Smith   Users manual sections:
12956e1639daSBarry Smith .   sec_singular
12966e1639daSBarry Smith 
1297d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
1298d9274352SBarry Smith S*/
129974637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
1300d9274352SBarry Smith 
1301c1ac3661SBarry Smith EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*);
1302dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace);
1303dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
1304dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceAttach(Mat,MatNullSpace);
1305dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace,Mat);
130674637425SBarry Smith 
1307dfbe8321SBarry Smith EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat,IS);
1308dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1309c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat,PetscInt *);
1310273d9f13SBarry Smith 
13113f1d51d7SBarry Smith 
1312c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMAIJ(Mat,PetscInt,Mat*);
1313c1ac3661SBarry Smith EXTERN PetscErrorCode MatMAIJRedimension(Mat,PetscInt,Mat*);
1314dfbe8321SBarry Smith EXTERN PetscErrorCode MatMAIJGetAIJ(Mat,Mat*);
1315c4f061fbSSatish Balay 
1316dfbe8321SBarry Smith EXTERN PetscErrorCode MatComputeExplicitOperator(Mat,Mat*);
1317b0a32e0cSBarry Smith 
1318dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat,Vec);
131904f1ad80SBarry Smith 
1320c1ac3661SBarry Smith EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
1321c1ac3661SBarry Smith EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
13227dbadf16SMatthew Knepley 
1323e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
13242eac72dbSBarry Smith #endif
1325