xref: /petsc/include/petscmat.h (revision 08480c60afa5ef1d2e4e27b9ebdf48b02c6a2186)
1 /* $Id: mat.h,v 1.69 1995/10/20 01:36:29 curfman Exp curfman $ */
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 #define MAT_SCATTER_COOKIE PETSC_COOKIE+15
11 
12 typedef struct _Mat*           Mat;
13 typedef struct _MatScatterCtx* MatScatterCtx;
14 
15 typedef enum { MATSAME=-1, MATSEQDENSE, MATSEQAIJ, MATMPIAIJ, MATSHELL,
16                MATSEQROW, MATMPIROW, MATMPIROWBS, MATSEQBDIAG, MATMPIBDIAG,
17                MATMPIDENSE } MatType;
18 
19 extern int MatCreateSeqDense(MPI_Comm,int,int,Mat*);
20 extern int MatCreateMPIDense(MPI_Comm,int,int,int,int,Mat*);
21 extern int MatCreateSeqAIJ(MPI_Comm,int,int,int,int *,Mat*);
22 extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
23 extern int MatCreateSeqRow(MPI_Comm,int,int,int,int *,Mat*);
24 extern int MatCreateMPIRow(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
25 extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*);
26 extern int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,
27                                     Scalar**,Mat*);
28 extern int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,
29                                     Scalar**,Mat*);
30 
31 extern int MatShellCreate(MPI_Comm,int,int,void *,Mat*);
32 extern int MatShellSetMult(Mat,int (*)(void*,Vec,Vec));
33 extern int MatShellSetDestroy(Mat,int (*)(void*));
34 extern int MatShellSetMultTrans(Mat,int (*)(void*,Vec,Vec));
35 extern int MatShellSetMultTransAdd(Mat,int (*)(void*,Vec,Vec,Vec));
36 
37 /* ------------------------------------------------------------*/
38 extern int  MatValidMatrix(Mat);
39 
40 typedef enum {FLUSH_ASSEMBLY=1,FINAL_ASSEMBLY=0} MatAssemblyType;
41 
42 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
43 extern int MatAssemblyBegin(Mat,MatAssemblyType);
44 extern int MatAssemblyEnd(Mat,MatAssemblyType);
45 
46 typedef enum {ROW_ORIENTED=1,COLUMN_ORIENTED=2,ROWS_SORTED=4,
47               COLUMNS_SORTED=8,NO_NEW_NONZERO_LOCATIONS=16,
48               YES_NEW_NONZERO_LOCATIONS=32,SYMMETRIC_MATRIX=64,
49               STRUCTURALLY_SYMMETRIC_MATRIX,NO_NEW_DIAGONALS,
50               YES_NEW_DIAGONALS} MatOption;
51 
52 extern int MatSetOption(Mat,MatOption);
53 extern int MatGetType(Mat,MatType*);
54 extern int MatGetName(Mat,char**);
55 extern int MatGetFormatFromOptions(MPI_Comm,MatType*,int*);
56 extern int MatGetValues(Mat,int,int*,int,int*,Scalar*);
57 extern int MatGetRow(Mat,int,int *,int **,Scalar**);
58 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
59 extern int MatGetCol(Mat,int,int *,int **,Scalar**);
60 extern int MatRestoreCol(Mat,int,int *,int **,Scalar**);
61 extern int MatGetArray(Mat,Scalar **);
62 extern int MatMult(Mat,Vec,Vec);
63 extern int MatMultAdd(Mat,Vec,Vec,Vec);
64 extern int MatMultTrans(Mat,Vec,Vec);
65 extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
66 
67 typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2,
68               ORDER_RCM=3,ORDER_QMD=4,ORDER_APPLICATION_1,
69               ORDER_APPLICATION_2} MatOrdering;
70 
71 extern int MatGetReordering(Mat,MatOrdering,IS*,IS*);
72 extern int MatGetReorderingTypeFromOptions(char *,MatOrdering*);
73 extern int MatReorderForNonzeroDiagonal(Mat,double,IS,IS);
74 extern int MatReorderingRegister(MatOrdering,char*,
75                      int (*)(int*,int*,int*,int*,int*));
76 extern int MatReorderingRegisterAll();
77 extern int MatReorderingRegisterDestroy();
78 
79 extern int MatLUFactor(Mat,IS,IS,double);
80 extern int MatILUFactor(Mat,IS,IS,double,int);
81 extern int MatCholeskyFactor(Mat,IS,double);
82 extern int MatLUFactorSymbolic(Mat,IS,IS,double,Mat*);
83 extern int MatILUFactorSymbolic(Mat,IS,IS,double,int,Mat*);
84 extern int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*);
85 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*);
86 extern int MatLUFactorNumeric(Mat,Mat*);
87 extern int MatCholeskyFactorNumeric(Mat,Mat*);
88 
89 extern int MatSolve(Mat,Vec,Vec);
90 extern int MatForwardSolve(Mat,Vec,Vec);
91 extern int MatBackwardSolve(Mat,Vec,Vec);
92 extern int MatSolveAdd(Mat,Vec,Vec,Vec);
93 extern int MatSolveTrans(Mat,Vec,Vec);
94 extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
95 
96 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
97               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
98               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
99               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128
100               } MatSORType;
101 
102 extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
103 
104 extern int MatConvert(Mat,MatType,Mat*);
105 extern int MatView(Mat,Viewer);
106 extern int MatLoad(Viewer,MatType,Mat*);
107 
108 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
109 
110 extern int MatGetInfo(Mat,MatInfoType,int*,int*,int*);
111 extern int MatGetDiagonal(Mat,Vec);
112 extern int MatTranspose(Mat,Mat*);
113 extern int MatScale(Mat,Vec,Vec);
114 extern int MatEqual(Mat,Mat);
115 extern int MatScatterBegin(Mat,Mat,InsertMode,MatScatterCtx);
116 extern int MatScatterEnd(Mat,Mat,InsertMode,MatScatterCtx);
117 extern int MatScatterCtxCreate(Mat,IS,IS,Mat,IS,IS,MatScatterCtx*);
118 extern int MatScatterCtxDestroy(MatScatterCtx);
119 
120 typedef enum {NORM_1=1,NORM_2=2,NORM_FROBENIUS=3,NORM_INFINITY=4} MatNormType;
121 extern int MatNorm(Mat,MatNormType,double *);
122 
123 extern int MatZeroEntries(Mat);
124 extern int MatZeroRows(Mat,IS,Scalar*);
125 extern int MatZeroColumns(Mat,IS,Scalar*);
126 
127 extern int MatDestroy(Mat);
128 
129 extern int MatGetSize(Mat,int*,int*);
130 extern int MatGetLocalSize(Mat,int*,int*);
131 extern int MatGetOwnershipRange(Mat,int*,int*);
132 
133 extern int MatCreate(MPI_Comm,int,int,Mat*);
134 
135 extern int MatGetSubMatrix(Mat,IS,IS,Mat*);
136 extern int MatGetSubMatrixInPlace(Mat,IS,IS);
137 
138 extern int MatAXPY(Scalar *,Mat,Mat);
139 extern int MatCompress(Mat);
140 
141 /* Routines unique to particular data structures */
142 extern int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***);
143 
144 #endif
145 
146 
147 
148