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