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