source: git/kernel/tgb.h @ 35aab3

spielwiese
Last change on this file since 35aab3 was 35aab3, checked in by Hans Schönemann <hannes@…>, 21 years ago
This commit was generated by cvs2svn to compensate for changes in r6879, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6880 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.0 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* gcd_of_terms;
95  int_pair_node* soon_free;
96  sorted_pair_node** apairs;
97#ifdef HEAD_BIN
98  struct omBin_s*   HeadBin;
99#endif
100  unsigned int reduction_steps;
101  int n;
102  int normal_forms;
103  int current_degree;
104  int Rcounter;
105  int last_index;
106  int max_pairs;
107  int pair_top;
108  int easy_product_crit;
109  int extended_product_crit;
110  int average_length;
111  BOOLEAN is_char0;
112};
113class red_object{
114 public:
115  kBucket_pt bucket;
116  poly p;
117  formal_sum_descriptor* sum;
118  unsigned long sev;
119  void flatten();
120  void validate();
121  void adjust_coefs(number c_r, number c_ac_r);
122  int guess_quality(calc_dat* c);
123  int clear_to_poly();
124  void canonicalize();
125};
126
127
128enum calc_state
129  {
130    UNCALCULATED,
131    HASTREP,
132    UNIMPORTANT,
133    SOONTREP
134  };
135
136static int add_to_reductors(calc_dat* c, poly h, int len);
137static int bucket_guess(kBucket* bucket);
138static poly redNFTail (poly h,const int sl,kStrategy strat, int len);
139static poly redNF2 (poly h,calc_dat* c , int &len, number&  m,int n=0);
140static void free_sorted_pair_node(sorted_pair_node* s, ring r);
141static void shorten_tails(calc_dat* c, poly monom);
142static void replace_pair(int & i, int & j, calc_dat* c);
143static sorted_pair_node** add_to_basis(poly h, int i, int j,calc_dat* c, int* ip=NULL);
144static void do_this_spoly_stuff(int i,int j,calc_dat* c);
145//ideal t_rep_gb(ring r,ideal arg_I);
146static BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, calc_dat* state);
147static int* make_connections(int from, poly bound, calc_dat* c);
148static int* make_connections(int from, int to, poly bound, calc_dat* c);
149static void now_t_rep(const int & arg_i, const int & arg_j, calc_dat* c);
150static void soon_t_rep(const int & arg_i, const int & arg_j, calc_dat* c);
151static int pLcmDeg(poly a, poly b);
152static int simple_posInS (kStrategy strat, poly p,int len, BOOLEAN is_char0);
153static BOOLEAN find_next_pair(calc_dat* c, BOOLEAN go_higher=TRUE);
154
155static sorted_pair_node* pop_pair(calc_dat* c);
156static BOOLEAN no_pairs(calc_dat* c);
157static void clean_top_of_pair_list(calc_dat* c);
158static void super_clean_top_of_pair_list(calc_dat* c);
159static BOOLEAN state_is(calc_state state, const int & i, const int & j, calc_dat* c);
160static BOOLEAN pair_better(sorted_pair_node* a,sorted_pair_node* b, calc_dat* c);
161static int pair_better_gen(const void* ap,const void* bp);
162static poly redTailShort(poly h, kStrategy strat);
163static poly gcd_of_terms(poly p, ring r);
164static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, calc_dat* c);
165static poly kBucketGcd(kBucket* b, ring r);
166static void multi_reduction(red_object* los, int & losl, calc_dat* c);
167static sorted_pair_node* quick_pop_pair(calc_dat* c);
168static sorted_pair_node* top_pair(calc_dat* c);
169static int quality(poly p, int len, calc_dat* c);
170/**
171   makes on each red_object in a region a single_step
172 **/
173class reduction_step{
174 public:
175  /// we assume hat all occuring red_objects have same lm, and all
176  /// occ. lm's in r[l...u] are the same, only reductor does not occur
177  virtual void reduce(red_object* r, int l, int u);
178  //int reduction_id;
179  virtual ~reduction_step();
180  calc_dat* c;
181  int reduction_id;
182};
183class simple_reducer:public reduction_step{
184 public:
185  poly p;
186  kBucket_pt fill_back;
187  int p_len;
188  simple_reducer(poly p, int p_len, calc_dat* c =NULL){
189    this->p=p;
190    this->p_len=p_len;
191    this->c=c;
192  }
193  virtual void pre_reduce(red_object* r, int l, int u);
194  virtual void reduce(red_object* r, int l, int u);
195  ~simple_reducer();
196
197  virtual void target_is_a_sum_reduce(red_object & ro);
198  virtual void target_is_no_sum_reduce(red_object & ro);
199};
200class join_simple_reducer:public simple_reducer{
201 public:
202  join_simple_reducer(poly p, int p_len, poly high_to):simple_reducer(p,p_len){
203    ac=new reduction_accumulator( p, p_len, high_to);
204   
205   
206  }
207    ~join_simple_reducer();
208   void pre_reduce(red_object* r, int l, int u);
209  void target_is_no_sum_reduce(red_object & ro);
210  reduction_accumulator* ac;
211};
212//class sum_canceling_reducer:public reduction_step {
213//  void reduce(red_object* r, int l, int u);
214//};
215struct find_erg{
216  poly expand;
217  int expand_length;
218  int to_reduce_u;
219  int to_reduce_l;
220  int reduce_by;//index of reductor
221  BOOLEAN fromS;//else from los
222
223};
224
225static void multi_reduce_step(find_erg & erg, red_object* r, calc_dat* c);
226void finalize_reduction_step(reduction_step* r){
227  delete r;
228}
229#endif
Note: See TracBrowser for help on using the repository browser.