source: git/Singular/tgb.h @ 10d1b7

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