xref: /petsc/include/petscmat.h (revision ab94cc7af4fcd5c63a93b94bdec4707d4e0807cd)
1 /* $Id: mat.h,v 1.102 1996/04/09 02:23:45 curfman Exp bsmith $ */
2 /*
3      Include file for the matrix component of PETSc
4 */
5 #ifndef __MAT_PACKAGE
6 #define __MAT_PACKAGE
7 #include "vec.h"
8 
9 #define MAT_COOKIE         PETSC_COOKIE+5
10 
11 typedef struct _Mat*           Mat;
12 
13 typedef enum { MATSAME=-1, MATSEQDENSE, MATSEQAIJ, MATMPIAIJ, MATSHELL,
14                MATMPIROWBS, MATSEQBDIAG, MATMPIBDIAG,
15                MATMPIDENSE, MATSEQBAIJ } MatType;
16 
17 extern int MatCreate(MPI_Comm,int,int,Mat*);
18 extern int MatCreateSeqDense(MPI_Comm,int,int,Scalar*,Mat*);
19 extern int MatCreateMPIDense(MPI_Comm,int,int,int,int,Scalar*,Mat*);
20 extern int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*);
21 extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
22 extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*);
23 extern int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,Scalar**,Mat*);
24 extern int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,Scalar**,Mat*);
25 extern int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*);
26 
27 extern int MatDestroy(Mat);
28 
29 extern int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*);
30 extern int MatShellGetContext(Mat,void **);
31 
32 
33 extern int MatPrintHelp(Mat);
34 
35 /* ------------------------------------------------------------*/
36 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
37 typedef enum {FLUSH_ASSEMBLY=1,FINAL_ASSEMBLY=0} MatAssemblyType;
38 extern int MatAssemblyBegin(Mat,MatAssemblyType);
39 extern int MatAssemblyEnd(Mat,MatAssemblyType);
40 
41 typedef enum {ROW_ORIENTED=1,COLUMN_ORIENTED=2,ROWS_SORTED=4,
42               COLUMNS_SORTED=8,NO_NEW_NONZERO_LOCATIONS=16,
43               YES_NEW_NONZERO_LOCATIONS=32,SYMMETRIC_MATRIX=64,
44               STRUCTURALLY_SYMMETRIC_MATRIX,NO_NEW_DIAGONALS,
45               YES_NEW_DIAGONALS,INODE_LIMIT_1,INODE_LIMIT_2,
46               INODE_LIMIT_3,INODE_LIMIT_4,INODE_LIMIT_5} MatOption;
47 extern int MatSetOption(Mat,MatOption);
48 extern int MatGetType(Mat,MatType*,char**);
49 extern int MatGetTypeFromOptions(MPI_Comm,char*,MatType*,int*);
50 extern int MatGetValues(Mat,int,int*,int,int*,Scalar*);
51 extern int MatGetRow(Mat,int,int *,int **,Scalar**);
52 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
53 extern int MatGetColumn(Mat,int,int *,int **,Scalar**);
54 extern int MatRestoreColumn(Mat,int,int *,int **,Scalar**);
55 extern int MatGetArray(Mat,Scalar **);
56 extern int MatRestoreArray(Mat,Scalar **);
57 
58 extern int MatMult(Mat,Vec,Vec);
59 extern int MatMultAdd(Mat,Vec,Vec,Vec);
60 extern int MatMultTrans(Mat,Vec,Vec);
61 extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
62 
63 extern int MatConvert(Mat,MatType,Mat*);
64 extern int MatCopy(Mat,Mat);
65 extern int MatView(Mat,Viewer);
66 extern int MatLoad(Viewer,MatType,Mat*);
67 
68 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
69 extern int MatGetInfo(Mat,MatInfoType,int*,int*,int*);
70 extern int MatValid(Mat,PetscTruth*);
71 extern int MatGetDiagonal(Mat,Vec);
72 extern int MatTranspose(Mat,Mat*);
73 extern int MatDiagonalScale(Mat,Vec,Vec);
74 extern int MatDiagonalShift(Mat,Vec);
75 extern int MatEqual(Mat,Mat, PetscTruth*);
76 
77 extern int MatNorm(Mat,NormType,double *);
78 extern int MatZeroEntries(Mat);
79 extern int MatZeroRows(Mat,IS,Scalar*);
80 extern int MatZeroColumns(Mat,IS,Scalar*);
81 
82 extern int MatGetSize(Mat,int*,int*);
83 extern int MatGetLocalSize(Mat,int*,int*);
84 extern int MatGetOwnershipRange(Mat,int*,int*);
85 
86 typedef enum {MAT_INITIAL_MATRIX, MAT_REUSE_MATRIX} MatGetSubMatrixCall;
87 extern int MatGetSubMatrix(Mat,IS,IS,MatGetSubMatrixCall,Mat*);
88 extern int MatGetSubMatrixInPlace(Mat,IS,IS);
89 extern int MatGetSubMatrices(Mat,int,IS *,IS *,MatGetSubMatrixCall,Mat **);
90 extern int MatIncreaseOverlap(Mat,int,IS *,int);
91 
92 extern int MatAXPY(Scalar *,Mat,Mat);
93 extern int MatCompress(Mat);
94 
95 extern int MatScale(Scalar *,Mat);
96 extern int MatShift(Scalar *,Mat);
97 
98 /* Routines unique to particular data structures */
99 extern int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***);
100 
101 /*
102   These routines are not usually accessed directly, rather solving is
103   done through the SLES, KSP and PC interfaces.
104 */
105 
106 typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2,
107               ORDER_RCM=3,ORDER_QMD=4,ORDER_ROWLENGTH=5,ORDER_APPLICATION_1,
108               ORDER_APPLICATION_2} MatOrdering;
109 extern int MatGetReordering(Mat,MatOrdering,IS*,IS*);
110 extern int MatGetReorderingTypeFromOptions(char *,MatOrdering*);
111 extern int MatReorderForNonzeroDiagonal(Mat,double,IS,IS);
112 extern int MatReorderingRegister(MatOrdering *,char*,PetscTruth,int,
113                                  int (*)(int*,int*,int*,int*,int*));
114 extern int MatReorderingRegisterAll();
115 extern int MatReorderingRegisterDestroy();
116 extern int MatReorderingGetName(MatOrdering,char **);
117 extern PetscTruth MatReorderingRequiresSymmetric[];
118 extern int MatReorderingIndexShift[];
119 
120 extern int MatLUFactor(Mat,IS,IS,double);
121 extern int MatILUFactor(Mat,IS,IS,double,int);
122 extern int MatCholeskyFactor(Mat,IS,double);
123 extern int MatLUFactorSymbolic(Mat,IS,IS,double,Mat*);
124 extern int MatILUFactorSymbolic(Mat,IS,IS,double,int,Mat*);
125 extern int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*);
126 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*);
127 extern int MatLUFactorNumeric(Mat,Mat*);
128 extern int MatCholeskyFactorNumeric(Mat,Mat*);
129 
130 extern int MatSolve(Mat,Vec,Vec);
131 extern int MatForwardSolve(Mat,Vec,Vec);
132 extern int MatBackwardSolve(Mat,Vec,Vec);
133 extern int MatSolveAdd(Mat,Vec,Vec,Vec);
134 extern int MatSolveTrans(Mat,Vec,Vec);
135 extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
136 
137 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
138               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
139               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
140               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128
141               } MatSORType;
142 extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
143 
144 typedef enum { MAT_SET_VALUES=0,
145                MAT_GET_ROW=1,
146                MAT_RESTORE_ROW=2,
147                MAT_MULT=3,
148                MAT_MULT_ADD=4,
149                MAT_MULT_TRANS=5,
150                MAT_MULT_TRANS_ADD=6,
151                MAT_SOLVE=7,
152                MAT_SOLVE_ADD=8,
153                MAT_SOLVE_TRANS=9,
154                MAT_SOLVE_TRANS_ADD=10,
155                MAT_LUFACTOR=11,
156                MAT_CHOLESKYFACTOR=12,
157                MAT_RELAX=13,
158                MAT_TRANSPOSE=14,
159                MAT_GETINFO=15,
160                MAT_EQUAL=16,
161                MAT_GET_DIAGONAL=17,
162                MAT_DIAGONAL_SCALE=18,
163                MAT_NORM=19,
164                MAT_ASSEMBLY_BEGIN=20,
165                MAT_ASSEMBLY_END=21,
166                MAT_COMPRESS=22,
167                MAT_SET_OPTION=23,
168                MAT_ZERO_ENTRIES=24,
169                MAT_ZERO_ROWS=25,
170                MAT_GET_REORDERING=26,
171                MAT_LUFACTOR_SYMBOLIC=27,
172                MAT_LUFACTOR_NUMERIC=28,
173                MAT_CHOLESKY_FACTOR_SYMBOLIC=29,
174                MAT_CHOLESKY_FACTOR_NUMERIC=30,
175                MAT_GET_SIZE=31,
176                MAT_GET_LOCAL_SIZE=32,
177                MAT_GET_OWNERSHIP_RANGE=33,
178                MAT_ILUFACTOR_SYMBOLIC=34,
179                MAT_INCOMPLETECHOLESKYFACTOR_SYMBOLIC=35,
180                MAT_GET_ARRAY=36,
181                MAT_RESTORE_ARRAY=37,
182                MAT_CONVERT=38,
183                MAT_GET_SUBMATRIX=39,
184                MAT_GET_SUBMATRIX_INPLACE=40,
185                MAT_CONVERT_SAME_TYPE=41,
186                MAT_FORWARD_SOLVE=42,
187                MAT_BACKWARD_SOLVE=43,
188                MAT_ILUFACTOR=44,
189                MAT_INCOMPLETECHOLEKSYFACTOR=45,
190                MAT_AXPY=46,
191                MAT_GET_SUBMATRICES=47,
192                MAT_INCREASE_OVERLAP=48,
193                MAT_GET_VALUES=49,
194                MAT_COPY=50,
195                MAT_PRINT_HELP=51,
196                MAT_SCALE=52,
197                MAT_SHIFT=53,
198                MAT_DIAGONAL_SHIFT=54,
199                MAT_DESTROY=250,
200                MAT_VIEW=251
201              } MatOperation;
202 extern int MatHasOperation(Mat,MatOperation,PetscTruth*);
203 extern int MatShellSetOperation(Mat,MatOperation,void *);
204 
205 /*  Not currently supported!
206 #define MAT_SCATTER_COOKIE PETSC_COOKIE+15
207 typedef struct _MatScatter* MatScatter;
208 
209 extern int MatScatterBegin(Mat,Mat,InsertMode,MatScatter);
210 extern int MatScatterEnd(Mat,Mat,InsertMode,MatScatter);
211 extern int MatScatterCreate(Mat,IS,IS,Mat,IS,IS,MatScatter*);
212 extern int MatScatterDestroy(MatScatter);
213 */
214 
215 /*
216    Codes for matrices stored on disk. By default they are
217  stored in a universal format. By changing the format with
218  ViewerSetFormat(viewer,BINARY_FORMAT_NATIVE); the matrices will
219  be stored in a way natural for the matrix, for example dense matrices
220  would be stored as dense. Matrices stored this way may only be
221  read into matrices of the same time.
222 */
223 #define MATRIX_BINARY_FORMAT_DENSE -1
224 
225 #endif
226 
227 
228 
229