xref: /petsc/include/petscmat.h (revision 7b80b807861f1542763fac2712b0420aa07468f2)
1*7b80b807SBarry Smith /* $Id: mat.h,v 1.83 1995/12/31 03:12:43 bsmith Exp bsmith $ */
22eac72dbSBarry Smith /*
32eac72dbSBarry Smith      Include file for the matrix component of PETSc
42eac72dbSBarry Smith */
51eb62cbbSBarry Smith #ifndef __MAT_PACKAGE
61eb62cbbSBarry Smith #define __MAT_PACKAGE
78ed539a5SBarry Smith #include "vec.h"
82eac72dbSBarry Smith 
99cd28387SBarry Smith #define MAT_COOKIE         PETSC_COOKIE+5
10f0479e8cSBarry Smith 
112eac72dbSBarry Smith typedef struct _Mat*           Mat;
122eac72dbSBarry Smith 
134ac9ca07SLois Curfman McInnes typedef enum { MATSAME=-1, MATSEQDENSE, MATSEQAIJ, MATMPIAIJ, MATSHELL,
144ac9ca07SLois Curfman McInnes                MATSEQROW, MATMPIROW, MATMPIROWBS, MATSEQBDIAG, MATMPIBDIAG,
154ac9ca07SLois Curfman McInnes                MATMPIDENSE } MatType;
1628988994SBarry Smith 
170e998a85SBarry Smith extern int MatCreate(MPI_Comm,int,int,Mat*);
18df6e0191SLois Curfman McInnes extern int MatCreateSeqDense(MPI_Comm,int,int,Scalar*,Mat*);
19d5bc1036SLois Curfman McInnes extern int MatCreateMPIDense(MPI_Comm,int,int,int,int,Scalar*,Mat*);
20de7da479SBarry Smith extern int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*);
219717bf64SBarry Smith extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
22de7da479SBarry Smith extern int MatCreateSeqRow(MPI_Comm,int,int,int,int*,Mat*);
23d7692543SLois Curfman McInnes extern int MatCreateMPIRow(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
24cfe223acSLois Curfman McInnes extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*);
25f26ada1bSBarry Smith extern int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,Scalar**,Mat*);
26f26ada1bSBarry Smith extern int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,Scalar**,Mat*);
279717bf64SBarry Smith 
28*7b80b807SBarry Smith extern int MatDestroy(Mat);
29*7b80b807SBarry Smith 
306b5873e3SBarry Smith extern int MatShellCreate(MPI_Comm,int,int,void *,Mat*);
3117116c71SBarry Smith extern int MatShellGetContext(Mat,void **);
32aabeff55SBarry Smith extern int MatShellSetMult(Mat,int (*)(void*,Vec,Vec));
33b9fa9cd0SBarry Smith extern int MatShellSetDestroy(Mat,int (*)(void*));
34aabeff55SBarry Smith extern int MatShellSetMultTrans(Mat,int (*)(void*,Vec,Vec));
35f0479e8cSBarry Smith extern int MatShellSetMultTransAdd(Mat,int (*)(void*,Vec,Vec,Vec));
362eac72dbSBarry Smith 
378ed539a5SBarry Smith /* ------------------------------------------------------------*/
38ee50ffe9SBarry Smith extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
39*7b80b807SBarry Smith typedef enum {FLUSH_ASSEMBLY=1,FINAL_ASSEMBLY=0} MatAssemblyType;
40ee50ffe9SBarry Smith extern int MatAssemblyBegin(Mat,MatAssemblyType);
41ee50ffe9SBarry Smith extern int MatAssemblyEnd(Mat,MatAssemblyType);
42ee50ffe9SBarry Smith 
43ee50ffe9SBarry Smith typedef enum {ROW_ORIENTED=1,COLUMN_ORIENTED=2,ROWS_SORTED=4,
44ee50ffe9SBarry Smith               COLUMNS_SORTED=8,NO_NEW_NONZERO_LOCATIONS=16,
4502834360SBarry Smith               YES_NEW_NONZERO_LOCATIONS=32,SYMMETRIC_MATRIX=64,
46c0bbcb79SLois Curfman McInnes               STRUCTURALLY_SYMMETRIC_MATRIX,NO_NEW_DIAGONALS,
47429c0c78SLois Curfman McInnes               YES_NEW_DIAGONALS,INODE_LIMIT_1,INODE_LIMIT_2,
48429c0c78SLois Curfman McInnes               INODE_LIMIT_3,INODE_LIMIT_4,INODE_LIMIT_5} MatOption;
49ee50ffe9SBarry Smith extern int MatSetOption(Mat,MatOption);
50dbd7a890SLois Curfman McInnes extern int MatGetType(Mat,MatType*);
51dae03382SLois Curfman McInnes extern int MatGetName(Mat,char**);
52e3726954SLois Curfman McInnes extern int MatGetFormatFromOptions(MPI_Comm,char*,MatType*,int*);
53ee50ffe9SBarry Smith extern int MatGetValues(Mat,int,int*,int,int*,Scalar*);
548ed539a5SBarry Smith extern int MatGetRow(Mat,int,int *,int **,Scalar**);
558ed539a5SBarry Smith extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
568ed539a5SBarry Smith extern int MatGetCol(Mat,int,int *,int **,Scalar**);
578ed539a5SBarry Smith extern int MatRestoreCol(Mat,int,int *,int **,Scalar**);
5864e87e97SBarry Smith extern int MatGetArray(Mat,Scalar **);
59*7b80b807SBarry Smith 
608ed539a5SBarry Smith extern int MatMult(Mat,Vec,Vec);
618ed539a5SBarry Smith extern int MatMultAdd(Mat,Vec,Vec,Vec);
628ed539a5SBarry Smith extern int MatMultTrans(Mat,Vec,Vec);
638ed539a5SBarry Smith extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
642eac72dbSBarry Smith 
65*7b80b807SBarry Smith extern int MatConvert(Mat,MatType,Mat*);
66*7b80b807SBarry Smith extern int MatCopy(Mat,Mat);
67*7b80b807SBarry Smith extern int MatView(Mat,Viewer);
68*7b80b807SBarry Smith extern int MatLoad(Viewer,MatType,Mat*);
69*7b80b807SBarry Smith 
70*7b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
71*7b80b807SBarry Smith extern int MatGetInfo(Mat,MatInfoType,int*,int*,int*);
72*7b80b807SBarry Smith extern int MatValidMatrix(Mat);
73*7b80b807SBarry Smith extern int MatGetDiagonal(Mat,Vec);
74*7b80b807SBarry Smith extern int MatTranspose(Mat,Mat*);
75*7b80b807SBarry Smith extern int MatScale(Mat,Vec,Vec);
76*7b80b807SBarry Smith extern int MatEqual(Mat,Mat);
77*7b80b807SBarry Smith 
78*7b80b807SBarry Smith extern int MatNorm(Mat,NormType,double *);
79*7b80b807SBarry Smith extern int MatZeroEntries(Mat);
80*7b80b807SBarry Smith extern int MatZeroRows(Mat,IS,Scalar*);
81*7b80b807SBarry Smith extern int MatZeroColumns(Mat,IS,Scalar*);
82*7b80b807SBarry Smith 
83*7b80b807SBarry Smith extern int MatGetSize(Mat,int*,int*);
84*7b80b807SBarry Smith extern int MatGetLocalSize(Mat,int*,int*);
85*7b80b807SBarry Smith extern int MatGetOwnershipRange(Mat,int*,int*);
86*7b80b807SBarry Smith 
87*7b80b807SBarry Smith typedef enum {MAT_INITIAL_MATRIX, MAT_REUSE_MATRIX} MatGetSubMatrixCall;
88*7b80b807SBarry Smith extern int MatGetSubMatrix(Mat,IS,IS,MatGetSubMatrixCall,Mat*);
89*7b80b807SBarry Smith extern int MatGetSubMatrixInPlace(Mat,IS,IS);
90*7b80b807SBarry Smith extern int MatGetSubMatrices(Mat,int,IS *,IS *,MatGetSubMatrixCall,Mat **);
91*7b80b807SBarry Smith extern int MatIncreaseOverlap(Mat,int,IS *,int);
92*7b80b807SBarry Smith 
93*7b80b807SBarry Smith extern int MatAXPY(Scalar *,Mat,Mat);
94*7b80b807SBarry Smith extern int MatCompress(Mat);
95*7b80b807SBarry Smith 
96*7b80b807SBarry Smith /* Routines unique to particular data structures */
97*7b80b807SBarry Smith extern int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***);
98*7b80b807SBarry Smith 
99*7b80b807SBarry Smith /*
100*7b80b807SBarry Smith   These routines are not usually accessed directly, rather solving is
101*7b80b807SBarry Smith   done through the SLES, KSP and PC interfaces.
102*7b80b807SBarry Smith */
103*7b80b807SBarry Smith 
10483f0b094SBarry Smith typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2,
105464493b3SBarry Smith               ORDER_RCM=3,ORDER_QMD=4,ORDER_APPLICATION_1,
106464493b3SBarry Smith               ORDER_APPLICATION_2} MatOrdering;
107ee50ffe9SBarry Smith extern int MatGetReordering(Mat,MatOrdering,IS*,IS*);
108d7b056bfSBarry Smith extern int MatGetReorderingTypeFromOptions(char *,MatOrdering*);
109832a8ecbSBarry Smith extern int MatReorderForNonzeroDiagonal(Mat,double,IS,IS);
110f26ada1bSBarry Smith extern int MatReorderingRegister(MatOrdering,char*,int (*)(int*,int*,int*,int*,int*));
111464493b3SBarry Smith extern int MatReorderingRegisterAll();
112464493b3SBarry Smith extern int MatReorderingRegisterDestroy();
1132eac72dbSBarry Smith 
11449d8b64dSBarry Smith extern int MatLUFactor(Mat,IS,IS,double);
115d7b056bfSBarry Smith extern int MatILUFactor(Mat,IS,IS,double,int);
11649d8b64dSBarry Smith extern int MatCholeskyFactor(Mat,IS,double);
11764051cb3SBarry Smith extern int MatLUFactorSymbolic(Mat,IS,IS,double,Mat*);
11864051cb3SBarry Smith extern int MatILUFactorSymbolic(Mat,IS,IS,double,int,Mat*);
11964051cb3SBarry Smith extern int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*);
12064051cb3SBarry Smith extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*);
12120563c6bSBarry Smith extern int MatLUFactorNumeric(Mat,Mat*);
12220563c6bSBarry Smith extern int MatCholeskyFactorNumeric(Mat,Mat*);
1238ed539a5SBarry Smith 
1248ed539a5SBarry Smith extern int MatSolve(Mat,Vec,Vec);
12522169318SLois Curfman McInnes extern int MatForwardSolve(Mat,Vec,Vec);
12622169318SLois Curfman McInnes extern int MatBackwardSolve(Mat,Vec,Vec);
1278ed539a5SBarry Smith extern int MatSolveAdd(Mat,Vec,Vec,Vec);
12828988994SBarry Smith extern int MatSolveTrans(Mat,Vec,Vec);
12928988994SBarry Smith extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
1308ed539a5SBarry Smith 
131ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
132ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
133ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
134ca9b4cbeSLois Curfman McInnes               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128
135ca9b4cbeSLois Curfman McInnes               } MatSORType;
136ca9b4cbeSLois Curfman McInnes extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec);
1378ed539a5SBarry Smith 
138037ecd73SBarry Smith /*  Not currently supported!
139037ecd73SBarry Smith #define MAT_SCATTER_COOKIE PETSC_COOKIE+15
140037ecd73SBarry Smith typedef struct _MatScatter* MatScatter;
141037ecd73SBarry Smith 
142037ecd73SBarry Smith extern int MatScatterBegin(Mat,Mat,InsertMode,MatScatter);
143037ecd73SBarry Smith extern int MatScatterEnd(Mat,Mat,InsertMode,MatScatter);
144037ecd73SBarry Smith extern int MatScatterCreate(Mat,IS,IS,Mat,IS,IS,MatScatter*);
145037ecd73SBarry Smith extern int MatScatterDestroy(MatScatter);
146037ecd73SBarry Smith */
1472eac72dbSBarry Smith 
1482eac72dbSBarry Smith #endif
1492eac72dbSBarry Smith 
1502eac72dbSBarry Smith 
1519d00d63dSBarry Smith 
152