xref: /petsc/include/petscmat.h (revision 31b3f9abac2636b12d9a4b9faef65da647524c4e)
1 /* $Id: petscmat.h,v 1.228 2001/09/07 20:09:08 bsmith Exp $ */
2 /*
3      Include file for the matrix component of PETSc
4 */
5 #ifndef __PETSCMAT_H
6 #define __PETSCMAT_H
7 #include "petscvec.h"
8 
9 /*S
10      Mat - Abstract PETSc matrix object
11 
12    Level: beginner
13 
14   Concepts: matrix; linear operator
15 
16 .seealso:  MatCreate(), MatType, MatSetType()
17 S*/
18 typedef struct _p_Mat*           Mat;
19 
20 /*E
21     MatType - String with the name of a PETSc matrix or the creation function
22        with an optional dynamic library name, for example
23        http://www.mcs.anl.gov/petsc/lib.a:mymatcreate()
24 
25    Level: beginner
26 
27 .seealso: MatSetType(), Mat
28 E*/
29 #define MATSAME     "same"
30 #define MATSEQMAIJ  "seqmaij"
31 #define MATMPIMAIJ  "mpimaij"
32 #define MATIS       "is"
33 #define MATMPIROWBS "mpirowbs"
34 #define MATSEQDENSE "seqdense"
35 #define MATSEQAIJ   "seqaij"
36 #define MATMPIAIJ   "mpiaij"
37 #define MATSHELL    "shell"
38 #define MATSEQBDIAG "seqbdiag"
39 #define MATMPIBDIAG "mpibdiag"
40 #define MATMPIDENSE "mpidense"
41 #define MATSEQBAIJ  "seqbaij"
42 #define MATMPIBAIJ  "mpibaij"
43 #define MATMPIADJ   "mpiadj"
44 #define MATSEQSBAIJ "seqsbaij"
45 #define MATMPISBAIJ "mpisbaij"
46 #define MATDAAD     "daad"
47 #define MATMFFD     "mffd"
48 #define MATESI      "esi"
49 #define MATPETSCESI "petscesi"
50 #define MATNORMAL   "normal"
51 typedef char* MatType;
52 
53 #define MAT_SER_SEQAIJ_BINARY "seqaij_binary"
54 #define MAT_SER_MPIAIJ_BINARY "mpiaij_binary"
55 typedef char *MatSerializeType;
56 
57 /* Logging support */
58 #define    MAT_FILE_COOKIE 1211216    /* used to indicate matrices in binary files */
59 extern int MAT_COOKIE;
60 extern int MATSNESMFCTX_COOKIE;
61 extern int MAT_FDCOLORING_COOKIE;
62 extern int MAT_PARTITIONING_COOKIE;
63 extern int MAT_NULLSPACE_COOKIE;
64 extern int MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose;
65 extern int MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose;
66 extern int MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic;
67 extern int MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor;
68 extern int MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin;
69 extern int MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering;
70 extern int MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate;
71 extern int MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction;
72 
73 EXTERN int MatInitializePackage(char *);
74 
75 EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*);
76 EXTERN int MatSetType(Mat,MatType);
77 EXTERN int MatSetFromOptions(Mat);
78 EXTERN int MatSetUpPreallocation(Mat);
79 EXTERN int MatRegisterAll(char*);
80 EXTERN int MatRegister(char*,char*,char*,int(*)(Mat));
81 EXTERN int MatSerializeRegister(const char [], const char [], const char [], int (*)(MPI_Comm, Mat *, PetscViewer, PetscTruth));
82 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
83 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
84 #define MatSerializeRegisterDynamic(a,b,c,d) MatSerializeRegister(a,b,c,0)
85 #else
86 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
87 #define MatSerializeRegisterDynamic(a,b,c,d) MatSerializeRegister(a,b,c,d)
88 #endif
89 extern PetscTruth MatRegisterAllCalled;
90 extern PetscFList MatList;
91 
92 EXTERN PetscFList MatSerializeList;
93 EXTERN int MatSerializeRegisterAll(const char []);
94 EXTERN int MatSerializeRegisterDestroy(void);
95 EXTERN int MatSerializeRegisterAllCalled;
96 EXTERN int MatSerialize(MPI_Comm, Mat *, PetscViewer, PetscTruth);
97 EXTERN int MatSetSerializeType(Mat, MatSerializeType);
98 
99 EXTERN int MatCreateSeqDense(MPI_Comm,int,int,PetscScalar*,Mat*);
100 EXTERN int MatCreateMPIDense(MPI_Comm,int,int,int,int,PetscScalar*,Mat*);
101 EXTERN int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*);
102 EXTERN int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
103 EXTERN int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,Mat*);
104 EXTERN int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,PetscScalar**,Mat*);
105 EXTERN int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,PetscScalar**,Mat*);
106 EXTERN int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
107 EXTERN int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
108 EXTERN int MatCreateMPIAdj(MPI_Comm,int,int,int*,int*,int *,Mat*);
109 EXTERN int MatCreateSeqSBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
110 EXTERN int MatCreateMPISBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*);
111 EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
112 EXTERN int MatCreateAdic(MPI_Comm,int,int,int,int,int,void (*)(void),Mat*);
113 EXTERN int MatCreateNormal(Mat,Mat*);
114 EXTERN int MatDestroy(Mat);
115 
116 EXTERN int MatPrintHelp(Mat);
117 EXTERN int MatGetPetscMaps(Mat,PetscMap*,PetscMap*);
118 
119 /* ------------------------------------------------------------*/
120 EXTERN int MatSetValues(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
121 EXTERN int MatSetValuesBlocked(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
122 
123 /*S
124      MatStencil - Data structure (C struct) for storing information about a single row or
125         column of a matrix as index on an associated grid.
126 
127    Level: beginner
128 
129   Concepts: matrix; linear operator
130 
131 .seealso:  MatSetValuesStencil(), MatSetStencil()
132 S*/
133 typedef struct {
134   int k,j,i,c;
135 } MatStencil;
136 
137 EXTERN int MatSetValuesStencil(Mat,int,MatStencil*,int,MatStencil*,PetscScalar*,InsertMode);
138 EXTERN int MatSetValuesBlockedStencil(Mat,int,MatStencil*,int,MatStencil*,PetscScalar*,InsertMode);
139 EXTERN int MatSetStencil(Mat,int,int*,int*,int);
140 
141 EXTERN int MatSetColoring(Mat,ISColoring);
142 EXTERN int MatSetValuesAdic(Mat,void*);
143 EXTERN int MatSetValuesAdifor(Mat,int,void*);
144 
145 /*E
146     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
147      to continue to add values to it
148 
149     Level: beginner
150 
151 .seealso: MatAssemblyBegin(), MatAssemblyEnd()
152 E*/
153 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
154 EXTERN int MatAssemblyBegin(Mat,MatAssemblyType);
155 EXTERN int MatAssemblyEnd(Mat,MatAssemblyType);
156 EXTERN int MatAssembled(Mat,PetscTruth*);
157 
158 #define MatSetValue(v,i,j,va,mode) \
159 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \
160   _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
161 }
162 #define MatGetValue(v,i,j,va) \
163 0; {int _ierr,_row = i,_col = j; \
164   _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \
165 }
166 #define MatSetValueLocal(v,i,j,va,mode) \
167 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \
168   _ierr = MatSetValuesLocal(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \
169 }
170 /*E
171     MatOption - Options that may be set for a matrix and its behavior or storage
172 
173     Level: beginner
174 
175    Any additions/changes here MUST also be made in include/finclude/petscmat.h
176 
177 .seealso: MatSetOption()
178 E*/
179 typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
180               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
181               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
182               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
183               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
184               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
185               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
186               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
187               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
188               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
189               MAT_DO_NOT_USE_INODES=82} MatOption;
190 EXTERN int MatSetOption(Mat,MatOption);
191 EXTERN int MatGetType(Mat,MatType*);
192 
193 EXTERN int MatGetValues(Mat,int,int*,int,int*,PetscScalar*);
194 EXTERN int MatGetRow(Mat,int,int *,int **,PetscScalar**);
195 EXTERN int MatRestoreRow(Mat,int,int *,int **,PetscScalar**);
196 EXTERN int MatGetColumn(Mat,int,int *,int **,PetscScalar**);
197 EXTERN int MatRestoreColumn(Mat,int,int *,int **,PetscScalar**);
198 EXTERN int MatGetColumnVector(Mat,Vec,int);
199 EXTERN int MatGetArray(Mat,PetscScalar **);
200 EXTERN int MatRestoreArray(Mat,PetscScalar **);
201 EXTERN int MatGetBlockSize(Mat,int *);
202 
203 EXTERN int MatMult(Mat,Vec,Vec);
204 EXTERN int MatMultAdd(Mat,Vec,Vec,Vec);
205 EXTERN int MatMultTranspose(Mat,Vec,Vec);
206 EXTERN int MatIsSymmetric(Mat,Mat,PetscTruth*);
207 EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec);
208 EXTERN int MatMultConstrained(Mat,Vec,Vec);
209 EXTERN int MatMultTransposeConstrained(Mat,Vec,Vec);
210 
211 /*E
212     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
213   its numerical values copied over or just its nonzero structure.
214 
215     Level: beginner
216 
217    Any additions/changes here MUST also be made in include/finclude/petscmat.h
218 
219 .seealso: MatDuplicate()
220 E*/
221 typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
222 
223 EXTERN int MatConvertRegister(char*,char*,char*,int (*)(Mat,MatType,Mat*));
224 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
225 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
226 #else
227 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
228 #endif
229 EXTERN int        MatConvertRegisterAll(char*);
230 EXTERN int        MatConvertRegisterDestroy(void);
231 extern PetscTruth MatConvertRegisterAllCalled;
232 extern PetscFList MatConvertList;
233 EXTERN int        MatConvert(Mat,MatType,Mat*);
234 EXTERN int        MatDuplicate(Mat,MatDuplicateOption,Mat*);
235 
236 /*E
237     MatStructure - Indicates if the matrix has the same nonzero structure
238 
239     Level: beginner
240 
241    Any additions/changes here MUST also be made in include/finclude/petscmat.h
242 
243 .seealso: MatCopy(), SLESSetOperators(), PCSetOperators()
244 E*/
245 typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure;
246 
247 EXTERN int MatCopy(Mat,Mat,MatStructure);
248 EXTERN int MatView(Mat,PetscViewer);
249 
250 EXTERN int MatLoadRegister(char*,char*,char*,int (*)(PetscViewer,MatType,Mat*));
251 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
252 #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,0)
253 #else
254 #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,d)
255 #endif
256 EXTERN int        MatLoadRegisterAll(char*);
257 EXTERN int        MatLoadRegisterDestroy(void);
258 extern PetscTruth MatLoadRegisterAllCalled;
259 extern PetscFList MatLoadList;
260 EXTERN int        MatLoad(PetscViewer,MatType,Mat*);
261 EXTERN int        MatMerge(MPI_Comm,Mat,Mat*);
262 
263 EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
264 EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
265 EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *);
266 EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *);
267 
268 /*S
269      MatInfo - Context of matrix information, used with MatGetInfo()
270 
271    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
272 
273    Level: intermediate
274 
275   Concepts: matrix^nonzero information
276 
277 .seealso:  MatGetInfo(), MatInfoType
278 S*/
279 typedef struct {
280   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
281   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
282   PetscLogDouble block_size;                         /* block size */
283   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
284   PetscLogDouble memory;                             /* memory allocated */
285   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
286   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
287   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
288   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
289 } MatInfo;
290 
291 /*E
292     MatInfoType - Indicates if you want information about the local part of the matrix,
293      the entire parallel matrix or the maximum over all the local parts.
294 
295     Level: beginner
296 
297    Any additions/changes here MUST also be made in include/finclude/petscmat.h
298 
299 .seealso: MatGetInfo(), MatInfo
300 E*/
301 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
302 EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*);
303 EXTERN int MatValid(Mat,PetscTruth*);
304 EXTERN int MatGetDiagonal(Mat,Vec);
305 EXTERN int MatGetRowMax(Mat,Vec);
306 EXTERN int MatTranspose(Mat,Mat*);
307 EXTERN int MatPermute(Mat,IS,IS,Mat *);
308 EXTERN int MatPermuteSparsify(Mat,int,PetscReal,PetscReal,IS,IS,Mat *);
309 EXTERN int MatDiagonalScale(Mat,Vec,Vec);
310 EXTERN int MatDiagonalSet(Mat,Vec,InsertMode);
311 EXTERN int MatEqual(Mat,Mat,PetscTruth*);
312 
313 EXTERN int MatNorm(Mat,NormType,PetscReal *);
314 EXTERN int MatZeroEntries(Mat);
315 EXTERN int MatZeroRows(Mat,IS,PetscScalar*);
316 EXTERN int MatZeroColumns(Mat,IS,PetscScalar*);
317 
318 EXTERN int MatUseScaledForm(Mat,PetscTruth);
319 EXTERN int MatScaleSystem(Mat,Vec,Vec);
320 EXTERN int MatUnScaleSystem(Mat,Vec,Vec);
321 
322 EXTERN int MatGetSize(Mat,int*,int*);
323 EXTERN int MatGetLocalSize(Mat,int*,int*);
324 EXTERN int MatGetOwnershipRange(Mat,int*,int*);
325 
326 /*E
327     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
328      or MatGetSubMatrix() are to be reused to store the new matrix values.
329 
330     Level: beginner
331 
332    Any additions/changes here MUST also be made in include/finclude/petscmat.h
333 
334 .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
335 E*/
336 typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
337 EXTERN int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **);
338 EXTERN int MatDestroyMatrices(int,Mat **);
339 EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *);
340 
341 EXTERN int MatIncreaseOverlap(Mat,int,IS *,int);
342 
343 EXTERN int MatAXPY(PetscScalar *,Mat,Mat,MatStructure);
344 EXTERN int MatAYPX(PetscScalar *,Mat,Mat);
345 EXTERN int MatCompress(Mat);
346 
347 EXTERN int MatScale(PetscScalar *,Mat);
348 EXTERN int MatShift(PetscScalar *,Mat);
349 
350 EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
351 EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
352 EXTERN int MatZeroRowsLocal(Mat,IS,PetscScalar*);
353 EXTERN int MatSetValuesLocal(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
354 EXTERN int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,PetscScalar*,InsertMode);
355 
356 EXTERN int MatSetStashInitialSize(Mat,int,int);
357 
358 EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec);
359 EXTERN int MatInterpolate(Mat,Vec,Vec);
360 EXTERN int MatRestrict(Mat,Vec,Vec);
361 
362 
363 /*MC
364    MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per
365        row in a matrix providing the data that one can use to correctly preallocate the matrix.
366 
367    Synopsis:
368    int MatPreallocateInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz)
369 
370    Collective on MPI_Comm
371 
372    Input Parameters:
373 +  comm - the communicator that will share the eventually allocated matrix
374 .  nrows - the number of rows in the matrix
375 -  ncols - the number of columns in the matrix
376 
377    Output Parameters:
378 +  dnz - the array that will be passed to the matrix preallocation routines
379 -  ozn - the other array passed to the matrix preallocation routines
380 
381 
382    Level: intermediate
383 
384    Notes:
385    See the chapter in the users manual on performance for more details
386 
387    Do not malloc or free dnz and onz that is handled internally by these routines
388 
389    Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices)
390 
391   Concepts: preallocation^Matrix
392 
393 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
394           MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal()
395 M*/
396 #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
397 { \
398   int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
399   _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
400   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\
401   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
402   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
403 
404 /*MC
405    MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per
406        row in a matrix providing the data that one can use to correctly preallocate the matrix.
407 
408    Synopsis:
409    int MatPreallocateSymmetricInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz)
410 
411    Collective on MPI_Comm
412 
413    Input Parameters:
414 +  comm - the communicator that will share the eventually allocated matrix
415 .  nrows - the number of rows in the matrix
416 -  ncols - the number of columns in the matrix
417 
418    Output Parameters:
419 +  dnz - the array that will be passed to the matrix preallocation routines
420 -  ozn - the other array passed to the matrix preallocation routines
421 
422 
423    Level: intermediate
424 
425    Notes:
426    See the chapter in the users manual on performance for more details
427 
428    Do not malloc or free dnz and onz that is handled internally by these routines
429 
430   Concepts: preallocation^Matrix
431 
432 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
433           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
434 M*/
435 #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \
436 { \
437   int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__end; \
438   _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
439   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\
440   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\
441   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
442 
443 /*MC
444    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
445        inserted using a local number of the rows and columns
446 
447    Synopsis:
448    int MatPreallocateSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
449 
450    Not Collective
451 
452    Input Parameters:
453 +  map - the mapping between local numbering and global numbering
454 .  nrows - the number of rows indicated
455 .  rows - the indices of the rows (these will be mapped in the
456 .  ncols - the number of columns in the matrix
457 .  cols - the columns indicated
458 .  dnz - the array that will be passed to the matrix preallocation routines
459 -  ozn - the other array passed to the matrix preallocation routines
460 
461 
462    Level: intermediate
463 
464    Notes:
465    See the chapter in the users manual on performance for more details
466 
467    Do not malloc or free dnz and onz that is handled internally by these routines
468 
469   Concepts: preallocation^Matrix
470 
471 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
472           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
473 M*/
474 #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
475 {\
476   int __l;\
477   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
478   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
479   for (__l=0;__l<nrows;__l++) {\
480     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
481   }\
482 }
483 
484 /*MC
485    MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
486        inserted using a local number of the rows and columns
487 
488    Synopsis:
489    int MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
490 
491    Not Collective
492 
493    Input Parameters:
494 +  map - the mapping between local numbering and global numbering
495 .  nrows - the number of rows indicated
496 .  rows - the indices of the rows (these will be mapped in the
497 .  ncols - the number of columns in the matrix
498 .  cols - the columns indicated
499 .  dnz - the array that will be passed to the matrix preallocation routines
500 -  ozn - the other array passed to the matrix preallocation routines
501 
502 
503    Level: intermediate
504 
505    Notes:
506    See the chapter in the users manual on performance for more details
507 
508    Do not malloc or free dnz and onz that is handled internally by these routines
509 
510   Concepts: preallocation^Matrix
511 
512 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
513           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
514 M*/
515 #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
516 {\
517   int __l;\
518   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
519   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
520   for (__l=0;__l<nrows;__l++) {\
521     _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
522   }\
523 }
524 
525 /*MC
526    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
527        inserted using a local number of the rows and columns
528 
529    Synopsis:
530    int MatPreallocateSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
531 
532    Not Collective
533 
534    Input Parameters:
535 +  nrows - the number of rows indicated
536 .  rows - the indices of the rows (these will be mapped in the
537 .  ncols - the number of columns in the matrix
538 .  cols - the columns indicated
539 .  dnz - the array that will be passed to the matrix preallocation routines
540 -  ozn - the other array passed to the matrix preallocation routines
541 
542 
543    Level: intermediate
544 
545    Notes:
546    See the chapter in the users manual on performance for more details
547 
548    Do not malloc or free dnz and onz that is handled internally by these routines
549 
550   Concepts: preallocation^Matrix
551 
552 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
553           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
554 M*/
555 #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
556 { int __i; \
557   for (__i=0; __i<nc; __i++) {\
558     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
559   }\
560   dnz[row - __rstart] = nc - onz[row - __rstart];\
561 }
562 
563 /*MC
564    MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
565        inserted using a local number of the rows and columns
566 
567    Synopsis:
568    int MatPreallocateSymmetricSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz)
569 
570    Not Collective
571 
572    Input Parameters:
573 +  nrows - the number of rows indicated
574 .  rows - the indices of the rows (these will be mapped in the
575 .  ncols - the number of columns in the matrix
576 .  cols - the columns indicated
577 .  dnz - the array that will be passed to the matrix preallocation routines
578 -  ozn - the other array passed to the matrix preallocation routines
579 
580 
581    Level: intermediate
582 
583    Notes:
584    See the chapter in the users manual on performance for more details
585 
586    Do not malloc or free dnz and onz that is handled internally by these routines
587 
588   Concepts: preallocation^Matrix
589 
590 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
591           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
592 M*/
593 #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\
594 { int __i; \
595   for (__i=0; __i<nc; __i++) {\
596     if (cols[__i] >= __end) onz[row - __rstart]++; \
597     else if (cols[__i] >= row) dnz[row - __rstart]++;\
598   }\
599 }
600 
601 /*MC
602    MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per
603        row in a matrix providing the data that one can use to correctly preallocate the matrix.
604 
605    Synopsis:
606    int MatPreallocateFinalize(int *dnz, int *onz)
607 
608    Collective on MPI_Comm
609 
610    Input Parameters:
611 +  dnz - the array that will be passed to the matrix preallocation routines
612 -  ozn - the other array passed to the matrix preallocation routines
613 
614 
615    Level: intermediate
616 
617    Notes:
618    See the chapter in the users manual on performance for more details
619 
620    Do not malloc or free dnz and onz that is handled internally by these routines
621 
622   Concepts: preallocation^Matrix
623 
624 .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
625           MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal()
626 M*/
627 #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);}
628 
629 
630 
631 /* Routines unique to particular data structures */
632 EXTERN int MatShellGetContext(Mat,void **);
633 
634 EXTERN int MatBDiagGetData(Mat,int*,int*,int**,int**,PetscScalar***);
635 EXTERN int MatSeqAIJSetColumnIndices(Mat,int *);
636 EXTERN int MatSeqBAIJSetColumnIndices(Mat,int *);
637 EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int*,int*,PetscScalar *,Mat*);
638 
639 EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,int*);
640 EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,int*);
641 EXTERN int MatSeqAIJSetPreallocation(Mat,int,int*);
642 EXTERN int MatSeqDensePreallocation(Mat,PetscScalar*);
643 EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,int*,PetscScalar**);
644 EXTERN int MatSeqDenseSetPreallocation(Mat,PetscScalar*);
645 
646 EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,int*,int,int*);
647 EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,int*,int,int*);
648 EXTERN int MatMPIAIJSetPreallocation(Mat,int,int*,int,int*);
649 EXTERN int MatMPIDensePreallocation(Mat,PetscScalar*);
650 EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,int*,PetscScalar**);
651 EXTERN int MatMPIAdjSetPreallocation(Mat,int*,int*,int*);
652 EXTERN int MatMPIDenseSetPreallocation(Mat,PetscScalar*);
653 EXTERN int MatMPIRowbsSetPreallocation(Mat,int,int*);
654 EXTERN int MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,int**);
655 EXTERN int MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,int**);
656 EXTERN int MatAdicSetLocalFunction(Mat,void (*)(void));
657 
658 EXTERN int MatSeqDenseSetLDA(Mat,int);
659 
660 EXTERN int MatStoreValues(Mat);
661 EXTERN int MatRetrieveValues(Mat);
662 
663 EXTERN int MatDAADSetCtx(Mat,void*);
664 
665 /*
666   These routines are not usually accessed directly, rather solving is
667   done through the SLES, KSP and PC interfaces.
668 */
669 
670 /*E
671     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
672        with an optional dynamic library name, for example
673        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
674 
675    Level: beginner
676 
677 .seealso: MatGetOrdering()
678 E*/
679 typedef char* MatOrderingType;
680 #define MATORDERING_NATURAL   "natural"
681 #define MATORDERING_ND        "nd"
682 #define MATORDERING_1WD       "1wd"
683 #define MATORDERING_RCM       "rcm"
684 #define MATORDERING_QMD       "qmd"
685 #define MATORDERING_ROWLENGTH "rowlength"
686 #define MATORDERING_DSC_ND    "dsc_nd"
687 #define MATORDERING_DSC_MMD   "dsc_mmd"
688 #define MATORDERING_DSC_MDF   "dsc_mdf"
689 #define MATORDERING_CONSTRAINED "constrained"
690 #define MATORDERING_IDENTITY  "identity"
691 #define MATORDERING_REVERSE   "reverse"
692 
693 EXTERN int MatGetOrdering(Mat,MatOrderingType,IS*,IS*);
694 EXTERN int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*));
695 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
696 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
697 #else
698 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
699 #endif
700 EXTERN int        MatOrderingRegisterDestroy(void);
701 EXTERN int        MatOrderingRegisterAll(char*);
702 extern PetscTruth MatOrderingRegisterAllCalled;
703 extern PetscFList      MatOrderingList;
704 
705 EXTERN int MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
706 
707 /*S
708    MatFactorInfo - Data based into the matrix factorization routines
709 
710    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE
711 
712    Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.
713 
714    Level: developer
715 
716 .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor()
717 
718 S*/
719 typedef struct {
720   PetscReal     damping;        /* scaling of identity added to matrix to prevent zero pivots */
721   PetscReal     shift;          /* if true, shift until positive pivots */
722   PetscReal     shift_fraction; /* record shift fraction taken */
723   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
724   PetscReal     dt;             /* drop tolerance */
725   PetscReal     dtcol;          /* tolerance for pivoting */
726   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
727   PetscReal     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
728   PetscReal     levels;         /* ICC/ILU(levels) */
729   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
730                                    factorization may be faster if do not pivot */
731   PetscReal     zeropivot;      /* pivot is called zero if less than this */
732 } MatFactorInfo;
733 
734 EXTERN int MatCholeskyFactor(Mat,IS,MatFactorInfo*);
735 EXTERN int MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
736 EXTERN int MatCholeskyFactorNumeric(Mat,Mat*);
737 EXTERN int MatLUFactor(Mat,IS,IS,MatFactorInfo*);
738 EXTERN int MatILUFactor(Mat,IS,IS,MatFactorInfo*);
739 EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
740 EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
741 EXTERN int MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
742 EXTERN int MatICCFactor(Mat,IS,MatFactorInfo*);
743 EXTERN int MatLUFactorNumeric(Mat,Mat*);
744 EXTERN int MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *);
745 EXTERN int MatGetInertia(Mat,int*,int*,int*);
746 EXTERN int MatSolve(Mat,Vec,Vec);
747 EXTERN int MatForwardSolve(Mat,Vec,Vec);
748 EXTERN int MatBackwardSolve(Mat,Vec,Vec);
749 EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec);
750 EXTERN int MatSolveTranspose(Mat,Vec,Vec);
751 EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
752 EXTERN int MatSolves(Mat,Vecs,Vecs);
753 
754 EXTERN int MatSetUnfactored(Mat);
755 
756 /*  MatSORType may be bitwise ORd together, so do not change the numbers */
757 /*E
758     MatSORType - What type of (S)SOR to perform
759 
760     Level: beginner
761 
762    May be bitwise ORd together
763 
764    Any additions/changes here MUST also be made in include/finclude/petscmat.h
765 
766 .seealso: MatRelax()
767 E*/
768 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
769               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
770               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
771               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
772 EXTERN int MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,int,int,Vec);
773 
774 /*
775     These routines are for efficiently computing Jacobians via finite differences.
776 */
777 
778 /*E
779     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
780        with an optional dynamic library name, for example
781        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
782 
783    Level: beginner
784 
785 .seealso: MatGetColoring()
786 E*/
787 typedef char* MatColoringType;
788 #define MATCOLORING_NATURAL "natural"
789 #define MATCOLORING_SL      "sl"
790 #define MATCOLORING_LF      "lf"
791 #define MATCOLORING_ID      "id"
792 
793 EXTERN int MatGetColoring(Mat,MatColoringType,ISColoring*);
794 EXTERN int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *));
795 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
796 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
797 #else
798 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
799 #endif
800 EXTERN int        MatColoringRegisterAll(char *);
801 extern PetscTruth MatColoringRegisterAllCalled;
802 EXTERN int        MatColoringRegisterDestroy(void);
803 EXTERN int        MatColoringPatch(Mat,int,int,ISColoringValue *,ISColoring*);
804 
805 /*S
806      MatFDColoring - Object for computing a sparse Jacobian via finite differences
807         and coloring
808 
809    Level: beginner
810 
811   Concepts: coloring, sparse Jacobian, finite differences
812 
813 .seealso:  MatFDColoringCreate()
814 S*/
815 typedef struct _p_MatFDColoring *MatFDColoring;
816 
817 EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
818 EXTERN int MatFDColoringDestroy(MatFDColoring);
819 EXTERN int MatFDColoringView(MatFDColoring,PetscViewer);
820 EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*);
821 EXTERN int MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
822 EXTERN int MatFDColoringSetFrequency(MatFDColoring,int);
823 EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*);
824 EXTERN int MatFDColoringSetFromOptions(MatFDColoring);
825 EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
826 EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
827 EXTERN int MatFDColoringSetRecompute(MatFDColoring);
828 EXTERN int MatFDColoringSetF(MatFDColoring,Vec);
829 EXTERN int MatFDColoringGetPerturbedColumns(MatFDColoring,int*,int**);
830 /*
831     These routines are for partitioning matrices: currently used only
832   for adjacency matrix, MatCreateMPIAdj().
833 */
834 
835 /*S
836      MatPartitioning - Object for managing the partitioning of a matrix or graph
837 
838    Level: beginner
839 
840   Concepts: partitioning
841 
842 .seealso:  MatPartitioningCreate(), MatPartitioningType
843 S*/
844 typedef struct _p_MatPartitioning *MatPartitioning;
845 
846 /*E
847     MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function
848        with an optional dynamic library name, for example
849        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
850 
851    Level: beginner
852 
853 .seealso: MatPartitioningCreate(), MatPartitioning
854 E*/
855 typedef char* MatPartitioningType;
856 #define MAT_PARTITIONING_CURRENT  "current"
857 #define MAT_PARTITIONING_PARMETIS "parmetis"
858 
859 EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*);
860 EXTERN int MatPartitioningSetType(MatPartitioning,MatPartitioningType);
861 EXTERN int MatPartitioningSetNParts(MatPartitioning,int);
862 EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat);
863 EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,int*);
864 EXTERN int MatPartitioningApply(MatPartitioning,IS*);
865 EXTERN int MatPartitioningDestroy(MatPartitioning);
866 
867 EXTERN int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning));
868 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
869 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
870 #else
871 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
872 #endif
873 
874 EXTERN int        MatPartitioningRegisterAll(char *);
875 extern PetscTruth MatPartitioningRegisterAllCalled;
876 EXTERN int        MatPartitioningRegisterDestroy(void);
877 
878 EXTERN int MatPartitioningView(MatPartitioning,PetscViewer);
879 EXTERN int MatPartitioningSetFromOptions(MatPartitioning);
880 EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
881 
882 EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
883 
884 /*
885     If you add entries here you must also add them to finclude/petscmat.h
886 */
887 typedef enum { MATOP_SET_VALUES=0,
888                MATOP_GET_ROW=1,
889                MATOP_RESTORE_ROW=2,
890                MATOP_MULT=3,
891                MATOP_MULT_ADD=4,
892                MATOP_MULT_TRANSPOSE=5,
893                MATOP_MULT_TRANSPOSE_ADD=6,
894                MATOP_SOLVE=7,
895                MATOP_SOLVE_ADD=8,
896                MATOP_SOLVE_TRANSPOSE=9,
897                MATOP_SOLVE_TRANSPOSE_ADD=10,
898                MATOP_LUFACTOR=11,
899                MATOP_CHOLESKYFACTOR=12,
900                MATOP_RELAX=13,
901                MATOP_TRANSPOSE=14,
902                MATOP_GETINFO=15,
903                MATOP_EQUAL=16,
904                MATOP_GET_DIAGONAL=17,
905                MATOP_DIAGONAL_SCALE=18,
906                MATOP_NORM=19,
907                MATOP_ASSEMBLY_BEGIN=20,
908                MATOP_ASSEMBLY_END=21,
909                MATOP_COMPRESS=22,
910                MATOP_SET_OPTION=23,
911                MATOP_ZERO_ENTRIES=24,
912                MATOP_ZERO_ROWS=25,
913                MATOP_LUFACTOR_SYMBOLIC=26,
914                MATOP_LUFACTOR_NUMERIC=27,
915                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
916                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
917                MATOP_SETUP_PREALLOCATION=30,
918                MATOP_ILUFACTOR_SYMBOLIC=31,
919                MATOP_ICCFACTOR_SYMBOLIC=32,
920                MATOP_GET_ARRAY=33,
921                MATOP_RESTORE_ARRAY=34,
922                MATOP_DUPLCIATE=35,
923                MATOP_FORWARD_SOLVE=36,
924                MATOP_BACKWARD_SOLVE=37,
925                MATOP_ILUFACTOR=38,
926                MATOP_ICCFACTOR=39,
927                MATOP_AXPY=40,
928                MATOP_GET_SUBMATRICES=41,
929                MATOP_INCREASE_OVERLAP=42,
930                MATOP_GET_VALUES=43,
931                MATOP_COPY=44,
932                MATOP_PRINT_HELP=45,
933                MATOP_SCALE=46,
934                MATOP_SHIFT=47,
935                MATOP_DIAGONAL_SHIFT=48,
936                MATOP_ILUDT_FACTOR=49,
937                MATOP_GET_BLOCK_SIZE=50,
938                MATOP_GET_ROW_IJ=51,
939                MATOP_RESTORE_ROW_IJ=52,
940                MATOP_GET_COLUMN_IJ=53,
941                MATOP_RESTORE_COLUMN_IJ=54,
942                MATOP_FDCOLORING_CREATE=55,
943                MATOP_COLORING_PATCH=56,
944                MATOP_SET_UNFACTORED=57,
945                MATOP_PERMUTE=58,
946                MATOP_SET_VALUES_BLOCKED=59,
947                MATOP_GET_SUBMATRIX=60,
948                MATOP_DESTROY=61,
949                MATOP_VIEW=62,
950                MATOP_GET_MAPS=63,
951                MATOP_USE_SCALED_FORM=64,
952                MATOP_SCALE_SYSTEM=65,
953                MATOP_UNSCALE_SYSTEM=66,
954                MATOP_SET_LOCAL_TO_GLOBAL_MAPPING=67,
955                MATOP_SET_VALUES_LOCAL=68,
956                MATOP_ZERO_ROWS_LOCAL=69,
957                MATOP_GET_ROW_MAX=70,
958                MATOP_CONVERT=71,
959                MATOP_SET_COLORING=72,
960                MATOP_SET_VALUES_ADIC=73,
961                MATOP_SET_VALUES_ADIFOR=74,
962                MATOP_FD_COLORING_APPLY=75,
963                MATOP_SET_FROM_OPTIONS=76,
964                MATOP_MULT_CONSTRAINED=77,
965                MATOP_MULT_TRANSPOSE_CONSTRAINED=78,
966                MATOP_ILU_FACTOR_SYMBOLIC_CONSTRAINED=79,
967                MATOP_PERMUTE_SPARSIFY=80,
968                MATOP_MULT_MULTIPLE=81,
969                MATOP_SOLVE_MULTIPLE=82
970              } MatOperation;
971 EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*);
972 EXTERN int MatShellSetOperation(Mat,MatOperation,void(*)(void));
973 EXTERN int MatShellGetOperation(Mat,MatOperation,void(**)(void));
974 EXTERN int MatShellSetContext(Mat,void*);
975 
976 /*
977    Codes for matrices stored on disk. By default they are
978  stored in a universal format. By changing the format with
979  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
980  be stored in a way natural for the matrix, for example dense matrices
981  would be stored as dense. Matrices stored this way may only be
982  read into matrices of the same time.
983 */
984 #define MATRIX_BINARY_FORMAT_DENSE -1
985 
986 /*
987      New matrix classes not yet distributed
988 */
989 /*
990     MatAIJIndices is a data structure for storing the nonzero location information
991   for sparse matrices. Several matrices with identical nonzero structure can share
992   the same MatAIJIndices.
993 */
994 typedef struct _p_MatAIJIndices* MatAIJIndices;
995 
996 EXTERN int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*);
997 EXTERN int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*);
998 EXTERN int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*);
999 EXTERN int MatDestroyAIJIndices(MatAIJIndices);
1000 EXTERN int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*);
1001 EXTERN int MatValidateAIJIndices(int,MatAIJIndices);
1002 EXTERN int MatShiftAIJIndices(MatAIJIndices);
1003 EXTERN int MatShrinkAIJIndices(MatAIJIndices);
1004 EXTERN int MatTransposeAIJIndices(MatAIJIndices,MatAIJIndices*);
1005 
1006 EXTERN int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*);
1007 EXTERN int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*);
1008 EXTERN int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,PetscScalarPrecision,Mat*);
1009 
1010 EXTERN int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *);
1011 EXTERN int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *);
1012 EXTERN int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,PetscScalarPrecision,Mat *);
1013 
1014 EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
1015 EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *);
1016 EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *);
1017 
1018 /*S
1019      MatNullSpace - Object that removes a null space from a vector, i.e.
1020          orthogonalizes the vector to a subsapce
1021 
1022    Level: advanced
1023 
1024   Concepts: matrix; linear operator, null space
1025 
1026   Users manual sections:
1027 .   sec_singular
1028 
1029 .seealso:  MatNullSpaceCreate()
1030 S*/
1031 typedef struct _p_MatNullSpace* MatNullSpace;
1032 
1033 EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,Vec *,MatNullSpace*);
1034 EXTERN int MatNullSpaceDestroy(MatNullSpace);
1035 EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
1036 EXTERN int MatNullSpaceAttach(Mat,MatNullSpace);
1037 EXTERN int MatNullSpaceTest(MatNullSpace,Mat);
1038 
1039 EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp);
1040 EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1041 EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *);
1042 
1043 EXTERN int MatMatMult(Mat A,Mat B, Mat *C);
1044 EXTERN int MatMatMultSymbolic(Mat A,Mat B,Mat *C);
1045 EXTERN int MatMatMultNumeric(Mat A,Mat B,Mat C);
1046 
1047 EXTERN int MatCreateMAIJ(Mat,int,Mat*);
1048 EXTERN int MatMAIJRedimension(Mat,int,Mat*);
1049 EXTERN int MatMAIJGetAIJ(Mat,Mat*);
1050 
1051 EXTERN int MatMPIAdjSetValues(Mat,int*,int*,int*);
1052 
1053 EXTERN int MatComputeExplicitOperator(Mat,Mat*);
1054 
1055 EXTERN int MatESISetType(Mat,char*);
1056 EXTERN int MatESISetFromOptions(Mat);
1057 
1058 EXTERN int MatDiagonalScaleLocal(Mat,Vec);
1059 
1060 EXTERN int PetscViewerMathematicaPutMatrix(PetscViewer, int, int, PetscReal *);
1061 EXTERN int PetscViewerMathematicaPutCSRMatrix(PetscViewer, int, int, int *, int *, PetscReal *);
1062 
1063 EXTERN int MatUseSpooles_SeqAIJ(Mat);
1064 EXTERN int MatUseUMFPACK_SeqAIJ(Mat);
1065 EXTERN int MatUseSuperLU_SeqAIJ(Mat);
1066 EXTERN int MatUseEssl_SeqAIJ(Mat);
1067 EXTERN int MatUseLUSOL_SeqAIJ(Mat);
1068 EXTERN int MatUseMatlab_SeqAIJ(Mat);
1069 EXTERN int MatUseDXML_SeqAIJ(Mat);
1070 EXTERN int MatUsePETSc_SeqAIJ(Mat);
1071 EXTERN int MatUseSuperLU_DIST_MPIAIJ(Mat);
1072 EXTERN int MatUseSpooles_MPIAIJ(Mat);
1073 EXTERN int MatUseSpooles_SeqSBAIJ(Mat);
1074 EXTERN int MatUseSpooles_MPISBAIJ(Mat);
1075 EXTERN int MatUseMUMPS_MPIAIJ(Mat);
1076 
1077 #endif
1078 
1079 
1080 
1081