xref: /petsc/include/petscmat.h (revision ee50ffe966498ec495bb64049319c83a41ec94f4)
12eac72dbSBarry Smith /*
22eac72dbSBarry Smith      Include file for the matrix component of PETSc
32eac72dbSBarry Smith */
41eb62cbbSBarry Smith #ifndef __MAT_PACKAGE
51eb62cbbSBarry Smith #define __MAT_PACKAGE
68ed539a5SBarry Smith #include "vec.h"
72eac72dbSBarry Smith 
89cd28387SBarry Smith #define MAT_COOKIE PETSC_COOKIE+5
9f0479e8cSBarry Smith 
102eac72dbSBarry Smith typedef struct _Mat*           Mat;
112eac72dbSBarry Smith typedef struct _MatScatterCtx* MatScatterCtx;
122eac72dbSBarry Smith 
131fb19edaSLois Curfman McInnes typedef enum { MATDENSE, MATAIJ, MATMPIAIJ, MATSHELL, MATROW,
14*ee50ffe9SBarry Smith                MATMPIROW, MATMPIROW_BS, MATBDIAG, MATMPIBDIAG } MatType;
1528988994SBarry Smith 
166b5873e3SBarry Smith extern int MatCreateSequentialDense(MPI_Comm,int,int,Mat*);
176b5873e3SBarry Smith extern int MatCreateSequentialAIJ(MPI_Comm,int,int,int,int *,Mat*);
189717bf64SBarry Smith extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
196b5873e3SBarry Smith extern int MatCreateSequentialRow(MPI_Comm,int,int,int,int *,Mat*);
20d7692543SLois Curfman McInnes extern int MatCreateMPIRow(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*);
21cfe223acSLois Curfman McInnes extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*);
22fdb36d4aSLois Curfman McInnes extern int MatCreateSequentialBDiag(MPI_Comm,int,int,int,int,int*,
23fdb36d4aSLois Curfman McInnes                                     Scalar**,Mat*);
249717bf64SBarry Smith 
256b5873e3SBarry Smith extern int MatShellCreate(MPI_Comm,int,int,void *,Mat*);
26aabeff55SBarry Smith extern int MatShellSetMult(Mat,int (*)(void*,Vec,Vec));
27aabeff55SBarry Smith extern int MatShellSetMultTrans(Mat,int (*)(void*,Vec,Vec));
28f0479e8cSBarry Smith extern int MatShellSetMultTransAdd(Mat,int (*)(void*,Vec,Vec,Vec));
292eac72dbSBarry Smith 
308ed539a5SBarry Smith /* ------------------------------------------------------------*/
318ed539a5SBarry Smith extern int  MatValidMatrix(Mat);
322eac72dbSBarry Smith 
33*ee50ffe9SBarry Smith typedef enum {FLUSH_ASSEMBLY=1,FINAL_ASSEMBLY=0} MatAssemblyType;
342eac72dbSBarry Smith 
35*ee50ffe9SBarry Smith extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode);
36*ee50ffe9SBarry Smith extern int MatAssemblyBegin(Mat,MatAssemblyType);
37*ee50ffe9SBarry Smith extern int MatAssemblyEnd(Mat,MatAssemblyType);
38*ee50ffe9SBarry Smith 
39*ee50ffe9SBarry Smith 
40*ee50ffe9SBarry Smith typedef enum {ROW_ORIENTED=1,COLUMN_ORIENTED=2,ROWS_SORTED=4,
41*ee50ffe9SBarry Smith               COLUMNS_SORTED=8,NO_NEW_NONZERO_LOCATIONS=16,
42*ee50ffe9SBarry Smith               YES_NEW_NONZERO_LOCATIONS=32} MatSORType;
43*ee50ffe9SBarry Smith 
44*ee50ffe9SBarry Smith extern int MatSetOption(Mat,MatOption);
45*ee50ffe9SBarry Smith 
46*ee50ffe9SBarry Smith extern int MatGetValues(Mat,int,int*,int,int*,Scalar*);
478ed539a5SBarry Smith extern int MatGetRow(Mat,int,int *,int **,Scalar**);
488ed539a5SBarry Smith extern int MatRestoreRow(Mat,int,int *,int **,Scalar**);
498ed539a5SBarry Smith extern int MatGetCol(Mat,int,int *,int **,Scalar**);
508ed539a5SBarry Smith extern int MatRestoreCol(Mat,int,int *,int **,Scalar**);
5164e87e97SBarry Smith extern int MatGetArray(Mat,Scalar **);
528ed539a5SBarry Smith extern int MatMult(Mat,Vec,Vec);
538ed539a5SBarry Smith extern int MatMultAdd(Mat,Vec,Vec,Vec);
548ed539a5SBarry Smith extern int MatMultTrans(Mat,Vec,Vec);
558ed539a5SBarry Smith extern int MatMultTransAdd(Mat,Vec,Vec,Vec);
562eac72dbSBarry Smith 
57*ee50ffe9SBarry Smith typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2,ORDER_RCM=3,
58*ee50ffe9SBarry Smith               ORDER_QMD=4} MatOrdering);
59*ee50ffe9SBarry Smith 
60*ee50ffe9SBarry Smith extern int MatGetReordering(Mat,MatOrdering,IS*,IS*);
612eac72dbSBarry Smith 
628ed539a5SBarry Smith extern int MatLUFactor(Mat,IS,IS);
638ed539a5SBarry Smith extern int MatCholeskyFactor(Mat,IS);
648ed539a5SBarry Smith extern int MatLUFactorSymbolic(Mat,IS,IS,Mat*);
65da3a660dSBarry Smith extern int MatILUFactorSymbolic(Mat,IS,IS,int,Mat*);
668ed539a5SBarry Smith extern int MatCholeskyFactorSymbolic(Mat,IS,Mat*);
67da3a660dSBarry Smith extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,int,Mat*);
6820563c6bSBarry Smith extern int MatLUFactorNumeric(Mat,Mat*);
6920563c6bSBarry Smith extern int MatCholeskyFactorNumeric(Mat,Mat*);
708ed539a5SBarry Smith 
718ed539a5SBarry Smith extern int MatSolve(Mat,Vec,Vec);
728ed539a5SBarry Smith extern int MatSolveAdd(Mat,Vec,Vec,Vec);
7328988994SBarry Smith extern int MatSolveTrans(Mat,Vec,Vec);
7428988994SBarry Smith extern int MatSolveTransAdd(Mat,Vec,Vec,Vec);
758ed539a5SBarry Smith 
76*ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3,
77*ee50ffe9SBarry Smith               SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8,
78*ee50ffe9SBarry Smith               SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16,
79*ee50ffe9SBarry Smith               SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} SORType;
80*ee50ffe9SBarry Smith 
81*ee50ffe9SBarry Smith extern int MatRelax(Mat,Vec,double,SORType,double,int,Vec);
828ed539a5SBarry Smith 
838ed539a5SBarry Smith extern int MatCopy(Mat,Mat*);
84bd39fac1SBarry Smith extern int MatConvert(Mat,MATTYPE,Mat*);
858ed539a5SBarry Smith extern int MatView(Mat,Viewer);
868ed539a5SBarry Smith #include <stdio.h>
8796c0e93cSLois Curfman McInnes 
88*ee50ffe9SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType;
8996c0e93cSLois Curfman McInnes 
90*ee50ffe9SBarry Smith extern int MatGetInfo(Mat,MatInfoType,int*,int*,int*);
918ed539a5SBarry Smith extern int MatGetDiagonal(Mat,Vec);
928ed539a5SBarry Smith extern int MatTranspose(Mat);
938ed539a5SBarry Smith extern int MatScale(Mat,Vec,Vec);
948ed539a5SBarry Smith extern int MatEqual(Mat,Mat);
9520563c6bSBarry Smith extern int MatScatterBegin(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*);
9620563c6bSBarry Smith extern int MatScatterEnd(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*);
972eac72dbSBarry Smith 
98*ee50ffe9SBarry Smith typedef enum {NORM_1=1,NORM_2=2,NORM_FROBENIUS=3,NORM_INFINITY=4} MatNormType;
99*ee50ffe9SBarry Smith extern int MatNorm(Mat,MatNormType,double *);
1002eac72dbSBarry Smith 
1018ed539a5SBarry Smith extern int MatZeroEntries(Mat);
10220563c6bSBarry Smith extern int MatZeroRows(Mat,IS,Scalar*);
10320563c6bSBarry Smith extern int MatZeroColumns(Mat,IS,Scalar*);
1048ed539a5SBarry Smith 
1058ed539a5SBarry Smith extern int MatDestroy(Mat);
1068ed539a5SBarry Smith 
1071eb62cbbSBarry Smith extern int MatGetSize(Mat,int*,int*);
1081eb62cbbSBarry Smith extern int MatGetLocalSize(Mat,int*,int*);
109d6dfbf8fSBarry Smith extern int MatGetOwnershipRange(Mat,int*,int*);
1101eb62cbbSBarry Smith 
1116b5873e3SBarry Smith extern int MatCreateInitialMatrix(MPI_Comm,int,int,Mat*);
1128ed539a5SBarry Smith 
1136eafb6e7SBarry Smith extern int MatGetSubMatrix(Mat,IS,IS,Mat*);
1146eafb6e7SBarry Smith extern int MatGetSubMatrixInPlace(Mat,IS,IS);
1152eac72dbSBarry Smith #endif
1162eac72dbSBarry Smith 
1172eac72dbSBarry Smith 
118