xref: /petsc/include/petscmat.h (revision d9274352047c8d529d528c2cabe6598c10356637)
1*d9274352SBarry Smith /* $Id: petscmat.h,v 1.213 2001/01/19 23:20:23 balay 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 
11*d9274352SBarry Smith /*S
12*d9274352SBarry Smith      Mat - Abstract PETSc matrix object
132eac72dbSBarry Smith 
14d91e6319SBarry Smith    Level: beginner
15d91e6319SBarry Smith 
16*d9274352SBarry Smith   Concepts: matrix; linear operator
17*d9274352SBarry Smith 
18*d9274352SBarry Smith .seealso:  MatCreate(), MatType, MatSetType()
19*d9274352SBarry Smith S*/
20*d9274352SBarry Smith typedef struct _p_Mat*           Mat;
21*d9274352SBarry Smith 
22*d9274352SBarry Smith /*E
23*d9274352SBarry Smith     MatType - String with the name of a PETSc matrix or the creation function
24*d9274352SBarry Smith        with an optional dynamic library name, for example
25*d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:mymatcreate()
26*d9274352SBarry Smith 
27*d9274352SBarry Smith    Level: beginner
28*d9274352SBarry Smith 
29*d9274352SBarry 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*);
778a3eeb68SSatish Balay 
78ca44d042SBarry Smith EXTERN int MatDestroy(Mat);
797b80b807SBarry Smith 
80ca44d042SBarry Smith EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
81ca44d042SBarry Smith EXTERN int MatShellGetContext(Mat,void **);
8221c89e3eSBarry Smith 
83ca44d042SBarry Smith EXTERN int MatPrintHelp(Mat);
84ca44d042SBarry Smith EXTERN int MatGetMaps(Mat,Map*,Map*);
85ec0117caSBarry Smith 
868ed539a5SBarry Smith /* ------------------------------------------------------------*/
87ca44d042SBarry Smith EXTERN int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
88ca44d042SBarry Smith EXTERN int MatSetValuesBlocked(Mat,int,int*,int,int*,Scalar*,InsertMode);
8984cb2905SBarry Smith 
90d91e6319SBarry Smith /*E
91d91e6319SBarry Smith     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
92d91e6319SBarry Smith      to continue to add values to it
93d91e6319SBarry Smith 
94d91e6319SBarry Smith     Level: beginner
95d91e6319SBarry Smith 
96d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd()
97d91e6319SBarry Smith E*/
986d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
99ca44d042SBarry Smith EXTERN int MatAssemblyBegin(Mat,MatAssemblyType);
100ca44d042SBarry Smith EXTERN int MatAssemblyEnd(Mat,MatAssemblyType);
101ca44d042SBarry Smith EXTERN int MatAssembled(Mat,PetscTruth*);
1024f9c727eSBarry Smith 
103b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \
104d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; Scalar _va = va; \
105b951964fSBarry Smith   _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
106b951964fSBarry Smith }
107ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \
108d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; \
109ea06a074SBarry Smith   _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \
110ea06a074SBarry Smith }
111d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \
112d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; Scalar _va = va; \
113d91e6319SBarry Smith   _ierr = MatSetValuesLocal(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
114d91e6319SBarry Smith }
115d91e6319SBarry Smith /*E
116d91e6319SBarry Smith     MatOption - Options that may be set for a matrix and its behavior or storage
117d91e6319SBarry Smith 
118d91e6319SBarry Smith     Level: beginner
119d91e6319SBarry Smith 
1200a835dfdSSatish Balay    Any additions/changes here MUST also be made in include/finclude/petscmat.h
121d91e6319SBarry Smith 
122d91e6319SBarry Smith .seealso: MatSetOption()
123d91e6319SBarry Smith E*/
1246d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
1256d4a8577SBarry Smith               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
1266d4a8577SBarry Smith               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
1276ca9ecd3SBarry Smith               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
1286ca9ecd3SBarry Smith               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
1296ca9ecd3SBarry Smith               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
1306ca9ecd3SBarry Smith               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
1314787f768SSatish Balay               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
1327c922b88SBarry Smith               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
1332bad1931SBarry Smith               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
134f9d29acdSSatish Balay               MAT_DO_NOT_USE_INODES=82} MatOption;
135ca44d042SBarry Smith EXTERN int MatSetOption(Mat,MatOption);
136273d9f13SBarry Smith EXTERN int MatGetType(Mat,MatType*);
13784cb2905SBarry Smith 
138ca44d042SBarry Smith EXTERN int MatGetValues(Mat,int,int*,int,int*,Scalar*);
139ca44d042SBarry Smith EXTERN int MatGetRow(Mat,int,int *,int **,Scalar**);
140ca44d042SBarry Smith EXTERN int MatRestoreRow(Mat,int,int *,int **,Scalar**);
141ca44d042SBarry Smith EXTERN int MatGetColumn(Mat,int,int *,int **,Scalar**);
142ca44d042SBarry Smith EXTERN int MatRestoreColumn(Mat,int,int *,int **,Scalar**);
143ca44d042SBarry Smith EXTERN int MatGetColumnVector(Mat,Vec,int);
144ca44d042SBarry Smith EXTERN int MatGetArray(Mat,Scalar **);
145ca44d042SBarry Smith EXTERN int MatRestoreArray(Mat,Scalar **);
146ca44d042SBarry Smith EXTERN int MatGetBlockSize(Mat,int *);
1477b80b807SBarry Smith 
148ca44d042SBarry Smith EXTERN int MatMult(Mat,Vec,Vec);
149ca44d042SBarry Smith EXTERN int MatMultAdd(Mat,Vec,Vec,Vec);
150ca44d042SBarry Smith EXTERN int MatMultTranspose(Mat,Vec,Vec);
151ca44d042SBarry Smith EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec);
1522eac72dbSBarry Smith 
153d91e6319SBarry Smith /*E
154d91e6319SBarry Smith     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
155d91e6319SBarry Smith   its numerical values copied over or just its nonzero structure.
156d91e6319SBarry Smith 
157d91e6319SBarry Smith     Level: beginner
158d91e6319SBarry Smith 
159d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
160d91e6319SBarry Smith 
161d91e6319SBarry Smith .seealso: MatDuplicate()
162d91e6319SBarry Smith E*/
1632e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
1642e8a6d31SBarry Smith 
165273d9f13SBarry Smith EXTERN int MatConvertRegister(char*,char*,char*,int (*)(Mat,MatType,Mat*));
166273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
167273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
168273d9f13SBarry Smith #else
169273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
170273d9f13SBarry Smith #endif
171273d9f13SBarry Smith EXTERN int MatConvertRegisterAll(char*);
172273d9f13SBarry Smith EXTERN int MatConvertRegisterDestroy(void);
173273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled;
174b0a32e0cSBarry Smith extern PetscFList      MatConvertList;
175ca44d042SBarry Smith EXTERN int MatConvert(Mat,MatType,Mat*);
176ca44d042SBarry Smith EXTERN int MatDuplicate(Mat,MatDuplicateOption,Mat*);
17794a9d846SBarry Smith 
178d91e6319SBarry Smith /*E
179d91e6319SBarry Smith     MatStructure - Indicates if the matrix has the same nonzero structure
180d91e6319SBarry Smith 
181d91e6319SBarry Smith     Level: beginner
182d91e6319SBarry Smith 
183d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
184d91e6319SBarry Smith 
185d91e6319SBarry Smith .seealso: MatCopy(), SLESSetOperators(), PCSetOperators()
186d91e6319SBarry Smith E*/
187cb5b572fSBarry Smith typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER} MatStructure;
188cb5b572fSBarry Smith 
189ca44d042SBarry Smith EXTERN int MatCopy(Mat,Mat,MatStructure);
190b0a32e0cSBarry Smith EXTERN int MatView(Mat,PetscViewer);
191273d9f13SBarry Smith 
192b0a32e0cSBarry Smith EXTERN int MatLoadRegister(char*,char*,char*,int (*)(PetscViewer,MatType,Mat*));
193273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
194273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,0)
195273d9f13SBarry Smith #else
196273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,d)
197273d9f13SBarry Smith #endif
198273d9f13SBarry Smith EXTERN int MatLoadRegisterAll(char*);
199273d9f13SBarry Smith EXTERN int MatLoadRegisterDestroy(void);
200273d9f13SBarry Smith extern PetscTruth MatLoadRegisterAllCalled;
201b0a32e0cSBarry Smith extern PetscFList      MatLoadList;
202b0a32e0cSBarry Smith EXTERN int MatLoad(PetscViewer,MatType,Mat*);
2037b80b807SBarry Smith 
204ca44d042SBarry Smith EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
205ca44d042SBarry Smith EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
206ca44d042SBarry Smith EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
207ca44d042SBarry Smith EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
208d4fbbf0eSBarry Smith 
209d91e6319SBarry Smith /*S
210d91e6319SBarry Smith      MatInfo - Context of matrix information, used with MatGetInfo()
211d91e6319SBarry Smith 
212d91e6319SBarry Smith    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
213d91e6319SBarry Smith 
214d91e6319SBarry Smith    Level: intermediate
215d91e6319SBarry Smith 
216d91e6319SBarry Smith   Concepts: matrix^nonzero information
217d91e6319SBarry Smith 
218*d9274352SBarry Smith .seealso:  MatGetInfo(), MatInfoType
219d91e6319SBarry Smith S*/
2204e220ebcSLois Curfman McInnes typedef struct {
221b0a32e0cSBarry Smith   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
222b0a32e0cSBarry Smith   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
223b0a32e0cSBarry Smith   PetscLogDouble block_size;                         /* block size */
224b0a32e0cSBarry Smith   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
225b0a32e0cSBarry Smith   PetscLogDouble memory;                             /* memory allocated */
226b0a32e0cSBarry Smith   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
227b0a32e0cSBarry Smith   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
228b0a32e0cSBarry Smith   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
229b0a32e0cSBarry Smith   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
2304e220ebcSLois Curfman McInnes } MatInfo;
2314e220ebcSLois Curfman McInnes 
232*d9274352SBarry Smith /*E
233*d9274352SBarry Smith     MatInfoType - Indicates if you want information about the local part of the matrix,
234*d9274352SBarry Smith      the entire parallel matrix or the maximum over all the local parts.
235*d9274352SBarry Smith 
236*d9274352SBarry Smith     Level: beginner
237*d9274352SBarry Smith 
238*d9274352SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
239*d9274352SBarry Smith 
240*d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo
241*d9274352SBarry Smith E*/
2427b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
243ca44d042SBarry Smith EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*);
244ca44d042SBarry Smith EXTERN int MatValid(Mat,PetscTruth*);
245ca44d042SBarry Smith EXTERN int MatGetDiagonal(Mat,Vec);
246273d9f13SBarry Smith EXTERN int MatGetRowMax(Mat,Vec);
247ca44d042SBarry Smith EXTERN int MatTranspose(Mat,Mat*);
248ca44d042SBarry Smith EXTERN int MatPermute(Mat,IS,IS,Mat *);
249ca44d042SBarry Smith EXTERN int MatDiagonalScale(Mat,Vec,Vec);
25006ef90c2SBarry Smith EXTERN int MatDiagonalSet(Mat,Vec,InsertMode);
251ca44d042SBarry Smith EXTERN int MatEqual(Mat,Mat,PetscTruth*);
2527b80b807SBarry Smith 
253ca44d042SBarry Smith EXTERN int MatNorm(Mat,NormType,double *);
254ca44d042SBarry Smith EXTERN int MatZeroEntries(Mat);
255ca44d042SBarry Smith EXTERN int MatZeroRows(Mat,IS,Scalar*);
256ca44d042SBarry Smith EXTERN int MatZeroColumns(Mat,IS,Scalar*);
2577b80b807SBarry Smith 
258ca44d042SBarry Smith EXTERN int MatUseScaledForm(Mat,PetscTruth);
259ca44d042SBarry Smith EXTERN int MatScaleSystem(Mat,Vec,Vec);
260ca44d042SBarry Smith EXTERN int MatUnScaleSystem(Mat,Vec,Vec);
2615ef9f2a5SBarry Smith 
262ca44d042SBarry Smith EXTERN int MatGetSize(Mat,int*,int*);
263ca44d042SBarry Smith EXTERN int MatGetLocalSize(Mat,int*,int*);
264ca44d042SBarry Smith EXTERN int MatGetOwnershipRange(Mat,int*,int*);
2657b80b807SBarry Smith 
266d91e6319SBarry Smith /*E
267d91e6319SBarry Smith     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
268d91e6319SBarry Smith      or MatGetSubMatrix() are to be reused to store the new matrix values.
269d91e6319SBarry Smith 
270d91e6319SBarry Smith     Level: beginner
271d91e6319SBarry Smith 
272d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
273d91e6319SBarry Smith 
274d91e6319SBarry Smith .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
275d91e6319SBarry Smith E*/
2767b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
277ca44d042SBarry Smith EXTERN int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **);
278ca44d042SBarry Smith EXTERN int MatDestroyMatrices(int,Mat **);
279ca44d042SBarry Smith EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *);
2808efafbd8SBarry Smith 
281ca44d042SBarry Smith EXTERN int MatIncreaseOverlap(Mat,int,IS *,int);
2827b80b807SBarry Smith 
283ca44d042SBarry Smith EXTERN int MatAXPY(Scalar *,Mat,Mat);
284ca44d042SBarry Smith EXTERN int MatAYPX(Scalar *,Mat,Mat);
285ca44d042SBarry Smith EXTERN int MatCompress(Mat);
2867b80b807SBarry Smith 
287ca44d042SBarry Smith EXTERN int MatScale(Scalar *,Mat);
288ca44d042SBarry Smith EXTERN int MatShift(Scalar *,Mat);
289052efed2SBarry Smith 
290ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
291ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
292ca44d042SBarry Smith EXTERN int MatZeroRowsLocal(Mat,IS,Scalar*);
293ca44d042SBarry Smith EXTERN int MatSetValuesLocal(Mat,int,int*,int,int*,Scalar*,InsertMode);
294ca44d042SBarry Smith EXTERN int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,Scalar*,InsertMode);
29590f02eecSBarry Smith 
296ca44d042SBarry Smith EXTERN int MatSetStashInitialSize(Mat,int,int);
297649db694SBarry Smith 
298ca44d042SBarry Smith EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec);
299ca44d042SBarry Smith EXTERN int MatInterpolate(Mat,Vec,Vec);
300ca44d042SBarry Smith EXTERN int MatRestrict(Mat,Vec,Vec);
3017c922b88SBarry Smith 
3027c922b88SBarry Smith /*
303c4f061fbSSatish Balay       These three (or four) macros MUST be used together. The third one closes the open { of the first one
3047c922b88SBarry Smith */
305c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
3067c922b88SBarry Smith { \
3077c922b88SBarry Smith   int __ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
30882502324SSatish Balay   __ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(__ierr);onz = dnz + __tmp;\
3097c922b88SBarry Smith   __ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(__ierr);\
3107c922b88SBarry Smith   __ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(__ierr); __start = __end - __ctmp;\
3117c922b88SBarry Smith   __ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(__ierr); __rstart = __rstart - __tmp;
3127c922b88SBarry Smith 
313c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
314c4f061fbSSatish Balay {\
315c4f061fbSSatish Balay   int __l;\
316c4f061fbSSatish Balay   __ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(__ierr);\
317c4f061fbSSatish Balay   __ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(__ierr);\
318c4f061fbSSatish Balay   for (__l=0;__l<nrows;__l++) {\
319c4f061fbSSatish Balay     __ierr = MatPreallocateSet(rows[__l],ncols,cols,dnz,onz);CHKERRQ(__ierr);\
320c4f061fbSSatish Balay   }\
321c4f061fbSSatish Balay }
322c4f061fbSSatish Balay 
323c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
3247c922b88SBarry Smith { int __i; \
3257c922b88SBarry Smith   for (__i=0; __i<nc; __i++) {\
3267c922b88SBarry Smith     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
3277c922b88SBarry Smith   }\
3287c922b88SBarry Smith   dnz[row - __rstart] = nc - onz[row - __rstart];\
3297c922b88SBarry Smith }
3307c922b88SBarry Smith 
331c4f061fbSSatish Balay #define MatPreallocateFinalize(dnz,onz) 0;__ierr = PetscFree(dnz);CHKERRQ(__ierr);}
3327c922b88SBarry Smith 
3337b80b807SBarry Smith /* Routines unique to particular data structures */
334ca44d042SBarry Smith EXTERN int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***);
335ca44d042SBarry Smith EXTERN int MatSeqAIJSetColumnIndices(Mat,int *);
336ca44d042SBarry Smith EXTERN int MatSeqBAIJSetColumnIndices(Mat,int *);
337ca44d042SBarry Smith EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int*,int*,Scalar *,Mat*);
3387b80b807SBarry Smith 
339273d9f13SBarry Smith EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,int*);
340273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,int*);
341273d9f13SBarry Smith EXTERN int MatSeqAIJSetPreallocation(Mat,int,int*);
342273d9f13SBarry Smith EXTERN int MatSeqDensePreallocation(Mat,Scalar*);
343273d9f13SBarry Smith EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,int*,Scalar**);
344273d9f13SBarry Smith EXTERN int MatSeqDenseSetPreallocation(Mat,Scalar*);
345273d9f13SBarry Smith 
346273d9f13SBarry Smith EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,int*,int,int*);
347273d9f13SBarry Smith EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,int*,int,int*);
348273d9f13SBarry Smith EXTERN int MatMPIAIJSetPreallocation(Mat,int,int*,int,int*);
349273d9f13SBarry Smith EXTERN int MatMPIDensePreallocation(Mat,Scalar*);
350273d9f13SBarry Smith EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,int*,Scalar**);
351273d9f13SBarry Smith EXTERN int MatMPIAdjSetPreallocation(Mat,int*,int*,int*);
352273d9f13SBarry Smith EXTERN int MatMPIDenseSetPreallocation(Mat,Scalar*);
353273d9f13SBarry Smith EXTERN int MatMPIRowbsSetPreallocation(Mat,int,int*);
354273d9f13SBarry Smith 
355ca44d042SBarry Smith EXTERN int MatStoreValues(Mat);
356ca44d042SBarry Smith EXTERN int MatRetrieveValues(Mat);
3572e8a6d31SBarry Smith 
3587b80b807SBarry Smith /*
3597b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
3607b80b807SBarry Smith   done through the SLES, KSP and PC interfaces.
3617b80b807SBarry Smith */
3627b80b807SBarry Smith 
363*d9274352SBarry Smith /*E
364*d9274352SBarry Smith     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
365*d9274352SBarry Smith        with an optional dynamic library name, for example
366*d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
367*d9274352SBarry Smith 
368*d9274352SBarry Smith    Level: beginner
369*d9274352SBarry Smith 
370*d9274352SBarry Smith .seealso: MatGetOrdering()
371*d9274352SBarry Smith E*/
372b12f92e5SBarry Smith typedef char* MatOrderingType;
373b12f92e5SBarry Smith #define MATORDERING_NATURAL   "natural"
374b12f92e5SBarry Smith #define MATORDERING_ND        "nd"
375b12f92e5SBarry Smith #define MATORDERING_1WD       "1wd"
376b12f92e5SBarry Smith #define MATORDERING_RCM       "rcm"
377b12f92e5SBarry Smith #define MATORDERING_QMD       "qmd"
378b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength"
37962152c8bSBarry Smith #define MATORDERING_DSC_ND    "dsc_nd"
38062152c8bSBarry Smith #define MATORDERING_DSC_MMD   "dsc_mmd"
38162152c8bSBarry Smith #define MATORDERING_DSC_MDF   "dsc_mdf"
382b12f92e5SBarry Smith 
383ca44d042SBarry Smith EXTERN int MatGetOrdering(Mat,MatOrderingType,IS*,IS*);
384ca44d042SBarry Smith EXTERN int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*));
385aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
386f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
387b12f92e5SBarry Smith #else
388f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
389b12f92e5SBarry Smith #endif
390ca44d042SBarry Smith EXTERN int        MatOrderingRegisterDestroy(void);
391ca44d042SBarry Smith EXTERN int        MatOrderingRegisterAll(char*);
3922bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled;
393b0a32e0cSBarry Smith extern PetscFList      MatOrderingList;
394d4fbbf0eSBarry Smith 
395ca44d042SBarry Smith EXTERN int MatReorderForNonzeroDiagonal(Mat,double,IS,IS);
396a2ce50c7SBarry Smith 
397ca44d042SBarry Smith EXTERN int MatCholeskyFactor(Mat,IS,double);
398ca44d042SBarry Smith EXTERN int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*);
399ca44d042SBarry Smith EXTERN int MatCholeskyFactorNumeric(Mat,Mat*);
400a2ce50c7SBarry Smith 
401d91e6319SBarry Smith /*S
402d91e6319SBarry Smith    MatILUInfo - Data based into the matrix ILU factorization routines
4035ef9f2a5SBarry Smith 
404d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_ILUINFO_SIZE
40514822f30SBarry Smith 
406d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of ILU
407d91e6319SBarry Smith           All entries are double precision.
408d91e6319SBarry Smith 
409d91e6319SBarry Smith    Level: developer
410d91e6319SBarry Smith 
411d91e6319SBarry Smith .seealso: MatILUFactorSymbolic(), MatILUFactor(), MatLUInfo, MatCholeskyInfo
412d91e6319SBarry Smith 
413d91e6319SBarry Smith S*/
4145ef9f2a5SBarry Smith typedef struct {
4155ef9f2a5SBarry Smith   double     levels;         /* ILU(levels) */
4165ef9f2a5SBarry Smith   double     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
4175ef9f2a5SBarry Smith   double     diagonal_fill;  /* force diagonal to fill in if initially not filled */
41836db0b34SBarry Smith   double     dt;             /* drop tolerance */
41936db0b34SBarry Smith   double     dtcol;          /* tolerance for pivoting */
42036db0b34SBarry Smith   double     dtcount;        /* maximum nonzeros to be allowed per row */
421d91e6319SBarry Smith   double     damping;        /* scaling of identity added to matrix to prevent zero pivots */
422d91e6319SBarry Smith   double     damp;           /* if is 1.0 and factorization fails, damp until successful */
4235ef9f2a5SBarry Smith } MatILUInfo;
4245ef9f2a5SBarry Smith 
425d91e6319SBarry Smith /*S
426d91e6319SBarry Smith    MatLUInfo - Data based into the matrix LU factorization routines
427d91e6319SBarry Smith 
428d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_LUINFO_SIZE
429d91e6319SBarry Smith 
430d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of LU
431d91e6319SBarry Smith           All entries are double precision.
432d91e6319SBarry Smith 
433d91e6319SBarry Smith    Level: developer
434d91e6319SBarry Smith 
435d91e6319SBarry Smith .seealso: MatLUFactorSymbolic(), MatILUInfo, MatCholeskyInfo
436d91e6319SBarry Smith 
437d91e6319SBarry Smith S*/
43814822f30SBarry Smith typedef struct {
43914822f30SBarry Smith   double     fill;    /* expected fill; nonzeros in factored matrix/nonzeros in original matrix */
44014822f30SBarry Smith   double     dtcol;   /* tolerance for pivoting; pivot if off_diagonal*dtcol > diagonal */
441d91e6319SBarry Smith   double     damping; /* scaling of identity added to matrix to prevent zero pivots */
442d91e6319SBarry Smith   double     damp;    /* if this is 1.0 and factorization fails, damp until successful */
44314822f30SBarry Smith } MatLUInfo;
44414822f30SBarry Smith 
445d91e6319SBarry Smith /*S
446d91e6319SBarry Smith    MatCholeskyInfo - Data based into the matrix Cholesky factorization routines
447d91e6319SBarry Smith 
448d91e6319SBarry Smith    In Fortran these are simply double precision arrays of size MAT_CHOLESKYINFO_SIZE
449d91e6319SBarry Smith 
450d91e6319SBarry Smith    Notes: These are not usually directly used by users, instead use the PC type of Cholesky
451d91e6319SBarry Smith           All entries are double precision.
452d91e6319SBarry Smith 
453d91e6319SBarry Smith    Level: developer
454d91e6319SBarry Smith 
455d91e6319SBarry Smith .seealso: MatCholeskyFactorSymbolic(), MatLUInfo, MatILUInfo
456d91e6319SBarry Smith 
457d91e6319SBarry Smith S*/
458ffa6d0a5SLois Curfman McInnes typedef struct {
459ffa6d0a5SLois Curfman McInnes   double     fill;    /* expected fill; nonzeros in factored matrix/nonzeros in original matrix */
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 */
462ffa6d0a5SLois Curfman McInnes } MatCholeskyInfo;
463ffa6d0a5SLois Curfman McInnes 
46414822f30SBarry Smith EXTERN int MatLUFactor(Mat,IS,IS,MatLUInfo*);
465ca44d042SBarry Smith EXTERN int MatILUFactor(Mat,IS,IS,MatILUInfo*);
46614822f30SBarry Smith EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatLUInfo*,Mat*);
467ca44d042SBarry Smith EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatILUInfo*,Mat*);
468ca44d042SBarry Smith EXTERN int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*);
46974637425SBarry Smith EXTERN int MatIncompleteCholeskyFactor(Mat,IS,double,int);
470ca44d042SBarry Smith EXTERN int MatLUFactorNumeric(Mat,Mat*);
471ca44d042SBarry Smith EXTERN int MatILUDTFactor(Mat,MatILUInfo*,IS,IS,Mat *);
472a2ce50c7SBarry Smith 
473ca44d042SBarry Smith EXTERN int MatSolve(Mat,Vec,Vec);
474ca44d042SBarry Smith EXTERN int MatForwardSolve(Mat,Vec,Vec);
475ca44d042SBarry Smith EXTERN int MatBackwardSolve(Mat,Vec,Vec);
476ca44d042SBarry Smith EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec);
477ca44d042SBarry Smith EXTERN int MatSolveTranspose(Mat,Vec,Vec);
478ca44d042SBarry Smith EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
4798ed539a5SBarry Smith 
480ca44d042SBarry Smith EXTERN int MatSetUnfactored(Mat);
481bb5a7306SBarry Smith 
482bb1eb677SSatish Balay /*  MatSORType may be bitwise ORd together, so do not change the numbers */
483d91e6319SBarry Smith /*E
484d91e6319SBarry Smith     MatSORType - What type of (S)SOR to perform
485bb1eb677SSatish Balay 
486d91e6319SBarry Smith     Level: beginner
487d91e6319SBarry Smith 
488*d9274352SBarry Smith    May be bitwise ORd together
489*d9274352SBarry Smith 
490d91e6319SBarry Smith    Any additions/changes here MUST also be made in include/finclude/petscmat.h
491d91e6319SBarry Smith 
492d91e6319SBarry Smith .seealso: MatRelax()
493d91e6319SBarry Smith E*/
494ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
495ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
496ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
49784cb2905SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
498ca44d042SBarry Smith EXTERN int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
4998ed539a5SBarry Smith 
500d4fbbf0eSBarry Smith /*
501639f9d9dSBarry Smith     These routines are for efficiently computing Jacobians via finite differences.
502639f9d9dSBarry Smith */
503b12f92e5SBarry Smith 
504*d9274352SBarry Smith /*E
505*d9274352SBarry Smith     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
506*d9274352SBarry Smith        with an optional dynamic library name, for example
507*d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
508*d9274352SBarry Smith 
509*d9274352SBarry Smith    Level: beginner
510*d9274352SBarry Smith 
511*d9274352SBarry Smith .seealso: MatGetColoring()
512*d9274352SBarry Smith E*/
513b12f92e5SBarry Smith typedef char* MatColoringType;
514b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural"
515b12f92e5SBarry Smith #define MATCOLORING_SL      "sl"
516b12f92e5SBarry Smith #define MATCOLORING_LF      "lf"
517b12f92e5SBarry Smith #define MATCOLORING_ID      "id"
518b12f92e5SBarry Smith 
519ca44d042SBarry Smith EXTERN int MatGetColoring(Mat,MatColoringType,ISColoring*);
520ca44d042SBarry Smith EXTERN int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *));
521aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
522f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
523b12f92e5SBarry Smith #else
524f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
525b12f92e5SBarry Smith #endif
526ca44d042SBarry Smith EXTERN int        MatColoringRegisterAll(char *);
5272bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled;
528ca44d042SBarry Smith EXTERN int        MatColoringRegisterDestroy(void);
529ca44d042SBarry Smith EXTERN int        MatColoringPatch(Mat,int,int *,ISColoring*);
530639f9d9dSBarry Smith 
5311a0a18cdSSatish Balay #define MAT_FDCOLORING_COOKIE PETSC_COOKIE + 23
532*d9274352SBarry Smith /*S
533*d9274352SBarry Smith      MatFDColoring - Object for computing a sparse Jacobian via finite differences
534*d9274352SBarry Smith         and coloring
535639f9d9dSBarry Smith 
536*d9274352SBarry Smith    Level: beginner
537*d9274352SBarry Smith 
538*d9274352SBarry Smith   Concepts: coloring, sparse Jacobian, finite differences
539*d9274352SBarry Smith 
540*d9274352SBarry Smith .seealso:  MatFDColoringCreate()
541*d9274352SBarry Smith S*/
542e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring;
543639f9d9dSBarry Smith 
544ca44d042SBarry Smith EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
545ca44d042SBarry Smith EXTERN int MatFDColoringDestroy(MatFDColoring);
546b0a32e0cSBarry Smith EXTERN int MatFDColoringView(MatFDColoring,PetscViewer);
547ca44d042SBarry Smith EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*);
548ca44d042SBarry Smith EXTERN int MatFDColoringSetParameters(MatFDColoring,double,double);
549ca44d042SBarry Smith EXTERN int MatFDColoringSetFrequency(MatFDColoring,int);
550ca44d042SBarry Smith EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*);
551ca44d042SBarry Smith EXTERN int MatFDColoringSetFromOptions(MatFDColoring);
552ca44d042SBarry Smith EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
553ca44d042SBarry Smith EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,double,Vec,MatStructure*,void *);
55462152c8bSBarry Smith EXTERN int MatFDColoringSetRecompute(MatFDColoring);
555639f9d9dSBarry Smith 
556639f9d9dSBarry Smith /*
5570752156aSBarry Smith     These routines are for partitioning matrices: currently used only
5583eda8832SBarry Smith   for adjacency matrix, MatCreateMPIAdj().
5590752156aSBarry Smith */
56091e9ee9fSBarry Smith #define MATPARTITIONING_COOKIE PETSC_COOKIE + 25
561ca161407SBarry Smith 
562*d9274352SBarry Smith /*S
563*d9274352SBarry Smith      MatPartitioning - Object for managing the partitioning of a matrix or graph
564*d9274352SBarry Smith 
565*d9274352SBarry Smith    Level: beginner
566*d9274352SBarry Smith 
567*d9274352SBarry Smith   Concepts: partitioning
568*d9274352SBarry Smith 
569*d9274352SBarry Smith .seealso:  MatParitioningCreate(), MatPartitioningType
570*d9274352SBarry Smith S*/
57191e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning;
572*d9274352SBarry Smith 
573*d9274352SBarry Smith /*E
574*d9274352SBarry Smith     MatPartitioningType - String with the name of a PETSc matrix partitioing or the creation function
575*d9274352SBarry Smith        with an optional dynamic library name, for example
576*d9274352SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
577*d9274352SBarry Smith 
578*d9274352SBarry Smith    Level: beginner
579*d9274352SBarry Smith 
580*d9274352SBarry Smith .seealso: MatPartitioingCreate(), MatPartitioning
581*d9274352SBarry Smith E*/
5822aabb6bbSBarry Smith typedef char* MatPartitioningType;
5832aabb6bbSBarry Smith #define MATPARTITIONING_CURRENT  "current"
5842aabb6bbSBarry Smith #define MATPARTITIONING_PARMETIS "parmetis"
585ca161407SBarry Smith 
586ca44d042SBarry Smith EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*);
587ca44d042SBarry Smith EXTERN int MatPartitioningSetType(MatPartitioning,MatPartitioningType);
588ca44d042SBarry Smith EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat);
589ca44d042SBarry Smith EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,int*);
590ca44d042SBarry Smith EXTERN int MatPartitioningApply(MatPartitioning,IS*);
591ca44d042SBarry Smith EXTERN int MatPartitioningDestroy(MatPartitioning);
5922aabb6bbSBarry Smith 
593ca44d042SBarry Smith EXTERN int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning));
594aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
595f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
5962aabb6bbSBarry Smith #else
597f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
5982aabb6bbSBarry Smith #endif
5992aabb6bbSBarry Smith 
600ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterAll(char *);
6012bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled;
602ca44d042SBarry Smith EXTERN int        MatPartitioningRegisterDestroy(void);
6032bad1931SBarry Smith 
604b0a32e0cSBarry Smith EXTERN int MatPartitioningView(MatPartitioning,PetscViewer);
605ca44d042SBarry Smith EXTERN int MatPartitioningSetFromOptions(MatPartitioning);
606ca44d042SBarry Smith EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
607ca161407SBarry Smith 
608ca44d042SBarry Smith EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
6090752156aSBarry Smith 
6100752156aSBarry Smith /*
6110a835dfdSSatish Balay     If you add entries here you must also add them to finclude/petscmat.h
612d4fbbf0eSBarry Smith */
6131c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0,
6141c1c02c0SLois Curfman McInnes                MATOP_GET_ROW=1,
6151c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ROW=2,
6161c1c02c0SLois Curfman McInnes                MATOP_MULT=3,
6171c1c02c0SLois Curfman McInnes                MATOP_MULT_ADD=4,
6187c922b88SBarry Smith                MATOP_MULT_TRANSPOSE=5,
6197c922b88SBarry Smith                MATOP_MULT_TRANSPOSE_ADD=6,
6201c1c02c0SLois Curfman McInnes                MATOP_SOLVE=7,
6211c1c02c0SLois Curfman McInnes                MATOP_SOLVE_ADD=8,
6227c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE=9,
6237c922b88SBarry Smith                MATOP_SOLVE_TRANSPOSE_ADD=10,
6241c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR=11,
6251c1c02c0SLois Curfman McInnes                MATOP_CHOLESKYFACTOR=12,
6261c1c02c0SLois Curfman McInnes                MATOP_RELAX=13,
6271c1c02c0SLois Curfman McInnes                MATOP_TRANSPOSE=14,
6281c1c02c0SLois Curfman McInnes                MATOP_GETINFO=15,
6291c1c02c0SLois Curfman McInnes                MATOP_EQUAL=16,
6301c1c02c0SLois Curfman McInnes                MATOP_GET_DIAGONAL=17,
6311c1c02c0SLois Curfman McInnes                MATOP_DIAGONAL_SCALE=18,
6321c1c02c0SLois Curfman McInnes                MATOP_NORM=19,
6331c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_BEGIN=20,
6341c1c02c0SLois Curfman McInnes                MATOP_ASSEMBLY_END=21,
6351c1c02c0SLois Curfman McInnes                MATOP_COMPRESS=22,
6361c1c02c0SLois Curfman McInnes                MATOP_SET_OPTION=23,
6371c1c02c0SLois Curfman McInnes                MATOP_ZERO_ENTRIES=24,
6381c1c02c0SLois Curfman McInnes                MATOP_ZERO_ROWS=25,
6391c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_SYMBOLIC=26,
6401c1c02c0SLois Curfman McInnes                MATOP_LUFACTOR_NUMERIC=27,
6411c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
6421c1c02c0SLois Curfman McInnes                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
6431c1c02c0SLois Curfman McInnes                MATOP_GET_SIZE=30,
6441c1c02c0SLois Curfman McInnes                MATOP_GET_LOCAL_SIZE=31,
6451c1c02c0SLois Curfman McInnes                MATOP_GET_OWNERSHIP_RANGE=32,
6461c1c02c0SLois Curfman McInnes                MATOP_ILUFACTOR_SYMBOLIC=33,
6471c1c02c0SLois Curfman McInnes                MATOP_INCOMPLETECHOLESKYFACTOR_SYMBOLIC=34,
6481c1c02c0SLois Curfman McInnes                MATOP_GET_ARRAY=35,
6491c1c02c0SLois Curfman McInnes                MATOP_RESTORE_ARRAY=36,
6507bf97ca4SSatish Balay 
651005c665bSBarry Smith                MATOP_CONVERT_SAME_TYPE=37,
652005c665bSBarry Smith                MATOP_FORWARD_SOLVE=38,
653005c665bSBarry Smith                MATOP_BACKWARD_SOLVE=39,
654005c665bSBarry Smith                MATOP_ILUFACTOR=40,
655005c665bSBarry Smith                MATOP_INCOMPLETECHOLESKYFACTOR=41,
656005c665bSBarry Smith                MATOP_AXPY=42,
657005c665bSBarry Smith                MATOP_GET_SUBMATRICES=43,
658005c665bSBarry Smith                MATOP_INCREASE_OVERLAP=44,
659005c665bSBarry Smith                MATOP_GET_VALUES=45,
660005c665bSBarry Smith                MATOP_COPY=46,
661005c665bSBarry Smith                MATOP_PRINT_HELP=47,
662005c665bSBarry Smith                MATOP_SCALE=48,
663005c665bSBarry Smith                MATOP_SHIFT=49,
664005c665bSBarry Smith                MATOP_DIAGONAL_SHIFT=50,
665005c665bSBarry Smith                MATOP_ILUDT_FACTOR=51,
666005c665bSBarry Smith                MATOP_GET_BLOCK_SIZE=52,
667005c665bSBarry Smith                MATOP_GET_ROW_IJ=53,
668005c665bSBarry Smith                MATOP_RESTORE_ROW_IJ=54,
669005c665bSBarry Smith                MATOP_GET_COLUMN_IJ=55,
670005c665bSBarry Smith                MATOP_RESTORE_COLUMN_IJ=56,
671005c665bSBarry Smith                MATOP_FDCOLORING_CREATE=57,
672005c665bSBarry Smith                MATOP_COLORING_PATCH=58,
673005c665bSBarry Smith                MATOP_SET_UNFACTORED=59,
674005c665bSBarry Smith                MATOP_PERMUTE=60,
675005c665bSBarry Smith                MATOP_SET_VALUES_BLOCKED=61,
6761c1c02c0SLois Curfman McInnes                MATOP_DESTROY=250,
6771c1c02c0SLois Curfman McInnes                MATOP_VIEW=251
678fae171e0SBarry Smith              } MatOperation;
679ca44d042SBarry Smith EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*);
680ca44d042SBarry Smith EXTERN int MatShellSetOperation(Mat,MatOperation,void *);
681ca44d042SBarry Smith EXTERN int MatShellGetOperation(Mat,MatOperation,void **);
682273d9f13SBarry Smith EXTERN int MatShellSetContext(Mat,void*);
683112a2221SBarry Smith 
68490ace30eSBarry Smith /*
68590ace30eSBarry Smith    Codes for matrices stored on disk. By default they are
68690ace30eSBarry Smith  stored in a universal format. By changing the format with
687fb9695e5SSatish Balay  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
68890ace30eSBarry Smith  be stored in a way natural for the matrix, for example dense matrices
68990ace30eSBarry Smith  would be stored as dense. Matrices stored this way may only be
69090ace30eSBarry Smith  read into matrices of the same time.
69190ace30eSBarry Smith */
69290ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1
69390ace30eSBarry Smith 
6943f1d51d7SBarry Smith /*
6953f1d51d7SBarry Smith      New matrix classes not yet distributed
6963f1d51d7SBarry Smith */
6973f1d51d7SBarry Smith /*
6983f1d51d7SBarry Smith     MatAIJIndices is a data structure for storing the nonzero location information
6993f1d51d7SBarry Smith   for sparse matrices. Several matrices with identical nonzero structure can share
7003f1d51d7SBarry Smith   the same MatAIJIndices.
7013f1d51d7SBarry Smith */
702e2a1c21fSSatish Balay typedef struct _p_MatAIJIndices* MatAIJIndices;
7033f1d51d7SBarry Smith 
704ca44d042SBarry Smith EXTERN int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*);
705ca44d042SBarry Smith EXTERN int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*);
706ca44d042SBarry Smith EXTERN int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*);
707ca44d042SBarry Smith EXTERN int MatDestroyAIJIndices(MatAIJIndices);
708ca44d042SBarry Smith EXTERN int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*);
709ca44d042SBarry Smith EXTERN int MatValidateAIJIndices(int,MatAIJIndices);
710ca44d042SBarry Smith EXTERN int MatShiftAIJIndices(MatAIJIndices);
711ca44d042SBarry Smith EXTERN int MatShrinkAIJIndices(MatAIJIndices);
712ca44d042SBarry Smith EXTERN int MatTransposeAIJIndices(MatAIJIndices,MatAIJIndices*);
7133f1d51d7SBarry Smith 
714ca44d042SBarry Smith EXTERN int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*);
715ca44d042SBarry Smith EXTERN int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*);
716ca44d042SBarry Smith EXTERN int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,ScalarPrecision,Mat*);
7173f1d51d7SBarry Smith 
718ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *);
719ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *);
720ca44d042SBarry Smith EXTERN int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,ScalarPrecision,Mat *);
7213f1d51d7SBarry Smith 
7226d053be9SSatish Balay EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
723ca44d042SBarry Smith EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *);
72408918a0eSSatish Balay EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *);
725860d1616SSatish Balay 
726*d9274352SBarry Smith /*S
727*d9274352SBarry Smith      MatNullSpace - Object that removes a null space from a vector, i.e.
728*d9274352SBarry Smith          orthogonalizes the vector to a subsapce
729*d9274352SBarry Smith 
730*d9274352SBarry Smith    Level: beginner
731*d9274352SBarry Smith 
732*d9274352SBarry Smith   Concepts: matrix; linear operator, null space
733*d9274352SBarry Smith 
734*d9274352SBarry Smith .seealso:  MatNullSpaceCreate()
735*d9274352SBarry Smith S*/
73674637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace;
737*d9274352SBarry Smith 
73874637425SBarry Smith #define MATNULLSPACE_COOKIE    PETSC_COOKIE+17
73974637425SBarry Smith 
74074637425SBarry Smith EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,Vec *,MatNullSpace*);
74174637425SBarry Smith EXTERN int MatNullSpaceDestroy(MatNullSpace);
74274637425SBarry Smith EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
74374637425SBarry Smith EXTERN int MatNullSpaceAttach(Mat,MatNullSpace);
74474637425SBarry Smith EXTERN int MatNullSpaceTest(MatNullSpace,Mat);
74574637425SBarry Smith 
746273d9f13SBarry Smith EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp);
747273d9f13SBarry Smith EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
748273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *);
749273d9f13SBarry Smith 
7503f1d51d7SBarry Smith 
751f069c275SSatish Balay EXTERN int MatCreateMAIJ(Mat,int,Mat*);
752c4f061fbSSatish Balay EXTERN int MatMAIJRedimension(Mat,int,Mat*);
753c4f061fbSSatish Balay EXTERN int MatMAIJGetAIJ(Mat,Mat*);
754c4f061fbSSatish Balay 
755273d9f13SBarry Smith EXTERN int MatMPIAdjSetValues(Mat,int*,int*,int*);
756f069c275SSatish Balay 
757b0a32e0cSBarry Smith EXTERN int MatComputeExplicitOperator(Mat,Mat*);
758b0a32e0cSBarry Smith 
7592eac72dbSBarry Smith #endif
7602eac72dbSBarry Smith 
7612eac72dbSBarry Smith 
7629d00d63dSBarry Smith 
763