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, 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 #define FLUSH_ASSEMBLY 1 34 #define FINAL_ASSEMBLY 0 35 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode); 36 extern int MatBeginAssembly(Mat,int); 37 extern int MatEndAssembly(Mat,int); 38 extern int MatSetOption(Mat,int); 39 #define ROW_ORIENTED 1 40 #define COLUMN_ORIENTED 2 41 #define ROWS_SORTED 4 42 #define COLUMNS_SORTED 8 43 #define NO_NEW_NONZERO_LOCATIONS 16 44 #define YES_NEW_NONZERO_LOCATIONS 32 45 46 extern int MatGetValues(Mat,Scalar*,int,int*,int,int*); 47 extern int MatGetRow(Mat,int,int *,int **,Scalar**); 48 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**); 49 extern int MatGetCol(Mat,int,int *,int **,Scalar**); 50 extern int MatRestoreCol(Mat,int,int *,int **,Scalar**); 51 extern int MatGetArray(Mat,Scalar **); 52 extern int MatMult(Mat,Vec,Vec); 53 extern int MatMultAdd(Mat,Vec,Vec,Vec); 54 extern int MatMultTrans(Mat,Vec,Vec); 55 extern int MatMultTransAdd(Mat,Vec,Vec,Vec); 56 57 #define ORDER_NATURAL 0 58 #define ORDER_ND 1 59 #define ORDER_1WD 2 60 #define ORDER_RCM 3 61 #define ORDER_QMD 4 62 extern int MatGetReordering(Mat,int,IS*,IS*); 63 64 extern int MatLUFactor(Mat,IS,IS); 65 extern int MatCholeskyFactor(Mat,IS); 66 extern int MatLUFactorSymbolic(Mat,IS,IS,Mat*); 67 extern int MatILUFactorSymbolic(Mat,IS,IS,int,Mat*); 68 extern int MatCholeskyFactorSymbolic(Mat,IS,Mat*); 69 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,int,Mat*); 70 extern int MatLUFactorNumeric(Mat,Mat*); 71 extern int MatCholeskyFactorNumeric(Mat,Mat*); 72 73 extern int MatSolve(Mat,Vec,Vec); 74 extern int MatSolveAdd(Mat,Vec,Vec,Vec); 75 extern int MatSolveTrans(Mat,Vec,Vec); 76 extern int MatSolveTransAdd(Mat,Vec,Vec,Vec); 77 78 #define SOR_FORWARD_SWEEP 1 79 #define SOR_BACKWARD_SWEEP 2 80 #define SOR_SYMMETRIC_SWEEP 3 81 #define SOR_LOCAL_FORWARD_SWEEP 4 82 #define SOR_LOCAL_BACKWARD_SWEEP 8 83 #define SOR_LOCAL_SYMMETRIC_SWEEP 12 84 #define SOR_ZERO_INITIAL_GUESS 16 85 #define SOR_EISENSTAT 32 86 #define SOR_APPLY_UPPER 64 87 #define SOR_APPLY_LOWER 128 88 extern int MatRelax(Mat,Vec,double,int,double,int,Vec); 89 90 extern int MatCopy(Mat,Mat*); 91 extern int MatConvert(Mat,MATTYPE,Mat*); 92 extern int MatView(Mat,Viewer); 93 #include <stdio.h> 94 extern int MatPrintMatlab(Mat,FILE*,char *); 95 96 #define MAT_LOCAL 1 97 #define MAT_GLOBAL_MAX 2 98 #define MAT_GLOBAL_SUM 3 99 100 extern int MatGetInfo(Mat,int,int*,int*,int*); 101 extern int MatGetDiagonal(Mat,Vec); 102 extern int MatTranspose(Mat); 103 extern int MatScale(Mat,Vec,Vec); 104 extern int MatShrink(Mat,int,int*,int,int*); 105 extern int MatEqual(Mat,Mat); 106 extern int MatScatterBegin(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*); 107 extern int MatScatterEnd(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*); 108 109 #define NORM_1 1 110 #define NORM_2 2 111 #define NORM_FROBENIUS 3 112 #define NORM_INFINITY 4 113 extern int MatNorm(Mat,int,double *); 114 115 extern int MatZeroEntries(Mat); 116 extern int MatZeroRows(Mat,IS,Scalar*); 117 extern int MatZeroColumns(Mat,IS,Scalar*); 118 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 extern int MatGetSubMatrix(Mat,IS,IS,Mat*); 128 extern int MatGetSubMatrixInPlace(Mat,IS,IS); 129 #endif 130 131 132