source: git/kernel/tgb_internal.h @ 6b9532

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