xref: /petsc/include/petscmat.h (revision be1d678a52e6eff2808b2fa31ae986cdbf03c9fe)
1 /*
2      Include file for the matrix component of PETSc
3 */
4 #ifndef __PETSCMAT_H
5 #define __PETSCMAT_H
6 #include "petscvec.h"
7 PETSC_EXTERN_CXX_BEGIN
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 MATMAIJ            "maij"
33 #define MATIS              "is"
34 #define MATMPIROWBS        "mpirowbs"
35 #define MATSEQAIJ          "seqaij"
36 #define MATMPIAIJ          "mpiaij"
37 #define MATAIJ             "aij"
38 #define MATSHELL           "shell"
39 #define MATSEQBDIAG        "seqbdiag"
40 #define MATMPIBDIAG        "mpibdiag"
41 #define MATBDIAG           "bdiag"
42 #define MATSEQDENSE        "seqdense"
43 #define MATMPIDENSE        "mpidense"
44 #define MATDENSE           "dense"
45 #define MATSEQBAIJ         "seqbaij"
46 #define MATMPIBAIJ         "mpibaij"
47 #define MATBAIJ            "baij"
48 #define MATMPIADJ          "mpiadj"
49 #define MATSEQSBAIJ        "seqsbaij"
50 #define MATMPISBAIJ        "mpisbaij"
51 #define MATSBAIJ           "sbaij"
52 #define MATDAAD            "daad"
53 #define MATMFFD            "mffd"
54 #define MATNORMAL          "normal"
55 #define MATSEQAIJSPOOLES   "seqaijspooles"
56 #define MATMPIAIJSPOOLES   "mpiaijspooles"
57 #define MATSEQSBAIJSPOOLES "seqsbaijspooles"
58 #define MATMPISBAIJSPOOLES "mpisbaijspooles"
59 #define MATAIJSPOOLES      "aijspooles"
60 #define MATSBAIJSPOOLES    "sbaijspooles"
61 #define MATSUPERLU         "superlu"
62 #define MATSUPERLU_DIST    "superlu_dist"
63 #define MATUMFPACK         "umfpack"
64 #define MATESSL            "essl"
65 #define MATLUSOL           "lusol"
66 #define MATAIJMUMPS        "aijmumps"
67 #define MATSBAIJMUMPS      "sbaijmumps"
68 #define MATDSCPACK         "dscpack"
69 #define MATMATLAB          "matlab"
70 #define MatType char*
71 
72 /* Logging support */
73 #define    MAT_FILE_COOKIE 1211216    /* used to indicate matrices in binary files */
74 extern PetscCookie PETSCMAT_DLLEXPORT MAT_COOKIE;
75 extern PetscCookie PETSCMAT_DLLEXPORT MATSNESMFCTX_COOKIE;
76 extern PetscCookie PETSCMAT_DLLEXPORT MAT_FDCOLORING_COOKIE;
77 extern PetscCookie PETSCMAT_DLLEXPORT MAT_PARTITIONING_COOKIE;
78 extern PetscCookie PETSCMAT_DLLEXPORT MAT_NULLSPACE_COOKIE;
79 extern PetscEvent  MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose;
80 extern PetscEvent  MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose;
81 extern PetscEvent  MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic;
82 extern PetscEvent  MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor;
83 extern PetscEvent  MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin;
84 extern PetscEvent  MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering;
85 extern PetscEvent  MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate;
86 extern PetscEvent  MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction;
87 extern PetscEvent  MAT_MatMult, MAT_MatMultSymbolic, MAT_MatMultNumeric;
88 extern PetscEvent  MAT_PtAP, MAT_PtAPSymbolic, MAT_PtAPNumeric;
89 extern PetscEvent  MAT_MatMultTranspose, MAT_MatMultTransposeSymbolic, MAT_MatMultTransposeNumeric;
90 
91 /*E
92     MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices()
93      or MatGetSubMatrix() are to be reused to store the new matrix values.
94 
95     Level: beginner
96 
97    Any additions/changes here MUST also be made in include/finclude/petscmat.h
98 
99 .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices()
100 E*/
101 typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse;
102 
103 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInitializePackage(char *);
104 
105 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreate(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*);
106 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetType(Mat,const MatType);
107 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetFromOptions(Mat);
108 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUpPreallocation(Mat);
109 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegisterAll(const char[]);
110 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat));
111 
112 /*MC
113    MatRegisterDynamic - Adds a new matrix type
114 
115    Synopsis:
116    PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat))
117 
118    Not Collective
119 
120    Input Parameters:
121 +  name - name of a new user-defined matrix type
122 .  path - path (either absolute or relative) the library containing this solver
123 .  name_create - name of routine to create method context
124 -  routine_create - routine to create method context
125 
126    Notes:
127    MatRegisterDynamic() may be called multiple times to add several user-defined solvers.
128 
129    If dynamic libraries are used, then the fourth input argument (routine_create)
130    is ignored.
131 
132    Sample usage:
133 .vb
134    MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a,
135                "MyMatCreate",MyMatCreate);
136 .ve
137 
138    Then, your solver can be chosen with the procedural interface via
139 $     MatSetType(Mat,"my_mat")
140    or at runtime via the option
141 $     -mat_type my_mat
142 
143    Level: advanced
144 
145    Notes: ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
146          If your function is not being put into a shared library then use VecRegister() instead
147 
148 .keywords: Mat, register
149 
150 .seealso: MatRegisterAll(), MatRegisterDestroy()
151 
152 M*/
153 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
154 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0)
155 #else
156 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d)
157 #endif
158 
159 extern PetscTruth MatRegisterAllCalled;
160 extern PetscFList MatList;
161 
162 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*);
163 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*);
164 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
165 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
166 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
167 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
168 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*);
169 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
170 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
171 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*);
172 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*);
173 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*);
174 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*);
175 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*);
176 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateNormal(Mat,Mat*);
177 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroy(Mat);
178 
179 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPrintHelp(Mat);
180 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetPetscMaps(Mat,PetscMap*,PetscMap*);
181 
182 /* ------------------------------------------------------------*/
183 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
184 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
185 
186 /*S
187      MatStencil - Data structure (C struct) for storing information about a single row or
188         column of a matrix as index on an associated grid.
189 
190    Level: beginner
191 
192   Concepts: matrix; linear operator
193 
194 .seealso:  MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil()
195 S*/
196 typedef struct {
197   PetscInt k,j,i,c;
198 } MatStencil;
199 
200 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
201 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode);
202 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt);
203 
204 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetColoring(Mat,ISColoring);
205 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesAdic(Mat,void*);
206 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesAdifor(Mat,PetscInt,void*);
207 
208 /*E
209     MatAssemblyType - Indicates if the matrix is now to be used, or if you plan
210      to continue to add values to it
211 
212     Level: beginner
213 
214 .seealso: MatAssemblyBegin(), MatAssemblyEnd()
215 E*/
216 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType;
217 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssemblyBegin(Mat,MatAssemblyType);
218 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssemblyEnd(Mat,MatAssemblyType);
219 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAssembled(Mat,PetscTruth*);
220 
221 extern PETSCMAT_DLLEXPORT PetscInt    MatSetValue_Row;
222 extern PETSCMAT_DLLEXPORT PetscInt    MatSetValue_Column;
223 extern PETSCMAT_DLLEXPORT PetscScalar MatSetValue_Value;
224 
225 /*MC
226    MatSetValue - Set a single entry into a matrix.
227 
228    Synopsis:
229    PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode);
230 
231    Not collective
232 
233    Input Parameters:
234 +  m - the matrix
235 .  row - the row location of the entry
236 .  col - the column location of the entry
237 .  value - the value to insert
238 -  mode - either INSERT_VALUES or ADD_VALUES
239 
240    Notes:
241    For efficiency one should use MatSetValues() and set several or many
242    values simultaneously if possible.
243 
244    Level: beginner
245 
246 .seealso: MatSetValues(), MatSetValueLocal()
247 M*/
248 #define MatSetValue(v,i,j,va,mode) \
249   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
250    MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
251 
252 #define MatGetValue(v,i,j,va) \
253   ((MatSetValue_Row = i,MatSetValue_Column = j,0) || \
254    MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va))
255 
256 #define MatSetValueLocal(v,i,j,va,mode) \
257   ((MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va,0) || \
258    MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode))
259 
260 /*E
261     MatOption - Options that may be set for a matrix and its behavior or storage
262 
263     Level: beginner
264 
265    Any additions/changes here MUST also be made in include/finclude/petscmat.h
266 
267 .seealso: MatSetOption()
268 E*/
269 typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4,
270               MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16,
271               MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64,
272               MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66,
273               MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69,
274               MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72,
275               MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74,
276               MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76,
277               MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78,
278               MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81,
279               MAT_DO_NOT_USE_INODES=82,MAT_NOT_SYMMETRIC=83,MAT_HERMITIAN=84,
280               MAT_NOT_STRUCTURALLY_SYMMETRIC=85,MAT_NOT_HERMITIAN=86,
281               MAT_SYMMETRY_ETERNAL=87,MAT_NOT_SYMMETRY_ETERNAL=88,
282               MAT_USE_COMPRESSEDROW=89,MAT_DO_NOT_USE_COMPRESSEDROW=90,
283               MAT_IGNORE_LOWER_TRIANGULAR=91,MAT_ERROR_LOWER_TRIANGULAR=92} MatOption;
284 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetOption(Mat,MatOption);
285 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetType(Mat,MatType*);
286 
287 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]);
288 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
289 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
290 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
291 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]);
292 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumnVector(Mat,Vec,PetscInt);
293 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetArray(Mat,PetscScalar *[]);
294 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreArray(Mat,PetscScalar *[]);
295 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBlockSize(Mat,PetscInt *);
296 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetBlockSize(Mat,PetscInt);
297 
298 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMult(Mat,Vec,Vec);
299 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultAdd(Mat,Vec,Vec,Vec);
300 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTranspose(Mat,Vec,Vec);
301 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*);
302 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeAdd(Mat,Vec,Vec,Vec);
303 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultConstrained(Mat,Vec,Vec);
304 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeConstrained(Mat,Vec,Vec);
305 
306 /*E
307     MatDuplicateOption - Indicates if a duplicated sparse matrix should have
308   its numerical values copied over or just its nonzero structure.
309 
310     Level: beginner
311 
312    Any additions/changes here MUST also be made in include/finclude/petscmat.h
313 
314 .seealso: MatDuplicate()
315 E*/
316 typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption;
317 
318 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegister(const char[],const char[],const char[],PetscErrorCode (*)(Mat,MatType,MatReuse,Mat*));
319 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
320 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0)
321 #else
322 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d)
323 #endif
324 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegisterAll(const char[]);
325 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvertRegisterDestroy(void);
326 extern PetscTruth MatConvertRegisterAllCalled;
327 extern PetscFList MatConvertList;
328 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatConvert(Mat,const MatType,MatReuse,Mat*);
329 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDuplicate(Mat,MatDuplicateOption,Mat*);
330 
331 /*E
332     MatStructure - Indicates if the matrix has the same nonzero structure
333 
334     Level: beginner
335 
336    Any additions/changes here MUST also be made in include/finclude/petscmat.h
337 
338 .seealso: MatCopy(), KSPSetOperators(), PCSetOperators()
339 E*/
340 typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure;
341 
342 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCopy(Mat,Mat,MatStructure);
343 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatView(Mat,PetscViewer);
344 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsSymmetric(Mat,PetscReal,PetscTruth*);
345 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsStructurallySymmetric(Mat,PetscTruth*);
346 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitian(Mat,PetscTruth*);
347 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*);
348 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIsHermitianKnown(Mat,PetscTruth*,PetscTruth*);
349 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLoad(PetscViewer,const MatType,Mat*);
350 
351 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
352 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
353 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *);
354 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *);
355 
356 /*S
357      MatInfo - Context of matrix information, used with MatGetInfo()
358 
359    In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE
360 
361    Level: intermediate
362 
363   Concepts: matrix^nonzero information
364 
365 .seealso:  MatGetInfo(), MatInfoType
366 S*/
367 typedef struct {
368   PetscLogDouble rows_global,columns_global;         /* number of global rows and columns */
369   PetscLogDouble rows_local,columns_local;           /* number of local rows and columns */
370   PetscLogDouble block_size;                         /* block size */
371   PetscLogDouble nz_allocated,nz_used,nz_unneeded;   /* number of nonzeros */
372   PetscLogDouble memory;                             /* memory allocated */
373   PetscLogDouble assemblies;                         /* number of matrix assemblies called */
374   PetscLogDouble mallocs;                            /* number of mallocs during MatSetValues() */
375   PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */
376   PetscLogDouble factor_mallocs;                     /* number of mallocs during factorization */
377 } MatInfo;
378 
379 /*E
380     MatInfoType - Indicates if you want information about the local part of the matrix,
381      the entire parallel matrix or the maximum over all the local parts.
382 
383     Level: beginner
384 
385    Any additions/changes here MUST also be made in include/finclude/petscmat.h
386 
387 .seealso: MatGetInfo(), MatInfo
388 E*/
389 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
390 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetInfo(Mat,MatInfoType,MatInfo*);
391 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatValid(Mat,PetscTruth*);
392 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetDiagonal(Mat,Vec);
393 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetRowMax(Mat,Vec);
394 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatTranspose(Mat,Mat*);
395 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPermute(Mat,IS,IS,Mat *);
396 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *);
397 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScale(Mat,Vec,Vec);
398 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalSet(Mat,Vec,InsertMode);
399 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatEqual(Mat,Mat,PetscTruth*);
400 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultEqual(Mat,Mat,PetscInt,PetscTruth*);
401 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultAddEqual(Mat,Mat,PetscInt,PetscTruth*);
402 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeEqual(Mat,Mat,PetscInt,PetscTruth*);
403 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscTruth*);
404 
405 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNorm(Mat,NormType,PetscReal *);
406 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroEntries(Mat);
407 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRows(Mat,IS,const PetscScalar*);
408 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroColumns(Mat,IS,const PetscScalar*);
409 
410 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatUseScaledForm(Mat,PetscTruth);
411 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScaleSystem(Mat,Vec,Vec);
412 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatUnScaleSystem(Mat,Vec,Vec);
413 
414 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSize(Mat,PetscInt*,PetscInt*);
415 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalSize(Mat,PetscInt*,PetscInt*);
416 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOwnershipRange(Mat,PetscInt*,PetscInt*);
417 
418 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]);
419 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroyMatrices(PetscInt,Mat *[]);
420 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *);
421 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*);
422 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*);
423 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPISymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*);
424 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMerge_SeqsToMPINumeric(Mat,Mat);
425 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDestroy_MPIAIJ_SeqsToMPI(Mat);
426 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalMat(Mat,MatReuse,Mat*);
427 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*);
428 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*);
429 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetBrowsOfAoCols(Mat,Mat,MatReuse,PetscInt**,PetscScalar**,Mat*);
430 
431 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt);
432 
433 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*);
434 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*);
435 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultNumeric(Mat,Mat,Mat);
436 
437 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*);
438 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*);
439 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPtAPNumeric(Mat,Mat,Mat);
440 
441 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*);
442 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*);
443 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMatMultTransposeNumeric(Mat,Mat,Mat);
444 
445 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAXPY(const PetscScalar *,Mat,Mat,MatStructure);
446 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAYPX(const PetscScalar *,Mat,Mat);
447 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCompress(Mat);
448 
449 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatScale(const PetscScalar *,Mat);
450 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShift(const PetscScalar *,Mat);
451 
452 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping);
453 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping);
454 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatZeroRowsLocal(Mat,IS,const PetscScalar*);
455 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
456 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
457 
458 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStashSetInitialSize(Mat,PetscInt,PetscInt);
459 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
460 
461 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInterpolateAdd(Mat,Vec,Vec,Vec);
462 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInterpolate(Mat,Vec,Vec);
463 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRestrict(Mat,Vec,Vec);
464 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetVecs(Mat,Vec*,Vec*);
465 
466 /*MC
467    MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per
468        row in a matrix providing the data that one can use to correctly preallocate the matrix.
469 
470    Synopsis:
471    PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
472 
473    Collective on MPI_Comm
474 
475    Input Parameters:
476 +  comm - the communicator that will share the eventually allocated matrix
477 .  nrows - the number of LOCAL rows in the matrix
478 -  ncols - the number of LOCAL columns in the matrix
479 
480    Output Parameters:
481 +  dnz - the array that will be passed to the matrix preallocation routines
482 -  ozn - the other array passed to the matrix preallocation routines
483 
484 
485    Level: intermediate
486 
487    Notes:
488    See the chapter in the users manual on performance for more details
489 
490    Do not malloc or free dnz and onz, that is handled internally by these routines
491 
492    Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices)
493 
494   Concepts: preallocation^Matrix
495 
496 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
497           MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal()
498 M*/
499 #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \
500 { \
501   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \
502   _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
503   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
504   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\
505   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
506 
507 /*MC
508    MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per
509        row in a matrix providing the data that one can use to correctly preallocate the matrix.
510 
511    Synopsis:
512    PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz)
513 
514    Collective on MPI_Comm
515 
516    Input Parameters:
517 +  comm - the communicator that will share the eventually allocated matrix
518 .  nrows - the number of LOCAL rows in the matrix
519 -  ncols - the number of LOCAL columns in the matrix
520 
521    Output Parameters:
522 +  dnz - the array that will be passed to the matrix preallocation routines
523 -  ozn - the other array passed to the matrix preallocation routines
524 
525 
526    Level: intermediate
527 
528    Notes:
529    See the chapter in the users manual on performance for more details
530 
531    Do not malloc or free dnz and onz, that is handled internally by these routines
532 
533   Concepts: preallocation^Matrix
534 
535 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
536           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
537 M*/
538 #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \
539 { \
540   PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__end; \
541   _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\
542   _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\
543   _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\
544   _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp;
545 
546 /*MC
547    MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
548        inserted using a local number of the rows and columns
549 
550    Synopsis:
551    PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
552 
553    Not Collective
554 
555    Input Parameters:
556 +  map - the mapping between local numbering and global numbering
557 .  nrows - the number of rows indicated
558 .  rows - the indices of the rows
559 .  ncols - the number of columns in the matrix
560 .  cols - the columns indicated
561 .  dnz - the array that will be passed to the matrix preallocation routines
562 -  ozn - the other array passed to the matrix preallocation routines
563 
564 
565    Level: intermediate
566 
567    Notes:
568    See the chapter in the users manual on performance for more details
569 
570    Do not malloc or free dnz and onz, that is handled internally by these routines
571 
572   Concepts: preallocation^Matrix
573 
574 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
575           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal()
576 M*/
577 #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
578 {\
579   PetscInt __l;\
580   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
581   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
582   for (__l=0;__l<nrows;__l++) {\
583     _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
584   }\
585 }
586 
587 /*MC
588    MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be
589        inserted using a local number of the rows and columns
590 
591    Synopsis:
592    PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
593 
594    Not Collective
595 
596    Input Parameters:
597 +  map - the mapping between local numbering and global numbering
598 .  nrows - the number of rows indicated
599 .  rows - the indices of the rows
600 .  ncols - the number of columns in the matrix
601 .  cols - the columns indicated
602 .  dnz - the array that will be passed to the matrix preallocation routines
603 -  ozn - the other array passed to the matrix preallocation routines
604 
605 
606    Level: intermediate
607 
608    Notes:
609    See the chapter in the users manual on performance for more details
610 
611    Do not malloc or free dnz and onz that is handled internally by these routines
612 
613   Concepts: preallocation^Matrix
614 
615 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
616           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
617 M*/
618 #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\
619 {\
620   PetscInt __l;\
621   _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\
622   _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\
623   for (__l=0;__l<nrows;__l++) {\
624     _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\
625   }\
626 }
627 
628 /*MC
629    MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
630        inserted using a local number of the rows and columns
631 
632    Synopsis:
633    PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
634 
635    Not Collective
636 
637    Input Parameters:
638 +  nrows - the number of rows indicated
639 .  rows - the indices of the rows
640 .  ncols - the number of columns in the matrix
641 -  cols - the columns indicated
642 
643    Output Parameters:
644 +  dnz - the array that will be passed to the matrix preallocation routines
645 -  ozn - the other array passed to the matrix preallocation routines
646 
647 
648    Level: intermediate
649 
650    Notes:
651    See the chapter in the users manual on performance for more details
652 
653    Do not malloc or free dnz and onz that is handled internally by these routines
654 
655   Concepts: preallocation^Matrix
656 
657 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
658           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
659 M*/
660 #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\
661 { PetscInt __i; \
662   for (__i=0; __i<nc; __i++) {\
663     if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \
664   }\
665   dnz[row - __rstart] = nc - onz[row - __rstart];\
666 }
667 
668 /*MC
669    MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be
670        inserted using a local number of the rows and columns
671 
672    Synopsis:
673    PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz)
674 
675    Not Collective
676 
677    Input Parameters:
678 +  nrows - the number of rows indicated
679 .  rows - the indices of the rows
680 .  ncols - the number of columns in the matrix
681 .  cols - the columns indicated
682 .  dnz - the array that will be passed to the matrix preallocation routines
683 -  ozn - the other array passed to the matrix preallocation routines
684 
685 
686    Level: intermediate
687 
688    Notes:
689    See the chapter in the users manual on performance for more details
690 
691    Do not malloc or free dnz and onz that is handled internally by these routines
692 
693   Concepts: preallocation^Matrix
694 
695 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(),
696           MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal()
697 M*/
698 #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\
699 { PetscInt __i; \
700   for (__i=0; __i<nc; __i++) {\
701     if (cols[__i] >= __end) onz[row - __rstart]++; \
702     else if (cols[__i] >= row) dnz[row - __rstart]++;\
703   }\
704 }
705 
706 /*MC
707    MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per
708        row in a matrix providing the data that one can use to correctly preallocate the matrix.
709 
710    Synopsis:
711    PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz)
712 
713    Collective on MPI_Comm
714 
715    Input Parameters:
716 +  dnz - the array that will be passed to the matrix preallocation routines
717 -  ozn - the other array passed to the matrix preallocation routines
718 
719 
720    Level: intermediate
721 
722    Notes:
723    See the chapter in the users manual on performance for more details
724 
725    Do not malloc or free dnz and onz that is handled internally by these routines
726 
727   Concepts: preallocation^Matrix
728 
729 .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(),
730           MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal()
731 M*/
732 #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);}
733 
734 
735 
736 /* Routines unique to particular data structures */
737 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellGetContext(Mat,void **);
738 
739 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatBDiagGetData(Mat,PetscInt*,PetscInt*,PetscInt*[],PetscInt*[],PetscScalar***);
740 
741 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInodeAdjustForInodes(Mat,IS*,IS*);
742 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatInodeGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *);
743 
744 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetColumnIndices(Mat,PetscInt[]);
745 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJSetColumnIndices(Mat,PetscInt[]);
746 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*);
747 
748 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
749 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]);
750 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]);
751 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDensePreallocation(Mat,PetscScalar[]);
752 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
753 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDenseSetPreallocation(Mat,PetscScalar[]);
754 
755 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
756 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
757 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]);
758 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]);
759 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]);
760 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIDensePreallocation(Mat,PetscScalar[]);
761 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]);
762 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]);
763 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIDenseSetPreallocation(Mat,PetscScalar[]);
764 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]);
765 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]);
766 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]);
767 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatAdicSetLocalFunction(Mat,void (*)(void));
768 
769 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqDenseSetLDA(Mat,PetscInt);
770 
771 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatStoreValues(Mat);
772 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRetrieveValues(Mat);
773 
774 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDAADSetCtx(Mat,void*);
775 
776 /*
777   These routines are not usually accessed directly, rather solving is
778   done through the KSP and PC interfaces.
779 */
780 
781 /*E
782     MatOrderingType - String with the name of a PETSc matrix ordering or the creation function
783        with an optional dynamic library name, for example
784        http://www.mcs.anl.gov/petsc/lib.a:orderingcreate()
785 
786    Level: beginner
787 
788 .seealso: MatGetOrdering()
789 E*/
790 #define MatOrderingType char*
791 #define MATORDERING_NATURAL   "natural"
792 #define MATORDERING_ND        "nd"
793 #define MATORDERING_1WD       "1wd"
794 #define MATORDERING_RCM       "rcm"
795 #define MATORDERING_QMD       "qmd"
796 #define MATORDERING_ROWLENGTH "rowlength"
797 #define MATORDERING_DSC_ND    "dsc_nd"
798 #define MATORDERING_DSC_MMD   "dsc_mmd"
799 #define MATORDERING_DSC_MDF   "dsc_mdf"
800 #define MATORDERING_CONSTRAINED "constrained"
801 #define MATORDERING_IDENTITY  "identity"
802 #define MATORDERING_REVERSE   "reverse"
803 
804 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOrdering(Mat,const MatOrderingType,IS*,IS*);
805 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetOrderingList(PetscFList *list);
806 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*));
807 
808 /*MC
809    MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the
810                                matrix package.
811 
812    Synopsis:
813    PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering))
814 
815    Not Collective
816 
817    Input Parameters:
818 +  sname - name of ordering (for example MATORDERING_ND)
819 .  path - location of library where creation routine is
820 .  name - name of function that creates the ordering type,a string
821 -  function - function pointer that creates the ordering
822 
823    Level: developer
824 
825    If dynamic libraries are used, then the fourth input argument (function)
826    is ignored.
827 
828    Sample usage:
829 .vb
830    MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a,
831                "MyOrder",MyOrder);
832 .ve
833 
834    Then, your partitioner can be chosen with the procedural interface via
835 $     MatOrderingSetType(part,"my_order)
836    or at runtime via the option
837 $     -pc_ilu_mat_ordering_type my_order
838 $     -pc_lu_mat_ordering_type my_order
839 
840    ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values.
841 
842 .keywords: matrix, ordering, register
843 
844 .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll()
845 M*/
846 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
847 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0)
848 #else
849 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d)
850 #endif
851 
852 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegisterDestroy(void);
853 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatOrderingRegisterAll(const char[]);
854 extern PetscTruth MatOrderingRegisterAllCalled;
855 extern PetscFList MatOrderingList;
856 
857 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS);
858 
859 /*S
860    MatFactorInfo - Data based into the matrix factorization routines
861 
862    In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE
863 
864    Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC.
865 
866    Level: developer
867 
868 .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(),
869           MatFactorInfoInitialize()
870 
871 S*/
872 typedef struct {
873   PetscReal     shiftnz;        /* scaling of identity added to matrix to prevent zero pivots */
874   PetscTruth    shiftpd;         /* if true, shift until positive pivots */
875   PetscReal     shift_fraction; /* record shift fraction taken */
876   PetscReal     diagonal_fill;  /* force diagonal to fill in if initially not filled */
877   PetscReal     dt;             /* drop tolerance */
878   PetscReal     dtcol;          /* tolerance for pivoting */
879   PetscReal     dtcount;        /* maximum nonzeros to be allowed per row */
880   PetscReal     fill;           /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/
881   PetscReal     levels;         /* ICC/ILU(levels) */
882   PetscReal     pivotinblocks;  /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0
883                                    factorization may be faster if do not pivot */
884   PetscReal     zeropivot;      /* pivot is called zero if less than this */
885 } MatFactorInfo;
886 
887 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFactorInfoInitialize(MatFactorInfo*);
888 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactor(Mat,IS,MatFactorInfo*);
889 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
890 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCholeskyFactorNumeric(Mat,MatFactorInfo*,Mat*);
891 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactor(Mat,IS,IS,MatFactorInfo*);
892 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUFactor(Mat,IS,IS,MatFactorInfo*);
893 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
894 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*);
895 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*);
896 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatICCFactor(Mat,IS,MatFactorInfo*);
897 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatLUFactorNumeric(Mat,MatFactorInfo*,Mat*);
898 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatILUDTFactor(Mat,IS,IS,MatFactorInfo*,Mat *);
899 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*);
900 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolve(Mat,Vec,Vec);
901 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatForwardSolve(Mat,Vec,Vec);
902 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatBackwardSolve(Mat,Vec,Vec);
903 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveAdd(Mat,Vec,Vec,Vec);
904 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveTranspose(Mat,Vec,Vec);
905 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolveTransposeAdd(Mat,Vec,Vec,Vec);
906 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSolves(Mat,Vecs,Vecs);
907 
908 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSetUnfactored(Mat);
909 
910 /*E
911     MatSORType - What type of (S)SOR to perform
912 
913     Level: beginner
914 
915    May be bitwise ORd together
916 
917    Any additions/changes here MUST also be made in include/finclude/petscmat.h
918 
919    MatSORType may be bitwise ORd together, so do not change the numbers
920 
921 .seealso: MatRelax(), MatPBRelax()
922 E*/
923 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
924               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
925               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
926               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType;
927 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
928 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec);
929 
930 /*
931     These routines are for efficiently computing Jacobians via finite differences.
932 */
933 
934 /*E
935     MatColoringType - String with the name of a PETSc matrix coloring or the creation function
936        with an optional dynamic library name, for example
937        http://www.mcs.anl.gov/petsc/lib.a:coloringcreate()
938 
939    Level: beginner
940 
941 .seealso: MatGetColoring()
942 E*/
943 #define MatColoringType char*
944 #define MATCOLORING_NATURAL "natural"
945 #define MATCOLORING_SL      "sl"
946 #define MATCOLORING_LF      "lf"
947 #define MATCOLORING_ID      "id"
948 
949 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatGetColoring(Mat,const MatColoringType,ISColoring*);
950 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatColoringType,ISColoring *));
951 
952 /*MC
953    MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the
954                                matrix package.
955 
956    Synopsis:
957    PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring))
958 
959    Not Collective
960 
961    Input Parameters:
962 +  sname - name of Coloring (for example MATCOLORING_SL)
963 .  path - location of library where creation routine is
964 .  name - name of function that creates the Coloring type, a string
965 -  function - function pointer that creates the coloring
966 
967    Level: developer
968 
969    If dynamic libraries are used, then the fourth input argument (function)
970    is ignored.
971 
972    Sample usage:
973 .vb
974    MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a,
975                "MyColor",MyColor);
976 .ve
977 
978    Then, your partitioner can be chosen with the procedural interface via
979 $     MatColoringSetType(part,"my_color")
980    or at runtime via the option
981 $     -mat_coloring_type my_color
982 
983    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
984 
985 .keywords: matrix, Coloring, register
986 
987 .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll()
988 M*/
989 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
990 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0)
991 #else
992 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d)
993 #endif
994 
995 extern PetscTruth MatColoringRegisterAllCalled;
996 
997 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegisterAll(const char[]);
998 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringRegisterDestroy(void);
999 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*);
1000 
1001 /*S
1002      MatFDColoring - Object for computing a sparse Jacobian via finite differences
1003         and coloring
1004 
1005    Level: beginner
1006 
1007   Concepts: coloring, sparse Jacobian, finite differences
1008 
1009 .seealso:  MatFDColoringCreate()
1010 S*/
1011 typedef struct _p_MatFDColoring *MatFDColoring;
1012 
1013 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringCreate(Mat,ISColoring,MatFDColoring *);
1014 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringDestroy(MatFDColoring);
1015 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringView(MatFDColoring,PetscViewer);
1016 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*);
1017 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal);
1018 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFrequency(MatFDColoring,PetscInt);
1019 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetFrequency(MatFDColoring,PetscInt*);
1020 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetFromOptions(MatFDColoring);
1021 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *);
1022 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *);
1023 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetRecompute(MatFDColoring);
1024 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringSetF(MatFDColoring,Vec);
1025 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]);
1026 /*
1027     These routines are for partitioning matrices: currently used only
1028   for adjacency matrix, MatCreateMPIAdj().
1029 */
1030 
1031 /*S
1032      MatPartitioning - Object for managing the partitioning of a matrix or graph
1033 
1034    Level: beginner
1035 
1036   Concepts: partitioning
1037 
1038 .seealso:  MatPartitioningCreate(), MatPartitioningType
1039 S*/
1040 typedef struct _p_MatPartitioning *MatPartitioning;
1041 
1042 /*E
1043     MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function
1044        with an optional dynamic library name, for example
1045        http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate()
1046 
1047    Level: beginner
1048 
1049 .seealso: MatPartitioningCreate(), MatPartitioning
1050 E*/
1051 #define MatPartitioningType char*
1052 #define MAT_PARTITIONING_CURRENT  "current"
1053 #define MAT_PARTITIONING_SQUARE   "square"
1054 #define MAT_PARTITIONING_PARMETIS "parmetis"
1055 #define MAT_PARTITIONING_CHACO    "chaco"
1056 #define MAT_PARTITIONING_JOSTLE   "jostle"
1057 #define MAT_PARTITIONING_PARTY    "party"
1058 #define MAT_PARTITIONING_SCOTCH   "scotch"
1059 
1060 
1061 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningCreate(MPI_Comm,MatPartitioning*);
1062 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetType(MatPartitioning,const MatPartitioningType);
1063 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetNParts(MatPartitioning,PetscInt);
1064 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetAdjacency(MatPartitioning,Mat);
1065 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]);
1066 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []);
1067 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningApply(MatPartitioning,IS*);
1068 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningDestroy(MatPartitioning);
1069 
1070 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning));
1071 
1072 /*MC
1073    MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the
1074    matrix package.
1075 
1076    Synopsis:
1077    PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning))
1078 
1079    Not Collective
1080 
1081    Input Parameters:
1082 +  sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis
1083 .  path - location of library where creation routine is
1084 .  name - name of function that creates the partitioning type, a string
1085 -  function - function pointer that creates the partitioning type
1086 
1087    Level: developer
1088 
1089    If dynamic libraries are used, then the fourth input argument (function)
1090    is ignored.
1091 
1092    Sample usage:
1093 .vb
1094    MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a,
1095                "MyPartCreate",MyPartCreate);
1096 .ve
1097 
1098    Then, your partitioner can be chosen with the procedural interface via
1099 $     MatPartitioningSetType(part,"my_part")
1100    or at runtime via the option
1101 $     -mat_partitioning_type my_part
1102 
1103    $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
1104 
1105 .keywords: matrix, partitioning, register
1106 
1107 .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll()
1108 M*/
1109 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
1110 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0)
1111 #else
1112 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d)
1113 #endif
1114 
1115 extern PetscTruth MatPartitioningRegisterAllCalled;
1116 
1117 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegisterAll(const char[]);
1118 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningRegisterDestroy(void);
1119 
1120 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningView(MatPartitioning,PetscViewer);
1121 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningSetFromOptions(MatPartitioning);
1122 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningGetType(MatPartitioning,MatPartitioningType*);
1123 
1124 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningParmetisSetCoarseSequential(MatPartitioning);
1125 
1126 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal);
1127 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningJostleSetCoarseSequential(MatPartitioning);
1128 
1129 typedef enum { MP_CHACO_MULTILEVEL_KL, MP_CHACO_SPECTRAL, MP_CHACO_LINEAR,
1130     MP_CHACO_RANDOM, MP_CHACO_SCATTERED } MPChacoGlobalType;
1131 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType);
1132 typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType;
1133 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType);
1134 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal);
1135 typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType;
1136 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType);
1137 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal);
1138 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt);
1139 
1140 #define MP_PARTY_OPT "opt"
1141 #define MP_PARTY_LIN "lin"
1142 #define MP_PARTY_SCA "sca"
1143 #define MP_PARTY_RAN "ran"
1144 #define MP_PARTY_GBF "gbf"
1145 #define MP_PARTY_GCF "gcf"
1146 #define MP_PARTY_BUB "bub"
1147 #define MP_PARTY_DEF "def"
1148 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetGlobal(MatPartitioning, const char*);
1149 #define MP_PARTY_HELPFUL_SETS "hs"
1150 #define MP_PARTY_KERNIGHAN_LIN "kl"
1151 #define MP_PARTY_NONE "no"
1152 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetLocal(MatPartitioning, const char*);
1153 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal);
1154 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetBipart(MatPartitioning,PetscTruth);
1155 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth);
1156 
1157 typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType;
1158 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetArch(MatPartitioning,const char*);
1159 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetMultilevel(MatPartitioning);
1160 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType);
1161 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal);
1162 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetHostList(MatPartitioning,const char*);
1163 typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType;
1164 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType);
1165 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetMapping(MatPartitioning);
1166 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatPartitioningScotchSetStrategy(MatPartitioning,char*);
1167 
1168 /*
1169     If you add entries here you must also add them to finclude/petscmat.h
1170 */
1171 typedef enum { MATOP_SET_VALUES=0,
1172                MATOP_GET_ROW=1,
1173                MATOP_RESTORE_ROW=2,
1174                MATOP_MULT=3,
1175                MATOP_MULT_ADD=4,
1176                MATOP_MULT_TRANSPOSE=5,
1177                MATOP_MULT_TRANSPOSE_ADD=6,
1178                MATOP_SOLVE=7,
1179                MATOP_SOLVE_ADD=8,
1180                MATOP_SOLVE_TRANSPOSE=9,
1181                MATOP_SOLVE_TRANSPOSE_ADD=10,
1182                MATOP_LUFACTOR=11,
1183                MATOP_CHOLESKYFACTOR=12,
1184                MATOP_RELAX=13,
1185                MATOP_TRANSPOSE=14,
1186                MATOP_GETINFO=15,
1187                MATOP_EQUAL=16,
1188                MATOP_GET_DIAGONAL=17,
1189                MATOP_DIAGONAL_SCALE=18,
1190                MATOP_NORM=19,
1191                MATOP_ASSEMBLY_BEGIN=20,
1192                MATOP_ASSEMBLY_END=21,
1193                MATOP_COMPRESS=22,
1194                MATOP_SET_OPTION=23,
1195                MATOP_ZERO_ENTRIES=24,
1196                MATOP_ZERO_ROWS=25,
1197                MATOP_LUFACTOR_SYMBOLIC=26,
1198                MATOP_LUFACTOR_NUMERIC=27,
1199                MATOP_CHOLESKY_FACTOR_SYMBOLIC=28,
1200                MATOP_CHOLESKY_FACTOR_NUMERIC=29,
1201                MATOP_SETUP_PREALLOCATION=30,
1202                MATOP_ILUFACTOR_SYMBOLIC=31,
1203                MATOP_ICCFACTOR_SYMBOLIC=32,
1204                MATOP_GET_ARRAY=33,
1205                MATOP_RESTORE_ARRAY=34,
1206                MATOP_DUPLCIATE=35,
1207                MATOP_FORWARD_SOLVE=36,
1208                MATOP_BACKWARD_SOLVE=37,
1209                MATOP_ILUFACTOR=38,
1210                MATOP_ICCFACTOR=39,
1211                MATOP_AXPY=40,
1212                MATOP_GET_SUBMATRICES=41,
1213                MATOP_INCREASE_OVERLAP=42,
1214                MATOP_GET_VALUES=43,
1215                MATOP_COPY=44,
1216                MATOP_PRINT_HELP=45,
1217                MATOP_SCALE=46,
1218                MATOP_SHIFT=47,
1219                MATOP_DIAGONAL_SHIFT=48,
1220                MATOP_ILUDT_FACTOR=49,
1221                MATOP_GET_BLOCK_SIZE=50,
1222                MATOP_GET_ROW_IJ=51,
1223                MATOP_RESTORE_ROW_IJ=52,
1224                MATOP_GET_COLUMN_IJ=53,
1225                MATOP_RESTORE_COLUMN_IJ=54,
1226                MATOP_FDCOLORING_CREATE=55,
1227                MATOP_COLORING_PATCH=56,
1228                MATOP_SET_UNFACTORED=57,
1229                MATOP_PERMUTE=58,
1230                MATOP_SET_VALUES_BLOCKED=59,
1231                MATOP_GET_SUBMATRIX=60,
1232                MATOP_DESTROY=61,
1233                MATOP_VIEW=62,
1234                MATOP_GET_MAPS=63,
1235                MATOP_USE_SCALED_FORM=64,
1236                MATOP_SCALE_SYSTEM=65,
1237                MATOP_UNSCALE_SYSTEM=66,
1238                MATOP_SET_LOCAL_TO_GLOBAL_MAP=67,
1239                MATOP_SET_VALUES_LOCAL=68,
1240                MATOP_ZERO_ROWS_LOCAL=69,
1241                MATOP_GET_ROW_MAX=70,
1242                MATOP_CONVERT=71,
1243                MATOP_SET_COLORING=72,
1244                MATOP_SET_VALUES_ADIC=73,
1245                MATOP_SET_VALUES_ADIFOR=74,
1246                MATOP_FD_COLORING_APPLY=75,
1247                MATOP_SET_FROM_OPTIONS=76,
1248                MATOP_MULT_CON=77,
1249                MATOP_MULT_TRANSPOSE_CON=78,
1250                MATOP_ILU_FACTOR_SYMBOLIC_CON=79,
1251                MATOP_PERMUTE_SPARSIFY=80,
1252                MATOP_MULT_MULTIPLE=81,
1253                MATOP_SOLVE_MULTIPLE=82,
1254                MATOP_GET_INERTIA=83,
1255                MATOP_LOAD=84,
1256                MATOP_IS_SYMMETRIC=85,
1257                MATOP_IS_HERMITIAN=86,
1258                MATOP_IS_STRUCTURALLY_SYMMETRIC=87,
1259                MATOP_PB_RELAX=88,
1260                MATOP_GET_VECS=89,
1261                MATOP_MAT_MULT=90,
1262                MATOP_MAT_MULT_SYMBOLIC=91,
1263                MATOP_MAT_MULT_NUMERIC=92,
1264                MATOP_PTAP=93,
1265                MATOP_PTAP_SYMBOLIC=94,
1266                MATOP_PTAP_NUMERIC=95,
1267                MATOP_MAT_MULTTRANSPOSE=96,
1268                MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97,
1269                MATOP_MAT_MULTTRANSPOSE_NUMERIC=98,
1270                MATOP_PTAP_SYMBOLIC_SEQAIJ=99,
1271                MATOP_PTAP_NUMERIC_SEQAIJ=100,
1272                MATOP_PTAP_SYMBOLIC_MPIAIJ=101,
1273                MATOP_PTAP_NUMERIC_MPIAIJ=102
1274              } MatOperation;
1275 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatHasOperation(Mat,MatOperation,PetscTruth*);
1276 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellSetOperation(Mat,MatOperation,void(*)(void));
1277 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellGetOperation(Mat,MatOperation,void(**)(void));
1278 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatShellSetContext(Mat,void*);
1279 
1280 /*
1281    Codes for matrices stored on disk. By default they are
1282  stored in a universal format. By changing the format with
1283  PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will
1284  be stored in a way natural for the matrix, for example dense matrices
1285  would be stored as dense. Matrices stored this way may only be
1286  read into matrices of the same time.
1287 */
1288 #define MATRIX_BINARY_FORMAT_DENSE -1
1289 
1290 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIBAIJSetHashTableFactor(Mat,PetscReal);
1291 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPIRowbsGetColor(Mat,ISColoring *);
1292 
1293 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatISGetLocalMat(Mat,Mat*);
1294 
1295 /*S
1296      MatNullSpace - Object that removes a null space from a vector, i.e.
1297          orthogonalizes the vector to a subsapce
1298 
1299    Level: advanced
1300 
1301   Concepts: matrix; linear operator, null space
1302 
1303   Users manual sections:
1304 .   sec_singular
1305 
1306 .seealso:  MatNullSpaceCreate()
1307 S*/
1308 typedef struct _p_MatNullSpace* MatNullSpace;
1309 
1310 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*);
1311 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceDestroy(MatNullSpace);
1312 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceRemove(MatNullSpace,Vec,Vec*);
1313 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceAttach(Mat,MatNullSpace);
1314 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatNullSpaceTest(MatNullSpace,Mat);
1315 
1316 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatReorderingSeqSBAIJ(Mat,IS);
1317 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMPISBAIJSetHashTableFactor(Mat,PetscReal);
1318 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatSeqSBAIJSetColumnIndices(Mat,PetscInt *);
1319 
1320 
1321 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatCreateMAIJ(Mat,PetscInt,Mat*);
1322 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMAIJRedimension(Mat,PetscInt,Mat*);
1323 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatMAIJGetAIJ(Mat,Mat*);
1324 
1325 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatComputeExplicitOperator(Mat,Mat*);
1326 
1327 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT MatDiagonalScaleLocal(Mat,Vec);
1328 
1329 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *);
1330 EXTERN PetscErrorCode PETSCMAT_DLLEXPORT PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *);
1331 
1332 PETSC_EXTERN_CXX_END
1333 #endif
1334