source: git/kernel/GBEngine/kutil.h @ 89f4843

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