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 14 #define MATDENSESEQ 0 15 #define MATAIJSEQ 1 16 #define MATAIJMPI 2 17 #define MATSHELL 3 18 19 extern int MatCreateSequentialDense(int,int,Mat*); 20 extern int MatCreateSequentialAIJ(int,int,int,int *,Mat*); 21 extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*); 22 23 extern int MatShellCreate(int,int,void *,Mat*); 24 extern int MatShellSetMult(Mat,int (*)(void*,Vec,Vec)); 25 extern int MatShellSetMultTrans(Mat,int (*)(void*,Vec,Vec)); 26 extern int MatShellSetMultTransAdd(Mat,int (*)(void*,Vec,Vec,Vec)); 27 28 /* ------------------------------------------------------------*/ 29 extern int MatValidMatrix(Mat); 30 31 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode); 32 extern int MatBeginAssembly(Mat); 33 extern int MatEndAssembly(Mat); 34 extern int MatSetOption(Mat,int); 35 #define ROW_ORIENTED 1 36 #define COLUMN_ORIENTED 2 37 #define ROWS_SORTED 4 38 #define COLUMNS_SORTED 8 39 #define NO_NEW_NONZERO_LOCATIONS 16 40 #define YES_NEW_NONZERO_LOCATIONS 32 41 42 extern int MatGetValues(Mat,Scalar*,int,int*,int,int*); 43 extern int MatGetRow(Mat,int,int *,int **,Scalar**); 44 extern int MatRestoreRow(Mat,int,int *,int **,Scalar**); 45 extern int MatGetCol(Mat,int,int *,int **,Scalar**); 46 extern int MatRestoreCol(Mat,int,int *,int **,Scalar**); 47 48 extern int MatMult(Mat,Vec,Vec); 49 extern int MatMultAdd(Mat,Vec,Vec,Vec); 50 extern int MatMultTrans(Mat,Vec,Vec); 51 extern int MatMultTransAdd(Mat,Vec,Vec,Vec); 52 53 #define ORDER_NATURAL 0 54 #define ORDER_ND 1 55 #define ORDER_1WD 2 56 #define ORDER_RCM 3 57 #define ORDER_QMD 4 58 extern int MatGetReordering(Mat,int,IS*,IS*); 59 60 extern int MatLUFactor(Mat,IS,IS); 61 extern int MatCholeskyFactor(Mat,IS); 62 extern int MatLUFactorSymbolic(Mat,IS,IS,Mat*); 63 extern int MatILUFactorSymbolic(Mat,IS,IS,int,Mat*); 64 extern int MatCholeskyFactorSymbolic(Mat,IS,Mat*); 65 extern int MatIncompleteCholeskyFactorSymbolic(Mat,IS,int,Mat*); 66 extern int MatLUFactorNumeric(Mat,Mat*); 67 extern int MatCholeskyFactorNumeric(Mat,Mat*); 68 69 extern int MatSolve(Mat,Vec,Vec); 70 extern int MatSolveAdd(Mat,Vec,Vec,Vec); 71 extern int MatSolveTrans(Mat,Vec,Vec); 72 extern int MatSolveTransAdd(Mat,Vec,Vec,Vec); 73 74 #define SOR_FORWARD_SWEEP 1 75 #define SOR_BACKWARD_SWEEP 2 76 #define SOR_SYMMETRIC_SWEEP 3 77 #define SOR_LOCAL_FORWARD_SWEEP 4 78 #define SOR_LOCAL_BACKWARD_SWEEP 8 79 #define SOR_LOCAL_SYMMETRIC_SWEEP 12 80 #define SOR_ZERO_INITIAL_GUESS 16 81 #define SOR_EISENSTAT 32 82 #define SOR_APPLY_UPPER 64 83 #define SOR_APPLY_LOWER 128 84 extern int MatRelax(Mat,Vec,double,int,double,int,Vec); 85 86 extern int MatCopy(Mat,Mat*); 87 extern int MatView(Mat,Viewer); 88 #include <stdio.h> 89 extern int MatPrintMatlab(Mat,FILE*,char *); 90 extern int MatNonZeros(Mat,int*); 91 extern int MatMemoryUsed(Mat,int*); 92 extern int MatGetDiagonal(Mat,Vec); 93 extern int MatTranspose(Mat); 94 extern int MatScale(Mat,Vec,Vec); 95 extern int MatShrink(Mat,int,int*,int,int*); 96 extern int MatEqual(Mat,Mat); 97 extern int MatScatterBegin(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*); 98 extern int MatScatterEnd(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*); 99 extern int MatReOrder(Mat,IS,IS); 100 101 #define NORM_1 1 102 #define NORM_2 2 103 #define NORM_FROBENIUS 3 104 #define NORM_INFINITY 4 105 extern int MatNorm(Mat,int,double *); 106 107 extern int MatZeroEntries(Mat); 108 extern int MatZeroRows(Mat,IS,Scalar*); 109 extern int MatZeroColumns(Mat,IS,Scalar*); 110 111 extern int MatCompress(Mat); 112 extern int MatDestroy(Mat); 113 114 extern int MatGetSize(Mat,int*,int*); 115 extern int MatGetLocalSize(Mat,int*,int*); 116 extern int MatGetOwnershipRange(Mat,int*,int*); 117 118 extern int MatCreateInitialMatrix(int,int,Mat*); 119 120 121 122 123 #endif 124 125 126