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