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