source: git/kernel/tgb_internal.h @ a60a21

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