xref: /petsc/include/petscmat.h (revision 6b5873e37b549cc139dbd34cfb32e6aff4f310b3)
1 /*
2      Include file for the matrix component of PETSc
3 */
4 #ifndef __MAT_PACKAGE
5 #define __MAT_PACKAGE
6 #include "vec.h"
7 
8 #define MAT_COOKIE PETSC_COOKIE+5
9 
10 typedef struct _Mat*           Mat;
11 typedef struct _MatScatterCtx* MatScatterCtx;
12 
13 typedef enum { MATDENSE, MATAIJ, MATMPIAIJ, MATSHELL, MATROW,
14                MATMPIROW, MATMPIROW_BS } MATTYPE;
15 
16 extern int MatCreateSequentialDense(MPI_Comm,int,int,Mat*);
17 extern int MatCreateSequentialAIJ(MPI_Comm,int,int,int,int *,Mat*);
18 extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
19 extern int MatCreateSequentialRow(MPI_Comm,int,int,int,int *,Mat*);
20 extern int MatCreateMPIRow(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
21 extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*);
22 
23 extern int MatShellCreate(MPI_Comm,int,int,void *,Mat*);
24 extern int MatShellSetMult(Mat,int (*)(void*,Vec,Vec));
25 extern int MatShellSetMultTrans(Mat,int (*)(void*,Vec,Vec));
26 extern int MatShellSetMultTransAdd(Mat,int (*)(void*,Vec,Vec,Vec));
27 
28 /* ------------------------------------------------------------*/
29 extern int  MatValidMatrix(Mat);
30 
31 #define FLUSH_ASSEMBLY 1
32 #define FINAL_ASSEMBLY 0
33 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
34 extern int MatBeginAssembly(Mat,int);
35 extern int MatEndAssembly(Mat,int);
36 extern int MatSetOption(Mat,int);
37 #define ROW_ORIENTED              1
38 #define COLUMN_ORIENTED           2
39 #define ROWS_SORTED               4
40 #define COLUMNS_SORTED            8
41 #define NO_NEW_NONZERO_LOCATIONS  16
42 #define YES_NEW_NONZERO_LOCATIONS 32
43 
44 extern int MatGetValues(Mat,Scalar*,int,int*,int,int*);
45 extern int MatGetRow(Mat,int,int *,int **,Scalar**);
46 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
47 extern int MatGetCol(Mat,int,int *,int **,Scalar**);
48 extern int MatRestoreCol(Mat,int,int *,int **,Scalar**);
49 extern int MatGetArray(Mat,Scalar **);
50 extern int MatMult(Mat,Vec,Vec);
51 extern int MatMultAdd(Mat,Vec,Vec,Vec);
52 extern int MatMultTrans(Mat,Vec,Vec);
53 extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
54 
55 #define ORDER_NATURAL 0
56 #define ORDER_ND      1
57 #define ORDER_1WD     2
58 #define ORDER_RCM     3
59 #define ORDER_QMD     4
60 extern int MatGetReordering(Mat,int,IS*,IS*);
61 
62 extern int MatLUFactor(Mat,IS,IS);
63 extern int MatCholeskyFactor(Mat,IS);
64 extern int MatLUFactorSymbolic(Mat,IS,IS,Mat*);
65 extern int MatILUFactorSymbolic(Mat,IS,IS,int,Mat*);
66 extern int MatCholeskyFactorSymbolic(Mat,IS,Mat*);
67 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,int,Mat*);
68 extern int MatLUFactorNumeric(Mat,Mat*);
69 extern int MatCholeskyFactorNumeric(Mat,Mat*);
70 
71 extern int MatSolve(Mat,Vec,Vec);
72 extern int MatSolveAdd(Mat,Vec,Vec,Vec);
73 extern int MatSolveTrans(Mat,Vec,Vec);
74 extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
75 
76 #define SOR_FORWARD_SWEEP            1
77 #define SOR_BACKWARD_SWEEP           2
78 #define SOR_SYMMETRIC_SWEEP          3
79 #define SOR_LOCAL_FORWARD_SWEEP      4
80 #define SOR_LOCAL_BACKWARD_SWEEP     8
81 #define SOR_LOCAL_SYMMETRIC_SWEEP    12
82 #define SOR_ZERO_INITIAL_GUESS       16
83 #define SOR_EISENSTAT                32
84 #define SOR_APPLY_UPPER              64
85 #define SOR_APPLY_LOWER              128
86 extern int MatRelax(Mat,Vec,double,int,double,int,Vec);
87 
88 extern int MatCopy(Mat,Mat*);
89 extern int MatConvert(Mat,MATTYPE,Mat*);
90 extern int MatView(Mat,Viewer);
91 #include <stdio.h>
92 extern int MatPrintMatlab(Mat,FILE*,char *);
93 
94 #define MAT_LOCAL      1
95 #define MAT_GLOBAL_MAX 2
96 #define MAT_GLOBAL_SUM 3
97 
98 extern int MatGetInfo(Mat,int,int*,int*,int*);
99 extern int MatGetDiagonal(Mat,Vec);
100 extern int MatTranspose(Mat);
101 extern int MatScale(Mat,Vec,Vec);
102 extern int MatShrink(Mat,int,int*,int,int*);
103 extern int MatEqual(Mat,Mat);
104 extern int MatScatterBegin(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*);
105 extern int MatScatterEnd(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*);
106 extern int MatReOrder(Mat,IS,IS);
107 
108 #define NORM_1         1
109 #define NORM_2         2
110 #define NORM_FROBENIUS 3
111 #define NORM_INFINITY  4
112 extern int MatNorm(Mat,int,double *);
113 
114 extern int MatZeroEntries(Mat);
115 extern int MatZeroRows(Mat,IS,Scalar*);
116 extern int MatZeroColumns(Mat,IS,Scalar*);
117 
118 extern int MatCompress(Mat);
119 extern int MatDestroy(Mat);
120 
121 extern int MatGetSize(Mat,int*,int*);
122 extern int MatGetLocalSize(Mat,int*,int*);
123 extern int MatGetOwnershipRange(Mat,int*,int*);
124 
125 extern int MatCreateInitialMatrix(MPI_Comm,int,int,Mat*);
126 
127 #endif
128 
129 
130