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

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