source: git/kernel/kutil.h @ b085fba

Last change on this file since b085fba was b085fba, checked in by Christian Eder, 9 years ago
adds experimental sba tailred (disabled by default)
  • Property mode set to 100644
File size: 28.0 KB
[35aab3]1#ifndef KUTIL_H
2#define KUTIL_H
4*  Computer Algebra System SINGULAR     *
7* ABSTRACT: kernel: utils for kStd
11#include <string.h>
[b1dfaf]13#include <omalloc/omalloc.h>
[c6e80e]14#include <misc/mylimits.h>
[737a68]17#include <kernel/polys.h>
[210e07]18#include <polys/operations/pShallowCopyDelete.h>
[c6e80e]20#include <kernel/structs.h>
[35aab3]22#if 1
23#define setmax 16
[425d94c]24#define setmaxL ((4096-12)/sizeof(LObject))
25#define setmaxLinc ((4096)/sizeof(LObject))
27#define setmaxT 64
28#define setmaxTinc 32
30#define setmax 16
31#define setmaxL 16
32#define setmaxLinc 16
33#define setmaxT 16
34#define setmaxTinc 16
[228b631]37// if you want std computations as in Singular version < 2:
38// This disables RedThrough, tailReductions against T (bba),
[35aab3]39// sets posInT = posInT15 (bba, strat->honey), and enables redFirst with LDeg
[228b631]40// NOTE: can be achieved with option(oldStd)
42#undef NO_KINLINE
43#if !defined(KDEBUG) && !defined(NO_INLINE)
44#define KINLINE inline
46#define KINLINE
47#define NO_KINLINE 1
50typedef int* intset;
[58ebad]51typedef int64  wlen_type;
[fe5ad5]52typedef wlen_type* wlen_set;
[35aab3]54typedef class sTObject TObject;
55typedef class sLObject LObject;
56typedef TObject * TSet;
57typedef LObject * LSet;
[526e40d]59typedef struct denominator_list_s denominator_list_s;
60typedef denominator_list_s *denominator_list;
62struct denominator_list_s{number n; denominator_list next;};
63extern denominator_list DENOMINATOR_LIST;
[35aab3]65class sTObject
[83be980]68  unsigned long sevSig;
69  poly sig;   // the signature of the element
[35aab3]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))
[ad07b8]73  ring tailRing;
[35aab3]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
[83be980]80  // used in incremental sba() with F5C:
[a9c298]81  // we know some of the redundant elements in
[83be980]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;
[a9c298]93#ifdef HAVE_PLURAL
[c656700]94  BOOLEAN is_special; // true, it is a new special S-poly (e.g. for SCA)
[35aab3]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);
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);
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();
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;
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;
[35aab3]131  KINLINE BOOLEAN IsNull() const;
133  KINLINE int GetpLength();
135  // makes sure that T.p exists
136  KINLINE void SetLmCurrRing();
138  // Iterations
139  // simply get the next monomial
140  KINLINE poly Next();
141  KINLINE void LmDeleteAndIter();
143  // deg stuff
[d5564f8]144  // compute pTotalDegree
145  KINLINE long pTotalDeg() const;
[35aab3]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;
153  // computes pLDeg
154  KINLINE long pLDeg();
155  // sets length, FDeg, returns LDeg
156  KINLINE long SetDegStuffReturnLDeg();
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();
167#ifdef KDEBUG
168  void wrp();
[2d9e1e]172#ifndef NDEBUG
173extern int strat_nr;
174extern int strat_fac_debug;
[35aab3]177class sLObject : public sTObject
181  unsigned long sev;
[83be980]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
[5313c0]190                      // NOTE: If checked = 3 then the corresponding pair is
191                      // detected by Buchberger's Product Criterion and can be
192                      // deleted
[63e7d6c]193  poly  p1,p2; /*- the pair p comes from,
194                 lm(pi) in currRing, tail(pi) in tailring -*/
196  poly  lcm;   /*- the lcm of p1,p2 -*/
197  kBucket_pt bucket;
198  int   i_r1, i_r2;
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);
206  // Frees the polys of L
207  KINLINE void Delete();
208  KINLINE void Clear();
210  // Iterations
211  KINLINE void LmDeleteAndIter();
212  KINLINE poly LmExtractAndIter();
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,
[f224d85]218                         int use_bucket, ring r);
[35aab3]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();
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();
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();
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);
242  // returns minimal component of p
243  KINLINE long MinComp();
244  // returns component of p
245  KINLINE long Comp();
247  KINLINE void ShallowCopyDelete(ring new_tailRing,
248                                 pShallowCopyDeleteProc p_shallow_copy_delete);
250  // sets sev
251  KINLINE void SetShortExpVector();
253  // enable assignment from TObject
254  KINLINE sLObject& operator=(const sTObject&);
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);
262  // simplify coefficients
263  KINLINE void Normalize();
264  KINLINE void HeadNormalize();
268extern int HCord;
270class skStrategy;
271typedef skStrategy * kStrategy;
272class skStrategy
275  kStrategy next;
276  int (*red)(LObject * L,kStrategy strat);
[83be980]277  int (*red2)(LObject * L,kStrategy strat);
[35aab3]278  void (*initEcart)(LObject * L);
279  int (*posInT)(const TSet T,const int tl,LObject &h);
[83be980]280  int (*posInLSba)(const LSet set, const int length,
281                LObject* L,const kStrategy strat);
[35aab3]282  int (*posInL)(const LSet set, const int length,
283                LObject* L,const kStrategy strat);
[b130fb]284  void (*enterS)(LObject h, int pos,kStrategy strat, int atR/* =-1*/ );
[35aab3]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);
[6c55ae]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);
[83be980]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*/);
[35aab3]293  pFDegProc pOrigFDeg;
294  pLDegProc pOrigLDeg;
295  pFDegProc pOrigFDeg_TailRing;
296  pLDegProc pOrigLDeg_TailRing;
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;
[83be980]303  polyset syz;
304  polyset sig;
[35aab3]305  intset ecartS;
[83be980]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  BOOLEAN incremental;
313  unsigned long currIdx;
314  int max_lower_index;
[35aab3]315  intset lenS;
[fe5ad5]316  wlen_set lenSw; /* for tgb.ccc */
[35aab3]317  intset fromQ;
318  unsigned long* sevS;
[83be980]319  unsigned long* sevSyz;
320  unsigned long* sevSig;
[35aab3]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;
[660ed3]331  BOOLEAN * pairtest;/*used for enterOnePair*/
[35aab3]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;
[2d9e1e]344#ifndef NDEBUG
345  int nr;
[35aab3]347  int cp,c3;
[1c473f]348  int cv; // in shift bases: counting V criterion
[35aab3]349  int sl,mu;
[83be980]350  int syzl,syzmax,syzidxmax;
[35aab3]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;
[63b728c]360  #ifdef HAVE_SHIFTBBA
361  int lV;
362  #endif
[35aab3]363  BOOLEAN interpt;
364  BOOLEAN homog;
[aef1b86]365#ifdef HAVE_PLURAL
366  BOOLEAN z2homog; // Z_2 - homogeneous input allows product criterion in commutative and SCA cases!
[35aab3]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*/
[a794e7]384#ifdef HAVE_PLURAL
[cce4a2f]385  // set this flag to 1 to stop the product criteria
386  // use ALLOW_PROD_CRIT(strat) to test
[a794e7]387  BOOLEAN no_prod_crit;
[cce4a2f]388#define ALLOW_PROD_CRIT(A) (!(A)->no_prod_crit)
[cce4a2f]390#define ALLOW_PROD_CRIT(A) (1)
[35aab3]392  char    redTailChange;
393  char    news;
394  char    newt;/*used for messageSets*/
[660ed3]395  char    noClearS;
[b57694]396  char    completeReduce_retry;
[d5564f8]397  char    overflow;
399  skStrategy();
400  ~skStrategy();
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);
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);
[83be980]412void deleteInSSba (int i,kStrategy strat);
[35aab3]413void cleanT (kStrategy strat);
[e259fe]414static inline LSet initL (int nr=setmaxL)
[27fc50]415{ return (LSet)omAlloc(nr*sizeof(LObject)); }
[35aab3]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);
[83be980]419void enterSSba (LObject p,int atS,kStrategy strat, int atR = -1);
[35aab3]420void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
421void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
[a9c298]422int posInS (const kStrategy strat, const int length, const poly p,
[391323]423            const int ecart_p);
[35aab3]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);
[83be980]428int posInTSig (const TSet set,const int length,LObject &p);
[35aab3]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);
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);
443void reorderS (int* suc,kStrategy strat);
[83be980]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);
[35aab3]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);
[830ef8]460int posInL110 (const LSet set, const int length,
461             LObject* L,const kStrategy strat);
[015bba]462KINLINE poly redtailBba (poly p,int pos,kStrategy strat,BOOLEAN normalize=FALSE);
[5eb865]463#ifdef HAVE_RINGS
464KINLINE poly redtailBba_Z (poly p,int pos,kStrategy strat);
465poly redtailBba_Z (LObject* L, int pos, kStrategy strat );
[015bba]467poly redtailBba (LObject *L, int pos,kStrategy strat,
468                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
[b085fba]469poly redtailSba (LObject *L, int pos,kStrategy strat,
470                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
[015bba]471poly redtailBba (TObject *T, int pos,kStrategy strat);
[35aab3]472poly redtail (poly p,int pos,kStrategy strat);
473poly redtail (LObject *L,int pos,kStrategy strat);
[ab1c36]474poly redNF (poly h,int & max_ind,int nonorm,kStrategy strat);
[35aab3]475int redNF0 (LObject *P,kStrategy strat);
476poly redNFTail (poly h,const int sl,kStrategy strat);
477int redHoney (LObject* h, kStrategy strat);
[206e158]478#ifdef HAVE_RINGS
[093f30e]479int redRing (LObject* h,kStrategy strat);
[c25b56c]480int redRiloc (LObject* h,kStrategy strat);
[f92547]481void enterExtendedSpoly(poly h,kStrategy strat);
482void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);
[6d09f28]483poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing);
[206e158]484long ind2(long arg);
[206e158]486long ind_fact_2(long arg);
487long twoPow(long arg);
[6d09f28]488ideal createG0();
[35aab3]490int redLazy (LObject* h,kStrategy strat);
491int redHomog (LObject* h,kStrategy strat);
[83be980]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);
[35aab3]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);
[930ea8]499void messageStat (int hilbcount,kStrategy strat);
[35aab3]500#ifdef KDEBUG
501void messageSets (kStrategy strat);
[d101b1]503#define messageSets(s)  do {} while (0)
506void initEcartNormal (LObject* h);
507void initEcartBBA (LObject* h);
508void initS (ideal F, ideal Q,kStrategy strat);
509void initSL (ideal F, ideal Q,kStrategy strat);
[83be980]510void initSLSba (ideal F, ideal Q,kStrategy strat);
[a9c298]512 * when initializing a new bunch of principal
[83be980]513 * syzygies at the beginning of a new iteration
[a9c298]514 * step in a signature-based algorithm we
[83be980]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);
[35aab3]521void updateS(BOOLEAN toT,kStrategy strat);
[83be980]522void enterSyz (LObject p,kStrategy strat);
[35aab3]523void enterT (LObject p,kStrategy strat, int atT = -1);
[5572c1]524void cancelunit (LObject* p,BOOLEAN inNF=FALSE);
[35aab3]525void HEckeTest (poly pp,kStrategy strat);
526void initBuchMoraCrit(kStrategy strat);
[83be980]527void initSbaCrit(kStrategy strat);
[35aab3]528void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
529void initBuchMoraPos(kStrategy strat);
[83be980]530void initSbaPos(kStrategy strat);
[35aab3]531void initBuchMora (ideal F, ideal Q,kStrategy strat);
[83be980]532void initSbaBuchMora (ideal F, ideal Q,kStrategy strat);
[35aab3]533void exitBuchMora (kStrategy strat);
[83be980]534void exitSba (kStrategy strat);
[35aab3]535void updateResult(ideal r,ideal Q,kStrategy strat);
[4d43ff]536void completeReduce (kStrategy strat, BOOLEAN withT=FALSE);
[35aab3]537void kFreeStrat(kStrategy strat);
[6c55ae]538void enterOnePairNormal (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR);
[83be980]539void enterOnePairSig (int i,poly p,poly pSig,int ecart, int isFromQ,kStrategy strat, int atR);
[6c55ae]540void chainCritNormal (poly p,int ecart,kStrategy strat);
[83be980]541void chainCritSig (poly p,int ecart,kStrategy strat);
[35aab3]542BOOLEAN homogTest(polyset F, int Fmax);
[930ea8]543BOOLEAN newHEdge(kStrategy strat);
[83be980]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);
[35aab3]550// returns index of p in TSet, or -1 if not found
551int kFindInT(poly p, TSet T, int tlength);
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
[391323]558int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L);
[7ba059]560int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L);
562kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T,
563                    long ecart = LONG_MAX);
566 *
567 * stuff to be inlined
568 *
569 ***************************************************************/
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);
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);
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);
[d681e8]590#ifdef HAVE_RINGS
[ca371d]591KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing,
[d681e8]592                               poly &m1, poly &m2, poly &lcm, const ring taiRing);
[35aab3]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);
[d101b1]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)
617 *
618 * From
619 *
620 ***************************************************************/
[a6889e]621poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing);
[35aab3]622ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
[83be980]623ideal sba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
[35aab3]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);
[83be980]627void initSba(ideal F,kStrategy strat);
[a9c298]628void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg,
[83be980]629          int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q,
630          intvec *w,intvec *hilb );
633 *
[c25b56c]634 * From
[35aab3]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);
[83be980]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);
[35aab3]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);
688KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red);
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);
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
705poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing);
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);
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);
[7245240]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);
[35aab3]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);
[4f7d76]743/// Output some debug info about a given strategy
744void kDebugPrint(kStrategy strat);
[83be980]746// getting sb order for sba computations
747ring sbaRing(kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1);
[ec69aa]749KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
750  kStrategy strat);
[c6e80e]752#include <kernel/kInline.h>
[cb0fbe]754/* shiftgb stuff */
[599326]755#include <kernel/shiftgb.h>
[4d2ab5c]757poly pMove2CurrTail(poly p, kStrategy strat);
759poly pMoveCurrTail2poly(poly p, kStrategy strat);
761poly pCopyL2p(LObject h, kStrategy strat);
[37a4c3]763void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV);
[37a4c3]765void initBuchMoraShift (ideal F,ideal Q,kStrategy strat);
767void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV); // ok
769void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV);
[4d2ab5c]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
773void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV);
[a9c298]775void initenterpairsShift (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR,int uptodeg, int lV);
777void updateSShift(kStrategy strat,int uptodeg,int lV);
779void initBbaShift(ideal F,kStrategy strat);
[37a4c3]781poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize);
783int redFirstShift (LObject* h,kStrategy strat); // ok
785ideal freegb(ideal I, int uptodeg, int lVblock);
787ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV);
[57fad3a]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);
Note: See TracBrowser for help on using the repository browser.