source: git/kernel/tgb_internal.h @ e6cbed

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