source: git/kernel/tgb_internal.h @ d491e3

spielwiese
Last change on this file since d491e3 was d491e3, checked in by Michael Brickenstein <bricken@…>, 19 years ago
*bricken: non commutative seems to work git-svn-id: file:///usr/local/Singular/svn/trunk@8437 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 6.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.16 2005-07-20 11:12:43 bricken Exp $ */
8/*
9 * ABSTRACT: tgb internal .h file
10*/
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
42
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
59struct poly_list_node{
60  poly p;
61  poly_list_node* next;
62};
63
64struct int_pair_node{
65  int_pair_node* next;
66  int a;
67  int b;
68};
69struct monom_poly{
70  poly m;
71  poly f;
72};
73struct mp_array_list{
74  monom_poly* mp;
75  int size;
76  mp_array_list* next;
77};
78
79
80struct poly_array_list{
81  poly* p;
82  int size;
83  poly_array_list* next;
84};
85class slimgb_alg
86{
87  public:
88    slimgb_alg(ideal I, BOOLEAN F4);
89    virtual ~slimgb_alg();
90  char** states;
91  ideal S;
92  ring r;
93  int* lengths;
94  long* short_Exps;
95  kStrategy strat;
96  int* T_deg;
97  int* T_deg_full;
98  poly tmp_lm;
99  poly* tmp_pair_lm;
100  sorted_pair_node** tmp_spn;
101  poly* expandS;
102  poly* gcd_of_terms;
103  int_pair_node* soon_free;
104  sorted_pair_node** apairs;
105  BOOLEAN* modifiedS;
106  poly_list_node* to_destroy;
107  //for F4
108  mp_array_list* F;
109  poly_array_list* F_minus;
110
111  //end for F4
112#ifdef HEAD_BIN
113  struct omBin_s*   HeadBin;
114#endif
115  unsigned int reduction_steps;
116  int n;
117  //! array_lengths should be greater equal n;
118  int array_lengths; 
119  int normal_forms;
120  int current_degree;
121  int Rcounter;
122  int last_index;
123  int max_pairs;
124  int pair_top;
125  int easy_product_crit;
126  int extended_product_crit;
127  int average_length;
128  BOOLEAN is_char0;
129  BOOLEAN is_homog;
130  BOOLEAN doubleSugar;
131  BOOLEAN F4_mode;
132  BOOLEAN nc;
133};
134class red_object{
135 public:
136  kBucket_pt bucket;
137  poly p;
138  unsigned long sev;
139  void flatten();
140  void validate();
141  void adjust_coefs(number c_r, number c_ac_r);
142  int guess_quality(slimgb_alg* c);
143  int clear_to_poly();
144  void canonicalize();
145};
146
147
148enum calc_state
149  {
150    UNCALCULATED,
151    HASTREP,
152    UNIMPORTANT,
153    SOONTREP
154  };
155
156static int add_to_reductors(slimgb_alg* c, poly h, int len);
157static int bucket_guess(kBucket* bucket);
158static poly redNFTail (poly h,const int sl,kStrategy strat, int len);
159static poly redNF2 (poly h,slimgb_alg* c , int &len, number&  m,int n=0);
160void free_sorted_pair_node(sorted_pair_node* s, ring r);
161static void shorten_tails(slimgb_alg* c, poly monom);
162static void replace_pair(int & i, int & j, slimgb_alg* c);
163//static sorted_pair_node** add_to_basis(poly h, int i, int j,slimgb_alg* c, int* ip=NULL);
164static void do_this_spoly_stuff(int i,int j,slimgb_alg* c);
165//ideal t_rep_gb(ring r,ideal arg_I);
166static BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, slimgb_alg* state);
167static int* make_connections(int from, poly bound, slimgb_alg* c);
168static int* make_connections(int from, int to, poly bound, slimgb_alg* c);
169void now_t_rep(const int & arg_i, const int & arg_j, slimgb_alg* c);
170static void soon_t_rep(const int & arg_i, const int & arg_j, slimgb_alg* c);
171static int pLcmDeg(poly a, poly b);
172static int simple_posInS (kStrategy strat, poly p,int len);
173static BOOLEAN find_next_pair(slimgb_alg* c, BOOLEAN go_higher=TRUE);
174
175static sorted_pair_node* pop_pair(slimgb_alg* c);
176static BOOLEAN no_pairs(slimgb_alg* c);
177void clean_top_of_pair_list(slimgb_alg* c);
178static void super_clean_top_of_pair_list(slimgb_alg* c);
179static BOOLEAN state_is(calc_state state, const int & i, const int & j, slimgb_alg* c);
180static BOOLEAN pair_better(sorted_pair_node* a,sorted_pair_node* b, slimgb_alg* c);
181static int tgb_pair_better_gen(const void* ap,const void* bp);
182static poly redTailShort(poly h, kStrategy strat);
183static poly gcd_of_terms(poly p, ring r);
184static BOOLEAN extended_product_criterion(poly p1, poly gcd1, poly p2, poly gcd2, slimgb_alg* c);
185static poly kBucketGcd(kBucket* b, ring r);
186static void multi_reduction(red_object* los, int & losl, slimgb_alg* c);
187sorted_pair_node* quick_pop_pair(slimgb_alg* c);
188sorted_pair_node* top_pair(slimgb_alg* c);
189sorted_pair_node** add_to_basis_ideal_quotient(poly h, int i_pos, int j_pos,slimgb_alg* c, int* ip);
190sorted_pair_node**  spn_merge(sorted_pair_node** p, int pn,sorted_pair_node **q, int qn,slimgb_alg* c);
191int kFindDivisibleByInS_easy(kStrategy strat,const red_object & obj);
192int tgb_pair_better_gen2(const void* ap,const void* bp);
193int kFindDivisibleByInS_easy(kStrategy strat,poly p, long sev);
194//static int quality(poly p, int len, slimgb_alg* c);
195/**
196   makes on each red_object in a region a single_step
197 **/
198class reduction_step{
199 public:
200  /// we assume hat all occuring red_objects have same lm, and all
201  /// occ. lm's in r[l...u] are the same, only reductor does not occur
202  virtual void reduce(red_object* r, int l, int u);
203  //int reduction_id;
204  virtual ~reduction_step();
205  slimgb_alg* c;
206  int reduction_id;
207};
208class simple_reducer:public reduction_step{
209 public:
210  poly p;
211  kBucket_pt fill_back;
212  int p_len;
213  simple_reducer(poly p, int p_len, slimgb_alg* c =NULL){
214    this->p=p;
215    assume(p_len==pLength(p));
216    this->p_len=p_len;
217    this->c=c;
218  }
219  virtual void pre_reduce(red_object* r, int l, int u);
220  virtual void reduce(red_object* r, int l, int u);
221  ~simple_reducer();
222
223
224  virtual void target_is_no_sum_reduce(red_object & ro);
225};
226
227//class sum_canceling_reducer:public reduction_step {
228//  void reduce(red_object* r, int l, int u);
229//};
230struct find_erg{
231  poly expand;
232  int expand_length;
233  int to_reduce_u;
234  int to_reduce_l;
235  int reduce_by;//index of reductor
236  BOOLEAN fromS;//else from los
237
238};
239
240static void multi_reduce_step(find_erg & erg, red_object* r, slimgb_alg* c);
241static void finalize_reduction_step(reduction_step* r);
242
243
244
245
246
247
248#endif
Note: See TracBrowser for help on using the repository browser.