source: git/kernel/tgb_internal.h @ 19370c

spielwiese
Last change on this file since 19370c was b68048, checked in by Michael Brickenstein <bricken@…>, 17 years ago
+ noro git-svn-id: file:///usr/local/Singular/svn/trunk@9815 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 8.2 KB
Line 
1#ifndef TGB_INTERNAL_H
2#define TGB_INTERNAL_H
3//!\file tgb_internal.h
4/****************************************
5*  Computer Algebra System SINGULAR     *
6****************************************/
7/* $Id: tgb_internal.h,v 1.49 2007-02-06 09:59:01 bricken Exp $ */
8/*
9 * ABSTRACT: tgb internal .h file
10*/
11#include <omalloc.h>
12#include "p_polys.h"
13
14#include "ideals.h"
15#include "ring.h"
16#include "febase.h"
17#include "structs.h"
18#include "polys.h"
19#include "stdlib.h"
20//#define USE_NORO 1
21#ifdef HAVE_BOOST_DYNAMIC_BITSET_HPP
22#define  HAVE_BOOST 1
23#endif
24//#define HAVE_BOOST 1
25//#define USE_STDVECBOOL 1
26#ifdef HAVE_BOOST
27#include "boost/dynamic_bitset.hpp"
28#include <vector>
29using boost::dynamic_bitset;
30using std::vector;
31#endif
32#ifdef USE_STDVECBOOL
33#include <vector>
34using std::vector;
35#endif
36#include "kutil.h"
37#include "kInline.cc"
38#include "kstd1.h"
39#include "kbuckets.h"
40
41
42
43
44//#define TGB_DEBUG
45#define FULLREDUCTIONS
46#define HANS_IDEA
47//#define HALFREDUCTIONS
48//#define HEAD_BIN
49//#define HOMOGENEOUS_EXAMPLE
50#define REDTAIL_S
51#define PAR_N 100
52#define PAR_N_F4 5000
53#define AC_NEW_MIN 2
54#define AC_FLATTEN 1
55
56//#define FIND_DETERMINISTIC
57//#define REDTAIL_PROT
58//#define QUICK_SPOLY_TEST
59struct sorted_pair_node{
60  //criterium, which is stable 0. small lcm 1. small i 2. small j
61  wlen_type expected_length;
62  poly lcm_of_lm;
63  int i;
64  int j;
65  int deg;
66 
67 
68};
69
70
71//static ideal debug_Ideal;
72
73
74struct poly_list_node{
75  poly p;
76  poly_list_node* next;
77};
78
79struct int_pair_node{
80  int_pair_node* next;
81  int a;
82  int b;
83};
84struct monom_poly{
85  poly m;
86  poly f;
87};
88struct mp_array_list{
89  monom_poly* mp;
90  int size;
91  mp_array_list* next;
92};
93
94
95struct poly_array_list{
96  poly* p;
97  int size;
98  poly_array_list* next;
99};
100class slimgb_alg
101{
102  public:
103    slimgb_alg(ideal I, int syz_comp,BOOLEAN F4);
104                void introduceDelayedPairs(poly* pa,int s);
105    virtual ~slimgb_alg();
106    void cleanDegs(int lower, int upper);
107#ifndef HAVE_BOOST
108#ifdef USE_STDVECBOOL
109  vector<vector<bool> > states;
110#else
111  char** states;
112#endif
113#else
114  vector<dynamic_bitset<> > states;
115#endif
116  ideal add_later;
117  ideal S;
118  ring r;
119  int* lengths;
120  wlen_type* weighted_lengths;
121  long* short_Exps;
122  kStrategy strat;
123  int* T_deg;
124  int* T_deg_full;
125  poly tmp_lm;
126  poly* tmp_pair_lm;
127  sorted_pair_node** tmp_spn;
128  poly* expandS;
129  poly* gcd_of_terms;
130  int_pair_node* soon_free;
131  sorted_pair_node** apairs;
132  #if 0
133  BOOLEAN* modifiedS;
134  #endif
135  #ifdef TGB_RESORT_PAIRS
136  bool* replaced;
137  #endif
138  poly_list_node* to_destroy;
139  //for F4
140  mp_array_list* F;
141  poly_array_list* F_minus;
142
143  //end for F4
144#ifdef HEAD_BIN
145  struct omBin_s*   HeadBin;
146#endif
147  unsigned int reduction_steps;
148  int n;
149  //! array_lengths should be greater equal n;
150  int syz_comp;
151  int array_lengths; 
152  int normal_forms;
153  int current_degree;
154  int Rcounter;
155  int last_index;
156  int max_pairs;
157  int pair_top;
158  int easy_product_crit;
159  int extended_product_crit;
160  int average_length;
161  int lastDpBlockStart;
162  int lastCleanedDeg;
163  BOOLEAN isDifficultField;
164  BOOLEAN completed;
165  BOOLEAN is_homog;
166  BOOLEAN tailReductions;
167  BOOLEAN eliminationProblem;
168  BOOLEAN F4_mode;
169  BOOLEAN nc;
170  #ifdef TGB_RESORT_PAIRS
171  BOOLEAN used_b;
172  #endif
173};
174class red_object{
175 public:
176  kBucket_pt bucket;
177  poly p;
178  unsigned long sev;
179  int sugar;
180  void flatten();
181  void validate();
182  wlen_type initial_quality;
183  void adjust_coefs(number c_r, number c_ac_r);
184  wlen_type guess_quality(slimgb_alg* c);
185  int clear_to_poly();
186  void canonicalize();
187};
188
189
190enum calc_state
191  {
192    UNCALCULATED,
193    HASTREP//,
194    //UNIMPORTANT,
195    //SOONTREP
196  };
197static BOOLEAN pair_cmp(sorted_pair_node* a,sorted_pair_node* b);
198template <class len_type, class set_type>  int pos_helper(kStrategy strat, poly p, len_type len, set_type setL, polyset set);
199static int add_to_reductors(slimgb_alg* c, poly h, int len, int ecart, BOOLEAN simplified=FALSE);
200static int bucket_guess(kBucket* bucket);
201static poly redNFTail (poly h,const int sl,kStrategy strat, int len);
202static poly redNF2 (poly h,slimgb_alg* c , int &len, number&  m,int n=0);
203void free_sorted_pair_node(sorted_pair_node* s, ring r);
204static void shorten_tails(slimgb_alg* c, poly monom);
205static void replace_pair(int & i, int & j, slimgb_alg* c);
206//static sorted_pair_node** add_to_basis(poly h, int i, int j,slimgb_alg* c, int* ip=NULL);
207static void do_this_spoly_stuff(int i,int j,slimgb_alg* c);
208//ideal t_rep_gb(ring r,ideal arg_I);
209static BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, slimgb_alg* state);
210static int* make_connections(int from, poly bound, slimgb_alg* c);
211static int* make_connections(int from, int to, poly bound, slimgb_alg* c);
212void now_t_rep(const int & arg_i, const int & arg_j, slimgb_alg* c);
213static void soon_t_rep(const int & arg_i, const int & arg_j, slimgb_alg* c);
214static int pLcmDeg(poly a, poly b);
215static int simple_posInS (kStrategy strat, poly p,int len, wlen_type wlen);
216static BOOLEAN find_next_pair(slimgb_alg* c, BOOLEAN go_higher=TRUE);
217
218static sorted_pair_node* pop_pair(slimgb_alg* c);
219static BOOLEAN no_pairs(slimgb_alg* c);
220void clean_top_of_pair_list(slimgb_alg* c);
221static void super_clean_top_of_pair_list(slimgb_alg* c);
222static BOOLEAN state_is(calc_state state, const int & i, const int & j, slimgb_alg* c);
223static BOOLEAN pair_better(sorted_pair_node* a,sorted_pair_node* b, slimgb_alg* c=NULL);
224static int tgb_pair_better_gen(const void* ap,const void* bp);
225static poly redTailShort(poly h, kStrategy strat);
226static poly gcd_of_terms(poly p, ring r);
227static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, slimgb_alg* c);
228static poly kBucketGcd(kBucket* b, ring r);
229static void multi_reduction(red_object* los, int & losl, slimgb_alg* c);
230int slim_nsize(number n, ring r);
231sorted_pair_node* quick_pop_pair(slimgb_alg* c);
232sorted_pair_node* top_pair(slimgb_alg* c);
233sorted_pair_node** add_to_basis_ideal_quotient(poly h, slimgb_alg* c, int* ip);//, BOOLEAN new_pairs=TRUE);
234sorted_pair_node**  spn_merge(sorted_pair_node** p, int pn,sorted_pair_node **q, int qn,slimgb_alg* c);
235int kFindDivisibleByInS_easy(kStrategy strat,const red_object & obj);
236int tgb_pair_better_gen2(const void* ap,const void* bp);
237int kFindDivisibleByInS_easy(kStrategy strat,poly p, long sev);
238//static int quality(poly p, int len, slimgb_alg* c);
239/**
240   makes on each red_object in a region a single_step
241 **/
242class reduction_step{
243 public:
244  /// we assume hat all occuring red_objects have same lm, and all
245  /// occ. lm's in r[l...u] are the same, only reductor does not occur
246  virtual void reduce(red_object* r, int l, int u);
247  //int reduction_id;
248  virtual ~reduction_step();
249  slimgb_alg* c;
250  int reduction_id;
251};
252class simple_reducer:public reduction_step{
253 public:
254  poly p;
255  kBucket_pt fill_back;
256  int p_len;
257  int reducer_deg;
258  simple_reducer(poly p, int p_len,int reducer_deg, slimgb_alg* c =NULL){
259    this->p=p;
260    this->reducer_deg=reducer_deg;
261    assume(p_len==pLength(p));
262    this->p_len=p_len;
263    this->c=c;
264  }
265  virtual void pre_reduce(red_object* r, int l, int u);
266  virtual void reduce(red_object* r, int l, int u);
267  ~simple_reducer();
268
269
270  virtual void do_reduce(red_object & ro);
271};
272
273//class sum_canceling_reducer:public reduction_step {
274//  void reduce(red_object* r, int l, int u);
275//};
276struct find_erg{
277  poly expand;
278  int expand_length;
279  int to_reduce_u;
280  int to_reduce_l;
281  int reduce_by;//index of reductor
282  BOOLEAN fromS;//else from los
283
284};
285
286static void multi_reduce_step(find_erg & erg, red_object* r, slimgb_alg* c);
287static void finalize_reduction_step(reduction_step* r);
288
289template <class len_type, class set_type>  int pos_helper(kStrategy strat, poly p, len_type len, set_type setL, polyset set){
290  //Print("POSHELER:%d",sizeof(wlen_type));
291  int length=strat->sl;
292  int i;
293  int an = 0;
294  int en= length;
295
296  if ((len>setL[length])
297      || ((len==setL[length]) && (pLmCmp(set[length],p)== -1)))
298    return length+1;
299
300  loop
301  {
302    if (an >= en-1)
303    {
304      if ((len<setL[an])
305          || ((len==setL[an]) && (pLmCmp(set[an],p) == 1))) return an;
306      return en;
307    }
308    i=(an+en) / 2;
309    if ((len<setL[i])
310        || ((len==setL[i]) && (pLmCmp(set[i],p) == 1))) en=i;
311    //else if ((len>setL[i])
312    //|| ((len==setL[i]) && (pLmCmp(set[i],p) == -1))) an=i;
313    else an=i;
314  }
315
316}
317
318
319static wlen_type pair_weighted_length(int i, int j, slimgb_alg* c);
320wlen_type pELength(poly p, ring r);
321
322#endif
Note: See TracBrowser for help on using the repository browser.