source: git/kernel/kutil.h @ 7b8818

spielwiese
Last change on this file since 7b8818 was d101b1, checked in by Oleksandr Motsak <http://goo.gl/mcpzY>, 11 years ago
Silence some warnings about statements without effect Insired by [039a51b3aa3c77c2b7bae73d24de8521df45aed2]
  • Property mode set to 100644
File size: 27.7 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  poly  p1,p2; /*- the pair p comes from,
191                 lm(pi) in currRing, tail(pi) in tailring -*/
192
193  poly  lcm;   /*- the lcm of p1,p2 -*/
194  kBucket_pt bucket;
195  int   i_r1, i_r2;
196
197  // initialization
198  KINLINE void Init(ring tailRing = currRing);
199  KINLINE sLObject(ring tailRing = currRing);
200  KINLINE sLObject(poly p, ring tailRing = currRing);
201  KINLINE sLObject(poly p, ring c_r, ring tailRing);
202
203  // Frees the polys of L
204  KINLINE void Delete();
205  KINLINE void Clear();
206
207  // Iterations
208  KINLINE void LmDeleteAndIter();
209  KINLINE poly LmExtractAndIter();
210
211  // spoly related things
212  // preparation for reduction if not spoly
213  KINLINE void PrepareRed(BOOLEAN use_bucket);
214  KINLINE void SetLmTail(poly lm, poly new_p, int length,
215                         int use_bucket, ring r);
216  KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether);
217  KINLINE void Tail_Mult_nn(number n);
218  // deletes bucket, makes sure that p and t_p exists
219  KINLINE poly GetP(omBin lmBin = NULL);
220  // similar, except that only t_p exists
221  KINLINE poly GetTP();
222
223  // does not delete bucket, just canonicalizes it
224  // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing
225  KINLINE poly CanonicalizeP();
226
227  // makes a copy of the poly of L
228  KINLINE void Copy();
229  // gets the poly and makes a copy of it
230  KINLINE poly CopyGetP();
231
232  KINLINE int GetpLength();
233  KINLINE long pLDeg(BOOLEAN use_last);
234  KINLINE long pLDeg();
235  KINLINE int SetLength(BOOLEAN lengt_pLength = FALSE);
236  KINLINE long SetDegStuffReturnLDeg();
237  KINLINE long SetDegStuffReturnLDeg(BOOLEAN use_last);
238
239  // returns minimal component of p
240  KINLINE long MinComp();
241  // returns component of p
242  KINLINE long Comp();
243
244  KINLINE void ShallowCopyDelete(ring new_tailRing,
245                                 pShallowCopyDeleteProc p_shallow_copy_delete);
246
247  // sets sev
248  KINLINE void SetShortExpVector();
249
250  // enable assignment from TObject
251  KINLINE sLObject& operator=(const sTObject&);
252
253  // get T's corresponding to p1, p2: they might return NULL
254  KINLINE TObject* T_1(const skStrategy* strat);
255  KINLINE TObject* T_2(const skStrategy* strat);
256  KINLINE void     T_1_2(const skStrategy* strat,
257                         TObject* &T_1, TObject* &T_2);
258
259  // simplify coefficients
260  KINLINE void Normalize();
261  KINLINE void HeadNormalize();
262};
263
264
265extern int HCord;
266
267class skStrategy;
268typedef skStrategy * kStrategy;
269class skStrategy
270{
271public:
272  kStrategy next;
273  int (*red)(LObject * L,kStrategy strat);
274  int (*red2)(LObject * L,kStrategy strat);
275  void (*initEcart)(LObject * L);
276  int (*posInT)(const TSet T,const int tl,LObject &h);
277  int (*posInLSba)(const LSet set, const int length,
278                LObject* L,const kStrategy strat);
279  int (*posInL)(const LSet set, const int length,
280                LObject* L,const kStrategy strat);
281  void (*enterS)(LObject h, int pos,kStrategy strat, int atR/* =-1*/ );
282  void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG);
283  int (*posInLOld)(const LSet Ls,const int Ll,
284                   LObject* Lo,const kStrategy strat);
285  void (*enterOnePair) (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR /*= -1*/);
286  void (*chainCrit) (poly p,int ecart,kStrategy strat);
287  BOOLEAN (*syzCrit) (poly sig, unsigned long not_sevSig, kStrategy strat);
288  BOOLEAN (*rewCrit1) (poly sig, unsigned long not_sevSig, kStrategy strat, int start /*= 0*/);
289  BOOLEAN (*rewCrit2) (poly sig, unsigned long not_sevSig, kStrategy strat, int start /*= 0*/);
290  pFDegProc pOrigFDeg;
291  pLDegProc pOrigLDeg;
292  pFDegProc pOrigFDeg_TailRing;
293  pLDegProc pOrigLDeg_TailRing;
294
295  LObject P;
296  ideal Shdl;
297  ideal D; /*V(S) is in D(D)*/
298  ideal M; /*set of minimal generators*/
299  polyset S;
300  polyset syz;
301  polyset sig;
302  intset ecartS;
303  intset fromS; // from which S[i] S[j] comes from
304                // this is important for signature-based
305                // algorithms
306  intset syzIdx;// index in the syz array at which the first
307                // syzygy of component i comes up
308                // important for signature-based algorithms
309  BOOLEAN incremental;
310  unsigned long currIdx;
311  int max_lower_index;
312  intset lenS;
313  wlen_set lenSw; /* for tgb.ccc */
314  intset fromQ;
315  unsigned long* sevS;
316  unsigned long* sevSyz;
317  unsigned long* sevSig;
318  unsigned long* sevT;
319  TSet T;
320  LSet L;
321  LSet    B;
322  poly    kHEdge;
323  poly    kNoether;
324  poly    t_kHEdge; // same polys in tailring
325  KINLINE poly    kNoetherTail();
326  poly    t_kNoether;
327  BOOLEAN * NotUsedAxis;
328  BOOLEAN * pairtest;/*used for enterOnePair*/
329  poly tail;
330  intvec * kModW;
331  intvec * kHomW;
332  // procedure for ShalloCopy from tailRing  to currRing
333  pShallowCopyDeleteProc p_shallow_copy_delete;
334  // pointers to Tobjects R[i] is ith Tobject which is generated
335  TObject**  R;
336  // S_2_R[i] yields Tobject which corresponds to S[i]
337  int*      S_2_R;
338  ring tailRing;
339  omBin lmBin;
340  omBin tailBin;
341#ifndef NDEBUG
342  int nr;
343#endif
344  int cp,c3;
345  int cv; // in shift bases: counting V criterion
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  #endif
360  BOOLEAN interpt;
361  BOOLEAN homog;
362#ifdef HAVE_PLURAL
363  BOOLEAN z2homog; // Z_2 - homogeneous input allows product criterion in commutative and SCA cases!
364#endif
365  BOOLEAN kHEdgeFound;
366  BOOLEAN honey,sugarCrit;
367  BOOLEAN Gebauer,noTailReduction;
368  BOOLEAN fromT;
369  BOOLEAN noetherSet;
370  BOOLEAN update;
371  BOOLEAN posInLOldFlag;
372  BOOLEAN use_buckets;
373  BOOLEAN interred_flag;
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 posInL0 (const LSet set, const int length,
446             LObject* L,const kStrategy strat);
447int posInL11 (const LSet set, const int length,
448             LObject* L,const kStrategy strat);
449int posInL13 (const LSet set, const int length,
450             LObject* L,const kStrategy strat);
451int posInL15 (const LSet set, const int length,
452             LObject* L,const kStrategy strat);
453int posInL17 (const LSet set, const int length,
454             LObject* L,const kStrategy strat);
455int posInL10 (const LSet set, const int length,
456             LObject* L,const kStrategy strat);
457int posInL110 (const LSet set, const int length,
458             LObject* L,const kStrategy strat);
459KINLINE poly redtailBba (poly p,int pos,kStrategy strat,BOOLEAN normalize=FALSE);
460#ifdef HAVE_RINGS
461KINLINE poly redtailBba_Z (poly p,int pos,kStrategy strat);
462poly redtailBba_Z (LObject* L, int pos, kStrategy strat );
463#endif
464poly redtailBba (LObject *L, int pos,kStrategy strat,
465                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
466poly redtailBba (TObject *T, int pos,kStrategy strat);
467poly redtail (poly p,int pos,kStrategy strat);
468poly redtail (LObject *L,int pos,kStrategy strat);
469poly redNF (poly h,int & max_ind,int nonorm,kStrategy strat);
470int redNF0 (LObject *P,kStrategy strat);
471poly redNFTail (poly h,const int sl,kStrategy strat);
472int redHoney (LObject* h, kStrategy strat);
473#ifdef HAVE_RINGS
474int redRing (LObject* h,kStrategy strat);
475void enterExtendedSpoly(poly h,kStrategy strat);
476void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);
477poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing);
478long ind2(long arg);
479
480long ind_fact_2(long arg);
481long twoPow(long arg);
482ideal createG0();
483#endif
484int redLazy (LObject* h,kStrategy strat);
485int redHomog (LObject* h,kStrategy strat);
486int redSig (LObject* h,kStrategy strat);
487//adds hSig to be able to check with F5's criteria when entering pairs!
488void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos,kStrategy strat, int atR = -1);
489void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1);
490void entersets (LObject h);
491void pairs ();
492void message (int i,int* reduc,int* olddeg,kStrategy strat,int red_result);
493void messageStat (int hilbcount,kStrategy strat);
494#ifdef KDEBUG
495void messageSets (kStrategy strat);
496#else
497#define messageSets(s)  do {} while (0)
498#endif
499
500void initEcartNormal (LObject* h);
501void initEcartBBA (LObject* h);
502void initS (ideal F, ideal Q,kStrategy strat);
503void initSL (ideal F, ideal Q,kStrategy strat);
504void initSLSba (ideal F, ideal Q,kStrategy strat);
505/*************************************************
506 * when initializing a new bunch of principal
507 * syzygies at the beginning of a new iteration
508 * step in a signature-based algorithm we
509 * compute ONLY the leading elements of those
510 * syzygies, NOT the whole syzygy
511 * NOTE: this needs to be adjusted for a more
512 * general approach on signature-based algorithms
513 ***********************************************/
514void initSyzRules (kStrategy strat);
515void updateS(BOOLEAN toT,kStrategy strat);
516void enterSyz (LObject p,kStrategy strat);
517void enterT (LObject p,kStrategy strat, int atT = -1);
518void cancelunit (LObject* p,BOOLEAN inNF=FALSE);
519void HEckeTest (poly pp,kStrategy strat);
520void initBuchMoraCrit(kStrategy strat);
521void initSbaCrit(kStrategy strat);
522void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
523void initBuchMoraPos(kStrategy strat);
524void initSbaPos(kStrategy strat);
525void initBuchMora (ideal F, ideal Q,kStrategy strat);
526void initSbaBuchMora (ideal F, ideal Q,kStrategy strat);
527void exitBuchMora (kStrategy strat);
528void exitSba (kStrategy strat);
529void updateResult(ideal r,ideal Q,kStrategy strat);
530void completeReduce (kStrategy strat, BOOLEAN withT=FALSE);
531void kFreeStrat(kStrategy strat);
532void enterOnePairNormal (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR);
533void enterOnePairSig (int i,poly p,poly pSig,int ecart, int isFromQ,kStrategy strat, int atR);
534void chainCritNormal (poly p,int ecart,kStrategy strat);
535void chainCritSig (poly p,int ecart,kStrategy strat);
536BOOLEAN homogTest(polyset F, int Fmax);
537BOOLEAN newHEdge(kStrategy strat);
538BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat);
539BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat);
540KINLINE BOOLEAN arriRewDummy(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
541BOOLEAN arriRewCriterion(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
542BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
543BOOLEAN findMinLMPair(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
544// returns index of p in TSet, or -1 if not found
545int kFindInT(poly p, TSet T, int tlength);
546
547// return -1 if no divisor is found
548//        number of first divisor, otherwise
549int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT,
550                        const int tl, const LObject* L, const int start=0);
551// same with S
552int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L);
553
554int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L);
555TObject*
556kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T,
557                    long ecart = LONG_MAX);
558
559/***************************************************************
560 *
561 * stuff to be inlined
562 *
563 ***************************************************************/
564
565KINLINE TSet initT ();
566KINLINE TObject** initR();
567KINLINE unsigned long* initsevT();
568KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
569KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin bin);
570KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
571KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing,  omBin bin);
572
573KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing);
574KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing);
575KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing);
576KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing);
577
578// if exp bound is not violated, return TRUE and
579//                               get m1 = LCM(LM(p1), LM(p2))/LM(p1)
580//                                   m2 = LCM(LM(p1), LM(p2))/LM(p2)
581// return FALSE and m1 == NULL, m2 == NULL     , otherwise
582KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r,
583                               poly &m1, poly &m2, const ring m_r);
584#ifdef HAVE_RINGS
585KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing,
586                               poly &m1, poly &m2, poly &lcm, const ring taiRing);
587#endif
588#ifdef KDEBUG
589// test strat
590BOOLEAN kTest(kStrategy strat);
591// test strat, and test that S is contained in T
592BOOLEAN kTest_TS(kStrategy strat);
593// test LObject
594BOOLEAN kTest_L(LObject* L, ring tailRing = NULL,
595                 BOOLEAN testp = FALSE, int lpos = -1,
596                 TSet T = NULL, int tlength = -1);
597// test TObject
598BOOLEAN kTest_T(TObject* T, ring tailRing = NULL, int tpos = -1, char TN = '?');
599// test set strat->SevS
600BOOLEAN kTest_S(kStrategy strat);
601#else
602#define kTest(A)        (TRUE)
603#define kTest_TS(A)     (TRUE)
604#define kTest_T(T)      (TRUE)
605#define kTest_S(T)      (TRUE)
606#define kTest_L(T)      (TRUE)
607#endif
608
609
610/***************************************************************
611 *
612 * From kstd2.cc
613 *
614 ***************************************************************/
615poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing);
616ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
617ideal sba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
618poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce);
619ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce);
620void initBba(ideal F,kStrategy strat);
621void initSba(ideal F,kStrategy strat);
622void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg, 
623          int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q,
624          intvec *w,intvec *hilb );
625
626/***************************************************************
627 *
628 * From kSpolys.cc
629 *
630 ***************************************************************/
631// Reduces PR with PW
632// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
633// Changes: PR
634// Const:   PW
635// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
636// If strat != NULL, tailRing is changed if reduction would violate exp bound
637// of tailRing
638// Returns: 0 everything ok, no tailRing change
639//          1 tailRing has successfully changed (strat != NULL)
640//          2 no reduction performed, tailRing needs to be changed first
641//            (strat == NULL)
642//         -1 tailRing change could not be performed due to exceeding exp
643//            bound of currRing
644int ksReducePoly(LObject* PR,
645                 TObject* PW,
646                 poly spNoether = NULL,
647                 number *coef = NULL,
648                 kStrategy strat = NULL);
649
650// Reduces PR with PW
651// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
652// Changes: PR
653// Const:   PW
654// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
655// If strat != NULL, tailRing is changed if reduction would violate exp bound
656// of tailRing
657// Returns: 0 everything ok, no tailRing change
658//          1 tailRing has successfully changed (strat != NULL)
659//          2 no reduction performed, tailRing needs to be changed first
660//            (strat == NULL)
661//          3 no reduction performed, not sig-safe!!!
662//         -1 tailRing change could not be performed due to exceeding exp
663//            bound of currRing
664int ksReducePolySig(LObject* PR,
665                 TObject* PW,
666                 long idx,
667                 poly spNoether = NULL,
668                 number *coef = NULL,
669                 kStrategy strat = NULL);
670
671// Reduces PR at Current->next with PW
672// Assumes PR != NULL, Current contained in PR
673//         Current->next != NULL, LM(PW) devides LM(Current->next)
674// Changes: PR
675// Const:   PW
676// Return: see ksReducePoly
677int ksReducePolyTail(LObject* PR,
678                     TObject* PW,
679                     poly Current,
680                     poly spNoether = NULL);
681
682KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red);
683
684// Creates S-Poly of Pair
685// Const:   Pair->p1, Pair->p2
686// Changes: Pair->p == S-Poly of p1, p2
687// Assume:  Pair->p1 != NULL && Pair->p2
688void ksCreateSpoly(LObject* Pair, poly spNoether = NULL,
689                   int use_buckets=0, ring tailRing=currRing,
690                   poly m1 = NULL, poly m2 = NULL, TObject** R = NULL);
691
692/*2
693* creates the leading term of the S-polynomial of p1 and p2
694* do not destroy p1 and p2
695* remarks:
696*   1. the coefficient is 0 (nNew)
697*   2. pNext is undefined
698*/
699poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing);
700
701
702// old stuff
703KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL);
704KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL);
705KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL, ring r = currRing);
706KINLINE void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r = currRing);
707
708/***************************************************************
709 *
710 * Routines related for ring changes during std computations
711 *
712 ***************************************************************/
713// return TRUE and set m1, m2 to k_GetLcmTerms,
714//             if spoly creation of strat->P does not violate
715//             exponent bound of strat->tailRing
716//      FALSE, otherwise
717BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2);
718#ifdef HAVE_RINGS
719// return TRUE if gcdpoly creation of R[atR] and S[atS] does not violate
720//             exponent bound of strat->tailRing
721//      FALSE, otherwise
722BOOLEAN kCheckStrongCreation(int atR, poly m1, int atS, poly m2, kStrategy strat);
723#endif
724// change strat->tailRing and adjust all data in strat, L, and T:
725// new tailRing has larger exponent bound
726// do nothing and return FALSE if exponent bound increase would result in
727// larger exponent bound that that of currRing
728BOOLEAN kStratChangeTailRing(kStrategy strat,
729                             LObject* L = NULL, TObject* T = NULL,
730                             // take this as new_expbound: if 0
731                             // new expbound is 2*expbound of tailRing
732                             unsigned long new_expbound = 0);
733// initiate a change of the tailRing of strat -- should be called
734// right before main loop in bba
735void kStratInitChangeTailRing(kStrategy strat);
736
737/// Output some debug info about a given strategy
738void kDebugPrint(kStrategy strat);
739
740// getting sb order for sba computations
741ring sbaRing(kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1);
742
743KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
744  kStrategy strat);
745
746#include <kernel/kInline.h>
747
748/* shiftgb stuff */
749#include <kernel/shiftgb.h>
750
751poly pMove2CurrTail(poly p, kStrategy strat);
752
753poly pMoveCurrTail2poly(poly p, kStrategy strat);
754
755poly pCopyL2p(LObject h, kStrategy strat);
756
757void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV);
758
759void initBuchMoraShift (ideal F,ideal Q,kStrategy strat);
760
761void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV); // ok
762
763void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV);
764
765void 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
766
767void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV);
768
769void initenterpairsShift (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR,int uptodeg, int lV); 
770
771void updateSShift(kStrategy strat,int uptodeg,int lV);
772
773void initBbaShift(ideal F,kStrategy strat);
774
775poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize);
776
777int redFirstShift (LObject* h,kStrategy strat); // ok
778
779ideal freegb(ideal I, int uptodeg, int lVblock);
780
781ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV);
782// test syz strategy: // will be removed soon
783extern  int (*test_PosInT)(const TSet T,const int tl,LObject &h);
784extern  int (*test_PosInL)(const LSet set, const int length,
785                LObject* L,const kStrategy strat);
786#endif
Note: See TracBrowser for help on using the repository browser.