1 /* $Id: mat.h,v 1.108 1996/07/08 22:24:30 bsmith Exp balay $ */ 2 /* 3 Include file for the matrix component of PETSc 4 */ 5 #ifndef __MAT_PACKAGE 6 #define __MAT_PACKAGE 7 #include "vec.h" 8 9 #define MAT_COOKIE PETSC_COOKIE+5 10 11 typedef struct _Mat* Mat; 12 13 typedef enum { MATSAME=-1, MATSEQDENSE, MATSEQAIJ, MATMPIAIJ, MATSHELL, 14 MATMPIROWBS, MATSEQBDIAG, MATMPIBDIAG, 15 MATMPIDENSE, MATSEQBAIJ, MATMPIBAIJ} MatType; 16 17 extern int MatCreate(MPI_Comm,int,int,Mat*); 18 extern int MatCreateSeqDense(MPI_Comm,int,int,Scalar*,Mat*); 19 extern int MatCreateMPIDense(MPI_Comm,int,int,int,int,Scalar*,Mat*); 20 extern int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*); 21 extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*); 22 extern int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,void*,Mat*); 23 extern int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,Scalar**,Mat*); 24 extern int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,Scalar**,Mat*); 25 extern int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*); 26 extern int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*); 27 28 extern int MatDestroy(Mat); 29 30 extern int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*); 31 extern int MatShellGetContext(Mat,void **); 32 33 34 extern int MatPrintHelp(Mat); 35 36 /* ------------------------------------------------------------*/ 37 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode); 38 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 39 extern int MatAssemblyBegin(Mat,MatAssemblyType); 40 extern int MatAssemblyEnd(Mat,MatAssemblyType); 41 42 typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4, 43 MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16, 44 MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64, 45 MAT_STRUCTURALLY_SYMMETRIC,MAT_NO_NEW_DIAGONALS, 46 MAT_YES_NEW_DIAGONALS,MAT_INODE_LIMIT_1,MAT_INODE_LIMIT_2, 47 MAT_INODE_LIMIT_3,MAT_INODE_LIMIT_4,MAT_INODE_LIMIT_5} MatOption; 48 extern int MatSetOption(Mat,MatOption); 49 extern int MatGetType(Mat,MatType*,char**); 50 extern int MatGetTypeFromOptions(MPI_Comm,char*,MatType*,int*); 51 extern int MatGetValues(Mat,int,int*,int,int*,Scalar*); 52 extern int MatGetRow(Mat,int,int *,int **,Scalar**); 53 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**); 54 extern int MatGetColumn(Mat,int,int *,int **,Scalar**); 55 extern int MatRestoreColumn(Mat,int,int *,int **,Scalar**); 56 extern int MatGetArray(Mat,Scalar **); 57 extern int MatRestoreArray(Mat,Scalar **); 58 extern int MatGetBlockSize(Mat,int *); 59 60 extern int MatMult(Mat,Vec,Vec); 61 extern int MatMultAdd(Mat,Vec,Vec,Vec); 62 extern int MatMultTrans(Mat,Vec,Vec); 63 extern int MatMultTransAdd(Mat,Vec,Vec,Vec); 64 65 extern int MatConvert(Mat,MatType,Mat*); 66 extern int MatCopy(Mat,Mat); 67 extern int MatView(Mat,Viewer); 68 extern int MatLoad(Viewer,MatType,Mat*); 69 70 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 71 extern int MatGetInfo(Mat,MatInfoType,int*,int*,int*); 72 extern int MatValid(Mat,PetscTruth*); 73 extern int MatGetDiagonal(Mat,Vec); 74 extern int MatTranspose(Mat,Mat*); 75 extern int MatDiagonalScale(Mat,Vec,Vec); 76 extern int MatDiagonalShift(Mat,Vec); 77 extern int MatEqual(Mat,Mat, PetscTruth*); 78 79 extern int MatNorm(Mat,NormType,double *); 80 extern int MatZeroEntries(Mat); 81 extern int MatZeroRows(Mat,IS,Scalar*); 82 extern int MatZeroColumns(Mat,IS,Scalar*); 83 84 extern int MatGetSize(Mat,int*,int*); 85 extern int MatGetLocalSize(Mat,int*,int*); 86 extern int MatGetOwnershipRange(Mat,int*,int*); 87 88 typedef enum {MAT_INITIAL_MATRIX, MAT_REUSE_MATRIX} MatGetSubMatrixCall; 89 extern int MatGetSubMatrix(Mat,IS,IS,MatGetSubMatrixCall,Mat*); 90 extern int MatGetSubMatrixInPlace(Mat,IS,IS); 91 extern int MatGetSubMatrices(Mat,int,IS *,IS *,MatGetSubMatrixCall,Mat **); 92 extern int MatIncreaseOverlap(Mat,int,IS *,int); 93 94 extern int MatAXPY(Scalar *,Mat,Mat); 95 extern int MatCompress(Mat); 96 97 extern int MatScale(Scalar *,Mat); 98 extern int MatShift(Scalar *,Mat); 99 100 /* Routines unique to particular data structures */ 101 extern int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***); 102 103 /* 104 These routines are not usually accessed directly, rather solving is 105 done through the SLES, KSP and PC interfaces. 106 */ 107 108 typedef enum {ORDER_NATURAL=0,ORDER_ND=1,ORDER_1WD=2, 109 ORDER_RCM=3,ORDER_QMD=4,ORDER_ROWLENGTH=5,ORDER_FLOW, 110 ORDER_APPLICATION_1,ORDER_APPLICATION_2} MatReordering; 111 extern int MatGetReordering(Mat,MatReordering,IS*,IS*); 112 extern int MatGetReorderingTypeFromOptions(char *,MatReordering*); 113 extern int MatReorderingRegister(MatReordering *,char*,PetscTruth,int, 114 int (*)(int*,int*,int*,int*,int*)); 115 extern int MatReorderingRegisterAll(); 116 extern int MatReorderingRegisterDestroy(); 117 extern int MatReorderingGetName(MatReordering,char **); 118 extern PetscTruth MatReorderingRequiresSymmetric[]; 119 extern int MatReorderingIndexShift[]; 120 121 extern int MatReorderForNonzeroDiagonal(Mat,double,IS,IS); 122 123 extern int MatCholeskyFactor(Mat,IS,double); 124 extern int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*); 125 extern int MatCholeskyFactorNumeric(Mat,Mat*); 126 127 extern int MatLUFactor(Mat,IS,IS,double); 128 extern int MatILUFactor(Mat,IS,IS,double,int); 129 extern int MatLUFactorSymbolic(Mat,IS,IS,double,Mat*); 130 extern int MatILUFactorSymbolic(Mat,IS,IS,double,int,Mat*); 131 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,double,int,Mat*); 132 extern int MatLUFactorNumeric(Mat,Mat*); 133 extern int MatILUDTFactor(Mat,double,int,IS,IS,Mat *); 134 135 136 extern int MatSolve(Mat,Vec,Vec); 137 extern int MatForwardSolve(Mat,Vec,Vec); 138 extern int MatBackwardSolve(Mat,Vec,Vec); 139 extern int MatSolveAdd(Mat,Vec,Vec,Vec); 140 extern int MatSolveTrans(Mat,Vec,Vec); 141 extern int MatSolveTransAdd(Mat,Vec,Vec,Vec); 142 143 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 144 SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 145 SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 146 SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128 147 } MatSORType; 148 extern int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec); 149 150 typedef enum { MAT_SET_VALUES=0, 151 MAT_GET_ROW=1, 152 MAT_RESTORE_ROW=2, 153 MAT_MULT=3, 154 MAT_MULT_ADD=4, 155 MAT_MULT_TRANS=5, 156 MAT_MULT_TRANS_ADD=6, 157 MAT_SOLVE=7, 158 MAT_SOLVE_ADD=8, 159 MAT_SOLVE_TRANS=9, 160 MAT_SOLVE_TRANS_ADD=10, 161 MAT_LUFACTOR=11, 162 MAT_CHOLESKYFACTOR=12, 163 MAT_RELAX=13, 164 MAT_TRANSPOSE=14, 165 MAT_GETINFO=15, 166 MAT_EQUAL=16, 167 MAT_GET_DIAGONAL=17, 168 MAT_DIAGONAL_SCALE=18, 169 MAT_NORM=19, 170 MAT_ASSEMBLY_BEGIN=20, 171 MAT_ASSEMBLY_END=21, 172 MAT_COMPRESS=22, 173 MAT_SET_OPTION=23, 174 MAT_ZERO_ENTRIES=24, 175 MAT_ZERO_ROWS=25, 176 MAT_GET_REORDERING=26, 177 MAT_LUFACTOR_SYMBOLIC=27, 178 MAT_LUFACTOR_NUMERIC=28, 179 MAT_CHOLESKY_FACTOR_SYMBOLIC=29, 180 MAT_CHOLESKY_FACTOR_NUMERIC=30, 181 MAT_GET_SIZE=31, 182 MAT_GET_LOCAL_SIZE=32, 183 MAT_GET_OWNERSHIP_RANGE=33, 184 MAT_ILUFACTOR_SYMBOLIC=34, 185 MAT_INCOMPLETECHOLESKYFACTOR_SYMBOLIC=35, 186 MAT_GET_ARRAY=36, 187 MAT_RESTORE_ARRAY=37, 188 MAT_CONVERT=38, 189 MAT_GET_SUBMATRIX=39, 190 MAT_GET_SUBMATRIX_INPLACE=40, 191 MAT_CONVERT_SAME_TYPE=41, 192 MAT_FORWARD_SOLVE=42, 193 MAT_BACKWARD_SOLVE=43, 194 MAT_ILUFACTOR=44, 195 MAT_INCOMPLETECHOLEKSYFACTOR=45, 196 MAT_AXPY=46, 197 MAT_GET_SUBMATRICES=47, 198 MAT_INCREASE_OVERLAP=48, 199 MAT_GET_VALUES=49, 200 MAT_COPY=50, 201 MAT_PRINT_HELP=51, 202 MAT_SCALE=52, 203 MAT_SHIFT=53, 204 MAT_DIAGONAL_SHIFT=54, 205 MAT_DESTROY=250, 206 MAT_VIEW=251 207 } MatOperation; 208 extern int MatHasOperation(Mat,MatOperation,PetscTruth*); 209 extern int MatShellSetOperation(Mat,MatOperation,void *); 210 211 /* 212 Codes for matrices stored on disk. By default they are 213 stored in a universal format. By changing the format with 214 ViewerSetFormat(viewer,BINARY_FORMAT_NATIVE); the matrices will 215 be stored in a way natural for the matrix, for example dense matrices 216 would be stored as dense. Matrices stored this way may only be 217 read into matrices of the same time. 218 */ 219 #define MATRIX_BINARY_FORMAT_DENSE -1 220 221 #endif 222 223 224 225