source: git/kernel/kutil.h @ f7f084

jengelh-datetimespielwiese
Last change on this file since f7f084 was f7f084, checked in by Christian Eder, 9 years ago
changes incremental flag to sbaOrder, no longer BOOLEAN => preparation in order to introduce more module orders for sba
  • Property mode set to 100644
File size: 28.0 KB
Line 
1#ifndef KUTIL_H
2#define KUTIL_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/*
7* ABSTRACT: kernel: utils for kStd
8*/
9
10
11#include <string.h>
12
13#include <omalloc/omalloc.h>
14#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#if 1
23#define setmax 16
24#define setmaxL ((4096-12)/sizeof(LObject))
25#define setmaxLinc ((4096)/sizeof(LObject))
26
27#define setmaxT 64
28#define setmaxTinc 32
29#else
30#define setmax 16
31#define setmaxL 16
32#define setmaxLinc 16
33#define setmaxT 16
34#define setmaxTinc 16
35#endif
36
37// if you want std computations as in Singular version < 2:
38// This disables RedThrough, tailReductions against T (bba),
39// sets posInT = posInT15 (bba, strat->honey), and enables redFirst with LDeg
40// NOTE: can be achieved with option(oldStd)
41
42#undef NO_KINLINE
43#if !defined(KDEBUG) && !defined(NO_INLINE)
44#define KINLINE inline
45#else
46#define KINLINE
47#define NO_KINLINE 1
48#endif
49
50typedef int* intset;
51typedef int64  wlen_type;
52typedef wlen_type* wlen_set;
53
54typedef class sTObject TObject;
55typedef class sLObject LObject;
56typedef TObject * TSet;
57typedef LObject * LSet;
58
59typedef struct denominator_list_s denominator_list_s;
60typedef denominator_list_s *denominator_list;
61
62struct denominator_list_s{number n; denominator_list next;};
63extern denominator_list DENOMINATOR_LIST;
64
65class sTObject
66{
67public:
68  unsigned long sevSig;
69  poly sig;   // the signature of the element
70  poly p;       // Lm(p) \in currRing Tail(p) \in tailRing
71  poly t_p;     // t_p \in tailRing: as monomials Lm(t_p) == Lm(p)
72  poly max;     // p_GetMaxExpP(pNext(p))
73  ring tailRing;
74  long FDeg;    // pFDeg(p)
75  int ecart,
76    length,     // as of pLDeg
77    pLength,    // either == 0, or == pLength(p)
78    i_r;        // index of TObject in R set, or -1 if not in T
79  BOOLEAN is_normalized; // true, if pNorm was called on p, false otherwise
80  // used in incremental sba() with F5C:
81  // we know some of the redundant elements in
82  // strat->T beforehand, so we can just discard
83  // them and do not need to consider them in the
84  // interreduction process
85  BOOLEAN is_redundant;
86  // used in sba's sig-safe reduction:
87  // sometimes we already know that a reducer
88  // is sig-safe, so no need for a real
89  // sig-safeness check
90  BOOLEAN is_sigsafe;
91
92
93#ifdef HAVE_PLURAL
94  BOOLEAN is_special; // true, it is a new special S-poly (e.g. for SCA)
95#endif
96
97  // initialization
98  KINLINE void Init(ring r = currRing);
99  KINLINE sTObject(ring tailRing = currRing);
100  KINLINE sTObject(poly p, ring tailRing = currRing);
101  KINLINE sTObject(poly p, ring c_r, ring tailRing);
102  KINLINE sTObject(sTObject* T, int copy);
103
104  KINLINE void Set(ring r=currRing);
105  KINLINE void Set(poly p_in, ring r=currRing);
106  KINLINE void Set(poly p_in, ring c_r, ring t_r);
107
108  // Frees the polys of T
109  KINLINE void Delete();
110  // Sets polys to NULL
111  KINLINE void Clear();
112  // makes a copy of the poly of T
113  KINLINE void Copy();
114
115  // ring-dependent Lm access: these might result in allocation of monomials
116  KINLINE poly GetLmCurrRing();
117  KINLINE poly GetLmTailRing();
118  KINLINE poly GetLm(ring r);
119  // this returns Lm and ring r (preferably from tailRing), but does not
120  // allocate a new poly
121  KINLINE void GetLm(poly &p, ring &r) const;
122
123#ifdef OLIVER_PRIVAT_LT
124  // routines for calc. with rings
125  KINLINE poly GetLtCurrRing();
126  KINLINE poly GetLtTailRing();
127  KINLINE poly GetLt(ring r);
128  KINLINE void GetLt(poly &p, ring &r) const;
129#endif
130
131  KINLINE BOOLEAN IsNull() const;
132
133  KINLINE int GetpLength();
134
135  // makes sure that T.p exists
136  KINLINE void SetLmCurrRing();
137
138  // Iterations
139  // simply get the next monomial
140  KINLINE poly Next();
141  KINLINE void LmDeleteAndIter();
142
143  // deg stuff
144  // compute pTotalDegree
145  KINLINE long pTotalDeg() const;
146  // computes pFDeg
147  KINLINE long pFDeg() const;
148  // computes and sets FDeg
149  KINLINE long SetpFDeg();
150  // gets stored FDeg
151  KINLINE long GetpFDeg() const;
152
153  // computes pLDeg
154  KINLINE long pLDeg();
155  // sets length, FDeg, returns LDeg
156  KINLINE long SetDegStuffReturnLDeg();
157
158  // arithmetic
159  KINLINE void Mult_nn(number n);
160  KINLINE void ShallowCopyDelete(ring new_tailRing, omBin new_tailBin,
161                                 pShallowCopyDeleteProc p_shallow_copy_delete,
162                                 BOOLEAN set_max = TRUE);
163  // manipulations
164  KINLINE void pNorm();
165  KINLINE void pCleardenom();
166
167#ifdef KDEBUG
168  void wrp();
169#endif
170};
171
172#ifndef NDEBUG
173extern int strat_nr;
174extern int strat_fac_debug;
175#endif
176
177class sLObject : public sTObject
178{
179
180public:
181  unsigned long sev;
182  unsigned long from; // from which polynomial it comes from
183            // this is important for signature-based
184            // algorithms
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                      // NOTE: If checked = 3 then the corresponding pair is
191                      // detected by Buchberger's Product Criterion and can be
192                      // deleted
193  poly  p1,p2; /*- the pair p comes from,
194                 lm(pi) in currRing, tail(pi) in tailring -*/
195
196  poly  lcm;   /*- the lcm of p1,p2 -*/
197  kBucket_pt bucket;
198  int   i_r1, i_r2;
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;
271typedef skStrategy * kStrategy;
272class skStrategy
273{
274public:
275  kStrategy next;
276  int (*red)(LObject * L,kStrategy strat);
277  int (*red2)(LObject * L,kStrategy strat);
278  void (*initEcart)(LObject * L);
279  int (*posInT)(const TSet T,const int tl,LObject &h);
280  int (*posInLSba)(const LSet set, const int length,
281                LObject* L,const kStrategy strat);
282  int (*posInL)(const LSet set, const int length,
283                LObject* L,const kStrategy strat);
284  void (*enterS)(LObject h, int pos,kStrategy strat, int atR/* =-1*/ );
285  void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG);
286  int (*posInLOld)(const LSet Ls,const int Ll,
287                   LObject* Lo,const kStrategy strat);
288  void (*enterOnePair) (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR /*= -1*/);
289  void (*chainCrit) (poly p,int ecart,kStrategy strat);
290  BOOLEAN (*syzCrit) (poly sig, unsigned long not_sevSig, kStrategy strat);
291  BOOLEAN (*rewCrit1) (poly sig, unsigned long not_sevSig, kStrategy strat, int start /*= 0*/);
292  BOOLEAN (*rewCrit2) (poly sig, unsigned long not_sevSig, kStrategy strat, int start /*= 0*/);
293  pFDegProc pOrigFDeg;
294  pLDegProc pOrigLDeg;
295  pFDegProc pOrigFDeg_TailRing;
296  pLDegProc pOrigLDeg_TailRing;
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  unsigned long 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#ifndef NDEBUG
345  int nr;
346#endif
347  int cp,c3;
348  int cv; // in shift bases: counting V criterion
349  int sl,mu;
350  int syzl,syzmax,syzidxmax;
351  int tl,tmax;
352  int Ll,Lmax;
353  int Bl,Bmax;
354  int ak,LazyDegree,LazyPass;
355  int syzComp;
356  int HCord;
357  int lastAxis;
358  int newIdeal;
359  int minim;
360  #ifdef HAVE_SHIFTBBA
361  int lV;
362  #endif
363  BOOLEAN interpt;
364  BOOLEAN homog;
365#ifdef HAVE_PLURAL
366  BOOLEAN z2homog; // Z_2 - homogeneous input allows product criterion in commutative and SCA cases!
367#endif
368  BOOLEAN kHEdgeFound;
369  BOOLEAN honey,sugarCrit;
370  BOOLEAN Gebauer,noTailReduction;
371  BOOLEAN fromT;
372  BOOLEAN noetherSet;
373  BOOLEAN update;
374  BOOLEAN posInLOldFlag;
375  BOOLEAN use_buckets;
376  BOOLEAN interred_flag;
377  // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength)
378  BOOLEAN LDegLast;
379  // if set, then L.length == L.pLength
380  BOOLEAN length_pLength;
381  // if set, then posInL does not depend on L.length
382  BOOLEAN posInLDependsOnLength;
383  /*FALSE, if posInL == posInL10*/
384#ifdef HAVE_PLURAL
385  // set this flag to 1 to stop the product criteria
386  // use ALLOW_PROD_CRIT(strat) to test
387  BOOLEAN no_prod_crit;
388#define ALLOW_PROD_CRIT(A) (!(A)->no_prod_crit)
389#else
390#define ALLOW_PROD_CRIT(A) (1)
391#endif
392  char    redTailChange;
393  char    news;
394  char    newt;/*used for messageSets*/
395  char    noClearS;
396  char    completeReduce_retry;
397  char    overflow;
398
399  skStrategy();
400  ~skStrategy();
401
402  // return TObject corresponding to S[i]: assume that it exists
403  // i.e. no error checking is done
404  KINLINE TObject* S_2_T(int i);
405  // like S_2_T, except that NULL is returned if it can not be found
406  KINLINE TObject* s_2_t(int i);
407};
408
409void deleteHC(poly *p, int *e, int *l, kStrategy strat);
410void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE);
411void deleteInS (int i,kStrategy strat);
412void deleteInSSba (int i,kStrategy strat);
413void cleanT (kStrategy strat);
414static inline LSet initL (int nr=setmaxL)
415{ return (LSet)omAlloc(nr*sizeof(LObject)); }
416void deleteInL(LSet set, int *length, int j,kStrategy strat);
417void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at);
418void enterSBba (LObject p,int atS,kStrategy strat, int atR = -1);
419void enterSSba (LObject p,int atS,kStrategy strat, int atR = -1);
420void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
421void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
422int posInS (const kStrategy strat, const int length, const poly p,
423            const int ecart_p);
424int posInT0 (const TSet set,const int length,LObject &p);
425int posInT1 (const TSet set,const int length,LObject &p);
426int posInT2 (const TSet set,const int length,LObject &p);
427int posInT11 (const TSet set,const int length,LObject &p);
428int posInTSig (const TSet set,const int length,LObject &p);
429int posInT110 (const TSet set,const int length,LObject &p);
430int posInT13 (const TSet set,const int length,LObject &p);
431int posInT15 (const TSet set,const int length,LObject &p);
432int posInT17 (const TSet set,const int length,LObject &p);
433int posInT19 (const TSet set,const int length,LObject &p);
434int posInT_EcartpLength(const TSet set,const int length,LObject &p);
435
436#ifdef HAVE_MORE_POS_IN_T
437int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p);
438int posInT_FDegpLength(const TSet set,const int length,LObject &p);
439int posInT_pLength(const TSet set,const int length,LObject &p);
440#endif
441
442
443void reorderS (int* suc,kStrategy strat);
444int posInLF5C (const LSet set, const int length,
445               LObject* L,const kStrategy strat);
446int posInLSig (const LSet set, const int length,
447               LObject* L,const kStrategy strat);
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 posInL13 (const LSet set, const int length,
453             LObject* L,const kStrategy strat);
454int posInL15 (const LSet set, const int length,
455             LObject* L,const kStrategy strat);
456int posInL17 (const LSet set, const int length,
457             LObject* L,const kStrategy strat);
458int posInL10 (const LSet set, const int length,
459             LObject* L,const kStrategy strat);
460int posInL110 (const LSet set, const int length,
461             LObject* L,const kStrategy strat);
462KINLINE poly redtailBba (poly p,int pos,kStrategy strat,BOOLEAN normalize=FALSE);
463#ifdef HAVE_RINGS
464KINLINE poly redtailBba_Z (poly p,int pos,kStrategy strat);
465poly redtailBba_Z (LObject* L, int pos, kStrategy strat );
466#endif
467poly redtailBba (LObject *L, int pos,kStrategy strat,
468                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
469poly redtailSba (LObject *L, int pos,kStrategy strat,
470                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
471poly redtailBba (TObject *T, int pos,kStrategy strat);
472poly redtail (poly p,int pos,kStrategy strat);
473poly redtail (LObject *L,int pos,kStrategy strat);
474poly redNF (poly h,int & max_ind,int nonorm,kStrategy strat);
475int redNF0 (LObject *P,kStrategy strat);
476poly redNFTail (poly h,const int sl,kStrategy strat);
477int redHoney (LObject* h, kStrategy strat);
478#ifdef HAVE_RINGS
479int redRing (LObject* h,kStrategy strat);
480int redRiloc (LObject* h,kStrategy strat);
481void enterExtendedSpoly(poly h,kStrategy strat);
482void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);
483poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing);
484long ind2(long arg);
485
486long ind_fact_2(long arg);
487long twoPow(long arg);
488ideal createG0();
489#endif
490int redLazy (LObject* h,kStrategy strat);
491int redHomog (LObject* h,kStrategy strat);
492int redSig (LObject* h,kStrategy strat);
493//adds hSig to be able to check with F5's criteria when entering pairs!
494void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos,kStrategy strat, int atR = -1);
495void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1);
496void entersets (LObject h);
497void pairs ();
498void message (int i,int* reduc,int* olddeg,kStrategy strat,int red_result);
499void messageStat (int hilbcount,kStrategy strat);
500#ifdef KDEBUG
501void messageSets (kStrategy strat);
502#else
503#define messageSets(s)  do {} while (0)
504#endif
505
506void initEcartNormal (LObject* h);
507void initEcartBBA (LObject* h);
508void initS (ideal F, ideal Q,kStrategy strat);
509void initSL (ideal F, ideal Q,kStrategy strat);
510void initSLSba (ideal F, ideal Q,kStrategy strat);
511/*************************************************
512 * when initializing a new bunch of principal
513 * syzygies at the beginning of a new iteration
514 * step in a signature-based algorithm we
515 * compute ONLY the leading elements of those
516 * syzygies, NOT the whole syzygy
517 * NOTE: this needs to be adjusted for a more
518 * general approach on signature-based algorithms
519 ***********************************************/
520void initSyzRules (kStrategy strat);
521void updateS(BOOLEAN toT,kStrategy strat);
522void enterSyz (LObject p,kStrategy strat);
523void enterT (LObject p,kStrategy strat, int atT = -1);
524void cancelunit (LObject* p,BOOLEAN inNF=FALSE);
525void HEckeTest (poly pp,kStrategy strat);
526void initBuchMoraCrit(kStrategy strat);
527void initSbaCrit(kStrategy strat);
528void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
529void initBuchMoraPos(kStrategy strat);
530void initSbaPos(kStrategy strat);
531void initBuchMora (ideal F, ideal Q,kStrategy strat);
532void initSbaBuchMora (ideal F, ideal Q,kStrategy strat);
533void exitBuchMora (kStrategy strat);
534void exitSba (kStrategy strat);
535void updateResult(ideal r,ideal Q,kStrategy strat);
536void completeReduce (kStrategy strat, BOOLEAN withT=FALSE);
537void kFreeStrat(kStrategy strat);
538void enterOnePairNormal (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR);
539void enterOnePairSig (int i,poly p,poly pSig,int ecart, int isFromQ,kStrategy strat, int atR);
540void chainCritNormal (poly p,int ecart,kStrategy strat);
541void chainCritSig (poly p,int ecart,kStrategy strat);
542BOOLEAN homogTest(polyset F, int Fmax);
543BOOLEAN newHEdge(kStrategy strat);
544BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat);
545BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat);
546KINLINE BOOLEAN arriRewDummy(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
547BOOLEAN arriRewCriterion(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
548BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
549BOOLEAN findMinLMPair(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
550// returns index of p in TSet, or -1 if not found
551int kFindInT(poly p, TSet T, int tlength);
552
553// return -1 if no divisor is found
554//        number of first divisor, otherwise
555int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT,
556                        const int tl, const LObject* L, const int start=0);
557// same with S
558int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L);
559
560int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L);
561TObject*
562kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T,
563                    long ecart = LONG_MAX);
564
565/***************************************************************
566 *
567 * stuff to be inlined
568 *
569 ***************************************************************/
570
571KINLINE TSet initT ();
572KINLINE TObject** initR();
573KINLINE unsigned long* initsevT();
574KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
575KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin bin);
576KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
577KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing,  omBin bin);
578
579KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing);
580KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing);
581KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing);
582KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing);
583
584// if exp bound is not violated, return TRUE and
585//                               get m1 = LCM(LM(p1), LM(p2))/LM(p1)
586//                                   m2 = LCM(LM(p1), LM(p2))/LM(p2)
587// return FALSE and m1 == NULL, m2 == NULL     , otherwise
588KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r,
589                               poly &m1, poly &m2, const ring m_r);
590#ifdef HAVE_RINGS
591KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing,
592                               poly &m1, poly &m2, poly &lcm, const ring taiRing);
593#endif
594#ifdef KDEBUG
595// test strat
596BOOLEAN kTest(kStrategy strat);
597// test strat, and test that S is contained in T
598BOOLEAN kTest_TS(kStrategy strat);
599// test LObject
600BOOLEAN kTest_L(LObject* L, ring tailRing = NULL,
601                 BOOLEAN testp = FALSE, int lpos = -1,
602                 TSet T = NULL, int tlength = -1);
603// test TObject
604BOOLEAN kTest_T(TObject* T, ring tailRing = NULL, int tpos = -1, char TN = '?');
605// test set strat->SevS
606BOOLEAN kTest_S(kStrategy strat);
607#else
608#define kTest(A)        (TRUE)
609#define kTest_TS(A)     (TRUE)
610#define kTest_T(T)      (TRUE)
611#define kTest_S(T)      (TRUE)
612#define kTest_L(T)      (TRUE)
613#endif
614
615
616/***************************************************************
617 *
618 * From kstd2.cc
619 *
620 ***************************************************************/
621poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing);
622ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
623ideal sba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
624poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce);
625ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce);
626void initBba(ideal F,kStrategy strat);
627void initSba(ideal F,kStrategy strat);
628void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg,
629          int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q,
630          intvec *w,intvec *hilb );
631
632/***************************************************************
633 *
634 * From kspoly.cc
635 *
636 ***************************************************************/
637// Reduces PR with PW
638// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
639// Changes: PR
640// Const:   PW
641// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
642// If strat != NULL, tailRing is changed if reduction would violate exp bound
643// of tailRing
644// Returns: 0 everything ok, no tailRing change
645//          1 tailRing has successfully changed (strat != NULL)
646//          2 no reduction performed, tailRing needs to be changed first
647//            (strat == NULL)
648//         -1 tailRing change could not be performed due to exceeding exp
649//            bound of currRing
650int ksReducePoly(LObject* PR,
651                 TObject* PW,
652                 poly spNoether = NULL,
653                 number *coef = NULL,
654                 kStrategy strat = NULL);
655
656// Reduces PR with PW
657// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
658// Changes: PR
659// Const:   PW
660// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
661// If strat != NULL, tailRing is changed if reduction would violate exp bound
662// of tailRing
663// Returns: 0 everything ok, no tailRing change
664//          1 tailRing has successfully changed (strat != NULL)
665//          2 no reduction performed, tailRing needs to be changed first
666//            (strat == NULL)
667//          3 no reduction performed, not sig-safe!!!
668//         -1 tailRing change could not be performed due to exceeding exp
669//            bound of currRing
670int ksReducePolySig(LObject* PR,
671                 TObject* PW,
672                 long idx,
673                 poly spNoether = NULL,
674                 number *coef = NULL,
675                 kStrategy strat = NULL);
676
677// Reduces PR at Current->next with PW
678// Assumes PR != NULL, Current contained in PR
679//         Current->next != NULL, LM(PW) devides LM(Current->next)
680// Changes: PR
681// Const:   PW
682// Return: see ksReducePoly
683int ksReducePolyTail(LObject* PR,
684                     TObject* PW,
685                     poly Current,
686                     poly spNoether = NULL);
687
688KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red);
689
690// Creates S-Poly of Pair
691// Const:   Pair->p1, Pair->p2
692// Changes: Pair->p == S-Poly of p1, p2
693// Assume:  Pair->p1 != NULL && Pair->p2
694void ksCreateSpoly(LObject* Pair, poly spNoether = NULL,
695                   int use_buckets=0, ring tailRing=currRing,
696                   poly m1 = NULL, poly m2 = NULL, TObject** R = NULL);
697
698/*2
699* creates the leading term of the S-polynomial of p1 and p2
700* do not destroy p1 and p2
701* remarks:
702*   1. the coefficient is 0 (nNew)
703*   2. pNext is undefined
704*/
705poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing);
706
707
708// old stuff
709KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL);
710KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL);
711KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL, ring r = currRing);
712KINLINE void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r = currRing);
713
714/***************************************************************
715 *
716 * Routines related for ring changes during std computations
717 *
718 ***************************************************************/
719// return TRUE and set m1, m2 to k_GetLcmTerms,
720//             if spoly creation of strat->P does not violate
721//             exponent bound of strat->tailRing
722//      FALSE, otherwise
723BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2);
724#ifdef HAVE_RINGS
725// return TRUE if gcdpoly creation of R[atR] and S[atS] does not violate
726//             exponent bound of strat->tailRing
727//      FALSE, otherwise
728BOOLEAN kCheckStrongCreation(int atR, poly m1, int atS, poly m2, kStrategy strat);
729#endif
730// change strat->tailRing and adjust all data in strat, L, and T:
731// new tailRing has larger exponent bound
732// do nothing and return FALSE if exponent bound increase would result in
733// larger exponent bound that that of currRing
734BOOLEAN kStratChangeTailRing(kStrategy strat,
735                             LObject* L = NULL, TObject* T = NULL,
736                             // take this as new_expbound: if 0
737                             // new expbound is 2*expbound of tailRing
738                             unsigned long new_expbound = 0);
739// initiate a change of the tailRing of strat -- should be called
740// right before main loop in bba
741void kStratInitChangeTailRing(kStrategy strat);
742
743/// Output some debug info about a given strategy
744void kDebugPrint(kStrategy strat);
745
746// getting sb order for sba computations
747ring sbaRing(kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1);
748
749KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
750  kStrategy strat);
751
752#include <kernel/kInline.h>
753
754/* shiftgb stuff */
755#include <kernel/shiftgb.h>
756
757poly pMove2CurrTail(poly p, kStrategy strat);
758
759poly pMoveCurrTail2poly(poly p, kStrategy strat);
760
761poly pCopyL2p(LObject h, kStrategy strat);
762
763void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV);
764
765void initBuchMoraShift (ideal F,ideal Q,kStrategy strat);
766
767void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV); // ok
768
769void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV);
770
771void 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
772
773void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV);
774
775void initenterpairsShift (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR,int uptodeg, int lV);
776
777void updateSShift(kStrategy strat,int uptodeg,int lV);
778
779void initBbaShift(ideal F,kStrategy strat);
780
781poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize);
782
783int redFirstShift (LObject* h,kStrategy strat); // ok
784
785ideal freegb(ideal I, int uptodeg, int lVblock);
786
787ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV);
788// test syz strategy: // will be removed soon
789extern  int (*test_PosInT)(const TSet T,const int tl,LObject &h);
790extern  int (*test_PosInL)(const LSet set, const int length,
791                LObject* L,const kStrategy strat);
792#endif
Note: See TracBrowser for help on using the repository browser.