source: git/kernel/GBEngine/kutil.h @ d56a028

spielwiese
Last change on this file since d56a028 was d56a028, checked in by Hans Schoenemann <hannes@…>, 3 years ago
opt: GetpLength, static
  • Property mode set to 100644
File size: 32.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#ifdef HAVE_OMALLOC
15#include "omalloc/omallocClass.h"
16#endif
17
18#include "misc/mylimits.h"
19
20#include "kernel/polys.h"
21#include "polys/operations/pShallowCopyDelete.h"
22
23#include "kernel/structs.h"
24#include "kernel/GBEngine/kstd1.h"   /* for s_poly_proc_t */
25
26// define if tailrings should be used
27#define HAVE_TAIL_RING
28
29#define setmax 128
30#define setmaxL ((4096-12)/sizeof(LObject))
31#define setmaxLinc ((4096)/sizeof(LObject))
32
33#define setmaxT ((4096-12)/sizeof(TObject))
34#define setmaxTinc ((4096)/sizeof(TObject))
35
36// if you want std computations as in Singular version < 2:
37// This disables RedThrough, tailReductions against T (bba),
38// sets posInT = posInT15 (bba, strat->honey), and enables redFirst with LDeg
39// NOTE: can be achieved with option(oldStd)
40
41#undef NO_KINLINE
42#if !defined(KDEBUG) && !defined(NO_INLINE)
43#define KINLINE inline
44#else
45#define KINLINE
46#define NO_KINLINE 1
47#endif
48
49typedef int* intset;
50typedef int64  wlen_type;
51typedef wlen_type* wlen_set;
52
53typedef class sTObject TObject;
54typedef class sLObject LObject;
55typedef TObject * TSet;
56typedef LObject * LSet;
57
58typedef struct denominator_list_s denominator_list_s;
59typedef denominator_list_s *denominator_list;
60
61struct denominator_list_s{number n; denominator_list next;};
62EXTERN_VAR denominator_list DENOMINATOR_LIST;
63
64class sTObject
65{
66public:
67  unsigned long sevSig;
68  poly sig;   // the signature of the element
69  poly p;       // Lm(p) \in currRing Tail(p) \in tailRing
70  poly t_p;     // t_p \in tailRing: as monomials Lm(t_p) == Lm(p)
71  poly max_exp;     // p_GetMaxExpP(pNext(p))
72  ring tailRing;
73  long FDeg;    // pFDeg(p)
74  int ecart,
75    length,     // as of pLDeg
76    pLength,    // either == 0, or == pLength(p)
77    i_r;        // index of TObject in R set, or -1 if not in T
78
79#ifdef HAVE_SHIFTBBA
80  int shift;
81#endif
82
83  /*BOOLEAN*/ char is_normalized; // true, if pNorm was called on p, false otherwise
84  // used in incremental sba() with F5C:
85  // we know some of the redundant elements in
86  // strat->T beforehand, so we can just discard
87  // them and do not need to consider them in the
88  // interreduction process
89  /*BOOLEAN*/ char is_redundant;
90  // used in sba's sig-safe reduction:
91  // sometimes we already know that a reducer
92  // is sig-safe, so no need for a real
93  // sig-safeness check
94  /*BOOLEAN*/ char is_sigsafe;
95
96
97#ifdef HAVE_PLURAL
98  /*BOOLEAN*/ char is_special; // true, it is a new special S-poly (e.g. for SCA)
99#endif
100
101  // initialization
102  KINLINE void Init(ring r = currRing);
103  KINLINE sTObject(ring tailRing = currRing);
104  KINLINE sTObject(poly p, ring tailRing = currRing);
105  KINLINE sTObject(poly p, ring c_r, ring tailRing);
106  KINLINE sTObject(sTObject* T, int copy);
107
108  KINLINE void Set(ring r=currRing);
109  KINLINE void Set(poly p_in, ring r=currRing);
110  KINLINE void Set(poly p_in, ring c_r, ring t_r);
111
112  // Frees the polys of T
113  KINLINE void Delete();
114  // Sets polys to NULL
115  KINLINE void Clear();
116  // makes a copy of the poly of T
117  KINLINE void Copy();
118
119  // ring-dependent Lm access: these might result in allocation of monomials
120  KINLINE poly GetLmCurrRing();
121  KINLINE poly GetLmTailRing();
122  KINLINE poly GetLm(ring r);
123  // this returns Lm and ring r (preferably from tailRing), but does not
124  // allocate a new poly
125  KINLINE void GetLm(poly &p, ring &r) const;
126
127#ifdef OLIVER_PRIVAT_LT
128  // routines for calc. with rings
129  KINLINE poly GetLtCurrRing();
130  KINLINE poly GetLtTailRing();
131  KINLINE poly GetLt(ring r);
132  KINLINE void GetLt(poly &p, ring &r) const;
133#endif
134
135  KINLINE BOOLEAN IsNull() const;
136
137  KINLINE int GetpLength();
138
139  // makes sure that T.p exists
140  KINLINE void SetLmCurrRing();
141
142  // Iterations
143  // simply get the next monomial
144  KINLINE poly Next();
145  KINLINE void LmDeleteAndIter();
146
147  // deg stuff
148  // compute pTotalDegree
149  KINLINE long pTotalDeg() const;
150  // computes pFDeg
151  KINLINE long pFDeg() const;
152  // computes and sets FDeg
153  KINLINE long SetpFDeg();
154  // gets stored FDeg
155  KINLINE long GetpFDeg() const;
156
157  // computes pLDeg
158  KINLINE long pLDeg();
159  // sets length, FDeg, returns LDeg
160  KINLINE long SetDegStuffReturnLDeg();
161
162  // arithmetic
163  KINLINE void Mult_nn(number n);
164  KINLINE void ShallowCopyDelete(ring new_tailRing, omBin new_tailBin,
165                                 pShallowCopyDeleteProc p_shallow_copy_delete,
166                                 BOOLEAN set_max = TRUE);
167  // manipulations
168  KINLINE void pNorm();
169  KINLINE void pCleardenom();
170  KINLINE void pContent();
171
172#ifdef KDEBUG
173  void wrp();
174#endif
175};
176
177EXTERN_VAR int strat_nr;
178
179class sLObject : public sTObject
180{
181
182public:
183  unsigned long sev;
184  poly  p1,p2; /*- the pair p comes from,
185                 lm(pi) in currRing, tail(pi) in tailring -*/
186
187  poly  lcm;   /*- the lcm of p1,p2 -*/
188  kBucket_pt bucket;
189  int   i_r1, i_r2;
190  unsigned checked; // this is the index of S up to which
191                      // the corresponding LObject was already checked in
192                      // critical pair creation => when entering the
193                      // reduction process it is enough to start a second
194                      // rewritten criterion check from checked+1 onwards
195  BOOLEAN prod_crit;
196                      // NOTE: If prod_crit = TRUE then the corresponding pair is
197                      // detected by Buchberger's Product Criterion and can be
198                      // deleted
199
200  // initialization
201  KINLINE void Init(ring tailRing = currRing);
202  KINLINE sLObject(ring tailRing = currRing);
203  KINLINE sLObject(poly p, ring tailRing = currRing);
204  KINLINE sLObject(poly p, ring c_r, ring tailRing);
205
206  // Frees the polys of L
207  KINLINE void Delete();
208  KINLINE void Clear();
209
210  // Iterations
211  KINLINE void LmDeleteAndIter();
212  KINLINE poly LmExtractAndIter();
213
214  // spoly related things
215  // preparation for reduction if not spoly
216  KINLINE void PrepareRed(BOOLEAN use_bucket);
217  KINLINE void SetLmTail(poly lm, poly new_p, int length,
218                         int use_bucket, ring r);
219  KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether);
220  KINLINE void Tail_Mult_nn(number n);
221  // deletes bucket, makes sure that p and t_p exists
222  KINLINE poly GetP(omBin lmBin = (omBin)NULL);
223  // similar, except that only t_p exists
224  KINLINE poly GetTP();
225
226  // does not delete bucket, just canonicalizes it
227  // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing
228  KINLINE void CanonicalizeP();
229
230  // makes a copy of the poly of L
231  KINLINE void Copy();
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_VAR int HCord;
267
268class skStrategy
269#ifdef HAVE_OMALLOC
270                 : public omallocClass
271#endif
272{
273public:
274  kStrategy next;
275  int (*red)(LObject * L,kStrategy strat);
276  int (*red2)(LObject * L,kStrategy strat);
277  void (*initEcart)(TObject * L);
278  int (*posInT)(const TSet T,const int tl,LObject &h);
279  int (*posInLSba)(const LSet set, const int length,
280                LObject* L,const kStrategy strat);
281  int (*posInL)(const LSet set, const int length,
282                LObject* L,const kStrategy strat);
283  void (*enterS)(LObject &h, int pos,kStrategy strat, int atR/* =-1*/ );
284  void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG);
285  int (*posInLOld)(const LSet Ls,const int Ll,
286                   LObject* Lo,const kStrategy strat);
287  void (*enterOnePair) (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR /*= -1*/);
288  void (*chainCrit) (poly p,int ecart,kStrategy strat);
289  BOOLEAN (*syzCrit) (poly sig, unsigned long not_sevSig, kStrategy strat);
290  BOOLEAN (*rewCrit1) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
291  BOOLEAN (*rewCrit2) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
292  BOOLEAN (*rewCrit3) (poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start /*= 0*/);
293  pFDegProc pOrigFDeg;
294  pLDegProc pOrigLDeg;
295  pFDegProc pOrigFDeg_TailRing;
296  pLDegProc pOrigLDeg_TailRing;
297  s_poly_proc_t s_poly;
298
299  LObject P;
300  ideal Shdl;
301  ideal D; /*V(S) is in D(D)*/
302  ideal M; /*set of minimal generators*/
303  polyset S;
304  polyset syz;
305  polyset sig;
306  intset ecartS;
307  intset fromS; // from which S[i] S[j] comes from
308                // this is important for signature-based
309                // algorithms
310  intset syzIdx;// index in the syz array at which the first
311                // syzygy of component i comes up
312                // important for signature-based algorithms
313  unsigned sbaOrder;
314  int currIdx;
315  int max_lower_index;
316  intset lenS;
317  wlen_set lenSw; /* for tgb.ccc */
318  intset fromQ;
319  unsigned long* sevS;
320  unsigned long* sevSyz;
321  unsigned long* sevSig;
322  unsigned long* sevT;
323  TSet T;
324  LSet L;
325  LSet    B;
326  poly    kHEdge;
327  poly    kNoether;
328  poly    t_kHEdge; // same polys in tailring
329  KINLINE poly    kNoetherTail();
330  poly    t_kNoether;
331  BOOLEAN * NotUsedAxis;
332  BOOLEAN * pairtest;/*used for enterOnePair*/
333  poly tail;
334  intvec * kModW;
335  intvec * kHomW;
336  // procedure for ShalloCopy from tailRing  to currRing
337  pShallowCopyDeleteProc p_shallow_copy_delete;
338  // pointers to Tobjects R[i] is ith Tobject which is generated
339  TObject**  R;
340  // S_2_R[i] yields Tobject which corresponds to S[i]
341  int*      S_2_R;
342  ring tailRing;
343  omBin lmBin;
344  omBin tailBin;
345  int nr;
346  int cp,c3;
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_RINGS
359  bool sigdrop; //This is used to check sigdrop in sba over Z
360  int nrsyzcrit; // counts how many pairs are deleted by SyzCrit
361  int nrrewcrit; // counts how many pairs are deleted by FaugereRewCrit
362  int sbaEnterS; // sba over Z strategy: if sigdrop element has _*gen(sbaEnterS+1), then
363                 // add directly sbaEnterS elements into S
364  int blockred;  // counter for blocked reductions in redSig
365  int blockredmax;
366  #endif
367  #ifdef HAVE_SHIFTBBA
368  int cv; // in shift bases: counting V criterion
369  /*BOOLEAN*/ char rightGB;
370  #endif
371  /*BOOLEAN*/ char interpt;
372  /*BOOLEAN*/ char homog;
373#ifdef HAVE_PLURAL
374  /*BOOLEAN*/ char z2homog; // Z_2 - homogeneous input allows product criterion in commutative and SCA cases!
375#endif
376  /*BOOLEAN*/ char kHEdgeFound;
377  /*BOOLEAN*/ char honey,sugarCrit;
378  /*BOOLEAN*/ char Gebauer,noTailReduction;
379  /*BOOLEAN*/ char fromT;
380  /*BOOLEAN*/ char noetherSet;
381  /*BOOLEAN*/ char update;
382  /*BOOLEAN*/ char posInLOldFlag;
383  /*BOOLEAN*/ char use_buckets;
384  // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength)
385  /*BOOLEAN*/ char LDegLast;
386  // if set, then L.length == L.pLength
387  /*BOOLEAN*/ char length_pLength;
388  // if set, then posInL does not depend on L.length
389  /*BOOLEAN*/ char posInLDependsOnLength;
390  /*FALSE, if posInL == posInL10*/
391#ifdef HAVE_PLURAL
392  // set this flag to 1 to stop the product criteria
393  // use ALLOW_PROD_CRIT(strat) to test
394  /*BOOLEAN*/ char no_prod_crit;
395#define ALLOW_PROD_CRIT(A) (!(A)->no_prod_crit)
396#else
397#define ALLOW_PROD_CRIT(A) (1)
398#endif
399  char    redTailChange;
400  char    news;
401  char    newt;/*used for messageSets*/
402  char    noClearS;
403  char    completeReduce_retry;
404  char    overflow;
405
406  skStrategy();
407  ~skStrategy();
408
409  // return TObject corresponding to S[i]: assume that it exists
410  // i.e. no error checking is done
411  KINLINE TObject* S_2_T(int i);
412  // like S_2_T, except that NULL is returned if it can not be found
413  KINLINE TObject* s_2_t(int i);
414};
415
416void deleteHC(poly *p, int *e, int *l, kStrategy strat);
417void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE);
418void deleteInS (int i,kStrategy strat);
419void deleteInSSba (int i,kStrategy strat);
420void cleanT (kStrategy strat);
421static inline LSet initL (int nr=setmaxL)
422{ return (LSet)omAlloc(nr*sizeof(LObject)); }
423void deleteInL(LSet set, int *length, int j,kStrategy strat);
424void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at);
425void enterSBba (LObject &p,int atS,kStrategy strat, int atR = -1);
426void enterSBbaShift (LObject &p,int atS,kStrategy strat, int atR = -1);
427void enterSSba (LObject &p,int atS,kStrategy strat, int atR = -1);
428void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
429void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG);
430int posInS (const kStrategy strat, const int length, const poly p,
431            const int ecart_p);
432int posInSMonFirst (const kStrategy strat, const int length, const poly p);
433int posInIdealMonFirst (const ideal F, const poly p,int start = 0,int end = -1);
434int posInT0 (const TSet set,const int length,LObject &p);
435int posInT1 (const TSet set,const int length,LObject &p);
436int posInT2 (const TSet set,const int length,LObject &p);
437int posInT11 (const TSet set,const int length,LObject &p);
438int posInTSig (const TSet set,const int length,LObject &p);
439int posInT110 (const TSet set,const int length,LObject &p);
440int posInT13 (const TSet set,const int length,LObject &p);
441int posInT15 (const TSet set,const int length,LObject &p);
442int posInT17 (const TSet set,const int length,LObject &p);
443int posInT17_c (const TSet set,const int length,LObject &p);
444int posInT19 (const TSet set,const int length,LObject &p);
445int posInT_EcartpLength(const TSet set,const int length,LObject &p);
446int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p);
447int posInT_FDegpLength(const TSet set,const int length,LObject &p);
448int posInT_pLength(const TSet set,const int length,LObject &p);
449
450#ifdef HAVE_MORE_POS_IN_T
451int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p);
452int posInT_FDegpLength(const TSet set,const int length,LObject &p);
453int posInT_pLength(const TSet set,const int length,LObject &p);
454#endif
455
456
457void reorderS (int* suc,kStrategy strat);
458int posInLF5C (const LSet set, const int length,
459               LObject* L,const kStrategy strat);
460int posInLSig (const LSet set, const int length,
461               LObject* L,const kStrategy strat);
462int posInLSigRing (const LSet set, const int length,
463               LObject* L,const kStrategy strat);
464int posInLRing (const LSet set, const int length,
465               LObject* L,const kStrategy strat);
466int posInSyz (const kStrategy strat, const poly sig);
467int posInL0 (const LSet set, const int length,
468             LObject* L,const kStrategy strat);
469int posInL11 (const LSet set, const int length,
470             LObject* L,const kStrategy strat);
471int posInL11Ring (const LSet set, const int length,
472             LObject* L,const kStrategy strat);
473int posInLF5CRing (const LSet set, int start , const int length,
474             LObject* L,const kStrategy strat);
475int posInL11Ringls (const LSet set, const int length,
476             LObject* L,const kStrategy strat);
477int posInL13 (const LSet set, const int length,
478             LObject* L,const kStrategy strat);
479int posInL15 (const LSet set, const int length,
480             LObject* L,const kStrategy strat);
481int posInL15Ring (const LSet set, const int length,
482             LObject* L,const kStrategy strat);
483int posInL17 (const LSet set, const int length,
484             LObject* L,const kStrategy strat);
485int posInL10 (const LSet set, const int length,
486             LObject* L,const kStrategy strat);
487int posInL10Ring (const LSet set, const int length,
488             LObject* L,const kStrategy strat);
489int posInL110 (const LSet set, const int length,
490             LObject* L,const kStrategy strat);
491KINLINE poly redtailBba (poly p,int end_pos,kStrategy strat,BOOLEAN normalize=FALSE);
492KINLINE poly redtailBbaBound (poly p,int end_pos,kStrategy strat,int bound,BOOLEAN normalize=FALSE);
493#ifdef HAVE_RINGS
494KINLINE poly redtailBba_Ring (poly p,int end_pos,kStrategy strat);
495KINLINE poly redtailBba_Z (poly p,int end_pos,kStrategy strat);
496poly redtailBba_Ring (LObject* L, int end_pos, kStrategy strat );
497poly redtailBba_Z (LObject* L, int end_pos, kStrategy strat );
498void redtailBbaAlsoLC_Z (LObject* L, int end_pos, kStrategy strat );
499#endif
500poly redtailBba (LObject *L, int end_pos,kStrategy strat,
501                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
502poly redtailBbaBound (LObject *L, int end_pos,kStrategy strat,int bound,
503                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
504poly redtailSba (LObject *L, int end_pos,kStrategy strat,
505                 BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE);
506poly redtailBba (TObject *T, int end_pos,kStrategy strat);
507poly redtail (poly p,int end_pos,kStrategy strat);
508poly redtail (LObject *L,int end_pos,kStrategy strat);
509poly redNF (poly h,int & max_ind,int nonorm,kStrategy strat);
510int redNF0 (LObject *P,kStrategy strat);
511poly redNFTail (poly h,const int sl,kStrategy strat);
512int redHoney (LObject* h, kStrategy strat);
513int redLiftstd (LObject* h, kStrategy strat);
514#ifdef HAVE_RINGS
515int redRing (LObject* h,kStrategy strat);
516int redRing_Z (LObject* h,kStrategy strat);
517int redRiloc (LObject* h,kStrategy strat);
518void enterExtendedSpoly(poly h,kStrategy strat);
519void enterExtendedSpolySig(poly h,poly hSig,kStrategy strat);
520void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);
521void superenterpairsSig (poly h,poly hSig,int hFrom,int k,int ecart,int pos,kStrategy strat, int atR = -1);
522poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing);
523long ind2(long arg);
524
525long ind_fact_2(long arg);
526ideal createG0();
527#endif
528int redLazy (LObject* h,kStrategy strat);
529int redHomog (LObject* h,kStrategy strat);
530int redSig (LObject* h,kStrategy strat);
531int redSigRing (LObject* h,kStrategy strat);
532//adds hSig to be able to check with F5's criteria when entering pairs!
533void enterpairsSig (poly h, poly hSig, int from, int k, int ec, int pos,kStrategy strat, int atR = -1);
534void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1);
535void entersets (LObject h);
536void pairs ();
537BOOLEAN sbaCheckGcdPair (LObject* h,kStrategy strat);
538void message (int i,int* reduc,int* olddeg,kStrategy strat,int red_result);
539void messageStat (int hilbcount,kStrategy strat);
540void messageStatSBA (int hilbcount,kStrategy strat);
541#ifdef KDEBUG
542void messageSets (kStrategy strat);
543#else
544#define messageSets(s)  do {} while (0)
545#endif
546
547void initEcartNormal (TObject* h);
548void initEcartBBA (TObject* h);
549void initS (ideal F, ideal Q,kStrategy strat);
550void initSL (ideal F, ideal Q,kStrategy strat);
551void initSLSba (ideal F, ideal Q,kStrategy strat);
552/*************************************************
553 * when initializing a new bunch of principal
554 * syzygies at the beginning of a new iteration
555 * step in a signature-based algorithm we
556 * compute ONLY the leading elements of those
557 * syzygies, NOT the whole syzygy
558 * NOTE: this needs to be adjusted for a more
559 * general approach on signature-based algorithms
560 ***********************************************/
561void initSyzRules (kStrategy strat);
562void updateS(BOOLEAN toT,kStrategy strat);
563void enterSyz (LObject &p,kStrategy strat, int atT);
564void enterT (LObject &p,kStrategy strat, int atT = -1);
565void replaceInLAndSAndT(LObject &p, int tj, kStrategy strat);
566#ifdef HAVE_RINGS
567void enterT_strong (LObject &p,kStrategy strat, int atT = -1);
568#endif
569void cancelunit (LObject* p,BOOLEAN inNF=FALSE);
570void HEckeTest (poly pp,kStrategy strat);
571void initBuchMoraCrit(kStrategy strat);
572void initSbaCrit(kStrategy strat);
573void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat);
574void initBuchMoraPos(kStrategy strat);
575void initBuchMoraPosRing(kStrategy strat);
576void initSbaPos(kStrategy strat);
577void initBuchMora (ideal F, ideal Q,kStrategy strat);
578void initSbaBuchMora (ideal F, ideal Q,kStrategy strat);
579void exitBuchMora (kStrategy strat);
580void exitSba (kStrategy strat);
581void updateResult(ideal r,ideal Q,kStrategy strat);
582void completeReduce (kStrategy strat, BOOLEAN withT=FALSE);
583void kFreeStrat(kStrategy strat);
584void enterOnePairNormal (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR);
585void chainCritNormal (poly p,int ecart,kStrategy strat);
586void chainCritOpt_1 (poly,int,kStrategy strat);
587void chainCritSig (poly p,int ecart,kStrategy strat);
588BOOLEAN homogTest(polyset F, int Fmax);
589BOOLEAN newHEdge(kStrategy strat);
590BOOLEAN syzCriterion(poly sig, unsigned long not_sevSig, kStrategy strat);
591BOOLEAN syzCriterionInc(poly sig, unsigned long not_sevSig, kStrategy strat);
592KINLINE BOOLEAN arriRewDummy(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
593BOOLEAN arriRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
594BOOLEAN arriRewCriterionPre(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
595BOOLEAN faugereRewCriterion(poly sig, unsigned long not_sevSig, poly lm, kStrategy strat, int start);
596BOOLEAN findMinLMPair(poly sig, unsigned long not_sevSig, kStrategy strat, int start);
597
598/// returns index of p in TSet, or -1 if not found
599int kFindInT(poly p, TSet T, int tlength);
600#ifdef HAVE_SHIFTBBA
601int kFindInTShift(poly p, TSet T, int tlength);
602#endif
603
604/// return -1 if no divisor is found
605///        number of first divisor in T, otherwise
606int kFindDivisibleByInT(const kStrategy strat, const LObject* L, const int start=0);
607int kFindDivisibleByInT_Z(const kStrategy strat, const LObject* L, const int start=0);
608int kFindSameLMInT_Z(const kStrategy strat, const LObject* L, const int start=0);
609
610/// tests if T[0] divides the leading monomial of L, returns -1 if not
611int kTestDivisibleByT0_Z(const kStrategy strat, const LObject* L);
612/// return -1 if no divisor is found
613///        number of first divisor in S, otherwise
614int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L);
615
616int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L);
617TObject* kFindDivisibleByInS_T(kStrategy strat, int end_pos, LObject* L, TObject *T, long ecart = LONG_MAX);
618
619/***************************************************************
620 *
621 * stuff to be inlined
622 *
623 ***************************************************************/
624
625KINLINE TSet initT ();
626KINLINE TObject** initR();
627KINLINE unsigned long* initsevT();
628KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
629KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin bin);
630KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin bin);
631KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing,  omBin bin);
632
633KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing);
634KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing);
635KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing);
636KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing);
637
638// if exp bound is not violated, return TRUE and
639//                               get m1 = LCM(LM(p1), LM(p2))/LM(p1)
640//                                   m2 = LCM(LM(p1), LM(p2))/LM(p2)
641// return FALSE and m1 == NULL, m2 == NULL     , otherwise
642KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r,
643                               poly &m1, poly &m2, const ring m_r);
644#ifdef HAVE_RINGS
645KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing,
646                               poly &m1, poly &m2, poly &lcm, const ring taiRing);
647#endif
648#ifdef KDEBUG
649// test strat
650BOOLEAN kTest(kStrategy strat);
651// test strat, and test that S is contained in T
652BOOLEAN kTest_TS(kStrategy strat);
653// test LObject
654BOOLEAN kTest_L(LObject* L, ring tailRing,
655                 BOOLEAN testp = FALSE, int lpos = -1,
656                 TSet T = NULL, int tlength = -1);
657// test TObject
658BOOLEAN kTest_T(TObject* T, ring tailRing = NULL, int tpos = -1, char TN = '?');
659// test set strat->SevS
660BOOLEAN kTest_S(kStrategy strat);
661#else
662#define kTest(A)        (TRUE)
663#define kTest_TS(A)     (TRUE)
664#define kTest_T(T)      (TRUE)
665#define kTest_S(T)      (TRUE)
666#define kTest_L(T,R)    (TRUE)
667#endif
668
669
670/***************************************************************
671 *
672 * From kstd2.cc
673 *
674 ***************************************************************/
675poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing);
676ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
677ideal sba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
678poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce);
679ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce);
680poly kNF2Bound (ideal F, ideal Q, poly q,int bound, kStrategy strat, int lazyReduce);
681ideal kNF2Bound (ideal F,ideal Q,ideal q,int bound, kStrategy strat, int lazyReduce);
682void initBba(kStrategy strat);
683void initSba(ideal F,kStrategy strat);
684void f5c (kStrategy strat, int& olddeg, int& minimcnt, int& hilbeledeg,
685          int& hilbcount, int& srmax, int& lrmax, int& reduc, ideal Q,
686          intvec *w,intvec *hilb );
687
688/***************************************************************
689 *
690 * From kspoly.cc
691 *
692 ***************************************************************/
693// Reduces PR with PW
694// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
695// Changes: PR
696// Const:   PW
697// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
698// If strat != NULL, tailRing is changed if reduction would violate exp bound
699// of tailRing
700// Returns: 0 everything ok, no tailRing change
701//          1 tailRing has successfully changed (strat != NULL)
702//          2 no reduction performed, tailRing needs to be changed first
703//            (strat == NULL)
704//         -1 tailRing change could not be performed due to exceeding exp
705//            bound of currRing
706int ksReducePoly(LObject* PR,
707                 TObject* PW,
708                 poly spNoether = NULL,
709                 number *coef = NULL,
710                 poly *mon =NULL,
711                 kStrategy strat = NULL);
712
713/* like ksReducePoly, but if the reducer has only 1 term we still
714 * compute a possible coefficient multiplier for PR. this comes from
715 * a special situation in redRing_Z and it is used only there. */
716int ksReducePolyZ(LObject* PR,
717                 TObject* PW,
718                 poly spNoether = NULL,
719                 number *coef = NULL,
720                 kStrategy strat = NULL);
721
722int ksReducePolyLC(LObject* PR,
723                 TObject* PW,
724                 poly spNoether = NULL,
725                 number *coef = NULL,
726                 kStrategy strat = NULL);
727
728
729int ksReducePolyGCD(LObject* PR,
730                 TObject* PW,
731                 poly spNoether = NULL,
732                 number *coef = NULL,
733                 kStrategy strat = NULL);
734
735int ksReducePolyBound(LObject* PR,
736                 TObject* PW,
737                 int bound,
738                 poly spNoether = NULL,
739                 number *coef = NULL,
740                 kStrategy strat = NULL);
741
742// Reduces PR with PW
743// Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)
744// Changes: PR
745// Const:   PW
746// If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW)
747// If strat != NULL, tailRing is changed if reduction would violate exp bound
748// of tailRing
749// Returns: 0 everything ok, no tailRing change
750//          1 tailRing has successfully changed (strat != NULL)
751//          2 no reduction performed, tailRing needs to be changed first
752//            (strat == NULL)
753//          3 no reduction performed, not sig-safe!!!
754//         -1 tailRing change could not be performed due to exceeding exp
755//            bound of currRing
756int ksReducePolySig(LObject* PR,
757                 TObject* PW,
758                 long idx,
759                 poly spNoether = NULL,
760                 number *coef = NULL,
761                 kStrategy strat = NULL);
762
763int ksReducePolySigRing(LObject* PR,
764                 TObject* PW,
765                 long idx,
766                 poly spNoether = NULL,
767                 number *coef = NULL,
768                 kStrategy strat = NULL);
769
770// Reduces PR at Current->next with PW
771// Assumes PR != NULL, Current contained in PR
772//         Current->next != NULL, LM(PW) devides LM(Current->next)
773// Changes: PR
774// Const:   PW
775// Return: see ksReducePoly
776int ksReducePolyTail(LObject* PR,
777                     TObject* PW,
778                     poly Current,
779                     poly spNoether = NULL);
780
781KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red);
782
783// Creates S-Poly of Pair
784// Const:   Pair->p1, Pair->p2
785// Changes: Pair->p == S-Poly of p1, p2
786// Assume:  Pair->p1 != NULL && Pair->p2
787void ksCreateSpoly(LObject* Pair, poly spNoether = NULL,
788                   int use_buckets=0, ring tailRing=currRing,
789                   poly m1 = NULL, poly m2 = NULL, TObject** R = NULL);
790
791/*2
792* creates the leading term of the S-polynomial of p1 and p2
793* do not destroy p1 and p2
794* remarks:
795*   1. the coefficient is 0 (nNew)
796*   2. pNext is undefined
797*/
798poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing);
799
800
801// old stuff
802KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL);
803KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL);
804KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL, ring r = currRing);
805KINLINE void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r = currRing);
806
807/***************************************************************
808 *
809 * Routines related for ring changes during std computations
810 *
811 ***************************************************************/
812// return TRUE and set m1, m2 to k_GetLcmTerms,
813//             if spoly creation of strat->P does not violate
814//             exponent bound of strat->tailRing
815//      FALSE, otherwise
816BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2);
817#ifdef HAVE_RINGS
818// return TRUE if gcdpoly creation of R[atR] and S[atS] does not violate
819//             exponent bound of strat->tailRing
820//      FALSE, otherwise
821BOOLEAN kCheckStrongCreation(int atR, poly m1, int atS, poly m2, kStrategy strat);
822poly preIntegerCheck(ideal F, ideal Q);
823void postReduceByMon(LObject* h, kStrategy strat);
824void postReduceByMonSig(LObject* h, kStrategy strat);
825void finalReduceByMon(kStrategy strat);
826#endif
827// change strat->tailRing and adjust all data in strat, L, and T:
828// new tailRing has larger exponent bound
829// do nothing and return FALSE if exponent bound increase would result in
830// larger exponent bound that that of currRing
831BOOLEAN kStratChangeTailRing(kStrategy strat,
832                             LObject* L = NULL, TObject* T = NULL,
833                             // take this as new_expbound: if 0
834                             // new expbound is 2*expbound of tailRing
835                             unsigned long new_expbound = 0);
836// initiate a change of the tailRing of strat -- should be called
837// right before main loop in bba
838void kStratInitChangeTailRing(kStrategy strat);
839
840/// Output some debug info about a given strategy
841void kDebugPrint(kStrategy strat);
842
843// getting sb order for sba computations
844ring sbaRing(kStrategy strat, const ring r=currRing, BOOLEAN complete=TRUE, int sgn=1);
845
846KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k,
847  kStrategy strat);
848
849#include "kernel/GBEngine/kInline.h"
850
851/* shiftgb stuff */
852#include "kernel/GBEngine/shiftgb.h"
853
854poly pMove2CurrTail(poly p, kStrategy strat);
855
856poly pMoveCurrTail2poly(poly p, kStrategy strat);
857
858poly pCopyL2p(LObject h, kStrategy strat);
859
860void enterTShift(LObject p, kStrategy strat, int atT = -1);
861
862void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS);
863
864void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR);
865
866void superenterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR);
867
868poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize);
869
870int redFirstShift (LObject* h,kStrategy strat); // ok
871
872ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
873// test syz strategy: // will be removed soon
874EXTERN_VAR int (*test_PosInT)(const TSet T,const int tl,LObject &h);
875EXTERN_VAR int (*test_PosInL)(const LSet set, const int length,
876                LObject* L,const kStrategy strat);
877
878static inline void kDeleteLcm(LObject *P)
879{
880 if (P->lcm!=NULL)
881 {
882 #ifdef HAVE_RINGS
883   if (rField_is_Ring(currRing))
884     pLmDelete(P->lcm);
885   else
886 #endif
887     pLmFree(P->lcm);
888   P->lcm=NULL;
889 }
890}
891
892void initenterpairs (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR = -1);
893#endif
Note: See TracBrowser for help on using the repository browser.