source: git/kernel/kutil.h @ 228e0b

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