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