source: git/kernel/GBEngine/kutil.h @ 2e41b6d

spielwiese
Last change on this file since 2e41b6d was 2e41b6d, checked in by Hans Schoenemann <hannes@…>, 3 years ago
use strat in kTest_L, kTest_T
  • Property mode set to 100644
File size: 32.6 KB
Line 
1#ifndef KUTIL_H
2#define KUTIL_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/*
7* ABSTRACT: kernel: utils for kStd
8*/
9
10
11#include <string.h>
12
13#include "omalloc/omalloc.h"
14#ifdef HAVE_OMALLOC
15#include "omalloc/omallocClass.h"
16#endif
17
18#include "misc/mylimits.h"
19
20#include "kernel/polys.h"
21#include "polys/operations/pShallowCopyDelete.h"
22
23#include "kernel/structs.h"
24#include "kernel/GBEngine/kstd1.h"   /* for s_poly_proc_t */
25
26// define if tailrings should be used
27#define HAVE_TAIL_RING
28
29#define setmax 128
30#define setmaxL ((4096-12)/sizeof(LObject))
31#define setmaxLinc ((4096)/sizeof(LObject))
32
33#define setmaxT ((4096-12)/sizeof(TObject))
34#define setmaxTinc ((4096)/sizeof(TObject))
35
36#define RED_CANONICALIZE 200
37#define REDNF_CANONICALIZE 60
38#define REDTAIL_CANONICALIZE 100
39
40// if you want std computations as in Singular version < 2:
41// This disables RedThrough, tailReductions against T (bba),
42// sets posInT = posInT15 (bba, strat->honey), and enables redFirst with LDeg
43// NOTE: can be achieved with option(oldStd)
44
45#undef NO_KINLINE
46#if !defined(KDEBUG) && !defined(NO_INLINE)
47#define KINLINE inline
48#else
49#define KINLINE
50#define NO_KINLINE 1
51#endif
52
53typedef int* intset;
54typedef int64  wlen_type;
55typedef wlen_type* wlen_set;
56
57typedef class sTObject TObject;
58typedef class sLObject LObject;
59typedef TObject * TSet;
60typedef LObject * LSet;
61
62typedef struct denominator_list_s denominator_list_s;
63typedef denominator_list_s *denominator_list;
64
65struct denominator_list_s{number n; denominator_list next;};
66EXTERN_VAR denominator_list DENOMINATOR_LIST;
67
68class sTObject
69{
70public:
71  unsigned long sevSig;
72  poly sig;   // the signature of the element
73  poly p;       // Lm(p) \in currRing Tail(p) \in tailRing
74  poly t_p;     // t_p \in tailRing: as monomials Lm(t_p) == Lm(p)
75  poly max_exp;     // p_GetMaxExpP(pNext(p))
76  ring tailRing;
77  long FDeg;    // pFDeg(p)
78  int ecart,
79    length,     // as of pLDeg
80    pLength,    // either == 0, or == pLength(p)
81    i_r;        // index of TObject in R set, or -1 if not in T
82
83#ifdef HAVE_SHIFTBBA
84  int shift;
85#endif
86
87  /*BOOLEAN*/ char is_normalized; // true, if pNorm was called on p, false otherwise
88  // used in incremental sba() with F5C:
89  // we know some of the redundant elements in
90  // strat->T beforehand, so we can just discard
91  // them and do not need to consider them in the
92  // interreduction process
93  /*BOOLEAN*/ char is_redundant;
94  // used in sba's sig-safe reduction:
95  // sometimes we already know that a reducer
96  // is sig-safe, so no need for a real
97  // sig-safeness check
98  /*BOOLEAN*/ char is_sigsafe;
99
100
101#ifdef HAVE_PLURAL
102  /*BOOLEAN*/ char is_special; // true, it is a new special S-poly (e.g. for SCA)
103#endif
104
105  // initialization
106  KINLINE void Init(ring r = currRing);
107  KINLINE sTObject(ring tailRing = currRing);
108  KINLINE sTObject(poly p, ring tailRing = currRing);
109  KINLINE sTObject(poly p, ring c_r, ring tailRing);
110  KINLINE sTObject(sTObject* T, int copy);
111
112  KINLINE void Set(ring r=currRing);
113  KINLINE void Set(poly p_in, ring r=currRing);
114  KINLINE void Set(poly p_in, ring c_r, ring t_r);
115
116  // Frees the polys of T
117  KINLINE void Delete();
118  // Sets polys to NULL
119  KINLINE void Clear();
120  // makes a copy of the poly of T
121  KINLINE void Copy();
122
123  // ring-dependent Lm access: these might result in allocation of monomials
124  KINLINE poly GetLmCurrRing();
125  KINLINE poly GetLmTailRing();
126  KINLINE poly GetLm(ring r);
127  // this returns Lm and ring r (preferably from tailRing), but does not
128  // allocate a new poly
129  KINLINE void GetLm(poly &p, ring &r) const;
130
131#ifdef OLIVER_PRIVAT_LT
132  // routines for calc. with rings
133  KINLINE poly GetLtCurrRing();
134  KINLINE poly GetLtTailRing();
135  KINLINE poly GetLt(ring r);
136  KINLINE void GetLt(poly &p, ring &r) const;
137#endif
138
139  KINLINE BOOLEAN IsNull() const;
140
141  KINLINE int GetpLength();
142
143  // makes sure that T.p exists
144  KINLINE void SetLmCurrRing();
145
146  // Iterations
147  // simply get the next monomial
148  KINLINE poly Next();
149  KINLINE void LmDeleteAndIter();
150
151  // deg stuff
152  // compute pTotalDegree
153  KINLINE long pTotalDeg() const;
154  // computes pFDeg
155  KINLINE long pFDeg() const;
156  // computes and sets FDeg
157  KINLINE long SetpFDeg();
158  // gets stored FDeg
159  KINLINE long GetpFDeg() const;
160
161  // computes pLDeg
162  KINLINE long pLDeg();
163  // sets length, FDeg, returns LDeg
164  KINLINE long SetDegStuffReturnLDeg();
165
166  // arithmetic
167  KINLINE void Mult_nn(number n);
168  KINLINE void ShallowCopyDelete(ring new_tailRing, omBin new_tailBin,
169                                 pShallowCopyDeleteProc p_shallow_copy_delete,
170                                 BOOLEAN set_max = TRUE);
171  // manipulations
172  KINLINE void pNorm();
173  KINLINE void pCleardenom();
174  KINLINE void pContent();
175
176#ifdef KDEBUG
177  void wrp();
178#endif
179};
180
181EXTERN_VAR int strat_nr;
182
183class sLObject : public sTObject
184{
185
186public:
187  unsigned long sev;
188  poly  p1,p2; /*- the pair p comes from,
189                 lm(pi) in currRing, tail(pi) in tailring -*/
190
191  poly  lcm;   /*- the lcm of p1,p2 -*/
192  kBucket_pt bucket;
193  int   i_r1, i_r2;
194  unsigned checked; // this is the index of S up to which
195                      // the corresponding LObject was already checked in
196                      // critical pair creation => when entering the
197                      // reduction process it is enough to start a second
198                      // rewritten criterion check from checked+1 onwards
199  BOOLEAN prod_crit;
200                      // NOTE: If prod_crit = TRUE then the corresponding pair is
201                      // detected by Buchberger's Product Criterion and can be
202                      // deleted
203
204  // initialization
205  KINLINE void Init(ring tailRing = currRing);
206  KINLINE sLObject(ring tailRing = currRing);
207  KINLINE sLObject(poly p, ring tailRing = currRing);
208  KINLINE sLObject(poly p, ring c_r, ring tailRing);
209
210  // Frees the polys of L
211  KINLINE void Delete();
212  KINLINE void Clear();
213
214  // Iterations
215  KINLINE void LmDeleteAndIter();
216  KINLINE poly LmExtractAndIter();
217
218  // spoly related things
219  // preparation for reduction if not spoly
220  KINLINE void PrepareRed(BOOLEAN use_bucket);
221  KINLINE void SetLmTail(poly lm, poly new_p, int length,
222                         int use_bucket, ring r);
223  KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether);
224  KINLINE void Tail_Mult_nn(number n);
225  // deletes bucket, makes sure that p and t_p exists
226  KINLINE poly GetP(omBin lmBin = (omBin)NULL);
227  // similar, except that only t_p exists
228  KINLINE poly GetTP();
229
230  // does not delete bucket, just canonicalizes it
231  // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing
232  KINLINE void CanonicalizeP();
233
234  // makes a copy of the poly of L
235  KINLINE void Copy();
236
237  KINLINE int GetpLength();
238  KINLINE long pLDeg(BOOLEAN use_last);
239  KINLINE long pLDeg();
240  KINLINE int SetLength(BOOLEAN lengt_pLength = FALSE);
241  KINLINE long SetDegStuffReturnLDeg();
242  KINLINE long SetDegStuffReturnLDeg(BOOLEAN use_last);
243
244  // returns minimal component of p
245  KINLINE long MinComp();
246  // returns component of p
247  KINLINE long Comp();
248
249  KINLINE void ShallowCopyDelete(ring new_tailRing,
250                                 pShallowCopyDeleteProc p_shallow_copy_delete);
251
252  // sets sev
253  KINLINE void SetShortExpVector();
254
255  // enable assignment from TObject
256  KINLINE sLObject& operator=(const sTObject&);
257
258  // get T's corresponding to p1, p2: they might return NULL
259  KINLINE TObject* T_1(const skStrategy* strat);
260  KINLINE TObject* T_2(const skStrategy* strat);
261  KINLINE void     T_1_2(const skStrategy* strat,
262                         TObject* &T_1, TObject* &T_2);
263
264  // simplify coefficients
265  KINLINE void Normalize();
266  KINLINE void HeadNormalize();
267};
268
269EXTERN_VAR int HCord;
270
271class skStrategy
272#ifdef HAVE_OMALLOC
273                 : public omallocClass
274#endif
275{
276public:
277  kStrategy next;
278  int (*red)(LObject * L,kStrategy strat);
279  int (*red2)(LObject * L,kStrategy strat);
280  void (*initEcart)(TObject * L);
281  int (*posInT)(const TSet T,const int tl,LObject &h);
282  int (*posInLSba)(const LSet set, const int length,
283                LObject* L,const kStrategy strat);
284  int (*posInL)(const LSet set, const int length,
285                LObject* L,const kStrategy strat);
286  void (*enterS)(LObject &h, int pos,kStrategy strat, int atR/* =-1*/ );
287  void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG);
288  int (*posInLOld)(const LSet Ls,const int Ll,
289                   LObject* Lo,const kStrategy strat);
290  void (*enterOnePair) (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR /*= -1*/);
291  void (*chainCrit) (poly p,int ecart,kStrategy strat);
292  BOOLEAN (*syzCrit) (poly sig, unsigned long not_sevSig, kStrategy strat);
293  BOOLEAN (*rewCrit1) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
294  BOOLEAN (*rewCrit2) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
295  BOOLEAN (*rewCrit3) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
296  pFDegProc pOrigFDeg;
297  pLDegProc pOrigLDeg;
298  pFDegProc pOrigFDeg_TailRing;
299  pLDegProc pOrigLDeg_TailRing;
300  s_poly_proc_t s_poly;
301
302  LObject P;
303  ideal Shdl;
304  ideal D; /*V(S) is in D(D)*/
305  ideal M; /*set of minimal generators*/
306  polyset S;
307  polyset syz;
308  polyset sig;
309  intset ecartS;
310  intset fromS; // from which S[i] S[j] comes from
311                // this is important for signature-based
312                // algorithms
313  intset syzIdx;// index in the syz array at which the first
314                // syzygy of component i comes up
315                // important for signature-based algorithms
316  unsigned sbaOrder;
317  int currIdx;
318  int max_lower_index;
319  intset lenS;
320  wlen_set lenSw; /* for tgb.ccc */
321  intset fromQ;
322  unsigned long* sevS;
323  unsigned long* sevSyz;
324  unsigned long* sevSig;
325  unsigned long* sevT;
326  TSet T;
327  LSet L;
328  LSet    B;
329  poly    kNoether;
330  poly    t_kNoether; // same polys in tailring
331  KINLINE poly    kNoetherTail();
332  BOOLEAN * NotUsedAxis;
333  BOOLEAN * pairtest;/*used for enterOnePair*/
334  poly tail;
335  intvec * kModW;
336  intvec * kHomW;
337  // procedure for ShalloCopy from tailRing  to currRing
338  pShallowCopyDeleteProc p_shallow_copy_delete;
339  // pointers to Tobjects R[i] is ith Tobject which is generated
340  TObject**  R;
341  // S_2_R[i] yields Tobject which corresponds to S[i]
342  int*      S_2_R;
343  ring tailRing;
344  omBin lmBin;
345  omBin tailBin;
346  int nr;
347  int cp,c3;
348  int sl,mu;
349  int syzl,syzmax,syzidxmax;
350  int tl,tmax;
351  int Ll,Lmax;
352  int Bl,Bmax;
353  int ak,LazyDegree,LazyPass;
354  int syzComp;
355  int lastAxis;
356  int newIdeal;
357  int minim;
358  #ifdef HAVE_RINGS
359  bool sigdrop; //This is used to check sigdrop in sba over Z
360  int nrsyzcrit; // counts how many pairs are deleted by SyzCrit
361  int nrrewcrit; // counts how many pairs are deleted by FaugereRewCrit
362  int sbaEnterS; // sba over Z strategy: if sigdrop element has _*gen(sbaEnterS+1), then
363                 // add directly sbaEnterS elements into S
364  int blockred;  // counter for blocked reductions in redSig
365  int blockredmax;
366  #endif
367  #ifdef HAVE_SHIFTBBA
368  int cv; // in shift bases: counting V criterion
369  /*BOOLEAN*/ char rightGB;
370  #endif
371  /*BOOLEAN*/ char interpt;
372  /*BOOLEAN*/ char homog;
373#ifdef HAVE_PLURAL
374  /*BOOLEAN*/ char z2homog; // Z_2 - homogeneous input allows product criterion in commutative and SCA cases!
375#endif
376  /*BOOLEAN*/ char kAllAxis; // all axis are used -> (re)compute noether
377  /*BOOLEAN*/ char honey,sugarCrit;
378  /*BOOLEAN*/ char Gebauer,noTailReduction;
379  /*BOOLEAN*/ char fromT;
380  /*BOOLEAN*/ char noetherSet;
381  /*BOOLEAN*/ char update;
382  /*BOOLEAN*/ char posInLOldFlag;
383  /*BOOLEAN*/ char use_buckets;
384  // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength)
385  /*BOOLEAN*/ char LDegLast;
386  // if set, then L.length == L.pLength
387  /*BOOLEAN*/ char length_pLength;
388  // if set, then posInL does not depend on L.length
389  /*BOOLEAN*/ char posInLDependsOnLength;
390  /*FALSE, if posInL == posInL10*/
391#ifdef HAVE_PLURAL
392  // set this flag to 1 to stop the product criteria
393  // use ALLOW_PROD_CRIT(strat) to test
394  /*BOOLEAN*/ char no_prod_crit;
395#define ALLOW_PROD_CRIT(A) (!(A)->no_prod_crit)
396#else
397#define ALLOW_PROD_CRIT(A) (1)
398#endif
399  char    redTailChange;
400  char    news;
401  char    newt;/*used for messageSets*/
402  char    noClearS;
403  char    completeReduce_retry;
404  char    overflow;
405
406  skStrategy();
407  ~skStrategy();
408
409  // return TObject corresponding to S[i]: assume that it exists
410  // i.e. no error checking is done
411  KINLINE TObject* S_2_T(int i);
412  // like S_2_T, except that NULL is returned if it can not be found
413  KINLINE TObject* s_2_t(int i);
414};
415
416void deleteHC(poly *p, int *e, int *l, kStrategy strat);
417void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE);
418void deleteInS (int i,kStrategy strat);
419void deleteInSSba (int i,kStrategy strat);
420void cleanT (kStrategy strat);
421static inline LSet initL (int nr=setmaxL)
422{ return (LSet)omAlloc(nr*sizeof(LObject)); }
423void deleteInL(LSet set, int *length, int j,kStrategy strat);
424void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at);
425void enterSBba (LObject &p,int atS,kStrategy strat, int atR = -1);
426void enterSBbaShift (LObject &p,int atS,kStrategy strat, int atR = -1);
427void enterSSba (LObject &p,int atS,kStrategy strat, int atR = -1);
428void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
429void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
430int posInS (const kStrategy strat, const int length, const poly p,
431            const int ecart_p);
432int posInSMonFirst (const kStrategy strat, const int length, const poly p);
433int posInIdealMonFirst (const ideal F, const poly p,int start = 0,int end = -1);
434int posInT0 (const TSet set,const int length,LObject &p);
435int posInT1 (const TSet set,const int length,LObject &p);
436int posInT2 (const TSet set,const int length,LObject &p);
437int posInT11 (const TSet set,const int length,LObject &p);
438int posInTSig (const TSet set,const int length,LObject &p);
439int posInT110 (const TSet set,const int length,LObject &p);
440int posInT13 (const TSet set,const int length,LObject &p);
441int posInT15 (const TSet set,const int length,LObject &p);
442int posInT17 (const TSet set,const int length,LObject &p);
443int posInT17_c (const TSet set,const int length,LObject &p);
444int posInT19 (const TSet set,const int length,LObject &p);
445int posInT_EcartpLength(const TSet set,const int length,LObject &p);
446int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p);
447int posInT_FDegpLength(const TSet set,const int length,LObject &p);
448int posInT_pLength(const TSet set,const int length,LObject &p);
449
450#ifdef HAVE_MORE_POS_IN_T
451int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p);
452int posInT_FDegpLength(const TSet set,const int length,LObject &p);
453int posInT_pLength(const TSet set,const int length,LObject &p);
454#endif
455
456
457void reorderS (int* suc,kStrategy strat);
458int posInLF5C (const LSet set, const int length,
459               LObject* L,const kStrategy strat);
460int posInLSig (const LSet set, const int length,
461               LObject* L,const kStrategy strat);
462int posInLSigRing (const LSet set, const int length,
463               LObject* L,const kStrategy strat);
464int posInLRing (const LSet set, const int length,
465               LObject* L,const kStrategy strat);
466int posInSyz (const kStrategy strat, const poly sig);
467int posInL0 (const LSet set, const int length,
468             LObject* L,const kStrategy strat);
469int posInL11 (const LSet set, const int length,
470             LObject* L,const kStrategy strat);
471int posInL11Ring (const LSet set, const int length,
472             LObject* L,const kStrategy strat);
473int posInLF5CRing (const LSet set, int start , const int length,
474             LObject* L,const kStrategy strat);
475int posInL11Ringls (const LSet set, const int length,
476             LObject* L,const kStrategy strat);
477int posInL13 (const LSet set, const int length,
478             LObject* L,const kStrategy strat);
479int posInL15 (const LSet set, const int length,
480             LObject* L,const kStrategy strat);
481int posInL15Ring (const LSet set, const int length,
482             LObject* L,const kStrategy strat);
483int posInL17 (const LSet set, const int length,
484             LObject* L,const kStrategy strat);
485int posInL10 (const LSet set, const int length,
486             LObject* L,const kStrategy strat);
487int posInL10Ring (const LSet set, const int length,
488             LObject* L,const kStrategy strat);
489int posInL110 (const LSet set, const int length,
490             LObject* L,const kStrategy strat);
491KINLINE poly redtailBba (poly p,int end_pos,kStrategy strat,BOOLEAN normalize=FALSE);
492KINLINE poly redtailBbaBound (poly p,int end_pos,kStrategy strat,int bound,BOOLEAN normalize=FALSE);
493#ifdef HAVE_RINGS
494KINLINE poly redtailBba_Ring (poly p,int end_pos,kStrategy strat);
495KINLINE poly redtailBba_Z (poly p,int end_pos,kStrategy strat);
496poly redtailBba_Ring (LObject* L, int end_pos, kStrategy strat );
497poly redtailBba_Z (LObject* L, int end_pos, kStrategy strat );
498void redtailBbaAlsoLC_Z (LObject* L, int end_pos, kStrategy strat );
499#endif
500poly redtailBba (LObject *L, int end_pos,kStrategy strat,
501                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
502poly redtailBbaBound (LObject *L, int end_pos,kStrategy strat,int bound,
503                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
504poly redtailSba (LObject *L, int end_pos,kStrategy strat,
505                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
506poly redtailBba (TObject *T, int end_pos,kStrategy strat);
507poly redtail (poly p,int end_pos,kStrategy strat);
508poly redtail (LObject *L,int end_pos,kStrategy strat);
509poly redNF (poly h,int & max_ind,int nonorm,kStrategy strat);
510int redNF0 (LObject *P,kStrategy strat);
511poly redNFTail (poly h,const int sl,kStrategy strat);
512int redHoney (LObject* h, kStrategy strat);
513int redLiftstd (LObject* h, kStrategy strat);
514#ifdef HAVE_RINGS
515int redRing (LObject* h,kStrategy strat);
516int redRing_Z (LObject* h,kStrategy strat);
517int redRiloc (LObject* h,kStrategy strat);
518void enterExtendedSpoly(poly h,kStrategy strat);
519void enterExtendedSpolySig(poly h,poly hSig,kStrategy strat);
520void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);
521void superenterpairsSig (poly h,poly hSig,int hFrom,int k,int ecart,int pos,kStrategy strat, int atR = -1);
522#endif
523int redLazy (LObject* h,kStrategy strat);
524int redHomog (LObject* h,kStrategy strat);
525int redSig (LObject* h,kStrategy strat);
526int redSigRing (LObject* h,kStrategy strat);
527//adds hSig to be able to check with F5's criteria when entering pairs!
528void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos,kStrategy strat, int atR = -1);
529void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1);
530void entersets (LObject h);
531void pairs ();
532BOOLEAN sbaCheckGcdPair (LObject* h,kStrategy strat);
533void message (int i,int* reduc,int* olddeg,kStrategy strat,int red_result);
534void messageStat (int hilbcount,kStrategy strat);
535void messageStatSBA (int hilbcount,kStrategy strat);
536#ifdef KDEBUG
537void messageSets (kStrategy strat);
538#else
539#define messageSets(s)  do {} while (0)
540#endif
541
542void initEcartNormal (TObject* h);
543void initEcartBBA (TObject* h);
544void initS (ideal F, ideal Q,kStrategy strat);
545void initSL (ideal F, ideal Q,kStrategy strat);
546void initSLSba (ideal F, ideal Q,kStrategy strat);
547/*************************************************
548 * when initializing a new bunch of principal
549 * syzygies at the beginning of a new iteration
550 * step in a signature-based algorithm we
551 * compute ONLY the leading elements of those
552 * syzygies, NOT the whole syzygy
553 * NOTE: this needs to be adjusted for a more
554 * general approach on signature-based algorithms
555 ***********************************************/
556void initSyzRules (kStrategy strat);
557void updateS(BOOLEAN toT,kStrategy strat);
558void enterSyz (LObject &p,kStrategy strat, int atT);
559void enterT (LObject &p,kStrategy strat, int atT = -1);
560void replaceInLAndSAndT(LObject &p, int tj, kStrategy strat);
561#ifdef HAVE_RINGS
562void enterT_strong (LObject &p,kStrategy strat, int atT = -1);
563#endif
564void cancelunit (LObject* p,BOOLEAN inNF=FALSE);
565void HEckeTest (poly pp,kStrategy strat);
566void initBuchMoraCrit(kStrategy strat);
567void initSbaCrit(kStrategy strat);
568void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
569void initBuchMoraPos(kStrategy strat);
570void initBuchMoraPosRing(kStrategy strat);
571void initSbaPos(kStrategy strat);
572void initBuchMora (ideal F, ideal Q,kStrategy strat);
573void initSbaBuchMora (ideal F, ideal Q,kStrategy strat);
574void exitBuchMora (kStrategy strat);
575void exitSba (kStrategy strat);
576void updateResult(ideal r,ideal Q,kStrategy strat);
577void completeReduce (kStrategy strat, BOOLEAN withT=FALSE);
578void kFreeStrat(kStrategy strat);
579void enterOnePairNormal (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR);
580void chainCritNormal (poly p,int ecart,kStrategy strat);
581void chainCritOpt_1 (poly,int,kStrategy strat);
582void chainCritSig (poly p,int ecart,kStrategy strat);
583BOOLEAN homogTest(polyset F, int Fmax);
584BOOLEAN newHEdge(kStrategy strat);
585BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat);
586BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat);
587KINLINE BOOLEAN arriRewDummy(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
588BOOLEAN arriRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
589BOOLEAN arriRewCriterionPre(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
590BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
591BOOLEAN findMinLMPair(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
592
593/// returns index of p in TSet, or -1 if not found
594int kFindInT(poly p, TSet T, int tlength);
595#ifdef HAVE_SHIFTBBA
596int kFindInTShift(poly p, TSet T, int tlength);
597#endif
598
599/// return -1 if no divisor is found
600///        number of first divisor in T, otherwise
601int kFindDivisibleByInT(const kStrategy strat, const LObject* L, const int start=0);
602int kFindDivisibleByInT_Z(const kStrategy strat, const LObject* L, const int start=0);
603int kFindSameLMInT_Z(const kStrategy strat, const LObject* L, const int start=0);
604
605/// tests if T[0] divides the leading monomial of L, returns -1 if not
606int kTestDivisibleByT0_Z(const kStrategy strat, const LObject* L);
607/// return -1 if no divisor is found
608///        number of first divisor in S, otherwise
609int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L);
610
611int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L);
612TObject* kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject* L, TObject *T, long ecart = LONG_MAX);
613
614/***************************************************************
615 *
616 * stuff to be inlined
617 *
618 ***************************************************************/
619
620KINLINE TSet initT ();
621KINLINE TObject** initR();
622KINLINE unsigned long* initsevT();
623KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
624KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin bin);
625KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
626KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing,  omBin bin);
627
628KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing);
629KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing);
630KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing);
631KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing);
632
633// if exp bound is not violated, return TRUE and
634//                               get m1 = LCM(LM(p1), LM(p2))/LM(p1)
635//                                   m2 = LCM(LM(p1), LM(p2))/LM(p2)
636// return FALSE and m1 == NULL, m2 == NULL     , otherwise
637KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r,
638                               poly &m1, poly &m2, const ring m_r);
639#ifdef HAVE_RINGS
640KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing,
641                               poly &m1, poly &m2, poly &lcm, const ring taiRing);
642#endif
643#ifdef KDEBUG
644// test strat
645BOOLEAN kTest(kStrategy strat);
646// test strat, and test that S is contained in T
647BOOLEAN kTest_TS(kStrategy strat);
648// test LObject
649BOOLEAN kTest_L(LObject* L, kStrategy strat,
650                 BOOLEAN testp = FALSE, int lpos = -1,
651                 TSet T = NULL, int tlength = -1);
652// test TObject
653BOOLEAN kTest_T(TObject* T, kStrategy strat, int tpos = -1, char TN = '?');
654// test set strat->SevS
655BOOLEAN kTest_S(kStrategy strat);
656#else
657#define kTest(A)        (TRUE)
658#define kTest_TS(A)     (TRUE)
659#define kTest_T(T,S)    (TRUE)
660#define kTest_S(T)      (TRUE)
661#define kTest_L(T,R)    (TRUE)
662#endif
663
664
665/***************************************************************
666 *
667 * From kstd2.cc
668 *
669 ***************************************************************/
670poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing);
671ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
672ideal sba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
673poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce);
674ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce);
675poly kNF2Bound (ideal F, ideal Q, poly q,int bound, kStrategy strat, int lazyReduce);
676ideal kNF2Bound (ideal F,ideal Q,ideal q,int bound, kStrategy strat, int lazyReduce);
677void initBba(kStrategy strat);
678void initSba(ideal F,kStrategy strat);
679void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg,
680          int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q,
681          intvec *w,intvec *hilb );
682
683/***************************************************************
684 *
685 * From kspoly.cc
686 *
687 ***************************************************************/
688// Reduces PR with PW
689// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
690// Changes: PR
691// Const:   PW
692// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
693// If strat != NULL, tailRing is changed if reduction would violate exp bound
694// of tailRing
695// Returns: 0 everything ok, no tailRing change
696//          1 tailRing has successfully changed (strat != NULL)
697//          2 no reduction performed, tailRing needs to be changed first
698//            (strat == NULL)
699//         -1 tailRing change could not be performed due to exceeding exp
700//            bound of currRing
701int ksReducePoly(LObject* PR,
702                 TObject* PW,
703                 poly spNoether = NULL,
704                 number *coef = NULL,
705                 poly *mon =NULL,
706                 kStrategy strat = NULL);
707
708/* like ksReducePoly, but if the reducer has only 1 term we still
709 * compute a possible coefficient multiplier for PR. this comes from
710 * a special situation in redRing_Z and it is used only there. */
711int ksReducePolyZ(LObject* PR,
712                 TObject* PW,
713                 poly spNoether = NULL,
714                 number *coef = NULL,
715                 kStrategy strat = NULL);
716
717int ksReducePolyLC(LObject* PR,
718                 TObject* PW,
719                 poly spNoether = NULL,
720                 number *coef = NULL,
721                 kStrategy strat = NULL);
722
723
724int ksReducePolyGCD(LObject* PR,
725                 TObject* PW,
726                 poly spNoether = NULL,
727                 number *coef = NULL,
728                 kStrategy strat = NULL);
729
730int ksReducePolyBound(LObject* PR,
731                 TObject* PW,
732                 int bound,
733                 poly spNoether = NULL,
734                 number *coef = NULL,
735                 kStrategy strat = NULL);
736
737// Reduces PR with PW
738// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
739// Changes: PR
740// Const:   PW
741// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
742// If strat != NULL, tailRing is changed if reduction would violate exp bound
743// of tailRing
744// Returns: 0 everything ok, no tailRing change
745//          1 tailRing has successfully changed (strat != NULL)
746//          2 no reduction performed, tailRing needs to be changed first
747//            (strat == NULL)
748//          3 no reduction performed, not sig-safe!!!
749//         -1 tailRing change could not be performed due to exceeding exp
750//            bound of currRing
751int ksReducePolySig(LObject* PR,
752                 TObject* PW,
753                 long idx,
754                 poly spNoether = NULL,
755                 number *coef = NULL,
756                 kStrategy strat = NULL);
757
758int ksReducePolySigRing(LObject* PR,
759                 TObject* PW,
760                 long idx,
761                 poly spNoether = NULL,
762                 number *coef = NULL,
763                 kStrategy strat = NULL);
764
765// Reduces PR at Current->next with PW
766// Assumes PR != NULL, Current contained in PR
767//         Current->next != NULL, LM(PW) devides LM(Current->next)
768// Changes: PR
769// Const:   PW
770// Return: see ksReducePoly
771int ksReducePolyTail(LObject* PR,
772                     TObject* PW,
773                     poly Current,
774                     poly spNoether = NULL);
775
776KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red);
777
778// Creates S-Poly of Pair
779// Const:   Pair->p1, Pair->p2
780// Changes: Pair->p == S-Poly of p1, p2
781// Assume:  Pair->p1 != NULL && Pair->p2
782void ksCreateSpoly(LObject* Pair, poly spNoether = NULL,
783                   int use_buckets=0, ring tailRing=currRing,
784                   poly m1 = NULL, poly m2 = NULL, TObject** R = NULL);
785
786/*2
787* creates the leading term of the S-polynomial of p1 and p2
788* do not destroy p1 and p2
789* remarks:
790*   1. the coefficient is 0 (nNew)
791*   2. pNext is undefined
792*/
793poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing);
794
795
796// old stuff
797KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL);
798KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL);
799KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL, ring r = currRing);
800KINLINE void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r = currRing);
801
802/***************************************************************
803 *
804 * Routines related for ring changes during std computations
805 *
806 ***************************************************************/
807// return TRUE and set m1, m2 to k_GetLcmTerms,
808//             if spoly creation of strat->P does not violate
809//             exponent bound of strat->tailRing
810//      FALSE, otherwise
811BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2);
812#ifdef HAVE_RINGS
813// return TRUE if gcdpoly creation of R[atR] and S[atS] does not violate
814//             exponent bound of strat->tailRing
815//      FALSE, otherwise
816BOOLEAN kCheckStrongCreation(int atR, poly m1, int atS, poly m2, kStrategy strat);
817poly preIntegerCheck(ideal F, ideal Q);
818void postReduceByMon(LObject* h, kStrategy strat);
819void postReduceByMonSig(LObject* h, kStrategy strat);
820void finalReduceByMon(kStrategy strat);
821#endif
822// change strat->tailRing and adjust all data in strat, L, and T:
823// new tailRing has larger exponent bound
824// do nothing and return FALSE if exponent bound increase would result in
825// larger exponent bound that that of currRing
826BOOLEAN kStratChangeTailRing(kStrategy strat,
827                             LObject* L = NULL, TObject* T = NULL,
828                             // take this as new_expbound: if 0
829                             // new expbound is 2*expbound of tailRing
830                             unsigned long new_expbound = 0);
831// initiate a change of the tailRing of strat -- should be called
832// right before main loop in bba
833void kStratInitChangeTailRing(kStrategy strat);
834
835/// Output some debug info about a given strategy
836void kDebugPrint(kStrategy strat);
837
838// getting sb order for sba computations
839ring sbaRing(kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1);
840
841KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
842  kStrategy strat);
843
844#include "kernel/GBEngine/kInline.h"
845
846/* shiftgb stuff */
847#include "kernel/GBEngine/shiftgb.h"
848
849poly pMove2CurrTail(poly p, kStrategy strat);
850
851poly pMoveCurrTail2poly(poly p, kStrategy strat);
852
853poly pCopyL2p(LObject h, kStrategy strat);
854
855void enterTShift(LObject p, kStrategy strat, int atT = -1);
856
857void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS);
858
859void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR);
860
861void superenterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR);
862
863poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize);
864
865int redFirstShift (LObject* h,kStrategy strat); // ok
866
867ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
868// test syz strategy: // will be removed soon
869EXTERN_VAR int (*test_PosInT)(const TSet T,const int tl,LObject &h);
870EXTERN_VAR int (*test_PosInL)(const LSet set, const int length,
871                LObject* L,const kStrategy strat);
872
873static inline void kDeleteLcm(LObject *P)
874{
875 if (P->lcm!=NULL)
876 {
877 #ifdef HAVE_RINGS
878   if (rField_is_Ring(currRing))
879     pLmDelete(P->lcm);
880   else
881 #endif
882     pLmFree(P->lcm);
883   P->lcm=NULL;
884 }
885}
886
887void initenterpairs (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR = -1);
888#endif
Note: See TracBrowser for help on using the repository browser.