xref: /petsc/include/petscmat.h (revision 77c4ece699e97450631aa6fc5b0ef04ff52df029)
1 /* $Id: mat.h,v 1.99 1996/03/18 00:43:55 bsmith 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,void *,Mat*);
30 extern int MatShellGetContext(Mat,void **);
31 extern int MatShellSetMult(Mat,int (*)(void*,Vec,Vec));
32 extern int MatShellSetDestroy(Mat,int (*)(void*));
33 extern int MatShellSetMultTrans(Mat,int (*)(void*,Vec,Vec));
34 extern int MatShellSetMultTransAdd(Mat,int (*)(void*,Vec,Vec,Vec));
35 
36 extern int MatPrintHelp(Mat);
37 
38 /* ------------------------------------------------------------*/
39 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
40 typedef enum {FLUSH_ASSEMBLY=1,FINAL_ASSEMBLY=0} MatAssemblyType;
41 extern int MatAssemblyBegin(Mat,MatAssemblyType);
42 extern int MatAssemblyEnd(Mat,MatAssemblyType);
43 
44 typedef enum {ROW_ORIENTED=1,COLUMN_ORIENTED=2,ROWS_SORTED=4,
45               COLUMNS_SORTED=8,NO_NEW_NONZERO_LOCATIONS=16,
46               YES_NEW_NONZERO_LOCATIONS=32,SYMMETRIC_MATRIX=64,
47               STRUCTURALLY_SYMMETRIC_MATRIX,NO_NEW_DIAGONALS,
48               YES_NEW_DIAGONALS,INODE_LIMIT_1,INODE_LIMIT_2,
49               INODE_LIMIT_3,INODE_LIMIT_4,INODE_LIMIT_5} MatOption;
50 extern int MatSetOption(Mat,MatOption);
51 extern int MatGetType(Mat,MatType*,char**);
52 extern int MatGetTypeFromOptions(MPI_Comm,char*,MatType*,int*);
53 extern int MatGetValues(Mat,int,int*,int,int*,Scalar*);
54 extern int MatGetRow(Mat,int,int *,int **,Scalar**);
55 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
56 extern int MatGetColumn(Mat,int,int *,int **,Scalar**);
57 extern int MatRestoreColumn(Mat,int,int *,int **,Scalar**);
58 extern int MatGetArray(Mat,Scalar **);
59 extern int MatRestoreArray(Mat,Scalar **);
60 
61 extern int MatMult(Mat,Vec,Vec);
62 extern int MatMultAdd(Mat,Vec,Vec,Vec);
63 extern int MatMultTrans(Mat,Vec,Vec);
64 extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
65 
66 extern int MatConvert(Mat,MatType,Mat*);
67 extern int MatCopy(Mat,Mat);
68 extern int MatView(Mat,Viewer);
69 extern int MatLoad(Viewer,MatType,Mat*);
70 
71 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
72 extern int MatGetInfo(Mat,MatInfoType,int*,int*,int*);
73 extern int MatValid(Mat,PetscTruth*);
74 extern int MatGetDiagonal(Mat,Vec);
75 extern int MatTranspose(Mat,Mat*);
76 extern int MatDiagonalScale(Mat,Vec,Vec);
77 extern int MatDiagonalShift(Mat,Vec);
78 extern int MatEqual(Mat,Mat, PetscTruth*);
79 
80 extern int MatNorm(Mat,NormType,double *);
81 extern int MatZeroEntries(Mat);
82 extern int MatZeroRows(Mat,IS,Scalar*);
83 extern int MatZeroColumns(Mat,IS,Scalar*);
84 
85 extern int MatGetSize(Mat,int*,int*);
86 extern int MatGetLocalSize(Mat,int*,int*);
87 extern int MatGetOwnershipRange(Mat,int*,int*);
88 
89 typedef enum {MAT_INITIAL_MATRIX, MAT_REUSE_MATRIX} MatGetSubMatrixCall;
90 extern int MatGetSubMatrix(Mat,IS,IS,MatGetSubMatrixCall,Mat*);
91 extern int MatGetSubMatrixInPlace(Mat,IS,IS);
92 extern int MatGetSubMatrices(Mat,int,IS *,IS *,MatGetSubMatrixCall,Mat **);
93 extern int MatIncreaseOverlap(Mat,int,IS *,int);
94 
95 extern int MatAXPY(Scalar *,Mat,Mat);
96 extern int MatCompress(Mat);
97 
98 extern int MatScale(Scalar *,Mat);
99 extern int MatShift(Scalar *,Mat);
100 
101 /* Routines unique to particular data structures */
102 extern int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***);
103 
104 /*
105   These routines are not usually accessed directly, rather solving is
106   done through the SLES, KSP and PC interfaces.
107 */
108 
109 typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2,
110               ORDER_RCM=3,ORDER_QMD=4,ORDER_ROWLENGTH=5,ORDER_APPLICATION_1,
111               ORDER_APPLICATION_2} MatOrdering;
112 extern int MatGetReordering(Mat,MatOrdering,IS*,IS*);
113 extern int MatGetReorderingTypeFromOptions(char *,MatOrdering*);
114 extern int MatReorderForNonzeroDiagonal(Mat,double,IS,IS);
115 extern int MatReorderingRegister(MatOrdering *,char*,PetscTruth,int,
116                                  int (*)(int*,int*,int*,int*,int*));
117 extern int MatReorderingRegisterAll();
118 extern int MatReorderingRegisterDestroy();
119 extern int MatReorderingGetName(MatOrdering,char **);
120 extern PetscTruth MatReorderingRequiresSymmetric[];
121 extern int MatReorderingIndexShift[];
122 
123 extern int MatLUFactor(Mat,IS,IS,double);
124 extern int MatILUFactor(Mat,IS,IS,double,int);
125 extern int MatCholeskyFactor(Mat,IS,double);
126 extern int MatLUFactorSymbolic(Mat,IS,IS,double,Mat*);
127 extern int MatILUFactorSymbolic(Mat,IS,IS,double,int,Mat*);
128 extern int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*);
129 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*);
130 extern int MatLUFactorNumeric(Mat,Mat*);
131 extern int MatCholeskyFactorNumeric(Mat,Mat*);
132 
133 extern int MatSolve(Mat,Vec,Vec);
134 extern int MatForwardSolve(Mat,Vec,Vec);
135 extern int MatBackwardSolve(Mat,Vec,Vec);
136 extern int MatSolveAdd(Mat,Vec,Vec,Vec);
137 extern int MatSolveTrans(Mat,Vec,Vec);
138 extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
139 
140 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
141               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
142               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
143               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128
144               } MatSORType;
145 extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
146 
147 typedef enum { MAT_GET_DIAGONAL=17 } MatOperation;
148 extern int MatHasOperation(Mat,MatOperation,PetscTruth*);
149 
150 /*  Not currently supported!
151 #define MAT_SCATTER_COOKIE PETSC_COOKIE+15
152 typedef struct _MatScatter* MatScatter;
153 
154 extern int MatScatterBegin(Mat,Mat,InsertMode,MatScatter);
155 extern int MatScatterEnd(Mat,Mat,InsertMode,MatScatter);
156 extern int MatScatterCreate(Mat,IS,IS,Mat,IS,IS,MatScatter*);
157 extern int MatScatterDestroy(MatScatter);
158 */
159 
160 /*
161    Codes for matrices stored on disk. By default they are
162  stored in a universal format. By changing the format with
163  ViewerSetFormat(viewer,BINARY_FORMAT_NATIVE); the matrices will
164  be stored in a way natural for the matrix, for example dense matrices
165  would be stored as dense. Matrices stored this way may only be
166  read into matrices of the same time.
167 */
168 #define MATRIX_BINARY_FORMAT_DENSE -1
169 
170 #endif
171 
172 
173 
174