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, 14ee50ffe9SBarry 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 33ee50ffe9SBarry Smith typedef enum {FLUSH_ASSEMBLY=1,FINAL_ASSEMBLY=0} MatAssemblyType; 342eac72dbSBarry Smith 35ee50ffe9SBarry Smith extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode); 36ee50ffe9SBarry Smith extern int MatAssemblyBegin(Mat,MatAssemblyType); 37ee50ffe9SBarry Smith extern int MatAssemblyEnd(Mat,MatAssemblyType); 38ee50ffe9SBarry Smith 39ee50ffe9SBarry Smith typedef enum {ROW_ORIENTED=1,COLUMN_ORIENTED=2,ROWS_SORTED=4, 40ee50ffe9SBarry Smith COLUMNS_SORTED=8,NO_NEW_NONZERO_LOCATIONS=16, 41*ca9b4cbeSLois Curfman McInnes YES_NEW_NONZERO_LOCATIONS=32} MatOption; 42ee50ffe9SBarry Smith 43ee50ffe9SBarry Smith extern int MatSetOption(Mat,MatOption); 44ee50ffe9SBarry Smith 45ee50ffe9SBarry Smith extern int MatGetValues(Mat,int,int*,int,int*,Scalar*); 468ed539a5SBarry Smith extern int MatGetRow(Mat,int,int *,int **,Scalar**); 478ed539a5SBarry Smith extern int MatRestoreRow(Mat,int,int *,int **,Scalar**); 488ed539a5SBarry Smith extern int MatGetCol(Mat,int,int *,int **,Scalar**); 498ed539a5SBarry Smith extern int MatRestoreCol(Mat,int,int *,int **,Scalar**); 5064e87e97SBarry Smith extern int MatGetArray(Mat,Scalar **); 518ed539a5SBarry Smith extern int MatMult(Mat,Vec,Vec); 528ed539a5SBarry Smith extern int MatMultAdd(Mat,Vec,Vec,Vec); 538ed539a5SBarry Smith extern int MatMultTrans(Mat,Vec,Vec); 548ed539a5SBarry Smith extern int MatMultTransAdd(Mat,Vec,Vec,Vec); 552eac72dbSBarry Smith 56ee50ffe9SBarry Smith typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2,ORDER_RCM=3, 57*ca9b4cbeSLois Curfman McInnes ORDER_QMD=4} MatOrdering; 58ee50ffe9SBarry Smith 59ee50ffe9SBarry Smith extern int MatGetReordering(Mat,MatOrdering,IS*,IS*); 602eac72dbSBarry Smith 618ed539a5SBarry Smith extern int MatLUFactor(Mat,IS,IS); 628ed539a5SBarry Smith extern int MatCholeskyFactor(Mat,IS); 638ed539a5SBarry Smith extern int MatLUFactorSymbolic(Mat,IS,IS,Mat*); 64da3a660dSBarry Smith extern int MatILUFactorSymbolic(Mat,IS,IS,int,Mat*); 658ed539a5SBarry Smith extern int MatCholeskyFactorSymbolic(Mat,IS,Mat*); 66da3a660dSBarry Smith extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,int,Mat*); 6720563c6bSBarry Smith extern int MatLUFactorNumeric(Mat,Mat*); 6820563c6bSBarry Smith extern int MatCholeskyFactorNumeric(Mat,Mat*); 698ed539a5SBarry Smith 708ed539a5SBarry Smith extern int MatSolve(Mat,Vec,Vec); 718ed539a5SBarry Smith extern int MatSolveAdd(Mat,Vec,Vec,Vec); 7228988994SBarry Smith extern int MatSolveTrans(Mat,Vec,Vec); 7328988994SBarry Smith extern int MatSolveTransAdd(Mat,Vec,Vec,Vec); 748ed539a5SBarry Smith 75ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 76ee50ffe9SBarry Smith SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 77ee50ffe9SBarry Smith SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 78*ca9b4cbeSLois Curfman McInnes SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128 79*ca9b4cbeSLois Curfman McInnes } MatSORType; 80ee50ffe9SBarry Smith 81*ca9b4cbeSLois Curfman McInnes extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec); 828ed539a5SBarry Smith 838ed539a5SBarry Smith extern int MatCopy(Mat,Mat*); 84*ca9b4cbeSLois Curfman McInnes extern int MatConvert(Mat,MatType,Mat*); 858ed539a5SBarry Smith extern int MatView(Mat,Viewer); 868ed539a5SBarry Smith #include <stdio.h> 8796c0e93cSLois Curfman McInnes 88ee50ffe9SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 8996c0e93cSLois Curfman McInnes 90ee50ffe9SBarry 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 98ee50ffe9SBarry Smith typedef enum {NORM_1=1,NORM_2=2,NORM_FROBENIUS=3,NORM_INFINITY=4} MatNormType; 99ee50ffe9SBarry 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