xref: /petsc/include/petscmat.h (revision edae2e7dd0bdd187ac013a59d14cdeee7e201c06)
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 { MATSAME=-1, MATDENSE, MATAIJ, MATMPIAIJ, MATSHELL, MATROW,
14                MATMPIROW, MATMPIROW_BS, MATBDIAG, MATMPIBDIAG } 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 extern int MatCreateSequentialBDiag(MPI_Comm,int,int,int,int,int*,
23                                     Scalar**,Mat*);
24 
25 extern int MatShellCreate(MPI_Comm,int,int,void *,Mat*);
26 extern int MatShellSetMult(Mat,int (*)(void*,Vec,Vec));
27 extern int MatShellSetMultTrans(Mat,int (*)(void*,Vec,Vec));
28 extern int MatShellSetMultTransAdd(Mat,int (*)(void*,Vec,Vec,Vec));
29 
30 /* ------------------------------------------------------------*/
31 extern int  MatValidMatrix(Mat);
32 
33 typedef enum {FLUSH_ASSEMBLY=1,FINAL_ASSEMBLY=0} MatAssemblyType;
34 
35 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
36 extern int MatAssemblyBegin(Mat,MatAssemblyType);
37 extern int MatAssemblyEnd(Mat,MatAssemblyType);
38 
39 typedef enum {ROW_ORIENTED=1,COLUMN_ORIENTED=2,ROWS_SORTED=4,
40               COLUMNS_SORTED=8,NO_NEW_NONZERO_LOCATIONS=16,
41               YES_NEW_NONZERO_LOCATIONS=32} MatOption;
42 
43 extern int MatSetOption(Mat,MatOption);
44 
45 extern int MatGetValues(Mat,int,int*,int,int*,Scalar*);
46 extern int MatGetRow(Mat,int,int *,int **,Scalar**);
47 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
48 extern int MatGetCol(Mat,int,int *,int **,Scalar**);
49 extern int MatRestoreCol(Mat,int,int *,int **,Scalar**);
50 extern int MatGetArray(Mat,Scalar **);
51 extern int MatMult(Mat,Vec,Vec);
52 extern int MatMultAdd(Mat,Vec,Vec,Vec);
53 extern int MatMultTrans(Mat,Vec,Vec);
54 extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
55 
56 typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2,ORDER_RCM=3,
57               ORDER_QMD=4} MatOrdering;
58 
59 extern int MatGetReordering(Mat,MatOrdering,IS*,IS*);
60 
61 extern int MatLUFactor(Mat,IS,IS);
62 extern int MatCholeskyFactor(Mat,IS);
63 extern int MatLUFactorSymbolic(Mat,IS,IS,Mat*);
64 extern int MatILUFactorSymbolic(Mat,IS,IS,int,Mat*);
65 extern int MatCholeskyFactorSymbolic(Mat,IS,Mat*);
66 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,int,Mat*);
67 extern int MatLUFactorNumeric(Mat,Mat*);
68 extern int MatCholeskyFactorNumeric(Mat,Mat*);
69 
70 extern int MatSolve(Mat,Vec,Vec);
71 extern int MatSolveAdd(Mat,Vec,Vec,Vec);
72 extern int MatSolveTrans(Mat,Vec,Vec);
73 extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
74 
75 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
76               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
77               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
78               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128
79               } MatSORType;
80 
81 extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
82 
83 extern int MatConvert(Mat,MatType,Mat*);
84 extern int MatView(Mat,Viewer);
85 #include <stdio.h>
86 
87 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
88 
89 extern int MatGetInfo(Mat,MatInfoType,int*,int*,int*);
90 extern int MatGetDiagonal(Mat,Vec);
91 extern int MatTranspose(Mat);
92 extern int MatScale(Mat,Vec,Vec);
93 extern int MatEqual(Mat,Mat);
94 extern int MatScatterBegin(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*);
95 extern int MatScatterEnd(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*);
96 
97 typedef enum {NORM_1=1,NORM_2=2,NORM_FROBENIUS=3,NORM_INFINITY=4} MatNormType;
98 extern int MatNorm(Mat,MatNormType,double *);
99 
100 extern int MatZeroEntries(Mat);
101 extern int MatZeroRows(Mat,IS,Scalar*);
102 extern int MatZeroColumns(Mat,IS,Scalar*);
103 
104 extern int MatDestroy(Mat);
105 
106 extern int MatGetSize(Mat,int*,int*);
107 extern int MatGetLocalSize(Mat,int*,int*);
108 extern int MatGetOwnershipRange(Mat,int*,int*);
109 
110 extern int MatCreateInitialMatrix(MPI_Comm,int,int,Mat*);
111 
112 extern int MatGetSubMatrix(Mat,IS,IS,Mat*);
113 extern int MatGetSubMatrixInPlace(Mat,IS,IS);
114 #endif
115 
116 
117