source: git/kernel/GBEngine/kutil.h @ 3e5610

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