source: git/kernel/GBEngine/kutil.h @ 216e12

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