xref: /petsc/include/petscmat.h (revision 2ef4de8b5c9d0c49aa48bf36763e1ccf1fcc5252)
1*2ef4de8bSBarry Smith /* $Id: petscmat.h,v 1.215 2001/03/22 20:29:47 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"
48273d9f13SBarry Smith typedef char* MatType;
49d91e6319SBarry Smith 
50273d9f13SBarry Smith EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*);
51273d9f13SBarry Smith EXTERN int MatSetType(Mat,MatType);
52273d9f13SBarry Smith EXTERN int MatSetFromOptions(Mat);
53273d9f13SBarry Smith EXTERN int MatSetUpPreallocation(Mat);
54273d9f13SBarry Smith EXTERN int MatRegisterAll(char*);
55273d9f13SBarry Smith EXTERN int MatRegister(char*,char*,char*,int(*)(Mat));
56273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
57273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
58273d9f13SBarry Smith #else
59273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
60273d9f13SBarry Smith #endif
61273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled;
62b0a32e0cSBarry Smith extern PetscFList MatList;
6328988994SBarry Smith 
64ca44d042SBarry Smith EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*);
65ca44d042SBarry Smith EXTERN int MatCreateSeqDense(MPI_Comm,int,int,Scalar*,Mat*);
66ca44d042SBarry Smith EXTERN int MatCreateMPIDense(MPI_Comm,int,int,int,int,Scalar*,Mat*);
67ca44d042SBarry Smith EXTERN int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*);
68ca44d042SBarry Smith EXTERN int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
69c4f061fbSSatish Balay EXTERN int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,Mat*);
70ca44d042SBarry Smith EXTERN int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,Scalar**,Mat*);
71ca44d042SBarry Smith EXTERN int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,Scalar**,Mat*);
72ca44d042SBarry Smith EXTERN int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
73ca44d042SBarry Smith EXTERN int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
74ca44d042SBarry Smith EXTERN int MatCreateMPIAdj(MPI_Comm,int,int,int*,int*,int *,Mat*);
75ca44d042SBarry Smith EXTERN int MatCreateSeqSBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
76ca44d042SBarry Smith EXTERN int MatCreateMPISBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
77ca44d042SBarry Smith EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
78435da068SBarry Smith EXTERN int MatDestroy(Mat);
7921c89e3eSBarry Smith 
80ca44d042SBarry Smith EXTERN int MatPrintHelp(Mat);
81ca44d042SBarry Smith EXTERN int MatGetMaps(Mat,Map*,Map*);
82ec0117caSBarry Smith 
838ed539a5SBarry Smith /* ------------------------------------------------------------*/
84ca44d042SBarry Smith EXTERN int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
85ca44d042SBarry Smith EXTERN int MatSetValuesBlocked(Mat,int,int*,int,int*,Scalar*,InsertMode);
8684cb2905SBarry Smith 
87*2ef4de8bSBarry Smith /*S
88*2ef4de8bSBarry Smith      MatStencil - Data structure (C struct) for storing information about a single row or
89*2ef4de8bSBarry Smith         column of a matrix as index on an associated grid.
90*2ef4de8bSBarry Smith 
91*2ef4de8bSBarry Smith    Level: beginner
92*2ef4de8bSBarry Smith 
93*2ef4de8bSBarry Smith   Concepts: matrix; linear operator
94*2ef4de8bSBarry Smith 
95*2ef4de8bSBarry Smith .seealso:  MatSetValuesStencil(), MatSetStencil()
96*2ef4de8bSBarry Smith S*/
97435da068SBarry Smith typedef struct {
98435da068SBarry Smith   int k,j,i,c;
99435da068SBarry Smith } MatStencil;
100*2ef4de8bSBarry Smith 
101435da068SBarry Smith EXTERN int MatSetValuesStencil(Mat,int,MatStencil*,int,MatStencil*,Scalar*,InsertMode);
102435da068SBarry Smith EXTERN int MatSetValuesBlockedStencil(Mat,int,MatStencil*,int,MatStencil*,Scalar*,InsertMode);
103435da068SBarry Smith EXTERN int MatSetStencil(Mat,int,int*,int*,int);
104435da068SBarry Smith 
105d91e6319SBarry Smith /*E
106d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
107d91e6319SBarry Smith      to continue to add values to it
108d91e6319SBarry Smith 
109d91e6319SBarry Smith     Level: beginner
110d91e6319SBarry Smith 
111d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
112d91e6319SBarry Smith E*/
1136d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
114ca44d042SBarry Smith EXTERN int MatAssemblyBegin(Mat,MatAssemblyType);
115ca44d042SBarry Smith EXTERN int MatAssemblyEnd(Mat,MatAssemblyType);
116ca44d042SBarry Smith EXTERN int MatAssembled(Mat,PetscTruth*);
1174f9c727eSBarry Smith 
118b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
119d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; Scalar _va = va; \
120b951964fSBarry Smith   _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
121b951964fSBarry Smith }
122ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
123d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; \
124ea06a074SBarry Smith   _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \
125ea06a074SBarry Smith }
126d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \
127d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; Scalar _va = va; \
128d91e6319SBarry Smith   _ierr = MatSetValuesLocal(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
129d91e6319SBarry Smith }
130d91e6319SBarry Smith /*E
131d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
132d91e6319SBarry Smith 
133d91e6319SBarry Smith     Level: beginner
134d91e6319SBarry Smith 
1350a835dfdSSatish Balay    Any additions/changes here MUST also be made in include/finclude/petscmat.h
136d91e6319SBarry Smith 
137d91e6319SBarry Smith .seealso: MatSetOption()
138d91e6319SBarry Smith E*/
1396d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
1406d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
1416d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
1426ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
1436ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
1446ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
1456ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
1464787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
1477c922b88SBarry Smith               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
1482bad1931SBarry Smith               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
149f9d29acdSSatish Balay               MAT_DO_NOT_USE_INODES=82} MatOption;
150ca44d042SBarry Smith EXTERN int MatSetOption(Mat,MatOption);
151273d9f13SBarry Smith EXTERN int MatGetType(Mat,MatType*);
15284cb2905SBarry Smith 
153ca44d042SBarry Smith EXTERN int MatGetValues(Mat,int,int*,int,int*,Scalar*);
154ca44d042SBarry Smith EXTERN int MatGetRow(Mat,int,int *,int **,Scalar**);
155ca44d042SBarry Smith EXTERN int MatRestoreRow(Mat,int,int *,int **,Scalar**);
156ca44d042SBarry Smith EXTERN int MatGetColumn(Mat,int,int *,int **,Scalar**);
157ca44d042SBarry Smith EXTERN int MatRestoreColumn(Mat,int,int *,int **,Scalar**);
158ca44d042SBarry Smith EXTERN int MatGetColumnVector(Mat,Vec,int);
159ca44d042SBarry Smith EXTERN int MatGetArray(Mat,Scalar **);
160ca44d042SBarry Smith EXTERN int MatRestoreArray(Mat,Scalar **);
161ca44d042SBarry Smith EXTERN int MatGetBlockSize(Mat,int *);
1627b80b807SBarry Smith 
163ca44d042SBarry Smith EXTERN int MatMult(Mat,Vec,Vec);
164ca44d042SBarry Smith EXTERN int MatMultAdd(Mat,Vec,Vec,Vec);
165ca44d042SBarry Smith EXTERN int MatMultTranspose(Mat,Vec,Vec);
166ca44d042SBarry Smith EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec);
1672eac72dbSBarry Smith 
168d91e6319SBarry Smith /*E
169d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
170d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
171d91e6319SBarry Smith 
172d91e6319SBarry Smith     Level: beginner
173d91e6319SBarry Smith 
174d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
175d91e6319SBarry Smith 
176d91e6319SBarry Smith .seealso: MatDuplicate()
177d91e6319SBarry Smith E*/
1782e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
1792e8a6d31SBarry Smith 
180273d9f13SBarry Smith EXTERN int MatConvertRegister(char*,char*,char*,int (*)(Mat,MatType,Mat*));
181273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
182273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
183273d9f13SBarry Smith #else
184273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
185273d9f13SBarry Smith #endif
186273d9f13SBarry Smith EXTERN int        MatConvertRegisterAll(char*);
187273d9f13SBarry Smith EXTERN int        MatConvertRegisterDestroy(void);
188273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled;
189b0a32e0cSBarry Smith extern PetscFList MatConvertList;
190ca44d042SBarry Smith EXTERN int        MatConvert(Mat,MatType,Mat*);
191ca44d042SBarry Smith EXTERN int        MatDuplicate(Mat,MatDuplicateOption,Mat*);
19294a9d846SBarry Smith 
193d91e6319SBarry Smith /*E
194d91e6319SBarry Smith     MatStructure - Indicates if the matrix has the same nonzero structure
195d91e6319SBarry Smith 
196d91e6319SBarry Smith     Level: beginner
197d91e6319SBarry Smith 
198d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
199d91e6319SBarry Smith 
200d91e6319SBarry Smith .seealso: MatCopy(), SLESSetOperators(), PCSetOperators()
201d91e6319SBarry Smith E*/
202cb5b572fSBarry Smith typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER} MatStructure;
203cb5b572fSBarry Smith 
204ca44d042SBarry Smith EXTERN int MatCopy(Mat,Mat,MatStructure);
205b0a32e0cSBarry Smith EXTERN int MatView(Mat,PetscViewer);
206273d9f13SBarry Smith 
207b0a32e0cSBarry Smith EXTERN int MatLoadRegister(char*,char*,char*,int (*)(PetscViewer,MatType,Mat*));
208273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
209273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,0)
210273d9f13SBarry Smith #else
211273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,d)
212273d9f13SBarry Smith #endif
213273d9f13SBarry Smith EXTERN int        MatLoadRegisterAll(char*);
214273d9f13SBarry Smith EXTERN int        MatLoadRegisterDestroy(void);
215273d9f13SBarry Smith extern PetscTruth MatLoadRegisterAllCalled;
216b0a32e0cSBarry Smith extern PetscFList MatLoadList;
217b0a32e0cSBarry Smith EXTERN int        MatLoad(PetscViewer,MatType,Mat*);
2187b80b807SBarry Smith 
219ca44d042SBarry Smith EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
220ca44d042SBarry Smith EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
221ca44d042SBarry Smith EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
222ca44d042SBarry Smith EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
223d4fbbf0eSBarry Smith 
224d91e6319SBarry Smith /*S
225d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
226d91e6319SBarry Smith 
227d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
228d91e6319SBarry Smith 
229d91e6319SBarry Smith    Level: intermediate
230d91e6319SBarry Smith 
231d91e6319SBarry Smith   Concepts: matrix^nonzero information
232d91e6319SBarry Smith 
233d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
234d91e6319SBarry Smith S*/
2354e220ebcSLois Curfman McInnes typedef struct {
236b0a32e0cSBarry Smith   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
237b0a32e0cSBarry Smith   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
238b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
239b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
240b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
241b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
242b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
243b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
244b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
2454e220ebcSLois Curfman McInnes } MatInfo;
2464e220ebcSLois Curfman McInnes 
247d9274352SBarry Smith /*E
248d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
249d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
250d9274352SBarry Smith 
251d9274352SBarry Smith     Level: beginner
252d9274352SBarry Smith 
253d9274352SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
254d9274352SBarry Smith 
255d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
256d9274352SBarry Smith E*/
2577b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
258ca44d042SBarry Smith EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*);
259ca44d042SBarry Smith EXTERN int MatValid(Mat,PetscTruth*);
260ca44d042SBarry Smith EXTERN int MatGetDiagonal(Mat,Vec);
261273d9f13SBarry Smith EXTERN int MatGetRowMax(Mat,Vec);
262ca44d042SBarry Smith EXTERN int MatTranspose(Mat,Mat*);
263ca44d042SBarry Smith EXTERN int MatPermute(Mat,IS,IS,Mat *);
264ca44d042SBarry Smith EXTERN int MatDiagonalScale(Mat,Vec,Vec);
26506ef90c2SBarry Smith EXTERN int MatDiagonalSet(Mat,Vec,InsertMode);
266ca44d042SBarry Smith EXTERN int MatEqual(Mat,Mat,PetscTruth*);
2677b80b807SBarry Smith 
268ca44d042SBarry Smith EXTERN int MatNorm(Mat,NormType,double *);
269ca44d042SBarry Smith EXTERN int MatZeroEntries(Mat);
270ca44d042SBarry Smith EXTERN int MatZeroRows(Mat,IS,Scalar*);
271ca44d042SBarry Smith EXTERN int MatZeroColumns(Mat,IS,Scalar*);
2727b80b807SBarry Smith 
273ca44d042SBarry Smith EXTERN int MatUseScaledForm(Mat,PetscTruth);
274ca44d042SBarry Smith EXTERN int MatScaleSystem(Mat,Vec,Vec);
275ca44d042SBarry Smith EXTERN int MatUnScaleSystem(Mat,Vec,Vec);
2765ef9f2a5SBarry Smith 
277ca44d042SBarry Smith EXTERN int MatGetSize(Mat,int*,int*);
278ca44d042SBarry Smith EXTERN int MatGetLocalSize(Mat,int*,int*);
279ca44d042SBarry Smith EXTERN int MatGetOwnershipRange(Mat,int*,int*);
2807b80b807SBarry Smith 
281d91e6319SBarry Smith /*E
282d91e6319SBarry Smith     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
283d91e6319SBarry Smith      or MatGetSubMatrix() are to be reused to store the new matrix values.
284d91e6319SBarry Smith 
285d91e6319SBarry Smith     Level: beginner
286d91e6319SBarry Smith 
287d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
288d91e6319SBarry Smith 
289d91e6319SBarry Smith .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
290d91e6319SBarry Smith E*/
2917b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
292ca44d042SBarry Smith EXTERN int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **);
293ca44d042SBarry Smith EXTERN int MatDestroyMatrices(int,Mat **);
294ca44d042SBarry Smith EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *);
2958efafbd8SBarry Smith 
296ca44d042SBarry Smith EXTERN int MatIncreaseOverlap(Mat,int,IS *,int);
2977b80b807SBarry Smith 
298ca44d042SBarry Smith EXTERN int MatAXPY(Scalar *,Mat,Mat);
299ca44d042SBarry Smith EXTERN int MatAYPX(Scalar *,Mat,Mat);
300ca44d042SBarry Smith EXTERN int MatCompress(Mat);
3017b80b807SBarry Smith 
302ca44d042SBarry Smith EXTERN int MatScale(Scalar *,Mat);
303ca44d042SBarry Smith EXTERN int MatShift(Scalar *,Mat);
304052efed2SBarry Smith 
305ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
306ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
307ca44d042SBarry Smith EXTERN int MatZeroRowsLocal(Mat,IS,Scalar*);
308ca44d042SBarry Smith EXTERN int MatSetValuesLocal(Mat,int,int*,int,int*,Scalar*,InsertMode);
309ca44d042SBarry Smith EXTERN int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,Scalar*,InsertMode);
31090f02eecSBarry Smith 
311ca44d042SBarry Smith EXTERN int MatSetStashInitialSize(Mat,int,int);
312649db694SBarry Smith 
313ca44d042SBarry Smith EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec);
314ca44d042SBarry Smith EXTERN int MatInterpolate(Mat,Vec,Vec);
315ca44d042SBarry Smith EXTERN int MatRestrict(Mat,Vec,Vec);
3167c922b88SBarry Smith 
3177c922b88SBarry Smith /*
318c4f061fbSSatish Balay       These three (or four) macros MUST be used together. The third one closes the open { of the first one
3197c922b88SBarry Smith */
320c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
3217c922b88SBarry Smith { \
3227c922b88SBarry Smith   int __ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
32382502324SSatish Balay   __ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(__ierr);onz = dnz + __tmp;\
3247c922b88SBarry Smith   __ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(__ierr);\
3257c922b88SBarry Smith   __ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(__ierr); __start = __end - __ctmp;\
3267c922b88SBarry Smith   __ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(__ierr); __rstart = __rstart - __tmp;
3277c922b88SBarry Smith 
328c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
329c4f061fbSSatish Balay {\
330c4f061fbSSatish Balay   int __l;\
331c4f061fbSSatish Balay   __ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(__ierr);\
332c4f061fbSSatish Balay   __ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(__ierr);\
333c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
334435da068SBarry Smith     __ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(__ierr);\
335c4f061fbSSatish Balay   }\
336c4f061fbSSatish Balay }
337c4f061fbSSatish Balay 
338c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
3397c922b88SBarry Smith { int __i; \
3407c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
3417c922b88SBarry Smith     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
3427c922b88SBarry Smith   }\
3437c922b88SBarry Smith   dnz[row - __rstart] = nc - onz[row - __rstart];\
3447c922b88SBarry Smith }
3457c922b88SBarry Smith 
346c4f061fbSSatish Balay #define MatPreallocateFinalize(dnz,onz) 0;__ierr = PetscFree(dnz);CHKERRQ(__ierr);}
3477c922b88SBarry Smith 
3487b80b807SBarry Smith /* Routines unique to particular data structures */
349435da068SBarry Smith EXTERN int MatShellGetContext(Mat,void **);
350435da068SBarry Smith 
351ca44d042SBarry Smith EXTERN int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***);
352ca44d042SBarry Smith EXTERN int MatSeqAIJSetColumnIndices(Mat,int *);
353ca44d042SBarry Smith EXTERN int MatSeqBAIJSetColumnIndices(Mat,int *);
354ca44d042SBarry Smith EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int*,int*,Scalar *,Mat*);
3557b80b807SBarry Smith 
356273d9f13SBarry Smith EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,int*);
357273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,int*);
358273d9f13SBarry Smith EXTERN int MatSeqAIJSetPreallocation(Mat,int,int*);
359273d9f13SBarry Smith EXTERN int MatSeqDensePreallocation(Mat,Scalar*);
360273d9f13SBarry Smith EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,int*,Scalar**);
361273d9f13SBarry Smith EXTERN int MatSeqDenseSetPreallocation(Mat,Scalar*);
362273d9f13SBarry Smith 
363273d9f13SBarry Smith EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,int*,int,int*);
364273d9f13SBarry Smith EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,int*,int,int*);
365273d9f13SBarry Smith EXTERN int MatMPIAIJSetPreallocation(Mat,int,int*,int,int*);
366273d9f13SBarry Smith EXTERN int MatMPIDensePreallocation(Mat,Scalar*);
367273d9f13SBarry Smith EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,int*,Scalar**);
368273d9f13SBarry Smith EXTERN int MatMPIAdjSetPreallocation(Mat,int*,int*,int*);
369273d9f13SBarry Smith EXTERN int MatMPIDenseSetPreallocation(Mat,Scalar*);
370273d9f13SBarry Smith EXTERN int MatMPIRowbsSetPreallocation(Mat,int,int*);
371435da068SBarry Smith EXTERN int MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,int**);
372435da068SBarry Smith EXTERN int MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,int**);
373273d9f13SBarry Smith 
374ca44d042SBarry Smith EXTERN int MatStoreValues(Mat);
375ca44d042SBarry Smith EXTERN int MatRetrieveValues(Mat);
3762e8a6d31SBarry Smith 
3777b80b807SBarry Smith /*
3787b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
3797b80b807SBarry Smith   done through the SLES, KSP and PC interfaces.
3807b80b807SBarry Smith */
3817b80b807SBarry Smith 
382d9274352SBarry Smith /*E
383d9274352SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
384d9274352SBarry Smith        with an optional dynamic library name, for example
385d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
386d9274352SBarry Smith 
387d9274352SBarry Smith    Level: beginner
388d9274352SBarry Smith 
389d9274352SBarry Smith .seealso: MatGetOrdering()
390d9274352SBarry Smith E*/
391b12f92e5SBarry Smith typedef char* MatOrderingType;
392b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
393b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
394b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
395b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
396b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
397b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
39862152c8bSBarry Smith #define MATORDERING_DSC_ND    "dsc_nd"
39962152c8bSBarry Smith #define MATORDERING_DSC_MMD   "dsc_mmd"
40062152c8bSBarry Smith #define MATORDERING_DSC_MDF   "dsc_mdf"
401b12f92e5SBarry Smith 
402ca44d042SBarry Smith EXTERN int MatGetOrdering(Mat,MatOrderingType,IS*,IS*);
403ca44d042SBarry Smith EXTERN int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*));
404aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
405f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
406b12f92e5SBarry Smith #else
407f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
408b12f92e5SBarry Smith #endif
409ca44d042SBarry Smith EXTERN int        MatOrderingRegisterDestroy(void);
410ca44d042SBarry Smith EXTERN int        MatOrderingRegisterAll(char*);
4112bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled;
412b0a32e0cSBarry Smith extern PetscFList      MatOrderingList;
413d4fbbf0eSBarry Smith 
414ca44d042SBarry Smith EXTERN int MatReorderForNonzeroDiagonal(Mat,double,IS,IS);
415a2ce50c7SBarry Smith 
416ca44d042SBarry Smith EXTERN int MatCholeskyFactor(Mat,IS,double);
417ca44d042SBarry Smith EXTERN int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*);
418ca44d042SBarry Smith EXTERN int MatCholeskyFactorNumeric(Mat,Mat*);
419a2ce50c7SBarry Smith 
420d91e6319SBarry Smith /*S
421d91e6319SBarry Smith    MatILUInfo - Data based into the matrix ILU factorization routines
4225ef9f2a5SBarry Smith 
423d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_ILUINFO_SIZE
42414822f30SBarry Smith 
425d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of ILU
426d91e6319SBarry Smith           All entries are double precision.
427d91e6319SBarry Smith 
428d91e6319SBarry Smith    Level: developer
429d91e6319SBarry Smith 
430d91e6319SBarry Smith .seealso: MatILUFactorSymbolic(), MatILUFactor(), MatLUInfo, MatCholeskyInfo
431d91e6319SBarry Smith 
432d91e6319SBarry Smith S*/
4335ef9f2a5SBarry Smith typedef struct {
4345ef9f2a5SBarry Smith   double     levels;         /* ILU(levels) */
4355ef9f2a5SBarry Smith   double     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
4365ef9f2a5SBarry Smith   double     diagonal_fill;  /* force diagonal to fill in if initially not filled */
43736db0b34SBarry Smith   double     dt;             /* drop tolerance */
43836db0b34SBarry Smith   double     dtcol;          /* tolerance for pivoting */
43936db0b34SBarry Smith   double     dtcount;        /* maximum nonzeros to be allowed per row */
440d91e6319SBarry Smith   double     damping;        /* scaling of identity added to matrix to prevent zero pivots */
441d91e6319SBarry Smith   double     damp;           /* if is 1.0 and factorization fails, damp until successful */
4425ef9f2a5SBarry Smith } MatILUInfo;
4435ef9f2a5SBarry Smith 
444d91e6319SBarry Smith /*S
445d91e6319SBarry Smith    MatLUInfo - Data based into the matrix LU factorization routines
446d91e6319SBarry Smith 
447d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_LUINFO_SIZE
448d91e6319SBarry Smith 
449d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of LU
450d91e6319SBarry Smith           All entries are double precision.
451d91e6319SBarry Smith 
452d91e6319SBarry Smith    Level: developer
453d91e6319SBarry Smith 
454d91e6319SBarry Smith .seealso: MatLUFactorSymbolic(), MatILUInfo, MatCholeskyInfo
455d91e6319SBarry Smith 
456d91e6319SBarry Smith S*/
45714822f30SBarry Smith typedef struct {
45814822f30SBarry Smith   double     fill;    /* expected fill; nonzeros in factored matrix/nonzeros in original matrix */
45914822f30SBarry Smith   double     dtcol;   /* tolerance for pivoting; pivot if off_diagonal*dtcol > diagonal */
460d91e6319SBarry Smith   double     damping; /* scaling of identity added to matrix to prevent zero pivots */
461d91e6319SBarry Smith   double     damp;    /* if this is 1.0 and factorization fails, damp until successful */
46214822f30SBarry Smith } MatLUInfo;
46314822f30SBarry Smith 
464d91e6319SBarry Smith /*S
465d91e6319SBarry Smith    MatCholeskyInfo - Data based into the matrix Cholesky factorization routines
466d91e6319SBarry Smith 
467d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_CHOLESKYINFO_SIZE
468d91e6319SBarry Smith 
469d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of Cholesky
470d91e6319SBarry Smith           All entries are double precision.
471d91e6319SBarry Smith 
472d91e6319SBarry Smith    Level: developer
473d91e6319SBarry Smith 
474d91e6319SBarry Smith .seealso: MatCholeskyFactorSymbolic(), MatLUInfo, MatILUInfo
475d91e6319SBarry Smith 
476d91e6319SBarry Smith S*/
477ffa6d0a5SLois Curfman McInnes typedef struct {
478ffa6d0a5SLois Curfman McInnes   double     fill;    /* expected fill; nonzeros in factored matrix/nonzeros in original matrix */
479d91e6319SBarry Smith   double     damping; /* scaling of identity added to matrix to prevent zero pivots */
480d91e6319SBarry Smith   double     damp;    /* if this is 1.0 and factorization fails, damp until successful */
481ffa6d0a5SLois Curfman McInnes } MatCholeskyInfo;
482ffa6d0a5SLois Curfman McInnes 
48314822f30SBarry Smith EXTERN int MatLUFactor(Mat,IS,IS,MatLUInfo*);
484ca44d042SBarry Smith EXTERN int MatILUFactor(Mat,IS,IS,MatILUInfo*);
48514822f30SBarry Smith EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatLUInfo*,Mat*);
486ca44d042SBarry Smith EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatILUInfo*,Mat*);
487ca44d042SBarry Smith EXTERN int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*);
48874637425SBarry Smith EXTERN int MatIncompleteCholeskyFactor(Mat,IS,double,int);
489ca44d042SBarry Smith EXTERN int MatLUFactorNumeric(Mat,Mat*);
490ca44d042SBarry Smith EXTERN int MatILUDTFactor(Mat,MatILUInfo*,IS,IS,Mat *);
491a2ce50c7SBarry Smith 
492ca44d042SBarry Smith EXTERN int MatSolve(Mat,Vec,Vec);
493ca44d042SBarry Smith EXTERN int MatForwardSolve(Mat,Vec,Vec);
494ca44d042SBarry Smith EXTERN int MatBackwardSolve(Mat,Vec,Vec);
495ca44d042SBarry Smith EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec);
496ca44d042SBarry Smith EXTERN int MatSolveTranspose(Mat,Vec,Vec);
497ca44d042SBarry Smith EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
4988ed539a5SBarry Smith 
499ca44d042SBarry Smith EXTERN int MatSetUnfactored(Mat);
500bb5a7306SBarry Smith 
501bb1eb677SSatish Balay /*  MatSORType may be bitwise ORd together, so do not change the numbers */
502d91e6319SBarry Smith /*E
503d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
504bb1eb677SSatish Balay 
505d91e6319SBarry Smith     Level: beginner
506d91e6319SBarry Smith 
507d9274352SBarry Smith    May be bitwise ORd together
508d9274352SBarry Smith 
509d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
510d91e6319SBarry Smith 
511d91e6319SBarry Smith .seealso: MatRelax()
512d91e6319SBarry Smith E*/
513ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
514ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
515ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
51684cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
517ca44d042SBarry Smith EXTERN int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
5188ed539a5SBarry Smith 
519d4fbbf0eSBarry Smith /*
520639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
521639f9d9dSBarry Smith */
522b12f92e5SBarry Smith 
523d9274352SBarry Smith /*E
524d9274352SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
525d9274352SBarry Smith        with an optional dynamic library name, for example
526d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
527d9274352SBarry Smith 
528d9274352SBarry Smith    Level: beginner
529d9274352SBarry Smith 
530d9274352SBarry Smith .seealso: MatGetColoring()
531d9274352SBarry Smith E*/
532b12f92e5SBarry Smith typedef char* MatColoringType;
533b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
534b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
535b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
536b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
537b12f92e5SBarry Smith 
538ca44d042SBarry Smith EXTERN int MatGetColoring(Mat,MatColoringType,ISColoring*);
539ca44d042SBarry Smith EXTERN int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *));
540aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
541f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
542b12f92e5SBarry Smith #else
543f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
544b12f92e5SBarry Smith #endif
545ca44d042SBarry Smith EXTERN int        MatColoringRegisterAll(char *);
5462bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled;
547ca44d042SBarry Smith EXTERN int        MatColoringRegisterDestroy(void);
548ca44d042SBarry Smith EXTERN int        MatColoringPatch(Mat,int,int *,ISColoring*);
549639f9d9dSBarry Smith 
5501a0a18cdSSatish Balay #define MAT_FDCOLORING_COOKIE PETSC_COOKIE + 23
551d9274352SBarry Smith /*S
552d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
553d9274352SBarry Smith         and coloring
554639f9d9dSBarry Smith 
555d9274352SBarry Smith    Level: beginner
556d9274352SBarry Smith 
557d9274352SBarry Smith   Concepts: coloring, sparse Jacobian, finite differences
558d9274352SBarry Smith 
559d9274352SBarry Smith .seealso:  MatFDColoringCreate()
560d9274352SBarry Smith S*/
561e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
562639f9d9dSBarry Smith 
563ca44d042SBarry Smith EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
564ca44d042SBarry Smith EXTERN int MatFDColoringDestroy(MatFDColoring);
565b0a32e0cSBarry Smith EXTERN int MatFDColoringView(MatFDColoring,PetscViewer);
566ca44d042SBarry Smith EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*);
567ca44d042SBarry Smith EXTERN int MatFDColoringSetParameters(MatFDColoring,double,double);
568ca44d042SBarry Smith EXTERN int MatFDColoringSetFrequency(MatFDColoring,int);
569ca44d042SBarry Smith EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*);
570ca44d042SBarry Smith EXTERN int MatFDColoringSetFromOptions(MatFDColoring);
571ca44d042SBarry Smith EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
572ca44d042SBarry Smith EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,double,Vec,MatStructure*,void *);
57362152c8bSBarry Smith EXTERN int MatFDColoringSetRecompute(MatFDColoring);
574639f9d9dSBarry Smith 
575639f9d9dSBarry Smith /*
5760752156aSBarry Smith     These routines are for partitioning matrices: currently used only
5773eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
5780752156aSBarry Smith */
57991e9ee9fSBarry Smith #define MATPARTITIONING_COOKIE PETSC_COOKIE + 25
580ca161407SBarry Smith 
581d9274352SBarry Smith /*S
582d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
583d9274352SBarry Smith 
584d9274352SBarry Smith    Level: beginner
585d9274352SBarry Smith 
586d9274352SBarry Smith   Concepts: partitioning
587d9274352SBarry Smith 
588d9274352SBarry Smith .seealso:  MatParitioningCreate(), MatPartitioningType
589d9274352SBarry Smith S*/
59091e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
591d9274352SBarry Smith 
592d9274352SBarry Smith /*E
593d9274352SBarry Smith     MatPartitioningType - String with the name of a PETSc matrix partitioing or the creation function
594d9274352SBarry Smith        with an optional dynamic library name, for example
595d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
596d9274352SBarry Smith 
597d9274352SBarry Smith    Level: beginner
598d9274352SBarry Smith 
599d9274352SBarry Smith .seealso: MatPartitioingCreate(), MatPartitioning
600d9274352SBarry Smith E*/
6012aabb6bbSBarry Smith typedef char* MatPartitioningType;
6022aabb6bbSBarry Smith #define MATPARTITIONING_CURRENT  "current"
6032aabb6bbSBarry Smith #define MATPARTITIONING_PARMETIS "parmetis"
604ca161407SBarry Smith 
605ca44d042SBarry Smith EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*);
606ca44d042SBarry Smith EXTERN int MatPartitioningSetType(MatPartitioning,MatPartitioningType);
607ca44d042SBarry Smith EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat);
608ca44d042SBarry Smith EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,int*);
609ca44d042SBarry Smith EXTERN int MatPartitioningApply(MatPartitioning,IS*);
610ca44d042SBarry Smith EXTERN int MatPartitioningDestroy(MatPartitioning);
6112aabb6bbSBarry Smith 
612ca44d042SBarry Smith EXTERN int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning));
613aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
614f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
6152aabb6bbSBarry Smith #else
616f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
6172aabb6bbSBarry Smith #endif
6182aabb6bbSBarry Smith 
619ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterAll(char *);
6202bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled;
621ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterDestroy(void);
6222bad1931SBarry Smith 
623b0a32e0cSBarry Smith EXTERN int MatPartitioningView(MatPartitioning,PetscViewer);
624ca44d042SBarry Smith EXTERN int MatPartitioningSetFromOptions(MatPartitioning);
625ca44d042SBarry Smith EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
626ca161407SBarry Smith 
627ca44d042SBarry Smith EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
6280752156aSBarry Smith 
6290752156aSBarry Smith /*
6300a835dfdSSatish Balay     If you add entries here you must also add them to finclude/petscmat.h
631d4fbbf0eSBarry Smith */
6321c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
6331c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
6341c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
6351c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
6361c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
6377c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
6387c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
6391c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
6401c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
6417c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
6427c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
6431c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
6441c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
6451c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
6461c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
6471c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
6481c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
6491c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
6501c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
6511c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
6521c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
6531c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
6541c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
6551c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
6561c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
6571c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
6581c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
6591c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
6601c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
6611c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
6621c1c02c0SLois Curfman McInnes                MATOP_GET_SIZE=30,
6631c1c02c0SLois Curfman McInnes                MATOP_GET_LOCAL_SIZE=31,
6641c1c02c0SLois Curfman McInnes                MATOP_GET_OWNERSHIP_RANGE=32,
6651c1c02c0SLois Curfman McInnes                MATOP_ILUFACTOR_SYMBOLIC=33,
6661c1c02c0SLois Curfman McInnes                MATOP_INCOMPLETECHOLESKYFACTOR_SYMBOLIC=34,
6671c1c02c0SLois Curfman McInnes                MATOP_GET_ARRAY=35,
6681c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ARRAY=36,
6697bf97ca4SSatish Balay 
670005c665bSBarry Smith                MATOP_CONVERT_SAME_TYPE=37,
671005c665bSBarry Smith                MATOP_FORWARD_SOLVE=38,
672005c665bSBarry Smith                MATOP_BACKWARD_SOLVE=39,
673005c665bSBarry Smith                MATOP_ILUFACTOR=40,
674005c665bSBarry Smith                MATOP_INCOMPLETECHOLESKYFACTOR=41,
675005c665bSBarry Smith                MATOP_AXPY=42,
676005c665bSBarry Smith                MATOP_GET_SUBMATRICES=43,
677005c665bSBarry Smith                MATOP_INCREASE_OVERLAP=44,
678005c665bSBarry Smith                MATOP_GET_VALUES=45,
679005c665bSBarry Smith                MATOP_COPY=46,
680005c665bSBarry Smith                MATOP_PRINT_HELP=47,
681005c665bSBarry Smith                MATOP_SCALE=48,
682005c665bSBarry Smith                MATOP_SHIFT=49,
683005c665bSBarry Smith                MATOP_DIAGONAL_SHIFT=50,
684005c665bSBarry Smith                MATOP_ILUDT_FACTOR=51,
685005c665bSBarry Smith                MATOP_GET_BLOCK_SIZE=52,
686005c665bSBarry Smith                MATOP_GET_ROW_IJ=53,
687005c665bSBarry Smith                MATOP_RESTORE_ROW_IJ=54,
688005c665bSBarry Smith                MATOP_GET_COLUMN_IJ=55,
689005c665bSBarry Smith                MATOP_RESTORE_COLUMN_IJ=56,
690005c665bSBarry Smith                MATOP_FDCOLORING_CREATE=57,
691005c665bSBarry Smith                MATOP_COLORING_PATCH=58,
692005c665bSBarry Smith                MATOP_SET_UNFACTORED=59,
693005c665bSBarry Smith                MATOP_PERMUTE=60,
694005c665bSBarry Smith                MATOP_SET_VALUES_BLOCKED=61,
6951c1c02c0SLois Curfman McInnes                MATOP_DESTROY=250,
6961c1c02c0SLois Curfman McInnes                MATOP_VIEW=251
697fae171e0SBarry Smith              } MatOperation;
698ca44d042SBarry Smith EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*);
699ca44d042SBarry Smith EXTERN int MatShellSetOperation(Mat,MatOperation,void *);
700ca44d042SBarry Smith EXTERN int MatShellGetOperation(Mat,MatOperation,void **);
701273d9f13SBarry Smith EXTERN int MatShellSetContext(Mat,void*);
702112a2221SBarry Smith 
70390ace30eSBarry Smith /*
70490ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
70590ace30eSBarry Smith  stored in a universal format. By changing the format with
706fb9695e5SSatish Balay  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
70790ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
70890ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
70990ace30eSBarry Smith  read into matrices of the same time.
71090ace30eSBarry Smith */
71190ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
71290ace30eSBarry Smith 
7133f1d51d7SBarry Smith /*
7143f1d51d7SBarry Smith      New matrix classes not yet distributed
7153f1d51d7SBarry Smith */
7163f1d51d7SBarry Smith /*
7173f1d51d7SBarry Smith     MatAIJIndices is a data structure for storing the nonzero location information
7183f1d51d7SBarry Smith   for sparse matrices. Several matrices with identical nonzero structure can share
7193f1d51d7SBarry Smith   the same MatAIJIndices.
7203f1d51d7SBarry Smith */
721e2a1c21fSSatish Balay typedef struct _p_MatAIJIndices* MatAIJIndices;
7223f1d51d7SBarry Smith 
723ca44d042SBarry Smith EXTERN int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*);
724ca44d042SBarry Smith EXTERN int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*);
725ca44d042SBarry Smith EXTERN int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*);
726ca44d042SBarry Smith EXTERN int MatDestroyAIJIndices(MatAIJIndices);
727ca44d042SBarry Smith EXTERN int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*);
728ca44d042SBarry Smith EXTERN int MatValidateAIJIndices(int,MatAIJIndices);
729ca44d042SBarry Smith EXTERN int MatShiftAIJIndices(MatAIJIndices);
730ca44d042SBarry Smith EXTERN int MatShrinkAIJIndices(MatAIJIndices);
731ca44d042SBarry Smith EXTERN int MatTransposeAIJIndices(MatAIJIndices,MatAIJIndices*);
7323f1d51d7SBarry Smith 
733ca44d042SBarry Smith EXTERN int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*);
734ca44d042SBarry Smith EXTERN int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*);
735ca44d042SBarry Smith EXTERN int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,ScalarPrecision,Mat*);
7363f1d51d7SBarry Smith 
737ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *);
738ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *);
739ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,ScalarPrecision,Mat *);
7403f1d51d7SBarry Smith 
7416d053be9SSatish Balay EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
742ca44d042SBarry Smith EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *);
74308918a0eSSatish Balay EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *);
744860d1616SSatish Balay 
745d9274352SBarry Smith /*S
746d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
747d9274352SBarry Smith          orthogonalizes the vector to a subsapce
748d9274352SBarry Smith 
749d9274352SBarry Smith    Level: beginner
750d9274352SBarry Smith 
751d9274352SBarry Smith   Concepts: matrix; linear operator, null space
752d9274352SBarry Smith 
753d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
754d9274352SBarry Smith S*/
75574637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
756d9274352SBarry Smith 
75774637425SBarry Smith #define MATNULLSPACE_COOKIE    PETSC_COOKIE+17
75874637425SBarry Smith 
75974637425SBarry Smith EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,Vec *,MatNullSpace*);
76074637425SBarry Smith EXTERN int MatNullSpaceDestroy(MatNullSpace);
76174637425SBarry Smith EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
76274637425SBarry Smith EXTERN int MatNullSpaceAttach(Mat,MatNullSpace);
76374637425SBarry Smith EXTERN int MatNullSpaceTest(MatNullSpace,Mat);
76474637425SBarry Smith 
765273d9f13SBarry Smith EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp);
766273d9f13SBarry Smith EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
767273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *);
768273d9f13SBarry Smith 
7693f1d51d7SBarry Smith 
770f069c275SSatish Balay EXTERN int MatCreateMAIJ(Mat,int,Mat*);
771c4f061fbSSatish Balay EXTERN int MatMAIJRedimension(Mat,int,Mat*);
772c4f061fbSSatish Balay EXTERN int MatMAIJGetAIJ(Mat,Mat*);
773c4f061fbSSatish Balay 
774273d9f13SBarry Smith EXTERN int MatMPIAdjSetValues(Mat,int*,int*,int*);
775f069c275SSatish Balay 
776b0a32e0cSBarry Smith EXTERN int MatComputeExplicitOperator(Mat,Mat*);
777b0a32e0cSBarry Smith 
7782eac72dbSBarry Smith #endif
7792eac72dbSBarry Smith 
7802eac72dbSBarry Smith 
7819d00d63dSBarry Smith 
782