source: git/kernel/GBEngine/kutil.h @ f6c77e9

spielwiese
Last change on this file since f6c77e9 was f6c77e9, checked in by Hans Schoenemann <hannes@…>, 9 years ago
fix: pLength in completeReduceFac (from master)
  • Property mode set to 100644
File size: 28.4 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#include <misc/mylimits.h>
15
16
17#include <kernel/polys.h>
18#include <polys/operations/pShallowCopyDelete.h>
19
20#include <kernel/structs.h>
21
22// define if tailrings should be used
23#define HAVE_TAIL_RING
24
25#if 1
26#define setmax 16
27#define setmaxL ((4096-12)/sizeof(LObject))
28#define setmaxLinc ((4096)/sizeof(LObject))
29
30#define setmaxT 64
31#define setmaxTinc 32
32#else
33#define setmax 16
34#define setmaxL 16
35#define setmaxLinc 16
36#define setmaxT 16
37#define setmaxTinc 16
38#endif
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 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;     // 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  BOOLEAN is_normalized; // true, if pNorm was called on p, false otherwise
83  // used in incremental sba() with F5C:
84  // we know some of the redundant elements in
85  // strat->T beforehand, so we can just discard
86  // them and do not need to consider them in the
87  // interreduction process
88  BOOLEAN is_redundant;
89  // used in sba's sig-safe reduction:
90  // sometimes we already know that a reducer
91  // is sig-safe, so no need for a real
92  // sig-safeness check
93  BOOLEAN is_sigsafe;
94
95
96#ifdef HAVE_PLURAL
97  BOOLEAN is_special; // true, it is a new special S-poly (e.g. for SCA)
98#endif
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
175#ifndef SING_NDEBUG
176extern int strat_nr;
177extern int strat_fac_debug;
178#endif
179
180class sLObject : public sTObject
181{
182
183public:
184  unsigned long sev;
185  unsigned long checked; // this is the index of S up to which
186                      // the corresponding LObject was already checked in
187                      // critical pair creation => when entering the
188                      // reduction process it is enough to start a second
189                      // rewritten criterion check from checked+1 onwards
190  BOOLEAN prod_crit;
191                      // NOTE: If prod_crit = TRUE then the corresponding pair is
192                      // detected by Buchberger's Product Criterion and can be
193                      // deleted
194  poly  p1,p2; /*- the pair p comes from,
195                 lm(pi) in currRing, tail(pi) in tailring -*/
196
197  poly  lcm;   /*- the lcm of p1,p2 -*/
198  kBucket_pt bucket;
199  int   i_r1, i_r2;
200
201  // initialization
202  KINLINE void Init(ring tailRing = currRing);
203  KINLINE sLObject(ring tailRing = currRing);
204  KINLINE sLObject(poly p, ring tailRing = currRing);
205  KINLINE sLObject(poly p, ring c_r, ring tailRing);
206
207  // Frees the polys of L
208  KINLINE void Delete();
209  KINLINE void Clear();
210
211  // Iterations
212  KINLINE void LmDeleteAndIter();
213  KINLINE poly LmExtractAndIter();
214
215  // spoly related things
216  // preparation for reduction if not spoly
217  KINLINE void PrepareRed(BOOLEAN use_bucket);
218  KINLINE void SetLmTail(poly lm, poly new_p, int length,
219                         int use_bucket, ring r);
220  KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether);
221  KINLINE void Tail_Mult_nn(number n);
222  // deletes bucket, makes sure that p and t_p exists
223  KINLINE poly GetP(omBin lmBin = NULL);
224  // similar, except that only t_p exists
225  KINLINE poly GetTP();
226
227  // does not delete bucket, just canonicalizes it
228  // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing
229  KINLINE poly CanonicalizeP();
230
231  // makes a copy of the poly of L
232  KINLINE void Copy();
233  // gets the poly and makes a copy of it
234  KINLINE poly CopyGetP();
235
236  KINLINE int GetpLength();
237  KINLINE long pLDeg(BOOLEAN use_last);
238  KINLINE long pLDeg();
239  KINLINE int SetLength(BOOLEAN lengt_pLength = FALSE);
240  KINLINE long SetDegStuffReturnLDeg();
241  KINLINE long SetDegStuffReturnLDeg(BOOLEAN use_last);
242
243  // returns minimal component of p
244  KINLINE long MinComp();
245  // returns component of p
246  KINLINE long Comp();
247
248  KINLINE void ShallowCopyDelete(ring new_tailRing,
249                                 pShallowCopyDeleteProc p_shallow_copy_delete);
250
251  // sets sev
252  KINLINE void SetShortExpVector();
253
254  // enable assignment from TObject
255  KINLINE sLObject& operator=(const sTObject&);
256
257  // get T's corresponding to p1, p2: they might return NULL
258  KINLINE TObject* T_1(const skStrategy* strat);
259  KINLINE TObject* T_2(const skStrategy* strat);
260  KINLINE void     T_1_2(const skStrategy* strat,
261                         TObject* &T_1, TObject* &T_2);
262
263  // simplify coefficients
264  KINLINE void Normalize();
265  KINLINE void HeadNormalize();
266};
267
268
269extern int HCord;
270
271class skStrategy;
272typedef skStrategy * kStrategy;
273class skStrategy
274{
275public:
276  kStrategy next;
277  int (*red)(LObject * L,kStrategy strat);
278  int (*red2)(LObject * L,kStrategy strat);
279  void (*initEcart)(TObject * L);
280  int (*posInT)(const TSet T,const int tl,LObject &h);
281  int (*posInLSba)(const LSet set, const int length,
282                LObject* L,const kStrategy strat);
283  int (*posInL)(const LSet set, const int length,
284                LObject* L,const kStrategy strat);
285  void (*enterS)(LObject h, int pos,kStrategy strat, int atR/* =-1*/ );
286  void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG);
287  int (*posInLOld)(const LSet Ls,const int Ll,
288                   LObject* Lo,const kStrategy strat);
289  void (*enterOnePair) (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR /*= -1*/);
290  void (*chainCrit) (poly p,int ecart,kStrategy strat);
291  BOOLEAN (*syzCrit) (poly sig, unsigned long not_sevSig, kStrategy strat);
292  BOOLEAN (*rewCrit1) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
293  BOOLEAN (*rewCrit2) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
294  BOOLEAN (*rewCrit3) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
295  pFDegProc pOrigFDeg;
296  pLDegProc pOrigLDeg;
297  pFDegProc pOrigFDeg_TailRing;
298  pLDegProc pOrigLDeg_TailRing;
299
300  LObject P;
301  ideal Shdl;
302  ideal D; /*V(S) is in D(D)*/
303  ideal M; /*set of minimal generators*/
304  polyset S;
305  polyset syz;
306  polyset sig;
307  intset ecartS;
308  intset fromS; // from which S[i] S[j] comes from
309                // this is important for signature-based
310                // algorithms
311  intset syzIdx;// index in the syz array at which the first
312                // syzygy of component i comes up
313                // important for signature-based algorithms
314  unsigned sbaOrder;
315  unsigned long currIdx;
316  int max_lower_index;
317  intset lenS;
318  wlen_set lenSw; /* for tgb.ccc */
319  intset fromQ;
320  unsigned long* sevS;
321  unsigned long* sevSyz;
322  unsigned long* sevSig;
323  unsigned long* sevT;
324  TSet T;
325  LSet L;
326  LSet    B;
327  poly    kHEdge;
328  poly    kNoether;
329  poly    t_kHEdge; // same polys in tailring
330  KINLINE poly    kNoetherTail();
331  poly    t_kNoether;
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#ifndef SING_NDEBUG
347  int nr;
348#endif
349  int cp,c3;
350  int cv; // in shift bases: counting V criterion
351  int sl,mu;
352  int syzl,syzmax,syzidxmax;
353  int tl,tmax;
354  int Ll,Lmax;
355  int Bl,Bmax;
356  int ak,LazyDegree,LazyPass;
357  int syzComp;
358  int HCord;
359  int lastAxis;
360  int newIdeal;
361  int minim;
362  #ifdef HAVE_SHIFTBBA
363  int lV;
364  #endif
365  BOOLEAN interpt;
366  BOOLEAN homog;
367#ifdef HAVE_PLURAL
368  BOOLEAN z2homog; // Z_2 - homogeneous input allows product criterion in commutative and SCA cases!
369#endif
370  BOOLEAN kHEdgeFound;
371  BOOLEAN honey,sugarCrit;
372  BOOLEAN Gebauer,noTailReduction;
373  BOOLEAN fromT;
374  BOOLEAN noetherSet;
375  BOOLEAN update;
376  BOOLEAN posInLOldFlag;
377  BOOLEAN use_buckets;
378  BOOLEAN interred_flag;
379  // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength)
380  BOOLEAN LDegLast;
381  // if set, then L.length == L.pLength
382  BOOLEAN length_pLength;
383  // if set, then posInL does not depend on L.length
384  BOOLEAN posInLDependsOnLength;
385  /*FALSE, if posInL == posInL10*/
386#ifdef HAVE_PLURAL
387  // set this flag to 1 to stop the product criteria
388  // use ALLOW_PROD_CRIT(strat) to test
389  BOOLEAN no_prod_crit;
390#define ALLOW_PROD_CRIT(A) (!(A)->no_prod_crit)
391#else
392#define ALLOW_PROD_CRIT(A) (1)
393#endif
394  char    redTailChange;
395  char    news;
396  char    newt;/*used for messageSets*/
397  char    noClearS;
398  char    completeReduce_retry;
399  char    overflow;
400
401  skStrategy();
402  ~skStrategy();
403
404  // return TObject corresponding to S[i]: assume that it exists
405  // i.e. no error checking is done
406  KINLINE TObject* S_2_T(int i);
407  // like S_2_T, except that NULL is returned if it can not be found
408  KINLINE TObject* s_2_t(int i);
409};
410
411void deleteHC(poly *p, int *e, int *l, kStrategy strat);
412void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE);
413void deleteInS (int i,kStrategy strat);
414void deleteInSSba (int i,kStrategy strat);
415void cleanT (kStrategy strat);
416static inline LSet initL (int nr=setmaxL)
417{ return (LSet)omAlloc(nr*sizeof(LObject)); }
418void deleteInL(LSet set, int *length, int j,kStrategy strat);
419void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at);
420void enterSBba (LObject p,int atS,kStrategy strat, int atR = -1);
421void enterSSba (LObject p,int atS,kStrategy strat, int atR = -1);
422void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
423void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
424int posInS (const kStrategy strat, const int length, const poly p,
425            const int ecart_p);
426int posInT0 (const TSet set,const int length,LObject &p);
427int posInT1 (const TSet set,const int length,LObject &p);
428int posInT2 (const TSet set,const int length,LObject &p);
429int posInT11 (const TSet set,const int length,LObject &p);
430int posInTSig (const TSet set,const int length,LObject &p);
431int posInT110 (const TSet set,const int length,LObject &p);
432int posInT13 (const TSet set,const int length,LObject &p);
433int posInT15 (const TSet set,const int length,LObject &p);
434int posInT17 (const TSet set,const int length,LObject &p);
435int posInT19 (const TSet set,const int length,LObject &p);
436int posInT_EcartpLength(const TSet set,const int length,LObject &p);
437
438#ifdef HAVE_MORE_POS_IN_T
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#endif
443
444
445void reorderS (int* suc,kStrategy strat);
446int posInLF5C (const LSet set, const int length,
447               LObject* L,const kStrategy strat);
448int posInLSig (const LSet set, const int length,
449               LObject* L,const kStrategy strat);
450int posInSyz (const kStrategy strat, const poly sig);
451int posInL0 (const LSet set, const int length,
452             LObject* L,const kStrategy strat);
453int posInL11 (const LSet set, const int length,
454             LObject* L,const kStrategy strat);
455int posInL13 (const LSet set, const int length,
456             LObject* L,const kStrategy strat);
457int posInL15 (const LSet set, const int length,
458             LObject* L,const kStrategy strat);
459int posInL17 (const LSet set, const int length,
460             LObject* L,const kStrategy strat);
461int posInL10 (const LSet set, const int length,
462             LObject* L,const kStrategy strat);
463int posInL110 (const LSet set, const int length,
464             LObject* L,const kStrategy strat);
465KINLINE poly redtailBba (poly p,int pos,kStrategy strat,BOOLEAN normalize=FALSE);
466#ifdef HAVE_RINGS
467KINLINE poly redtailBba_Z (poly p,int pos,kStrategy strat);
468poly redtailBba_Z (LObject* L, int pos, kStrategy strat );
469#endif
470poly redtailBba (LObject *L, int pos,kStrategy strat,
471                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
472poly redtailSba (LObject *L, int pos,kStrategy strat,
473                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
474poly redtailBba (TObject *T, int pos,kStrategy strat);
475poly redtail (poly p,int pos,kStrategy strat);
476poly redtail (LObject *L,int pos,kStrategy strat);
477poly redNF (poly h,int & max_ind,int nonorm,kStrategy strat);
478int redNF0 (LObject *P,kStrategy strat);
479poly redNFTail (poly h,const int sl,kStrategy strat);
480int redHoney (LObject* h, kStrategy strat);
481#ifdef HAVE_RINGS
482int redRing (LObject* h,kStrategy strat);
483int redRiloc (LObject* h,kStrategy strat);
484void enterExtendedSpoly(poly h,kStrategy strat);
485void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);
486poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing);
487long ind2(long arg);
488
489long ind_fact_2(long arg);
490long twoPow(long arg);
491ideal createG0();
492#endif
493int redLazy (LObject* h,kStrategy strat);
494int redHomog (LObject* h,kStrategy strat);
495int redSig (LObject* h,kStrategy strat);
496//adds hSig to be able to check with F5's criteria when entering pairs!
497void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos,kStrategy strat, int atR = -1);
498void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1);
499void entersets (LObject h);
500void pairs ();
501void message (int i,int* reduc,int* olddeg,kStrategy strat,int red_result);
502void messageStat (int hilbcount,kStrategy strat);
503#ifdef KDEBUG
504void messageSets (kStrategy strat);
505#else
506#define messageSets(s)  do {} while (0)
507#endif
508
509void initEcartNormal (TObject* h);
510void initEcartBBA (TObject* h);
511void initS (ideal F, ideal Q,kStrategy strat);
512void initSL (ideal F, ideal Q,kStrategy strat);
513void initSLSba (ideal F, ideal Q,kStrategy strat);
514/*************************************************
515 * when initializing a new bunch of principal
516 * syzygies at the beginning of a new iteration
517 * step in a signature-based algorithm we
518 * compute ONLY the leading elements of those
519 * syzygies, NOT the whole syzygy
520 * NOTE: this needs to be adjusted for a more
521 * general approach on signature-based algorithms
522 ***********************************************/
523void initSyzRules (kStrategy strat);
524void updateS(BOOLEAN toT,kStrategy strat);
525void enterSyz (LObject p,kStrategy strat, int atT);
526void enterT (LObject p,kStrategy strat, int atT = -1);
527void cancelunit (LObject* p,BOOLEAN inNF=FALSE);
528void HEckeTest (poly pp,kStrategy strat);
529void initBuchMoraCrit(kStrategy strat);
530void initSbaCrit(kStrategy strat);
531void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
532void initBuchMoraPos(kStrategy strat);
533void initSbaPos(kStrategy strat);
534void initBuchMora (ideal F, ideal Q,kStrategy strat);
535void initSbaBuchMora (ideal F, ideal Q,kStrategy strat);
536void exitBuchMora (kStrategy strat);
537void exitSba (kStrategy strat);
538void updateResult(ideal r,ideal Q,kStrategy strat);
539void completeReduce (kStrategy strat, BOOLEAN withT=FALSE);
540void kFreeStrat(kStrategy strat);
541void enterOnePairNormal (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR);
542void enterOnePairSig (int i,poly p,poly pSig,int ecart, int isFromQ,kStrategy strat, int atR);
543void chainCritNormal (poly p,int ecart,kStrategy strat);
544void chainCritSig (poly p,int ecart,kStrategy strat);
545BOOLEAN homogTest(polyset F, int Fmax);
546BOOLEAN newHEdge(kStrategy strat);
547BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat);
548BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat);
549KINLINE BOOLEAN arriRewDummy(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
550BOOLEAN arriRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
551BOOLEAN arriRewCriterionPre(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
552BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
553BOOLEAN findMinLMPair(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
554
555/// returns index of p in TSet, or -1 if not found
556int kFindInT(poly p, TSet T, int tlength);
557
558/// return -1 if no divisor is found
559///        number of first divisor in T, otherwise
560int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT,
561                        const int tl, const LObject* L, const int start=0);
562
563/// return -1 if no divisor is found
564///        number of first divisor in S, otherwise
565int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L);
566
567int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L);
568TObject*
569kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T,
570                    long ecart = LONG_MAX);
571
572/***************************************************************
573 *
574 * stuff to be inlined
575 *
576 ***************************************************************/
577
578KINLINE TSet initT ();
579KINLINE TObject** initR();
580KINLINE unsigned long* initsevT();
581KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
582KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin bin);
583KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
584KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing,  omBin bin);
585
586KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing);
587KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing);
588KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing);
589KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing);
590
591// if exp bound is not violated, return TRUE and
592//                               get m1 = LCM(LM(p1), LM(p2))/LM(p1)
593//                                   m2 = LCM(LM(p1), LM(p2))/LM(p2)
594// return FALSE and m1 == NULL, m2 == NULL     , otherwise
595KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r,
596                               poly &m1, poly &m2, const ring m_r);
597#ifdef HAVE_RINGS
598KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing,
599                               poly &m1, poly &m2, poly &lcm, const ring taiRing);
600#endif
601#ifdef KDEBUG
602// test strat
603BOOLEAN kTest(kStrategy strat);
604// test strat, and test that S is contained in T
605BOOLEAN kTest_TS(kStrategy strat);
606// test LObject
607BOOLEAN kTest_L(LObject* L, ring tailRing = NULL,
608                 BOOLEAN testp = FALSE, int lpos = -1,
609                 TSet T = NULL, int tlength = -1);
610// test TObject
611BOOLEAN kTest_T(TObject* T, ring tailRing = NULL, int tpos = -1, char TN = '?');
612// test set strat->SevS
613BOOLEAN kTest_S(kStrategy strat);
614#else
615#define kTest(A)        (TRUE)
616#define kTest_TS(A)     (TRUE)
617#define kTest_T(T)      (TRUE)
618#define kTest_S(T)      (TRUE)
619#define kTest_L(T)      (TRUE)
620#endif
621
622
623/***************************************************************
624 *
625 * From kstd2.cc
626 *
627 ***************************************************************/
628poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing);
629ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
630ideal sba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
631poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce);
632ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce);
633void initBba(ideal F,kStrategy strat);
634void initSba(ideal F,kStrategy strat);
635void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg,
636          int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q,
637          intvec *w,intvec *hilb );
638
639/***************************************************************
640 *
641 * From kspoly.cc
642 *
643 ***************************************************************/
644// Reduces PR with PW
645// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
646// Changes: PR
647// Const:   PW
648// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
649// If strat != NULL, tailRing is changed if reduction would violate exp bound
650// of tailRing
651// Returns: 0 everything ok, no tailRing change
652//          1 tailRing has successfully changed (strat != NULL)
653//          2 no reduction performed, tailRing needs to be changed first
654//            (strat == NULL)
655//         -1 tailRing change could not be performed due to exceeding exp
656//            bound of currRing
657int ksReducePoly(LObject* PR,
658                 TObject* PW,
659                 poly spNoether = NULL,
660                 number *coef = NULL,
661                 kStrategy strat = NULL);
662
663// Reduces PR with PW
664// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
665// Changes: PR
666// Const:   PW
667// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
668// If strat != NULL, tailRing is changed if reduction would violate exp bound
669// of tailRing
670// Returns: 0 everything ok, no tailRing change
671//          1 tailRing has successfully changed (strat != NULL)
672//          2 no reduction performed, tailRing needs to be changed first
673//            (strat == NULL)
674//          3 no reduction performed, not sig-safe!!!
675//         -1 tailRing change could not be performed due to exceeding exp
676//            bound of currRing
677int ksReducePolySig(LObject* PR,
678                 TObject* PW,
679                 long idx,
680                 poly spNoether = NULL,
681                 number *coef = NULL,
682                 kStrategy strat = NULL);
683
684// Reduces PR at Current->next with PW
685// Assumes PR != NULL, Current contained in PR
686//         Current->next != NULL, LM(PW) devides LM(Current->next)
687// Changes: PR
688// Const:   PW
689// Return: see ksReducePoly
690int ksReducePolyTail(LObject* PR,
691                     TObject* PW,
692                     poly Current,
693                     poly spNoether = NULL);
694
695KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red);
696
697// Creates S-Poly of Pair
698// Const:   Pair->p1, Pair->p2
699// Changes: Pair->p == S-Poly of p1, p2
700// Assume:  Pair->p1 != NULL && Pair->p2
701void ksCreateSpoly(LObject* Pair, poly spNoether = NULL,
702                   int use_buckets=0, ring tailRing=currRing,
703                   poly m1 = NULL, poly m2 = NULL, TObject** R = NULL);
704
705/*2
706* creates the leading term of the S-polynomial of p1 and p2
707* do not destroy p1 and p2
708* remarks:
709*   1. the coefficient is 0 (nNew)
710*   2. pNext is undefined
711*/
712poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing);
713
714
715// old stuff
716KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL);
717KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL);
718KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL, ring r = currRing);
719KINLINE void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r = currRing);
720
721/***************************************************************
722 *
723 * Routines related for ring changes during std computations
724 *
725 ***************************************************************/
726// return TRUE and set m1, m2 to k_GetLcmTerms,
727//             if spoly creation of strat->P does not violate
728//             exponent bound of strat->tailRing
729//      FALSE, otherwise
730BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2);
731#ifdef HAVE_RINGS
732// return TRUE if gcdpoly creation of R[atR] and S[atS] does not violate
733//             exponent bound of strat->tailRing
734//      FALSE, otherwise
735BOOLEAN kCheckStrongCreation(int atR, poly m1, int atS, poly m2, kStrategy strat);
736#endif
737// change strat->tailRing and adjust all data in strat, L, and T:
738// new tailRing has larger exponent bound
739// do nothing and return FALSE if exponent bound increase would result in
740// larger exponent bound that that of currRing
741BOOLEAN kStratChangeTailRing(kStrategy strat,
742                             LObject* L = NULL, TObject* T = NULL,
743                             // take this as new_expbound: if 0
744                             // new expbound is 2*expbound of tailRing
745                             unsigned long new_expbound = 0);
746// initiate a change of the tailRing of strat -- should be called
747// right before main loop in bba
748void kStratInitChangeTailRing(kStrategy strat);
749
750/// Output some debug info about a given strategy
751void kDebugPrint(kStrategy strat);
752
753// getting sb order for sba computations
754ring sbaRing(kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1);
755
756KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
757  kStrategy strat);
758
759#include <kernel/GBEngine/kInline.h>
760
761/* shiftgb stuff */
762#include <kernel/GBEngine/shiftgb.h>
763
764poly pMove2CurrTail(poly p, kStrategy strat);
765
766poly pMoveCurrTail2poly(poly p, kStrategy strat);
767
768poly pCopyL2p(LObject h, kStrategy strat);
769
770void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV);
771
772void initBuchMoraShift (ideal F,ideal Q,kStrategy strat);
773
774void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV); // ok
775
776void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV);
777
778void 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
779
780void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV);
781
782void initenterpairsShift (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR,int uptodeg, int lV);
783
784void updateSShift(kStrategy strat,int uptodeg,int lV);
785
786void initBbaShift(ideal F,kStrategy strat);
787
788poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize);
789
790int redFirstShift (LObject* h,kStrategy strat); // ok
791
792ideal freegb(ideal I, int uptodeg, int lVblock);
793
794ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV);
795// test syz strategy: // will be removed soon
796extern  int (*test_PosInT)(const TSet T,const int tl,LObject &h);
797extern  int (*test_PosInL)(const LSet set, const int length,
798                LObject* L,const kStrategy strat);
799#endif
Note: See TracBrowser for help on using the repository browser.