source: git/kernel/GBEngine/kutil.h @ 5efbf9

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