xref: /petsc/include/petscmat.h (revision ef66eb6987ddfdf4e414d6b820cbc8d8d7d17bc2)
1*ef66eb69SBarry Smith /* $Id: petscmat.h,v 1.227 2001/08/07 21:29:29 bsmith Exp bsmith $ */
22eac72dbSBarry Smith /*
32eac72dbSBarry Smith      Include file for the matrix component of PETSc
42eac72dbSBarry Smith */
50a835dfdSSatish Balay #ifndef __PETSCMAT_H
60a835dfdSSatish Balay #define __PETSCMAT_H
70a835dfdSSatish Balay #include "petscvec.h"
82eac72dbSBarry Smith 
99cd28387SBarry Smith #define MAT_COOKIE         PETSC_COOKIE+5
10f0479e8cSBarry Smith 
11d9274352SBarry Smith /*S
12d9274352SBarry Smith      Mat - Abstract PETSc matrix object
132eac72dbSBarry Smith 
14d91e6319SBarry Smith    Level: beginner
15d91e6319SBarry Smith 
16d9274352SBarry Smith   Concepts: matrix; linear operator
17d9274352SBarry Smith 
18d9274352SBarry Smith .seealso:  MatCreate(), MatType, MatSetType()
19d9274352SBarry Smith S*/
20d9274352SBarry Smith typedef struct _p_Mat*           Mat;
21d9274352SBarry Smith 
22d9274352SBarry Smith /*E
23d9274352SBarry Smith     MatType - String with the name of a PETSc matrix or the creation function
24d9274352SBarry Smith        with an optional dynamic library name, for example
25d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:mymatcreate()
26d9274352SBarry Smith 
27d9274352SBarry Smith    Level: beginner
28d9274352SBarry Smith 
29d9274352SBarry Smith .seealso: MatSetType(), Mat
30d91e6319SBarry Smith E*/
31273d9f13SBarry Smith #define MATSAME     "same"
32273d9f13SBarry Smith #define MATSEQMAIJ  "seqmaij"
33273d9f13SBarry Smith #define MATMPIMAIJ  "mpimaij"
34273d9f13SBarry Smith #define MATIS       "is"
35273d9f13SBarry Smith #define MATMPIROWBS "mpirowbs"
36273d9f13SBarry Smith #define MATSEQDENSE "seqdense"
37273d9f13SBarry Smith #define MATSEQAIJ   "seqaij"
38273d9f13SBarry Smith #define MATMPIAIJ   "mpiaij"
39273d9f13SBarry Smith #define MATSHELL    "shell"
40273d9f13SBarry Smith #define MATSEQBDIAG "seqbdiag"
41273d9f13SBarry Smith #define MATMPIBDIAG "mpibdiag"
42273d9f13SBarry Smith #define MATMPIDENSE "mpidense"
43273d9f13SBarry Smith #define MATSEQBAIJ  "seqbaij"
44273d9f13SBarry Smith #define MATMPIBAIJ  "mpibaij"
45273d9f13SBarry Smith #define MATMPIADJ   "mpiadj"
46273d9f13SBarry Smith #define MATSEQSBAIJ "seqsbaij"
47273d9f13SBarry Smith #define MATMPISBAIJ "mpisbaij"
48cebc7f6cSBarry Smith #define MATDAAD     "daad"
49cebc7f6cSBarry Smith #define MATMFFD     "mffd"
50273d9f13SBarry Smith typedef char* MatType;
51d91e6319SBarry Smith 
52273d9f13SBarry Smith EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*);
53273d9f13SBarry Smith EXTERN int MatSetType(Mat,MatType);
54273d9f13SBarry Smith EXTERN int MatSetFromOptions(Mat);
55273d9f13SBarry Smith EXTERN int MatSetUpPreallocation(Mat);
56273d9f13SBarry Smith EXTERN int MatRegisterAll(char*);
57273d9f13SBarry Smith EXTERN int MatRegister(char*,char*,char*,int(*)(Mat));
58273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
59273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
60273d9f13SBarry Smith #else
61273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
62273d9f13SBarry Smith #endif
63273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled;
64b0a32e0cSBarry Smith extern PetscFList MatList;
6528988994SBarry Smith 
66ca44d042SBarry Smith EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*);
6787828ca2SBarry Smith EXTERN int MatCreateSeqDense(MPI_Comm,int,int,PetscScalar*,Mat*);
6887828ca2SBarry Smith EXTERN int MatCreateMPIDense(MPI_Comm,int,int,int,int,PetscScalar*,Mat*);
69ca44d042SBarry Smith EXTERN int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*);
70ca44d042SBarry Smith EXTERN int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
71c4f061fbSSatish Balay EXTERN int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,Mat*);
7287828ca2SBarry Smith EXTERN int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,PetscScalar**,Mat*);
7387828ca2SBarry Smith EXTERN int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,PetscScalar**,Mat*);
74ca44d042SBarry Smith EXTERN int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
75ca44d042SBarry Smith EXTERN int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
76ca44d042SBarry Smith EXTERN int MatCreateMPIAdj(MPI_Comm,int,int,int*,int*,int *,Mat*);
77ca44d042SBarry Smith EXTERN int MatCreateSeqSBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
78ca44d042SBarry Smith EXTERN int MatCreateMPISBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
79ca44d042SBarry Smith EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
803a7fca6bSBarry Smith EXTERN int MatCreateAdic(MPI_Comm,int,int,int,int,int,void (*)(void),Mat*);
81435da068SBarry Smith EXTERN int MatDestroy(Mat);
8221c89e3eSBarry Smith 
83ca44d042SBarry Smith EXTERN int MatPrintHelp(Mat);
848a124369SBarry Smith EXTERN int MatGetPetscMaps(Mat,PetscMap*,PetscMap*);
85ec0117caSBarry Smith 
868ed539a5SBarry Smith /* ------------------------------------------------------------*/
8787828ca2SBarry Smith EXTERN int MatSetValues(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
8887828ca2SBarry Smith EXTERN int MatSetValuesBlocked(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
8984cb2905SBarry Smith 
902ef4de8bSBarry Smith /*S
912ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
922ef4de8bSBarry Smith         column of a matrix as index on an associated grid.
932ef4de8bSBarry Smith 
942ef4de8bSBarry Smith    Level: beginner
952ef4de8bSBarry Smith 
962ef4de8bSBarry Smith   Concepts: matrix; linear operator
972ef4de8bSBarry Smith 
982ef4de8bSBarry Smith .seealso:  MatSetValuesStencil(), MatSetStencil()
992ef4de8bSBarry Smith S*/
100435da068SBarry Smith typedef struct {
101435da068SBarry Smith   int k,j,i,c;
102435da068SBarry Smith } MatStencil;
1032ef4de8bSBarry Smith 
10487828ca2SBarry Smith EXTERN int MatSetValuesStencil(Mat,int,MatStencil*,int,MatStencil*,PetscScalar*,InsertMode);
10587828ca2SBarry Smith EXTERN int MatSetValuesBlockedStencil(Mat,int,MatStencil*,int,MatStencil*,PetscScalar*,InsertMode);
106435da068SBarry Smith EXTERN int MatSetStencil(Mat,int,int*,int*,int);
107435da068SBarry Smith 
1083a7fca6bSBarry Smith EXTERN int MatSetColoring(Mat,ISColoring);
1093a7fca6bSBarry Smith EXTERN int MatSetValuesAdic(Mat,void*);
1103a7fca6bSBarry Smith EXTERN int MatSetValuesAdifor(Mat,int,void*);
1113a7fca6bSBarry Smith 
112d91e6319SBarry Smith /*E
113d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
114d91e6319SBarry Smith      to continue to add values to it
115d91e6319SBarry Smith 
116d91e6319SBarry Smith     Level: beginner
117d91e6319SBarry Smith 
118d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
119d91e6319SBarry Smith E*/
1206d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
121ca44d042SBarry Smith EXTERN int MatAssemblyBegin(Mat,MatAssemblyType);
122ca44d042SBarry Smith EXTERN int MatAssemblyEnd(Mat,MatAssemblyType);
123ca44d042SBarry Smith EXTERN int MatAssembled(Mat,PetscTruth*);
1244f9c727eSBarry Smith 
125b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
126ea709b57SSatish Balay 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \
127b951964fSBarry Smith   _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
128b951964fSBarry Smith }
129ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
130d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; \
131ea06a074SBarry Smith   _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \
132ea06a074SBarry Smith }
133d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \
134ea709b57SSatish Balay 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \
135d91e6319SBarry Smith   _ierr = MatSetValuesLocal(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
136d91e6319SBarry Smith }
137d91e6319SBarry Smith /*E
138d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
139d91e6319SBarry Smith 
140d91e6319SBarry Smith     Level: beginner
141d91e6319SBarry Smith 
1420a835dfdSSatish Balay    Any additions/changes here MUST also be made in include/finclude/petscmat.h
143d91e6319SBarry Smith 
144d91e6319SBarry Smith .seealso: MatSetOption()
145d91e6319SBarry Smith E*/
1466d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
1476d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
1486d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
1496ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
1506ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
1516ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
1526ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
1534787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
1547c922b88SBarry Smith               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
1552bad1931SBarry Smith               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
1568b43beb6SKris Buschelman               MAT_DO_NOT_USE_INODES=82,MAT_USE_SINGLE_PRECISION_SOLVES=83} MatOption;
157ca44d042SBarry Smith EXTERN int MatSetOption(Mat,MatOption);
158273d9f13SBarry Smith EXTERN int MatGetType(Mat,MatType*);
15984cb2905SBarry Smith 
16087828ca2SBarry Smith EXTERN int MatGetValues(Mat,int,int*,int,int*,PetscScalar*);
16187828ca2SBarry Smith EXTERN int MatGetRow(Mat,int,int *,int **,PetscScalar**);
16287828ca2SBarry Smith EXTERN int MatRestoreRow(Mat,int,int *,int **,PetscScalar**);
16387828ca2SBarry Smith EXTERN int MatGetColumn(Mat,int,int *,int **,PetscScalar**);
16487828ca2SBarry Smith EXTERN int MatRestoreColumn(Mat,int,int *,int **,PetscScalar**);
165ca44d042SBarry Smith EXTERN int MatGetColumnVector(Mat,Vec,int);
16687828ca2SBarry Smith EXTERN int MatGetArray(Mat,PetscScalar **);
16787828ca2SBarry Smith EXTERN int MatRestoreArray(Mat,PetscScalar **);
168ca44d042SBarry Smith EXTERN int MatGetBlockSize(Mat,int *);
1697b80b807SBarry Smith 
170ca44d042SBarry Smith EXTERN int MatMult(Mat,Vec,Vec);
171ca44d042SBarry Smith EXTERN int MatMultAdd(Mat,Vec,Vec,Vec);
172ca44d042SBarry Smith EXTERN int MatMultTranspose(Mat,Vec,Vec);
173ca44d042SBarry Smith EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec);
1742eac72dbSBarry Smith 
175d91e6319SBarry Smith /*E
176d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
177d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
178d91e6319SBarry Smith 
179d91e6319SBarry Smith     Level: beginner
180d91e6319SBarry Smith 
181d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
182d91e6319SBarry Smith 
183d91e6319SBarry Smith .seealso: MatDuplicate()
184d91e6319SBarry Smith E*/
1852e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
1862e8a6d31SBarry Smith 
187273d9f13SBarry Smith EXTERN int MatConvertRegister(char*,char*,char*,int (*)(Mat,MatType,Mat*));
188273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
189273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
190273d9f13SBarry Smith #else
191273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
192273d9f13SBarry Smith #endif
193273d9f13SBarry Smith EXTERN int        MatConvertRegisterAll(char*);
194273d9f13SBarry Smith EXTERN int        MatConvertRegisterDestroy(void);
195273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled;
196b0a32e0cSBarry Smith extern PetscFList MatConvertList;
197ca44d042SBarry Smith EXTERN int        MatConvert(Mat,MatType,Mat*);
198ca44d042SBarry Smith EXTERN int        MatDuplicate(Mat,MatDuplicateOption,Mat*);
19994a9d846SBarry Smith 
200d91e6319SBarry Smith /*E
201d91e6319SBarry Smith     MatStructure - Indicates if the matrix has the same nonzero structure
202d91e6319SBarry Smith 
203d91e6319SBarry Smith     Level: beginner
204d91e6319SBarry Smith 
205d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
206d91e6319SBarry Smith 
207d91e6319SBarry Smith .seealso: MatCopy(), SLESSetOperators(), PCSetOperators()
208d91e6319SBarry Smith E*/
209cb5b572fSBarry Smith typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER} MatStructure;
210cb5b572fSBarry Smith 
211ca44d042SBarry Smith EXTERN int MatCopy(Mat,Mat,MatStructure);
212b0a32e0cSBarry Smith EXTERN int MatView(Mat,PetscViewer);
213273d9f13SBarry Smith 
214b0a32e0cSBarry Smith EXTERN int MatLoadRegister(char*,char*,char*,int (*)(PetscViewer,MatType,Mat*));
215273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
216273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,0)
217273d9f13SBarry Smith #else
218273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,d)
219273d9f13SBarry Smith #endif
220273d9f13SBarry Smith EXTERN int        MatLoadRegisterAll(char*);
221273d9f13SBarry Smith EXTERN int        MatLoadRegisterDestroy(void);
222273d9f13SBarry Smith extern PetscTruth MatLoadRegisterAllCalled;
223b0a32e0cSBarry Smith extern PetscFList MatLoadList;
224b0a32e0cSBarry Smith EXTERN int        MatLoad(PetscViewer,MatType,Mat*);
2257b80b807SBarry Smith 
226ca44d042SBarry Smith EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
227ca44d042SBarry Smith EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
228ca44d042SBarry Smith EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
229ca44d042SBarry Smith EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
230d4fbbf0eSBarry Smith 
231d91e6319SBarry Smith /*S
232d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
233d91e6319SBarry Smith 
234d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
235d91e6319SBarry Smith 
236d91e6319SBarry Smith    Level: intermediate
237d91e6319SBarry Smith 
238d91e6319SBarry Smith   Concepts: matrix^nonzero information
239d91e6319SBarry Smith 
240d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
241d91e6319SBarry Smith S*/
2424e220ebcSLois Curfman McInnes typedef struct {
243b0a32e0cSBarry Smith   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
244b0a32e0cSBarry Smith   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
245b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
246b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
247b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
248b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
249b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
250b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
251b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
2524e220ebcSLois Curfman McInnes } MatInfo;
2534e220ebcSLois Curfman McInnes 
254d9274352SBarry Smith /*E
255d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
256d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
257d9274352SBarry Smith 
258d9274352SBarry Smith     Level: beginner
259d9274352SBarry Smith 
260d9274352SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
261d9274352SBarry Smith 
262d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
263d9274352SBarry Smith E*/
2647b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
265ca44d042SBarry Smith EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*);
266ca44d042SBarry Smith EXTERN int MatValid(Mat,PetscTruth*);
267ca44d042SBarry Smith EXTERN int MatGetDiagonal(Mat,Vec);
268273d9f13SBarry Smith EXTERN int MatGetRowMax(Mat,Vec);
269ca44d042SBarry Smith EXTERN int MatTranspose(Mat,Mat*);
270ca44d042SBarry Smith EXTERN int MatPermute(Mat,IS,IS,Mat *);
271ca44d042SBarry Smith EXTERN int MatDiagonalScale(Mat,Vec,Vec);
27206ef90c2SBarry Smith EXTERN int MatDiagonalSet(Mat,Vec,InsertMode);
273ca44d042SBarry Smith EXTERN int MatEqual(Mat,Mat,PetscTruth*);
2747b80b807SBarry Smith 
27587828ca2SBarry Smith EXTERN int MatNorm(Mat,NormType,PetscReal *);
276ca44d042SBarry Smith EXTERN int MatZeroEntries(Mat);
27787828ca2SBarry Smith EXTERN int MatZeroRows(Mat,IS,PetscScalar*);
27887828ca2SBarry Smith EXTERN int MatZeroColumns(Mat,IS,PetscScalar*);
2797b80b807SBarry Smith 
280ca44d042SBarry Smith EXTERN int MatUseScaledForm(Mat,PetscTruth);
281ca44d042SBarry Smith EXTERN int MatScaleSystem(Mat,Vec,Vec);
282ca44d042SBarry Smith EXTERN int MatUnScaleSystem(Mat,Vec,Vec);
2835ef9f2a5SBarry Smith 
284ca44d042SBarry Smith EXTERN int MatGetSize(Mat,int*,int*);
285ca44d042SBarry Smith EXTERN int MatGetLocalSize(Mat,int*,int*);
286ca44d042SBarry Smith EXTERN int MatGetOwnershipRange(Mat,int*,int*);
2877b80b807SBarry Smith 
288d91e6319SBarry Smith /*E
289d91e6319SBarry Smith     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
290d91e6319SBarry Smith      or MatGetSubMatrix() are to be reused to store the new matrix values.
291d91e6319SBarry Smith 
292d91e6319SBarry Smith     Level: beginner
293d91e6319SBarry Smith 
294d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
295d91e6319SBarry Smith 
296d91e6319SBarry Smith .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
297d91e6319SBarry Smith E*/
2987b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
299ca44d042SBarry Smith EXTERN int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **);
300ca44d042SBarry Smith EXTERN int MatDestroyMatrices(int,Mat **);
301ca44d042SBarry Smith EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *);
3028efafbd8SBarry Smith 
303ca44d042SBarry Smith EXTERN int MatIncreaseOverlap(Mat,int,IS *,int);
3047b80b807SBarry Smith 
30587828ca2SBarry Smith EXTERN int MatAXPY(PetscScalar *,Mat,Mat);
30687828ca2SBarry Smith EXTERN int MatAYPX(PetscScalar *,Mat,Mat);
307ca44d042SBarry Smith EXTERN int MatCompress(Mat);
3087b80b807SBarry Smith 
30987828ca2SBarry Smith EXTERN int MatScale(PetscScalar *,Mat);
31087828ca2SBarry Smith EXTERN int MatShift(PetscScalar *,Mat);
311052efed2SBarry Smith 
312ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
313ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
31487828ca2SBarry Smith EXTERN int MatZeroRowsLocal(Mat,IS,PetscScalar*);
31587828ca2SBarry Smith EXTERN int MatSetValuesLocal(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
31687828ca2SBarry Smith EXTERN int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
31790f02eecSBarry Smith 
318ca44d042SBarry Smith EXTERN int MatSetStashInitialSize(Mat,int,int);
319649db694SBarry Smith 
320ca44d042SBarry Smith EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec);
321ca44d042SBarry Smith EXTERN int MatInterpolate(Mat,Vec,Vec);
322ca44d042SBarry Smith EXTERN int MatRestrict(Mat,Vec,Vec);
3237c922b88SBarry Smith 
3247c922b88SBarry Smith /*
325c4f061fbSSatish Balay       These three (or four) macros MUST be used together. The third one closes the open { of the first one
3267c922b88SBarry Smith */
327c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
3287c922b88SBarry Smith { \
329*ef66eb69SBarry Smith   int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
330*ef66eb69SBarry Smith   _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
331*ef66eb69SBarry Smith   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\
332*ef66eb69SBarry Smith   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
333*ef66eb69SBarry Smith   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
3347c922b88SBarry Smith 
335c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
336c4f061fbSSatish Balay {\
337c4f061fbSSatish Balay   int __l;\
338*ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
339*ef66eb69SBarry Smith   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
340c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
341*ef66eb69SBarry Smith     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
342c4f061fbSSatish Balay   }\
343c4f061fbSSatish Balay }
344c4f061fbSSatish Balay 
345c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
3467c922b88SBarry Smith { int __i; \
3477c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
3487c922b88SBarry Smith     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
3497c922b88SBarry Smith   }\
3507c922b88SBarry Smith   dnz[row - __rstart] = nc - onz[row - __rstart];\
3517c922b88SBarry Smith }
3527c922b88SBarry Smith 
353*ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);}
3547c922b88SBarry Smith 
3557b80b807SBarry Smith /* Routines unique to particular data structures */
356435da068SBarry Smith EXTERN int MatShellGetContext(Mat,void **);
357435da068SBarry Smith 
35887828ca2SBarry Smith EXTERN int MatBDiagGetData(Mat,int*,int*,int**,int**,PetscScalar***);
359ca44d042SBarry Smith EXTERN int MatSeqAIJSetColumnIndices(Mat,int *);
360ca44d042SBarry Smith EXTERN int MatSeqBAIJSetColumnIndices(Mat,int *);
36187828ca2SBarry Smith EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int*,int*,PetscScalar *,Mat*);
3627b80b807SBarry Smith 
363273d9f13SBarry Smith EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,int*);
364273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,int*);
365273d9f13SBarry Smith EXTERN int MatSeqAIJSetPreallocation(Mat,int,int*);
36687828ca2SBarry Smith EXTERN int MatSeqDensePreallocation(Mat,PetscScalar*);
36787828ca2SBarry Smith EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,int*,PetscScalar**);
36887828ca2SBarry Smith EXTERN int MatSeqDenseSetPreallocation(Mat,PetscScalar*);
369273d9f13SBarry Smith 
370273d9f13SBarry Smith EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,int*,int,int*);
371273d9f13SBarry Smith EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,int*,int,int*);
372273d9f13SBarry Smith EXTERN int MatMPIAIJSetPreallocation(Mat,int,int*,int,int*);
37387828ca2SBarry Smith EXTERN int MatMPIDensePreallocation(Mat,PetscScalar*);
37487828ca2SBarry Smith EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,int*,PetscScalar**);
375273d9f13SBarry Smith EXTERN int MatMPIAdjSetPreallocation(Mat,int*,int*,int*);
37687828ca2SBarry Smith EXTERN int MatMPIDenseSetPreallocation(Mat,PetscScalar*);
377273d9f13SBarry Smith EXTERN int MatMPIRowbsSetPreallocation(Mat,int,int*);
378435da068SBarry Smith EXTERN int MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,int**);
379435da068SBarry Smith EXTERN int MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,int**);
3803a7fca6bSBarry Smith EXTERN int MatAdicSetLocalFunction(Mat,void (*)(void));
381273d9f13SBarry Smith 
382ca44d042SBarry Smith EXTERN int MatStoreValues(Mat);
383ca44d042SBarry Smith EXTERN int MatRetrieveValues(Mat);
3842e8a6d31SBarry Smith 
3853a7fca6bSBarry Smith EXTERN int MatDAADSetCtx(Mat,void*);
3863a7fca6bSBarry Smith 
3877b80b807SBarry Smith /*
3887b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
3897b80b807SBarry Smith   done through the SLES, KSP and PC interfaces.
3907b80b807SBarry Smith */
3917b80b807SBarry Smith 
392d9274352SBarry Smith /*E
393d9274352SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
394d9274352SBarry Smith        with an optional dynamic library name, for example
395d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
396d9274352SBarry Smith 
397d9274352SBarry Smith    Level: beginner
398d9274352SBarry Smith 
399d9274352SBarry Smith .seealso: MatGetOrdering()
400d9274352SBarry Smith E*/
401b12f92e5SBarry Smith typedef char* MatOrderingType;
402b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
403b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
404b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
405b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
406b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
407b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
40862152c8bSBarry Smith #define MATORDERING_DSC_ND    "dsc_nd"
40962152c8bSBarry Smith #define MATORDERING_DSC_MMD   "dsc_mmd"
41062152c8bSBarry Smith #define MATORDERING_DSC_MDF   "dsc_mdf"
411b12f92e5SBarry Smith 
412ca44d042SBarry Smith EXTERN int MatGetOrdering(Mat,MatOrderingType,IS*,IS*);
413ca44d042SBarry Smith EXTERN int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*));
414aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
415f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
416b12f92e5SBarry Smith #else
417f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
418b12f92e5SBarry Smith #endif
419ca44d042SBarry Smith EXTERN int        MatOrderingRegisterDestroy(void);
420ca44d042SBarry Smith EXTERN int        MatOrderingRegisterAll(char*);
4212bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled;
422b0a32e0cSBarry Smith extern PetscFList      MatOrderingList;
423d4fbbf0eSBarry Smith 
42487828ca2SBarry Smith EXTERN int MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
425a2ce50c7SBarry Smith 
42687828ca2SBarry Smith EXTERN int MatCholeskyFactor(Mat,IS,PetscReal);
42787828ca2SBarry Smith EXTERN int MatCholeskyFactorSymbolic(Mat,IS,PetscReal,Mat*);
428ca44d042SBarry Smith EXTERN int MatCholeskyFactorNumeric(Mat,Mat*);
429a2ce50c7SBarry Smith 
430d91e6319SBarry Smith /*S
431d91e6319SBarry Smith    MatILUInfo - Data based into the matrix ILU factorization routines
4325ef9f2a5SBarry Smith 
433d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_ILUINFO_SIZE
43414822f30SBarry Smith 
435d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of ILU
436d91e6319SBarry Smith           All entries are double precision.
437d91e6319SBarry Smith 
438d91e6319SBarry Smith    Level: developer
439d91e6319SBarry Smith 
440d91e6319SBarry Smith .seealso: MatILUFactorSymbolic(), MatILUFactor(), MatLUInfo, MatCholeskyInfo
441d91e6319SBarry Smith 
442d91e6319SBarry Smith S*/
4435ef9f2a5SBarry Smith typedef struct {
444f6275e2eSBarry Smith   PetscReal     levels;         /* ILU(levels) */
445f6275e2eSBarry Smith   PetscReal     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
446f6275e2eSBarry Smith   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
447f6275e2eSBarry Smith   PetscReal     dt;             /* drop tolerance */
448f6275e2eSBarry Smith   PetscReal     dtcol;          /* tolerance for pivoting */
449f6275e2eSBarry Smith   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
450f6275e2eSBarry Smith   PetscReal     damping;        /* scaling of identity added to matrix to prevent zero pivots */
451f6275e2eSBarry Smith   PetscReal     damp;           /* if is 1.0 and factorization fails, damp until successful */
452f6275e2eSBarry Smith   PetscReal     zeropivot; /* pivot is called zero if less than this */
4535ef9f2a5SBarry Smith } MatILUInfo;
4545ef9f2a5SBarry Smith 
455d91e6319SBarry Smith /*S
456d91e6319SBarry Smith    MatLUInfo - Data based into the matrix LU factorization routines
457d91e6319SBarry Smith 
458d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_LUINFO_SIZE
459d91e6319SBarry Smith 
460d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of LU
461d91e6319SBarry Smith           All entries are double precision.
462d91e6319SBarry Smith 
463d91e6319SBarry Smith    Level: developer
464d91e6319SBarry Smith 
465d91e6319SBarry Smith .seealso: MatLUFactorSymbolic(), MatILUInfo, MatCholeskyInfo
466d91e6319SBarry Smith 
467d91e6319SBarry Smith S*/
46814822f30SBarry Smith typedef struct {
469f6275e2eSBarry Smith   PetscReal     fill;    /* expected fill; nonzeros in factored matrix/nonzeros in original matrix */
470f6275e2eSBarry Smith   PetscReal     dtcol;   /* tolerance for pivoting; pivot if off_diagonal*dtcol > diagonal */
471f6275e2eSBarry Smith   PetscReal     damping; /* scaling of identity added to matrix to prevent zero pivots */
472f6275e2eSBarry Smith   PetscReal     damp;    /* if this is 1.0 and factorization fails, damp until successful */
473f6275e2eSBarry Smith   PetscReal     zeropivot; /* pivot is called zero if less than this */
47414822f30SBarry Smith } MatLUInfo;
47514822f30SBarry Smith 
476d91e6319SBarry Smith /*S
477d91e6319SBarry Smith    MatCholeskyInfo - Data based into the matrix Cholesky factorization routines
478d91e6319SBarry Smith 
479d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_CHOLESKYINFO_SIZE
480d91e6319SBarry Smith 
481d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of Cholesky
482d91e6319SBarry Smith           All entries are double precision.
483d91e6319SBarry Smith 
484d91e6319SBarry Smith    Level: developer
485d91e6319SBarry Smith 
486d91e6319SBarry Smith .seealso: MatCholeskyFactorSymbolic(), MatLUInfo, MatILUInfo
487d91e6319SBarry Smith 
488d91e6319SBarry Smith S*/
489ffa6d0a5SLois Curfman McInnes typedef struct {
490f6275e2eSBarry Smith   PetscReal     fill;    /* expected fill; nonzeros in factored matrix/nonzeros in original matrix */
491f6275e2eSBarry Smith   PetscReal     damping; /* scaling of identity added to matrix to prevent zero pivots */
492f6275e2eSBarry Smith   PetscReal     damp;    /* if this is 1.0 and factorization fails, damp until successful */
493ffa6d0a5SLois Curfman McInnes } MatCholeskyInfo;
494ffa6d0a5SLois Curfman McInnes 
49514822f30SBarry Smith EXTERN int MatLUFactor(Mat,IS,IS,MatLUInfo*);
496ca44d042SBarry Smith EXTERN int MatILUFactor(Mat,IS,IS,MatILUInfo*);
49714822f30SBarry Smith EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatLUInfo*,Mat*);
498ca44d042SBarry Smith EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatILUInfo*,Mat*);
49987828ca2SBarry Smith EXTERN int MatICCFactorSymbolic(Mat,IS,PetscReal,int,Mat*);
50087828ca2SBarry Smith EXTERN int MatICCFactor(Mat,IS,PetscReal,int);
501ca44d042SBarry Smith EXTERN int MatLUFactorNumeric(Mat,Mat*);
502ca44d042SBarry Smith EXTERN int MatILUDTFactor(Mat,MatILUInfo*,IS,IS,Mat *);
503a2ce50c7SBarry Smith 
504ca44d042SBarry Smith EXTERN int MatSolve(Mat,Vec,Vec);
505ca44d042SBarry Smith EXTERN int MatForwardSolve(Mat,Vec,Vec);
506ca44d042SBarry Smith EXTERN int MatBackwardSolve(Mat,Vec,Vec);
507ca44d042SBarry Smith EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec);
508ca44d042SBarry Smith EXTERN int MatSolveTranspose(Mat,Vec,Vec);
509ca44d042SBarry Smith EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
5108ed539a5SBarry Smith 
511ca44d042SBarry Smith EXTERN int MatSetUnfactored(Mat);
512bb5a7306SBarry Smith 
513bb1eb677SSatish Balay /*  MatSORType may be bitwise ORd together, so do not change the numbers */
514d91e6319SBarry Smith /*E
515d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
516bb1eb677SSatish Balay 
517d91e6319SBarry Smith     Level: beginner
518d91e6319SBarry Smith 
519d9274352SBarry Smith    May be bitwise ORd together
520d9274352SBarry Smith 
521d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
522d91e6319SBarry Smith 
523d91e6319SBarry Smith .seealso: MatRelax()
524d91e6319SBarry Smith E*/
525ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
526ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
527ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
52884cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
52987828ca2SBarry Smith EXTERN int MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,int,Vec);
5308ed539a5SBarry Smith 
531d4fbbf0eSBarry Smith /*
532639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
533639f9d9dSBarry Smith */
534b12f92e5SBarry Smith 
535d9274352SBarry Smith /*E
536d9274352SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
537d9274352SBarry Smith        with an optional dynamic library name, for example
538d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
539d9274352SBarry Smith 
540d9274352SBarry Smith    Level: beginner
541d9274352SBarry Smith 
542d9274352SBarry Smith .seealso: MatGetColoring()
543d9274352SBarry Smith E*/
544b12f92e5SBarry Smith typedef char* MatColoringType;
545b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
546b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
547b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
548b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
549b12f92e5SBarry Smith 
550ca44d042SBarry Smith EXTERN int MatGetColoring(Mat,MatColoringType,ISColoring*);
551ca44d042SBarry Smith EXTERN int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *));
552aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
553f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
554b12f92e5SBarry Smith #else
555f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
556b12f92e5SBarry Smith #endif
557ca44d042SBarry Smith EXTERN int        MatColoringRegisterAll(char *);
5582bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled;
559ca44d042SBarry Smith EXTERN int        MatColoringRegisterDestroy(void);
560b9617806SBarry Smith EXTERN int        MatColoringPatch(Mat,int,int,int *,ISColoring*);
561639f9d9dSBarry Smith 
5621a0a18cdSSatish Balay #define MAT_FDCOLORING_COOKIE PETSC_COOKIE + 23
563d9274352SBarry Smith /*S
564d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
565d9274352SBarry Smith         and coloring
566639f9d9dSBarry Smith 
567d9274352SBarry Smith    Level: beginner
568d9274352SBarry Smith 
569d9274352SBarry Smith   Concepts: coloring, sparse Jacobian, finite differences
570d9274352SBarry Smith 
571d9274352SBarry Smith .seealso:  MatFDColoringCreate()
572d9274352SBarry Smith S*/
573e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
574639f9d9dSBarry Smith 
575ca44d042SBarry Smith EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
576ca44d042SBarry Smith EXTERN int MatFDColoringDestroy(MatFDColoring);
577b0a32e0cSBarry Smith EXTERN int MatFDColoringView(MatFDColoring,PetscViewer);
578ca44d042SBarry Smith EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*);
57987828ca2SBarry Smith EXTERN int MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
580ca44d042SBarry Smith EXTERN int MatFDColoringSetFrequency(MatFDColoring,int);
581ca44d042SBarry Smith EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*);
582ca44d042SBarry Smith EXTERN int MatFDColoringSetFromOptions(MatFDColoring);
583ca44d042SBarry Smith EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
58487828ca2SBarry Smith EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
58562152c8bSBarry Smith EXTERN int MatFDColoringSetRecompute(MatFDColoring);
5863a7fca6bSBarry Smith EXTERN int MatFDColoringSetF(MatFDColoring,Vec);
587639f9d9dSBarry Smith 
588639f9d9dSBarry Smith /*
5890752156aSBarry Smith     These routines are for partitioning matrices: currently used only
5903eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
5910752156aSBarry Smith */
59291e9ee9fSBarry Smith #define MATPARTITIONING_COOKIE PETSC_COOKIE + 25
593ca161407SBarry Smith 
594d9274352SBarry Smith /*S
595d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
596d9274352SBarry Smith 
597d9274352SBarry Smith    Level: beginner
598d9274352SBarry Smith 
599d9274352SBarry Smith   Concepts: partitioning
600d9274352SBarry Smith 
601d9274352SBarry Smith .seealso:  MatParitioningCreate(), MatPartitioningType
602d9274352SBarry Smith S*/
60391e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
604d9274352SBarry Smith 
605d9274352SBarry Smith /*E
606d9274352SBarry Smith     MatPartitioningType - String with the name of a PETSc matrix partitioing or the creation function
607d9274352SBarry Smith        with an optional dynamic library name, for example
608d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
609d9274352SBarry Smith 
610d9274352SBarry Smith    Level: beginner
611d9274352SBarry Smith 
612d9274352SBarry Smith .seealso: MatPartitioingCreate(), MatPartitioning
613d9274352SBarry Smith E*/
6142aabb6bbSBarry Smith typedef char* MatPartitioningType;
6152aabb6bbSBarry Smith #define MATPARTITIONING_CURRENT  "current"
6162aabb6bbSBarry Smith #define MATPARTITIONING_PARMETIS "parmetis"
617ca161407SBarry Smith 
618ca44d042SBarry Smith EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*);
619ca44d042SBarry Smith EXTERN int MatPartitioningSetType(MatPartitioning,MatPartitioningType);
620ca44d042SBarry Smith EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat);
621ca44d042SBarry Smith EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,int*);
622ca44d042SBarry Smith EXTERN int MatPartitioningApply(MatPartitioning,IS*);
623ca44d042SBarry Smith EXTERN int MatPartitioningDestroy(MatPartitioning);
6242aabb6bbSBarry Smith 
625ca44d042SBarry Smith EXTERN int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning));
626aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
627f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
6282aabb6bbSBarry Smith #else
629f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
6302aabb6bbSBarry Smith #endif
6312aabb6bbSBarry Smith 
632ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterAll(char *);
6332bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled;
634ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterDestroy(void);
6352bad1931SBarry Smith 
636b0a32e0cSBarry Smith EXTERN int MatPartitioningView(MatPartitioning,PetscViewer);
637ca44d042SBarry Smith EXTERN int MatPartitioningSetFromOptions(MatPartitioning);
638ca44d042SBarry Smith EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
639ca161407SBarry Smith 
640ca44d042SBarry Smith EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
6410752156aSBarry Smith 
6420752156aSBarry Smith /*
6430a835dfdSSatish Balay     If you add entries here you must also add them to finclude/petscmat.h
644d4fbbf0eSBarry Smith */
6451c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
6461c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
6471c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
6481c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
6491c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
6507c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
6517c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
6521c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
6531c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
6547c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
6557c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
6561c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
6571c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
6581c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
6591c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
6601c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
6611c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
6621c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
6631c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
6641c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
6651c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
6661c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
6671c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
6681c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
6691c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
6701c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
6711c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
6721c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
6731c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
6741c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
6751c1c02c0SLois Curfman McInnes                MATOP_GET_SIZE=30,
6761c1c02c0SLois Curfman McInnes                MATOP_GET_LOCAL_SIZE=31,
6771c1c02c0SLois Curfman McInnes                MATOP_GET_OWNERSHIP_RANGE=32,
6781c1c02c0SLois Curfman McInnes                MATOP_ILUFACTOR_SYMBOLIC=33,
6794d101231SSatish Balay                MATOP_ICCFACTOR_SYMBOLIC=34,
6801c1c02c0SLois Curfman McInnes                MATOP_GET_ARRAY=35,
6811c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ARRAY=36,
6827bf97ca4SSatish Balay 
683005c665bSBarry Smith                MATOP_CONVERT_SAME_TYPE=37,
684005c665bSBarry Smith                MATOP_FORWARD_SOLVE=38,
685005c665bSBarry Smith                MATOP_BACKWARD_SOLVE=39,
686005c665bSBarry Smith                MATOP_ILUFACTOR=40,
6874d101231SSatish Balay                MATOP_ICCFACTOR=41,
688005c665bSBarry Smith                MATOP_AXPY=42,
689005c665bSBarry Smith                MATOP_GET_SUBMATRICES=43,
690005c665bSBarry Smith                MATOP_INCREASE_OVERLAP=44,
691005c665bSBarry Smith                MATOP_GET_VALUES=45,
692005c665bSBarry Smith                MATOP_COPY=46,
693005c665bSBarry Smith                MATOP_PRINT_HELP=47,
694005c665bSBarry Smith                MATOP_SCALE=48,
695005c665bSBarry Smith                MATOP_SHIFT=49,
696005c665bSBarry Smith                MATOP_DIAGONAL_SHIFT=50,
697005c665bSBarry Smith                MATOP_ILUDT_FACTOR=51,
698005c665bSBarry Smith                MATOP_GET_BLOCK_SIZE=52,
699005c665bSBarry Smith                MATOP_GET_ROW_IJ=53,
700005c665bSBarry Smith                MATOP_RESTORE_ROW_IJ=54,
701005c665bSBarry Smith                MATOP_GET_COLUMN_IJ=55,
702005c665bSBarry Smith                MATOP_RESTORE_COLUMN_IJ=56,
703005c665bSBarry Smith                MATOP_FDCOLORING_CREATE=57,
704005c665bSBarry Smith                MATOP_COLORING_PATCH=58,
705005c665bSBarry Smith                MATOP_SET_UNFACTORED=59,
706005c665bSBarry Smith                MATOP_PERMUTE=60,
707005c665bSBarry Smith                MATOP_SET_VALUES_BLOCKED=61,
7081c1c02c0SLois Curfman McInnes                MATOP_DESTROY=250,
7091c1c02c0SLois Curfman McInnes                MATOP_VIEW=251
710fae171e0SBarry Smith              } MatOperation;
711ca44d042SBarry Smith EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*);
71237bd1cefSSatish Balay EXTERN int MatShellSetOperation(Mat,MatOperation,void(*)());
71337bd1cefSSatish Balay EXTERN int MatShellGetOperation(Mat,MatOperation,void(**)());
714273d9f13SBarry Smith EXTERN int MatShellSetContext(Mat,void*);
715112a2221SBarry Smith 
71690ace30eSBarry Smith /*
71790ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
71890ace30eSBarry Smith  stored in a universal format. By changing the format with
719fb9695e5SSatish Balay  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
72090ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
72190ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
72290ace30eSBarry Smith  read into matrices of the same time.
72390ace30eSBarry Smith */
72490ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
72590ace30eSBarry Smith 
7263f1d51d7SBarry Smith /*
7273f1d51d7SBarry Smith      New matrix classes not yet distributed
7283f1d51d7SBarry Smith */
7293f1d51d7SBarry Smith /*
7303f1d51d7SBarry Smith     MatAIJIndices is a data structure for storing the nonzero location information
7313f1d51d7SBarry Smith   for sparse matrices. Several matrices with identical nonzero structure can share
7323f1d51d7SBarry Smith   the same MatAIJIndices.
7333f1d51d7SBarry Smith */
734e2a1c21fSSatish Balay typedef struct _p_MatAIJIndices* MatAIJIndices;
7353f1d51d7SBarry Smith 
736ca44d042SBarry Smith EXTERN int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*);
737ca44d042SBarry Smith EXTERN int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*);
738ca44d042SBarry Smith EXTERN int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*);
739ca44d042SBarry Smith EXTERN int MatDestroyAIJIndices(MatAIJIndices);
740ca44d042SBarry Smith EXTERN int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*);
741ca44d042SBarry Smith EXTERN int MatValidateAIJIndices(int,MatAIJIndices);
742ca44d042SBarry Smith EXTERN int MatShiftAIJIndices(MatAIJIndices);
743ca44d042SBarry Smith EXTERN int MatShrinkAIJIndices(MatAIJIndices);
744ca44d042SBarry Smith EXTERN int MatTransposeAIJIndices(MatAIJIndices,MatAIJIndices*);
7453f1d51d7SBarry Smith 
746ca44d042SBarry Smith EXTERN int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*);
747ca44d042SBarry Smith EXTERN int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*);
74887828ca2SBarry Smith EXTERN int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,PetscScalarPrecision,Mat*);
7493f1d51d7SBarry Smith 
750ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *);
751ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *);
75287828ca2SBarry Smith EXTERN int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,PetscScalarPrecision,Mat *);
7533f1d51d7SBarry Smith 
7546d053be9SSatish Balay EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
755ca44d042SBarry Smith EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *);
75608918a0eSSatish Balay EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *);
757860d1616SSatish Balay 
758d9274352SBarry Smith /*S
759d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
760d9274352SBarry Smith          orthogonalizes the vector to a subsapce
761d9274352SBarry Smith 
762d9274352SBarry Smith    Level: beginner
763d9274352SBarry Smith 
764d9274352SBarry Smith   Concepts: matrix; linear operator, null space
765d9274352SBarry Smith 
766d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
767d9274352SBarry Smith S*/
76874637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
769d9274352SBarry Smith 
77074637425SBarry Smith #define MATNULLSPACE_COOKIE    PETSC_COOKIE+17
77174637425SBarry Smith 
77274637425SBarry Smith EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,Vec *,MatNullSpace*);
77374637425SBarry Smith EXTERN int MatNullSpaceDestroy(MatNullSpace);
77474637425SBarry Smith EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
77574637425SBarry Smith EXTERN int MatNullSpaceAttach(Mat,MatNullSpace);
77674637425SBarry Smith EXTERN int MatNullSpaceTest(MatNullSpace,Mat);
77774637425SBarry Smith 
778273d9f13SBarry Smith EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp);
779273d9f13SBarry Smith EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
780273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *);
781273d9f13SBarry Smith 
7823f1d51d7SBarry Smith 
783f069c275SSatish Balay EXTERN int MatCreateMAIJ(Mat,int,Mat*);
784c4f061fbSSatish Balay EXTERN int MatMAIJRedimension(Mat,int,Mat*);
785c4f061fbSSatish Balay EXTERN int MatMAIJGetAIJ(Mat,Mat*);
786c4f061fbSSatish Balay 
787273d9f13SBarry Smith EXTERN int MatMPIAdjSetValues(Mat,int*,int*,int*);
788f069c275SSatish Balay 
789b0a32e0cSBarry Smith EXTERN int MatComputeExplicitOperator(Mat,Mat*);
790b0a32e0cSBarry Smith 
7912eac72dbSBarry Smith #endif
7922eac72dbSBarry Smith 
7932eac72dbSBarry Smith 
7949d00d63dSBarry Smith 
795