source: git/Singular/tgb.h @ 32f58c

fieker-DuValspielwiese
Last change on this file since 32f58c was 32f58c, checked in by Michael Brickenstein <bricken@…>, 21 years ago
*bricken: some abstraction git-svn-id: file:///usr/local/Singular/svn/trunk@6586 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 5.4 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
21#define FULLREDUCTIONS
22//#define HALFREDUCTIONS
23//#define HEAD_BIN
24//#define HOMOGENEOUS_EXAMPLE
25#define REDTAIL_S
26#define PAR_N 1000
27#define AC_NEW_MIN 5
28//#define REDTAIL_PROT
29//#define QUICK_SPOLY_TEST
30struct sorted_pair_node{
31  //criterium, which is stable 0. small lcm 1. small i 2. small j
32  int i;
33  int j;
34  int deg;
35  int expected_length;
36  poly lcm_of_lm;
37};
38
39
40/**
41    reduction_accumulators are objects which are shared by several sums
42 **/
43
44class reduction_accumulator{
45 
46 public:
47  /// (1/multiplied)*bucket=reduced original data
48  number multiplied;
49  ///the polynomial data
50  kBucket_pt bucket;
51  /// the short exponent vector
52  unsigned long sev;
53  /// the reference counter
54  int counter;
55  /// decrease the reference counter, at 0 it deletes the object
56  void decrease_counter(){ 
57    if((--counter)==0)
58      {
59        delete this; //self destruction
60      }
61  }
62  int last_reduction_id;
63  reduction_accumulator(){
64    last_reduction_id=-1;
65    bucket=kBucketCreate(currRing);
66  }
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  BOOLEAN is_char0;
111};
112class red_object{
113 public:
114  kBucket_pt bucket;
115  poly p;
116  formal_sum_descriptor* sum;
117  unsigned long sev;
118  void flatten();
119  void validate();
120  void reduction_step(int reduction_id, poly reductor_full, int full_len, poly reductor_part, reduction_accumulator* join_to, calc_dat* c);
121  void adjust_coefs(number c_r, number c_ac_r);
122  int guess_quality(calc_dat* c);
123  int clear_to_poly();
124};
125
126
127enum calc_state
128  {
129    UNCALCULATED,
130    HASTREP,
131    UNIMPORTANT,
132    SOONTREP
133  };
134
135static int add_to_reductors(calc_dat* c, poly h, int len);
136static int bucket_guess(kBucket* bucket);
137static poly redNFTail (poly h,const int sl,kStrategy strat, int len);
138static poly redNF2 (poly h,calc_dat* c , int &len);
139static void free_sorted_pair_node(sorted_pair_node* s, ring r);
140static void shorten_tails(calc_dat* c, poly monom);
141static void replace_pair(int & i, int & j, calc_dat* c);
142static sorted_pair_node** add_to_basis(poly h, int i, int j,calc_dat* c, int* ip=NULL);
143static void do_this_spoly_stuff(int i,int j,calc_dat* c);
144ideal t_rep_gb(ring r,ideal arg_I);
145static BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, calc_dat* state);
146static int* make_connections(int from, poly bound, calc_dat* c);
147static int* make_connections(int from, int to, poly bound, calc_dat* c);
148static void now_t_rep(const int & arg_i, const int & arg_j, calc_dat* c);
149static void soon_t_rep(const int & arg_i, const int & arg_j, calc_dat* c);
150static int pLcmDeg(poly a, poly b);
151static int simple_posInS (kStrategy strat, poly p,int len, BOOLEAN is_char0);
152static BOOLEAN find_next_pair(calc_dat* c, BOOLEAN go_higher=TRUE);
153
154static sorted_pair_node* pop_pair(calc_dat* c);
155static BOOLEAN no_pairs(calc_dat* c);
156static void clean_top_of_pair_list(calc_dat* c);
157static void super_clean_top_of_pair_list(calc_dat* c);
158static BOOLEAN state_is(calc_state state, const int & i, const int & j, calc_dat* c);
159static BOOLEAN pair_better(sorted_pair_node* a,sorted_pair_node* b, calc_dat* c);
160static int pair_better_gen(const void* ap,const void* bp);
161static poly redTailShort(poly h, kStrategy strat);
162static poly gcd_of_terms(poly p, ring r);
163static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, calc_dat* c);
164static poly kBucketGcd(kBucket* b, ring r);
165static void multi_reduction(red_object* los, int & losl, calc_dat* c);
166static sorted_pair_node* quick_pop_pair(calc_dat* c);
167static sorted_pair_node* top_pair(calc_dat* c);
168static int quality(poly p, int len, calc_dat* c);
169/**
170   makes on each red_object in a region a single_step
171 **/
172class reduction_step{
173 public:
174  /// we assume hat all occuring red_objects have same lm, and all
175  /// occ. lm's in r[l...u] are the same, only reductor does not occur
176  virtual void reduce(red_object* r, int l, int u);
177  //int reduction_id;
178  virtual ~reduction_step();
179  calc_dat* c;
180  int reduction_id;
181};
182class simple_reducer:public reduction_step{
183 public:
184  poly p;
185  kBucket_pt fill_back;
186  int p_len;
187
188  void reduce(red_object* r, int l, int u);
189  ~simple_reducer();
190};
191//class sum_canceling_reducer:public reduction_step {
192//  void reduce(red_object* r, int l, int u);
193//};
194struct find_erg{
195  poly expand;
196  int expand_length;
197  int to_reduce_u;
198  int to_reduce_l;
199  int reduce_by;//index of reductor
200  BOOLEAN fromS;//else from los
201
202};
203
204reduction_step* create_reduction_step(find_erg & erg, red_object* r, calc_dat* c);
205void finalize_reduction_step(reduction_step* r){
206  delete r;
207}
208#endif
Note: See TracBrowser for help on using the repository browser.