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