source: git/kernel/tgb_internal.h @ 81306a

spielwiese
Last change on this file since 81306a was 81306a, checked in by Michael Brickenstein <bricken@…>, 19 years ago
*bricken: moved mac_poly things to tgbgauss git-svn-id: file:///usr/local/Singular/svn/trunk@8102 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.6 KB
Line 
1#ifndef TGB_INTERNAL_H
2#define TGB_INTERNAL_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
22
23
24//#define TGB_DEBUG
25#define FULLREDUCTIONS
26#define HANS_IDEA
27//#define HALFREDUCTIONS
28//#define HEAD_BIN
29//#define HOMOGENEOUS_EXAMPLE
30#define REDTAIL_S
31#define PAR_N 100
32#define PAR_N_F4 5000
33#define AC_NEW_MIN 2
34#define AC_FLATTEN 1
35
36//#define FIND_DETERMINISTIC
37//#define REDTAIL_PROT
38//#define QUICK_SPOLY_TEST
39struct sorted_pair_node{
40  //criterium, which is stable 0. small lcm 1. small i 2. small j
41  int i;
42  int j;
43  int deg;
44  int expected_length;
45  poly lcm_of_lm;
46};
47
48
49//static ideal debug_Ideal;
50/**
51    reduction_accumulators are objects which are shared by several sums
52 **/
53
54class reduction_accumulator{
55 
56 public:
57  /// (1/multiplied)*bucket=reduced original data
58  number multiplied;
59  ///the polynomial data
60  kBucket_pt bucket;
61  /// the short exponent vector
62  unsigned long sev;
63  /// the reference counter
64  int counter;
65  /// decrease the reference counter, at 0 it deletes the object
66  void decrease_counter(){ 
67    if((--counter)==0)
68      {
69        delete this; //self destruction
70      }
71  }
72  int last_reduction_id;
73  reduction_accumulator(poly p, int p_len, poly high_to);
74  ~reduction_accumulator(){
75    nDelete(&multiplied);
76    kBucketDeleteAndDestroy(&bucket);
77  } 
78
79 
80};
81struct poly_list_node{
82  poly p;
83  poly_list_node* next;
84};
85struct formal_sum_descriptor{
86  number c_my;
87  number c_ac;
88  reduction_accumulator* ac;
89};
90struct int_pair_node{
91  int_pair_node* next;
92  int a;
93  int b;
94};
95struct monom_poly{
96  poly m;
97  poly f;
98};
99struct mp_array_list{
100  monom_poly* mp;
101  int size;
102  mp_array_list* next;
103};
104
105
106struct poly_array_list{
107  poly* p;
108  int size;
109  poly_array_list* next;
110};
111struct calc_dat
112{
113  int* rep;
114  char** states;
115  ideal S;
116  ring r;
117  int* lengths;
118  long* short_Exps;
119  kStrategy strat;
120  int* T_deg;
121  int* T_deg_full;
122  poly tmp_lm;
123  poly* tmp_pair_lm;
124  sorted_pair_node** tmp_spn;
125  poly* expandS;
126  poly* gcd_of_terms;
127  int_pair_node* soon_free;
128  sorted_pair_node** apairs;
129  BOOLEAN* modifiedS;
130  poly_list_node* to_destroy;
131  //for F4
132  mp_array_list* F;
133  poly_array_list* F_minus;
134
135  //end for F4
136#ifdef HEAD_BIN
137  struct omBin_s*   HeadBin;
138#endif
139  unsigned int reduction_steps;
140  int n;
141  int normal_forms;
142  int current_degree;
143  int Rcounter;
144  int last_index;
145  int max_pairs;
146  int pair_top;
147  int easy_product_crit;
148  int extended_product_crit;
149  int average_length;
150  BOOLEAN is_char0;
151  BOOLEAN is_homog;
152  BOOLEAN F4_mode;
153};
154class red_object{
155 public:
156  kBucket_pt bucket;
157  poly p;
158  formal_sum_descriptor* sum;
159  unsigned long sev;
160  void flatten();
161  void validate();
162  void adjust_coefs(number c_r, number c_ac_r);
163  int guess_quality(calc_dat* c);
164  int clear_to_poly();
165  void canonicalize();
166};
167
168
169enum calc_state
170  {
171    UNCALCULATED,
172    HASTREP,
173    UNIMPORTANT,
174    SOONTREP
175  };
176
177static int add_to_reductors(calc_dat* c, poly h, int len);
178static int bucket_guess(kBucket* bucket);
179static poly redNFTail (poly h,const int sl,kStrategy strat, int len);
180static poly redNF2 (poly h,calc_dat* c , int &len, number&  m,int n=0);
181static void free_sorted_pair_node(sorted_pair_node* s, ring r);
182static void shorten_tails(calc_dat* c, poly monom);
183static void replace_pair(int & i, int & j, calc_dat* c);
184static sorted_pair_node** add_to_basis(poly h, int i, int j,calc_dat* c, int* ip=NULL);
185static void do_this_spoly_stuff(int i,int j,calc_dat* c);
186//ideal t_rep_gb(ring r,ideal arg_I);
187static BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, calc_dat* state);
188static int* make_connections(int from, poly bound, calc_dat* c);
189static int* make_connections(int from, int to, poly bound, calc_dat* c);
190static void now_t_rep(const int & arg_i, const int & arg_j, calc_dat* c);
191static void soon_t_rep(const int & arg_i, const int & arg_j, calc_dat* c);
192static int pLcmDeg(poly a, poly b);
193static int simple_posInS (kStrategy strat, poly p,int len);
194static BOOLEAN find_next_pair(calc_dat* c, BOOLEAN go_higher=TRUE);
195
196static sorted_pair_node* pop_pair(calc_dat* c);
197static BOOLEAN no_pairs(calc_dat* c);
198static void clean_top_of_pair_list(calc_dat* c);
199static void super_clean_top_of_pair_list(calc_dat* c);
200static BOOLEAN state_is(calc_state state, const int & i, const int & j, calc_dat* c);
201static BOOLEAN pair_better(sorted_pair_node* a,sorted_pair_node* b, calc_dat* c);
202static int pair_better_gen(const void* ap,const void* bp);
203static poly redTailShort(poly h, kStrategy strat);
204static poly gcd_of_terms(poly p, ring r);
205static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, calc_dat* c);
206static poly kBucketGcd(kBucket* b, ring r);
207static void multi_reduction(red_object* los, int & losl, calc_dat* c);
208static sorted_pair_node* quick_pop_pair(calc_dat* c);
209static sorted_pair_node* top_pair(calc_dat* c);
210//static int quality(poly p, int len, calc_dat* c);
211/**
212   makes on each red_object in a region a single_step
213 **/
214class reduction_step{
215 public:
216  /// we assume hat all occuring red_objects have same lm, and all
217  /// occ. lm's in r[l...u] are the same, only reductor does not occur
218  virtual void reduce(red_object* r, int l, int u);
219  //int reduction_id;
220  virtual ~reduction_step();
221  calc_dat* c;
222  int reduction_id;
223};
224class simple_reducer:public reduction_step{
225 public:
226  poly p;
227  kBucket_pt fill_back;
228  int p_len;
229  simple_reducer(poly p, int p_len, calc_dat* c =NULL){
230    this->p=p;
231    assume(p_len==pLength(p));
232    this->p_len=p_len;
233    this->c=c;
234  }
235  virtual void pre_reduce(red_object* r, int l, int u);
236  virtual void reduce(red_object* r, int l, int u);
237  ~simple_reducer();
238
239  virtual void target_is_a_sum_reduce(red_object & ro);
240  virtual void target_is_no_sum_reduce(red_object & ro);
241};
242class join_simple_reducer:public simple_reducer{
243 public:
244  join_simple_reducer(poly p, int p_len, poly high_to):simple_reducer(p,p_len){
245    ac=new reduction_accumulator( p, p_len, high_to);
246   
247   
248  }
249    ~join_simple_reducer();
250   void pre_reduce(red_object* r, int l, int u);
251  void target_is_no_sum_reduce(red_object & ro);
252  reduction_accumulator* ac;
253};
254//class sum_canceling_reducer:public reduction_step {
255//  void reduce(red_object* r, int l, int u);
256//};
257struct find_erg{
258  poly expand;
259  int expand_length;
260  int to_reduce_u;
261  int to_reduce_l;
262  int reduce_by;//index of reductor
263  BOOLEAN fromS;//else from los
264
265};
266
267static void multi_reduce_step(find_erg & erg, red_object* r, calc_dat* c);
268static void finalize_reduction_step(reduction_step* r);
269
270
271
272
273
274
275#endif
Note: See TracBrowser for help on using the repository browser.