1 | #ifndef TGB_H |
---|
2 | #define TGB_H |
---|
3 | |
---|
4 | #include "mod2.h" |
---|
5 | #include <omalloc.h> |
---|
6 | #include "p_polys.h" |
---|
7 | |
---|
8 | #include "ideals.h" |
---|
9 | #include "ring.h" |
---|
10 | #include "febase.h" |
---|
11 | #include "structs.h" |
---|
12 | #include "polys.h" |
---|
13 | #include "stdlib.h" |
---|
14 | |
---|
15 | |
---|
16 | #include "kutil.h" |
---|
17 | #include "kInline.cc" |
---|
18 | #include "kstd1.h" |
---|
19 | #include "kbuckets.h" |
---|
20 | |
---|
21 | #define FULLREDUCTIONS |
---|
22 | //#define HALFREDUCTIONS |
---|
23 | //#define HEAD_BIN |
---|
24 | //#define HOMOGENEOUS_EXAMPLE |
---|
25 | #define REDTAIL_S |
---|
26 | |
---|
27 | //#define REDTAIL_PROT |
---|
28 | //#define QUICK_SPOLY_TEST |
---|
29 | |
---|
30 | |
---|
31 | class reduction_accumulator{ |
---|
32 | public: |
---|
33 | number multiplied; |
---|
34 | kBucket_pt bucket; |
---|
35 | int counter; |
---|
36 | void decrease_counter(){ |
---|
37 | if((--counter)==0) |
---|
38 | { |
---|
39 | nDelete(&multiplied); |
---|
40 | kBucketDeleteAndDestroy(&bucket); |
---|
41 | delete this; //self destruction |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | }; |
---|
46 | struct formal_sum_descriptor{ |
---|
47 | number c_my; |
---|
48 | number c_ac; |
---|
49 | reduction_accumulator* ac; |
---|
50 | }; |
---|
51 | struct int_pair_node{ |
---|
52 | int_pair_node* next; |
---|
53 | int a; |
---|
54 | int b; |
---|
55 | }; |
---|
56 | class red_object{ |
---|
57 | public: |
---|
58 | kBucket_pt bucket; |
---|
59 | poly p; |
---|
60 | formal_sum_descriptor* sum; |
---|
61 | unsigned long sev; |
---|
62 | void flatten(); |
---|
63 | void validate(); |
---|
64 | }; |
---|
65 | struct sorted_pair_node{ |
---|
66 | //criterium, which is stable 0. small lcm 1. small i 2. small j |
---|
67 | int i; |
---|
68 | int j; |
---|
69 | int deg; |
---|
70 | int expected_length; |
---|
71 | poly lcm_of_lm; |
---|
72 | }; |
---|
73 | |
---|
74 | |
---|
75 | enum calc_state |
---|
76 | { |
---|
77 | UNCALCULATED, |
---|
78 | HASTREP, |
---|
79 | UNIMPORTANT, |
---|
80 | SOONTREP |
---|
81 | }; |
---|
82 | struct calc_dat |
---|
83 | { |
---|
84 | int* rep; |
---|
85 | char** states; |
---|
86 | ideal S; |
---|
87 | ring r; |
---|
88 | int* lengths; |
---|
89 | long* short_Exps; |
---|
90 | kStrategy strat; |
---|
91 | int* T_deg; |
---|
92 | poly* gcd_of_terms; |
---|
93 | int_pair_node* soon_free; |
---|
94 | sorted_pair_node** apairs; |
---|
95 | #ifdef HEAD_BIN |
---|
96 | struct omBin_s* HeadBin; |
---|
97 | #endif |
---|
98 | unsigned int reduction_steps; |
---|
99 | int n; |
---|
100 | int normal_forms; |
---|
101 | int current_degree; |
---|
102 | int Rcounter; |
---|
103 | int last_index; |
---|
104 | int max_pairs; |
---|
105 | int pair_top; |
---|
106 | int easy_product_crit; |
---|
107 | int extended_product_crit; |
---|
108 | BOOLEAN is_char0; |
---|
109 | }; |
---|
110 | static int add_to_reductors(calc_dat* c, poly h, int len); |
---|
111 | static int bucket_guess(kBucket* bucket); |
---|
112 | static poly redNFTail (poly h,const int sl,kStrategy strat, int len); |
---|
113 | static poly redNF2 (poly h,calc_dat* c , int &len); |
---|
114 | static void free_sorted_pair_node(sorted_pair_node* s, ring r); |
---|
115 | static void shorten_tails(calc_dat* c, poly monom); |
---|
116 | static void replace_pair(int & i, int & j, calc_dat* c); |
---|
117 | static sorted_pair_node** add_to_basis(poly h, int i, int j,calc_dat* c, int* ip=NULL); |
---|
118 | static void do_this_spoly_stuff(int i,int j,calc_dat* c); |
---|
119 | ideal t_rep_gb(ring r,ideal arg_I); |
---|
120 | static BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, calc_dat* state); |
---|
121 | static int* make_connections(int from, poly bound, calc_dat* c); |
---|
122 | static int* make_connections(int from, int to, poly bound, calc_dat* c); |
---|
123 | static void now_t_rep(const int & arg_i, const int & arg_j, calc_dat* c); |
---|
124 | static void soon_t_rep(const int & arg_i, const int & arg_j, calc_dat* c); |
---|
125 | static int pLcmDeg(poly a, poly b); |
---|
126 | static int simple_posInS (kStrategy strat, poly p,int len, BOOLEAN is_char0); |
---|
127 | static BOOLEAN find_next_pair(calc_dat* c, BOOLEAN go_higher=TRUE); |
---|
128 | |
---|
129 | static sorted_pair_node* pop_pair(calc_dat* c); |
---|
130 | static BOOLEAN no_pairs(calc_dat* c); |
---|
131 | static void clean_top_of_pair_list(calc_dat* c); |
---|
132 | static void super_clean_top_of_pair_list(calc_dat* c); |
---|
133 | static BOOLEAN state_is(calc_state state, const int & i, const int & j, calc_dat* c); |
---|
134 | static BOOLEAN pair_better(sorted_pair_node* a,sorted_pair_node* b, calc_dat* c); |
---|
135 | static int pair_better_gen(const void* ap,const void* bp); |
---|
136 | static poly redTailShort(poly h, kStrategy strat); |
---|
137 | static poly gcd_of_terms(poly p, ring r); |
---|
138 | static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, calc_dat* c); |
---|
139 | static poly kBucketGcd(kBucket* b, ring r); |
---|
140 | static void multi_reduction(red_object* los, int & losl, calc_dat* c); |
---|
141 | static sorted_pair_node* quick_pop_pair(calc_dat* c); |
---|
142 | static sorted_pair_node* top_pair(calc_dat* c); |
---|
143 | #endif |
---|