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 #define MATROWSEQ 4 19 #define MATROWMPI 5 20 21 extern int MatCreateSequentialDense(int,int,Mat*); 22 extern int MatCreateSequentialAIJ(int,int,int,int *,Mat*); 23 extern int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*); 24 extern int MatCreateSequentialRow(int,int,int,int *,Mat*); 25 extern int MatCreateMPIRow(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*); 26 27 extern int MatShellCreate(int,int,void *,Mat*); 28 extern int MatShellSetMult(Mat,int (*)(void*,Vec,Vec)); 29 extern int MatShellSetMultTrans(Mat,int (*)(void*,Vec,Vec)); 30 extern int MatShellSetMultTransAdd(Mat,int (*)(void*,Vec,Vec,Vec)); 31 32 /* ------------------------------------------------------------*/ 33 extern int MatValidMatrix(Mat); 34 35 extern int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode); 36 extern int MatBeginAssembly(Mat); 37 extern int MatEndAssembly(Mat); 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 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 MatView(Mat,Viewer); 92 #include <stdio.h> 93 extern int MatPrintMatlab(Mat,FILE*,char *); 94 extern int MatNonZeros(Mat,int*); 95 extern int MatMemoryUsed(Mat,int*); 96 extern int MatGetDiagonal(Mat,Vec); 97 extern int MatTranspose(Mat); 98 extern int MatScale(Mat,Vec,Vec); 99 extern int MatShrink(Mat,int,int*,int,int*); 100 extern int MatEqual(Mat,Mat); 101 extern int MatScatterBegin(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*); 102 extern int MatScatterEnd(Mat,IS,IS,Mat,IS,IS,InsertMode,MatScatterCtx*); 103 extern int MatReOrder(Mat,IS,IS); 104 105 #define NORM_1 1 106 #define NORM_2 2 107 #define NORM_FROBENIUS 3 108 #define NORM_INFINITY 4 109 extern int MatNorm(Mat,int,double *); 110 111 extern int MatZeroEntries(Mat); 112 extern int MatZeroRows(Mat,IS,Scalar*); 113 extern int MatZeroColumns(Mat,IS,Scalar*); 114 115 extern int MatCompress(Mat); 116 extern int MatDestroy(Mat); 117 118 extern int MatGetSize(Mat,int*,int*); 119 extern int MatGetLocalSize(Mat,int*,int*); 120 extern int MatGetOwnershipRange(Mat,int*,int*); 121 122 extern int MatCreateInitialMatrix(int,int,Mat*); 123 124 125 126 127 #endif 128 129 130