1 #ifndef TGBGAUSS_HEADER 2 #define TGBGAUSS_HEADER 3 /**************************************** 4 * Computer Algebra System SINGULAR * 5 ****************************************/ 6 /* 7 * ABSTRACT: gauss implementation for F4 header 8 */ 9 #include "coeffs/numbers.h" 10 #include "polys/monomials/p_polys.h" 11 #include "omalloc/omalloc.h" 12 #ifdef HAVE_OMALLOC 13 #include "omalloc/omallocClass.h" 14 #endif 15 16 class slimgb_alg; 17 18 class tgb_matrix 19 { 20 private: 21 number** n; 22 int columns; 23 int rows; 24 BOOLEAN free_numbers; 25 public: 26 tgb_matrix(int i, int j); 27 ~tgb_matrix(); 28 int get_rows(); 29 int get_columns(); 30 void print(); 31 void perm_rows(int i, int j); 32 void set(int i, int j, number n); 33 number get(int i, int j); 34 BOOLEAN is_zero_entry(int i, int j); 35 void free_row(int row, BOOLEAN free_non_zeros=TRUE); 36 int min_col_not_zero_in_row(int row); 37 int next_col_not_zero(int row,int pre); 38 BOOLEAN zero_row(int row); 39 void mult_row(int row,number factor); 40 void add_lambda_times_row(int add_to,int summand,number factor); 41 int non_zero_entries(int row); 42 }; 43 44 class mac_poly_r 45 #ifdef HAVE_OMALLOC 46 :public omallocClass 47 #endif 48 { 49 public: 50 number coef; 51 mac_poly_r* next; 52 int exp; mac_poly_r()53 mac_poly_r():next(NULL){} 54 }; 55 //mac_polys exp are smaller iff they are greater by monomial ordering 56 //corresponding to solving linear equations notation 57 58 typedef mac_poly_r* mac_poly; 59 60 class tgb_sparse_matrix 61 { 62 private: 63 ring r; 64 mac_poly* mp; 65 int columns; 66 int rows; 67 BOOLEAN free_numbers; 68 public: 69 void sort_rows(); 70 friend poly free_row_to_poly(tgb_sparse_matrix* mat, int row, poly* monoms, int monom_index); 71 friend void init_with_mac_poly(tgb_sparse_matrix* mat, int row, mac_poly m); 72 tgb_sparse_matrix(int i, int j, ring rarg); 73 ~tgb_sparse_matrix(); 74 int get_rows(); 75 int get_columns(); 76 void print(); 77 void row_normalize(int row); 78 void row_content(int row); 79 // void perm_rows(int i, int j); perm_rows(int i,int j)80 void perm_rows(int i, int j){ 81 mac_poly h; 82 h=mp[i]; 83 mp[i]=mp[j]; 84 mp[j]=h; 85 } 86 void set(int i, int j, number n); 87 number get(int i, int j); 88 BOOLEAN is_zero_entry(int i, int j); 89 void free_row(int row, BOOLEAN free_non_zeros=TRUE); 90 int min_col_not_zero_in_row(int row); 91 int next_col_not_zero(int row,int pre); 92 BOOLEAN zero_row(int row); 93 void mult_row(int row,number factor); 94 void add_lambda_times_row(int add_to,int summand,number factor); 95 int non_zero_entries(int row); 96 }; 97 void simple_gauss(tgb_sparse_matrix* mat, slimgb_alg* c); 98 void simple_gauss2(tgb_matrix* mat); 99 100 101 mac_poly mac_p_add_ff_qq(mac_poly a, number f,mac_poly b); 102 103 void mac_mult_cons(mac_poly p,number c); 104 int mac_length(mac_poly p); 105 106 //contrary to delete on the mac_poly_r, the coefficients are also destroyed here 107 void mac_destroy(mac_poly p); 108 109 #endif 110