1 | #ifndef KUTIL_H |
---|
2 | #define KUTIL_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id$ */ |
---|
7 | /* |
---|
8 | * ABSTRACT: kernel: utils for kStd |
---|
9 | */ |
---|
10 | |
---|
11 | |
---|
12 | #include <string.h> |
---|
13 | |
---|
14 | #include <omalloc/omalloc.h> |
---|
15 | #include <misc/mylimits.h> |
---|
16 | |
---|
17 | |
---|
18 | #include <polys/polys.h> |
---|
19 | #include <polys/operations/pShallowCopyDelete.h> |
---|
20 | |
---|
21 | #include <kernel/structs.h> |
---|
22 | |
---|
23 | #if 1 |
---|
24 | #define setmax 16 |
---|
25 | #define setmaxL ((4096-12)/sizeof(LObject)) |
---|
26 | #define setmaxLinc ((4096)/sizeof(LObject)) |
---|
27 | |
---|
28 | #define setmaxT 64 |
---|
29 | #define setmaxTinc 32 |
---|
30 | #else |
---|
31 | #define setmax 16 |
---|
32 | #define setmaxL 16 |
---|
33 | #define setmaxLinc 16 |
---|
34 | #define setmaxT 16 |
---|
35 | #define setmaxTinc 16 |
---|
36 | #endif |
---|
37 | |
---|
38 | // if you want std computations as in Singular version < 2: |
---|
39 | // This disables RedThrough, tailReductions against T (bba), |
---|
40 | // sets posInT = posInT15 (bba, strat->honey), and enables redFirst with LDeg |
---|
41 | // NOTE: can be achieved with option(oldStd) |
---|
42 | |
---|
43 | #undef NO_KINLINE |
---|
44 | #if !defined(KDEBUG) && !defined(NO_INLINE) |
---|
45 | #define KINLINE inline |
---|
46 | #else |
---|
47 | #define KINLINE |
---|
48 | #define NO_KINLINE 1 |
---|
49 | #endif |
---|
50 | |
---|
51 | typedef int* intset; |
---|
52 | typedef int64 wlen_type; |
---|
53 | typedef wlen_type* wlen_set; |
---|
54 | |
---|
55 | typedef class sTObject TObject; |
---|
56 | typedef class sLObject LObject; |
---|
57 | typedef TObject * TSet; |
---|
58 | typedef LObject * LSet; |
---|
59 | |
---|
60 | typedef struct denominator_list_s denominator_list_s; |
---|
61 | typedef denominator_list_s *denominator_list; |
---|
62 | |
---|
63 | struct denominator_list_s{number n; denominator_list next;}; |
---|
64 | extern denominator_list DENOMINATOR_LIST; |
---|
65 | |
---|
66 | class sTObject |
---|
67 | { |
---|
68 | public: |
---|
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; // 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 | BOOLEAN is_normalized; // true, if pNorm was called on p, false otherwise |
---|
79 | |
---|
80 | #ifdef HAVE_PLURAL |
---|
81 | BOOLEAN is_special; // true, it is a new special S-poly (e.g. for SCA) |
---|
82 | #endif |
---|
83 | |
---|
84 | // initialization |
---|
85 | KINLINE void Init(ring r = currRing); |
---|
86 | KINLINE sTObject(ring tailRing = currRing); |
---|
87 | KINLINE sTObject(poly p, ring tailRing = currRing); |
---|
88 | KINLINE sTObject(poly p, ring c_r, ring tailRing); |
---|
89 | KINLINE sTObject(sTObject* T, int copy); |
---|
90 | |
---|
91 | KINLINE void Set(ring r=currRing); |
---|
92 | KINLINE void Set(poly p_in, ring r=currRing); |
---|
93 | KINLINE void Set(poly p_in, ring c_r, ring t_r); |
---|
94 | |
---|
95 | // Frees the polys of T |
---|
96 | KINLINE void Delete(); |
---|
97 | // Sets polys to NULL |
---|
98 | KINLINE void Clear(); |
---|
99 | // makes a copy of the poly of T |
---|
100 | KINLINE void Copy(); |
---|
101 | |
---|
102 | // ring-dependent Lm access: these might result in allocation of monomials |
---|
103 | KINLINE poly GetLmCurrRing(); |
---|
104 | KINLINE poly GetLmTailRing(); |
---|
105 | KINLINE poly GetLm(ring r); |
---|
106 | // this returns Lm and ring r (preferably from tailRing), but does not |
---|
107 | // allocate a new poly |
---|
108 | KINLINE void GetLm(poly &p, ring &r) const; |
---|
109 | |
---|
110 | #ifdef OLIVER_PRIVAT_LT |
---|
111 | // routines for calc. with rings |
---|
112 | KINLINE poly GetLtCurrRing(); |
---|
113 | KINLINE poly GetLtTailRing(); |
---|
114 | KINLINE poly GetLt(ring r); |
---|
115 | KINLINE void GetLt(poly &p, ring &r) const; |
---|
116 | #endif |
---|
117 | |
---|
118 | KINLINE BOOLEAN IsNull() const; |
---|
119 | |
---|
120 | KINLINE int GetpLength(); |
---|
121 | |
---|
122 | // makes sure that T.p exists |
---|
123 | KINLINE void SetLmCurrRing(); |
---|
124 | |
---|
125 | // Iterations |
---|
126 | // simply get the next monomial |
---|
127 | KINLINE poly Next(); |
---|
128 | KINLINE void LmDeleteAndIter(); |
---|
129 | |
---|
130 | // deg stuff |
---|
131 | // compute pTotalDegree |
---|
132 | KINLINE long pTotalDeg() const; |
---|
133 | // computes pFDeg |
---|
134 | KINLINE long pFDeg() const; |
---|
135 | // computes and sets FDeg |
---|
136 | KINLINE long SetpFDeg(); |
---|
137 | // gets stored FDeg |
---|
138 | KINLINE long GetpFDeg() const; |
---|
139 | |
---|
140 | // computes pLDeg |
---|
141 | KINLINE long pLDeg(); |
---|
142 | // sets length, FDeg, returns LDeg |
---|
143 | KINLINE long SetDegStuffReturnLDeg(); |
---|
144 | |
---|
145 | // arithmetic |
---|
146 | KINLINE void Mult_nn(number n); |
---|
147 | KINLINE void ShallowCopyDelete(ring new_tailRing, omBin new_tailBin, |
---|
148 | pShallowCopyDeleteProc p_shallow_copy_delete, |
---|
149 | BOOLEAN set_max = TRUE); |
---|
150 | // manipulations |
---|
151 | KINLINE void pNorm(); |
---|
152 | KINLINE void pCleardenom(); |
---|
153 | |
---|
154 | #ifdef KDEBUG |
---|
155 | void wrp(); |
---|
156 | #endif |
---|
157 | }; |
---|
158 | |
---|
159 | #ifndef NDEBUG |
---|
160 | extern int strat_nr; |
---|
161 | extern int strat_fac_debug; |
---|
162 | #endif |
---|
163 | |
---|
164 | class sLObject : public sTObject |
---|
165 | { |
---|
166 | |
---|
167 | public: |
---|
168 | unsigned long sev; |
---|
169 | poly p1,p2; /*- the pair p comes from, |
---|
170 | lm(pi) in currRing, tail(pi) in tailring -*/ |
---|
171 | |
---|
172 | poly lcm; /*- the lcm of p1,p2 -*/ |
---|
173 | poly last; // pLast(p) during reductions |
---|
174 | kBucket_pt bucket; |
---|
175 | int i_r1, i_r2; |
---|
176 | |
---|
177 | // initialization |
---|
178 | KINLINE void Init(ring tailRing = currRing); |
---|
179 | KINLINE sLObject(ring tailRing = currRing); |
---|
180 | KINLINE sLObject(poly p, ring tailRing = currRing); |
---|
181 | KINLINE sLObject(poly p, ring c_r, ring tailRing); |
---|
182 | |
---|
183 | // Frees the polys of L |
---|
184 | KINLINE void Delete(); |
---|
185 | KINLINE void Clear(); |
---|
186 | |
---|
187 | // Iterations |
---|
188 | KINLINE void LmDeleteAndIter(); |
---|
189 | KINLINE poly LmExtractAndIter(); |
---|
190 | |
---|
191 | // spoly related things |
---|
192 | // preparation for reduction if not spoly |
---|
193 | KINLINE void PrepareRed(BOOLEAN use_bucket); |
---|
194 | KINLINE void SetLmTail(poly lm, poly new_p, int length, |
---|
195 | int use_bucket, ring r, poly last); |
---|
196 | KINLINE void Tail_Minus_mm_Mult_qq(poly m, poly qq, int lq, poly spNoether); |
---|
197 | KINLINE void Tail_Mult_nn(number n); |
---|
198 | // deletes bucket, makes sure that p and t_p exists |
---|
199 | KINLINE poly GetP(omBin lmBin = NULL); |
---|
200 | // similar, except that only t_p exists |
---|
201 | KINLINE poly GetTP(); |
---|
202 | |
---|
203 | // does not delete bucket, just canonicalizes it |
---|
204 | // returned poly is such that Lm(p) \in currRing, Tail(p) \in tailRing |
---|
205 | KINLINE poly CanonicalizeP(); |
---|
206 | |
---|
207 | // makes a copy of the poly of L |
---|
208 | KINLINE void Copy(); |
---|
209 | // gets the poly and makes a copy of it |
---|
210 | KINLINE poly CopyGetP(); |
---|
211 | |
---|
212 | KINLINE int GetpLength(); |
---|
213 | KINLINE long pLDeg(BOOLEAN use_last); |
---|
214 | KINLINE long pLDeg(); |
---|
215 | KINLINE int SetLength(BOOLEAN lengt_pLength = FALSE); |
---|
216 | KINLINE long SetDegStuffReturnLDeg(); |
---|
217 | KINLINE long SetDegStuffReturnLDeg(BOOLEAN use_last); |
---|
218 | |
---|
219 | // returns minimal component of p |
---|
220 | KINLINE long MinComp(); |
---|
221 | // returns component of p |
---|
222 | KINLINE long Comp(); |
---|
223 | |
---|
224 | KINLINE void ShallowCopyDelete(ring new_tailRing, |
---|
225 | pShallowCopyDeleteProc p_shallow_copy_delete); |
---|
226 | |
---|
227 | // sets sev |
---|
228 | KINLINE void SetShortExpVector(); |
---|
229 | |
---|
230 | // enable assignment from TObject |
---|
231 | KINLINE sLObject& operator=(const sTObject&); |
---|
232 | |
---|
233 | // get T's corresponding to p1, p2: they might return NULL |
---|
234 | KINLINE TObject* T_1(const skStrategy* strat); |
---|
235 | KINLINE TObject* T_2(const skStrategy* strat); |
---|
236 | KINLINE void T_1_2(const skStrategy* strat, |
---|
237 | TObject* &T_1, TObject* &T_2); |
---|
238 | |
---|
239 | // simplify coefficients |
---|
240 | KINLINE void Normalize(); |
---|
241 | KINLINE void HeadNormalize(); |
---|
242 | }; |
---|
243 | |
---|
244 | |
---|
245 | extern int HCord; |
---|
246 | |
---|
247 | class skStrategy; |
---|
248 | typedef skStrategy * kStrategy; |
---|
249 | class skStrategy |
---|
250 | { |
---|
251 | public: |
---|
252 | kStrategy next; |
---|
253 | int (*red)(LObject * L,kStrategy strat); |
---|
254 | void (*initEcart)(LObject * L); |
---|
255 | int (*posInT)(const TSet T,const int tl,LObject &h); |
---|
256 | int (*posInL)(const LSet set, const int length, |
---|
257 | LObject* L,const kStrategy strat); |
---|
258 | void (*enterS)(LObject h, int pos,kStrategy strat, int atR/* =-1*/ ); |
---|
259 | void (*initEcartPair)(LObject * h, poly f, poly g, int ecartF, int ecartG); |
---|
260 | int (*posInLOld)(const LSet Ls,const int Ll, |
---|
261 | LObject* Lo,const kStrategy strat); |
---|
262 | void (*enterOnePair) (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR /*= -1*/); |
---|
263 | void (*chainCrit) (poly p,int ecart,kStrategy strat); |
---|
264 | pFDegProc pOrigFDeg; |
---|
265 | pLDegProc pOrigLDeg; |
---|
266 | pFDegProc pOrigFDeg_TailRing; |
---|
267 | pLDegProc pOrigLDeg_TailRing; |
---|
268 | |
---|
269 | LObject P; |
---|
270 | ideal Shdl; |
---|
271 | ideal D; /*V(S) is in D(D)*/ |
---|
272 | ideal M; /*set of minimal generators*/ |
---|
273 | polyset S; |
---|
274 | intset ecartS; |
---|
275 | intset lenS; |
---|
276 | wlen_set lenSw; /* for tgb.ccc */ |
---|
277 | intset fromQ; |
---|
278 | unsigned long* sevS; |
---|
279 | unsigned long* sevT; |
---|
280 | TSet T; |
---|
281 | LSet L; |
---|
282 | LSet B; |
---|
283 | poly kHEdge; |
---|
284 | poly kNoether; |
---|
285 | poly t_kHEdge; // same polys in tailring |
---|
286 | KINLINE poly kNoetherTail(); |
---|
287 | poly t_kNoether; |
---|
288 | BOOLEAN * NotUsedAxis; |
---|
289 | BOOLEAN * pairtest;/*used for enterOnePair*/ |
---|
290 | poly tail; |
---|
291 | leftv kIdeal; |
---|
292 | intvec * kModW; |
---|
293 | intvec * kHomW; |
---|
294 | // procedure for ShalloCopy from tailRing to currRing |
---|
295 | pShallowCopyDeleteProc p_shallow_copy_delete; |
---|
296 | // pointers to Tobjects R[i] is ith Tobject which is generated |
---|
297 | TObject** R; |
---|
298 | // S_2_R[i] yields Tobject which corresponds to S[i] |
---|
299 | int* S_2_R; |
---|
300 | ring tailRing; |
---|
301 | omBin lmBin; |
---|
302 | omBin tailBin; |
---|
303 | #ifndef NDEBUG |
---|
304 | int nr; |
---|
305 | #endif |
---|
306 | int cp,c3; |
---|
307 | int cv; // in shift bases: counting V criterion |
---|
308 | int sl,mu; |
---|
309 | int tl,tmax; |
---|
310 | int Ll,Lmax; |
---|
311 | int Bl,Bmax; |
---|
312 | int ak,LazyDegree,LazyPass; |
---|
313 | int syzComp; |
---|
314 | int HCord; |
---|
315 | int lastAxis; |
---|
316 | int newIdeal; |
---|
317 | int minim; |
---|
318 | #ifdef HAVE_SHIFTBBA |
---|
319 | int lV; |
---|
320 | #endif |
---|
321 | BOOLEAN interpt; |
---|
322 | BOOLEAN homog; |
---|
323 | #ifdef HAVE_PLURAL |
---|
324 | BOOLEAN z2homog; // Z_2 - homogeneous input allows product criterion in commutative and SCA cases! |
---|
325 | #endif |
---|
326 | BOOLEAN kHEdgeFound; |
---|
327 | BOOLEAN honey,sugarCrit; |
---|
328 | BOOLEAN Gebauer,noTailReduction; |
---|
329 | BOOLEAN fromT; |
---|
330 | BOOLEAN noetherSet; |
---|
331 | BOOLEAN update; |
---|
332 | BOOLEAN posInLOldFlag; |
---|
333 | BOOLEAN use_buckets; |
---|
334 | BOOLEAN interred_flag; |
---|
335 | // if set, pLDeg(p, l) == (pFDeg(pLast(p), pLength) |
---|
336 | BOOLEAN LDegLast; |
---|
337 | // if set, then L.length == L.pLength |
---|
338 | BOOLEAN length_pLength; |
---|
339 | // if set, then posInL does not depend on L.length |
---|
340 | BOOLEAN posInLDependsOnLength; |
---|
341 | /*FALSE, if posInL == posInL10*/ |
---|
342 | #ifdef HAVE_PLURAL |
---|
343 | // set this flag to 1 to stop the product criteria |
---|
344 | // use ALLOW_PROD_CRIT(strat) to test |
---|
345 | BOOLEAN no_prod_crit; |
---|
346 | #define ALLOW_PROD_CRIT(A) (!(A)->no_prod_crit) |
---|
347 | #else |
---|
348 | #define ALLOW_PROD_CRIT(A) (1) |
---|
349 | #endif |
---|
350 | char redTailChange; |
---|
351 | char news; |
---|
352 | char newt;/*used for messageSets*/ |
---|
353 | char noClearS; |
---|
354 | char completeReduce_retry; |
---|
355 | char overflow; |
---|
356 | |
---|
357 | skStrategy(); |
---|
358 | ~skStrategy(); |
---|
359 | |
---|
360 | // return TObject corresponding to S[i]: assume that it exists |
---|
361 | // i.e. no error checking is done |
---|
362 | KINLINE TObject* S_2_T(int i); |
---|
363 | // like S_2_T, except that NULL is returned if it can not be found |
---|
364 | KINLINE TObject* s_2_t(int i); |
---|
365 | }; |
---|
366 | |
---|
367 | void deleteHC(poly *p, int *e, int *l, kStrategy strat); |
---|
368 | void deleteHC(LObject* L, kStrategy strat, BOOLEAN fromNext = FALSE); |
---|
369 | void deleteInS (int i,kStrategy strat); |
---|
370 | void cleanT (kStrategy strat); |
---|
371 | static inline LSet initL (int nr=setmaxL) |
---|
372 | { return (LSet)omAlloc(nr*sizeof(LObject)); } |
---|
373 | void deleteInL(LSet set, int *length, int j,kStrategy strat); |
---|
374 | void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at); |
---|
375 | void enterSBba (LObject p,int atS,kStrategy strat, int atR = -1); |
---|
376 | void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG); |
---|
377 | void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG); |
---|
378 | int posInS (const kStrategy strat, const int length, const poly p, |
---|
379 | const int ecart_p); |
---|
380 | int posInT0 (const TSet set,const int length,LObject &p); |
---|
381 | int posInT1 (const TSet set,const int length,LObject &p); |
---|
382 | int posInT2 (const TSet set,const int length,LObject &p); |
---|
383 | int posInT11 (const TSet set,const int length,LObject &p); |
---|
384 | int posInT110 (const TSet set,const int length,LObject &p); |
---|
385 | int posInT13 (const TSet set,const int length,LObject &p); |
---|
386 | int posInT15 (const TSet set,const int length,LObject &p); |
---|
387 | int posInT17 (const TSet set,const int length,LObject &p); |
---|
388 | int posInT19 (const TSet set,const int length,LObject &p); |
---|
389 | int posInT_EcartpLength(const TSet set,const int length,LObject &p); |
---|
390 | |
---|
391 | #ifdef HAVE_MORE_POS_IN_T |
---|
392 | int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p); |
---|
393 | int posInT_FDegpLength(const TSet set,const int length,LObject &p); |
---|
394 | int posInT_pLength(const TSet set,const int length,LObject &p); |
---|
395 | #endif |
---|
396 | |
---|
397 | |
---|
398 | void reorderS (int* suc,kStrategy strat); |
---|
399 | int posInL0 (const LSet set, const int length, |
---|
400 | LObject* L,const kStrategy strat); |
---|
401 | int posInL11 (const LSet set, const int length, |
---|
402 | LObject* L,const kStrategy strat); |
---|
403 | int posInL13 (const LSet set, const int length, |
---|
404 | LObject* L,const kStrategy strat); |
---|
405 | int posInL15 (const LSet set, const int length, |
---|
406 | LObject* L,const kStrategy strat); |
---|
407 | int posInL17 (const LSet set, const int length, |
---|
408 | LObject* L,const kStrategy strat); |
---|
409 | int posInL10 (const LSet set, const int length, |
---|
410 | LObject* L,const kStrategy strat); |
---|
411 | int posInL110 (const LSet set, const int length, |
---|
412 | LObject* L,const kStrategy strat); |
---|
413 | KINLINE poly redtailBba (poly p,int pos,kStrategy strat,BOOLEAN normalize=FALSE); |
---|
414 | #ifdef HAVE_RINGS |
---|
415 | KINLINE poly redtailBba_Z (poly p,int pos,kStrategy strat); |
---|
416 | poly redtailBba_Z (LObject* L, int pos, kStrategy strat ); |
---|
417 | #endif |
---|
418 | poly redtailBba (LObject *L, int pos,kStrategy strat, |
---|
419 | BOOLEAN withT = FALSE,BOOLEAN normalize=FALSE); |
---|
420 | poly redtailBba (TObject *T, int pos,kStrategy strat); |
---|
421 | poly redtail (poly p,int pos,kStrategy strat); |
---|
422 | poly redtail (LObject *L,int pos,kStrategy strat); |
---|
423 | poly redNF (poly h,int & max_ind,int nonorm,kStrategy strat); |
---|
424 | int redNF0 (LObject *P,kStrategy strat); |
---|
425 | poly redNFTail (poly h,const int sl,kStrategy strat); |
---|
426 | int redHoney (LObject* h, kStrategy strat); |
---|
427 | #ifdef HAVE_RINGS |
---|
428 | int redRing (LObject* h,kStrategy strat); |
---|
429 | void enterExtendedSpoly(poly h,kStrategy strat); |
---|
430 | void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1); |
---|
431 | poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing); |
---|
432 | long ind2(long arg); |
---|
433 | |
---|
434 | long ind_fact_2(long arg); |
---|
435 | long twoPow(long arg); |
---|
436 | ideal createG0(); |
---|
437 | #endif |
---|
438 | int redLazy (LObject* h,kStrategy strat); |
---|
439 | int redHomog (LObject* h,kStrategy strat); |
---|
440 | void enterpairs (poly h, int k, int ec, int pos,kStrategy strat, int atR = -1); |
---|
441 | void entersets (LObject h); |
---|
442 | void pairs (); |
---|
443 | void message (int i,int* reduc,int* olddeg,kStrategy strat,int red_result); |
---|
444 | void messageStat (int srmax,int lrmax,int hilbcount,kStrategy strat); |
---|
445 | #ifdef KDEBUG |
---|
446 | void messageSets (kStrategy strat); |
---|
447 | #else |
---|
448 | #define messageSets(s) ((void) 0) |
---|
449 | #endif |
---|
450 | |
---|
451 | void initEcartNormal (LObject* h); |
---|
452 | void initEcartBBA (LObject* h); |
---|
453 | void initS (ideal F, ideal Q,kStrategy strat); |
---|
454 | void initSL (ideal F, ideal Q,kStrategy strat); |
---|
455 | void updateS(BOOLEAN toT,kStrategy strat); |
---|
456 | void enterT (LObject p,kStrategy strat, int atT = -1); |
---|
457 | void cancelunit (LObject* p,BOOLEAN inNF=FALSE); |
---|
458 | void HEckeTest (poly pp,kStrategy strat); |
---|
459 | void initBuchMoraCrit(kStrategy strat); |
---|
460 | void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat); |
---|
461 | void initBuchMoraPos(kStrategy strat); |
---|
462 | void initBuchMora (ideal F, ideal Q,kStrategy strat); |
---|
463 | void exitBuchMora (kStrategy strat); |
---|
464 | void updateResult(ideal r,ideal Q,kStrategy strat); |
---|
465 | void completeReduce (kStrategy strat, BOOLEAN withT=FALSE); |
---|
466 | void kFreeStrat(kStrategy strat); |
---|
467 | void enterOnePairNormal (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR); |
---|
468 | void chainCritNormal (poly p,int ecart,kStrategy strat); |
---|
469 | BOOLEAN homogTest(polyset F, int Fmax); |
---|
470 | BOOLEAN newHEdge(polyset S, kStrategy strat); |
---|
471 | // returns index of p in TSet, or -1 if not found |
---|
472 | int kFindInT(poly p, TSet T, int tlength); |
---|
473 | |
---|
474 | // return -1 if no divisor is found |
---|
475 | // number of first divisor, otherwise |
---|
476 | int kFindDivisibleByInT(const TSet &T, const unsigned long* sevT, |
---|
477 | const int tl, const LObject* L, const int start=0); |
---|
478 | // same with S |
---|
479 | int kFindDivisibleByInS(const kStrategy strat, int *max_ind, LObject* L); |
---|
480 | |
---|
481 | int kFindNextDivisibleByInS(const kStrategy strat, int start,int max_ind, LObject* L); |
---|
482 | TObject* |
---|
483 | kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T, |
---|
484 | long ecart = LONG_MAX); |
---|
485 | |
---|
486 | /*************************************************************** |
---|
487 | * |
---|
488 | * stuff to be inlined |
---|
489 | * |
---|
490 | ***************************************************************/ |
---|
491 | |
---|
492 | KINLINE TSet initT (); |
---|
493 | KINLINE TObject** initR(); |
---|
494 | KINLINE unsigned long* initsevT(); |
---|
495 | KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing, omBin bin); |
---|
496 | KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing, omBin bin); |
---|
497 | KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing, omBin bin); |
---|
498 | KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing, omBin bin); |
---|
499 | |
---|
500 | KINLINE poly k_LmInit_currRing_2_tailRing(poly p, ring tailRing); |
---|
501 | KINLINE poly k_LmInit_tailRing_2_currRing(poly p, ring tailRing); |
---|
502 | KINLINE poly k_LmShallowCopyDelete_currRing_2_tailRing(poly p, ring tailRing); |
---|
503 | KINLINE poly k_LmShallowCopyDelete_tailRing_2_currRing(poly p, ring tailRing); |
---|
504 | |
---|
505 | // if exp bound is not violated, return TRUE and |
---|
506 | // get m1 = LCM(LM(p1), LM(p2))/LM(p1) |
---|
507 | // m2 = LCM(LM(p1), LM(p2))/LM(p2) |
---|
508 | // return FALSE and m1 == NULL, m2 == NULL , otherwise |
---|
509 | KINLINE BOOLEAN k_GetLeadTerms(const poly p1, const poly p2, const ring p_r, |
---|
510 | poly &m1, poly &m2, const ring m_r); |
---|
511 | #ifdef HAVE_RINGS |
---|
512 | KINLINE void k_GetStrongLeadTerms(const poly p1, const poly p2, const ring leadRing, |
---|
513 | poly &m1, poly &m2, poly &lcm, const ring taiRing); |
---|
514 | #endif |
---|
515 | #ifdef KDEBUG |
---|
516 | // test strat |
---|
517 | BOOLEAN kTest(kStrategy strat); |
---|
518 | // test strat, and test that S is contained in T |
---|
519 | BOOLEAN kTest_TS(kStrategy strat); |
---|
520 | // test LObject |
---|
521 | BOOLEAN kTest_L(LObject* L, ring tailRing = NULL, |
---|
522 | BOOLEAN testp = FALSE, int lpos = -1, |
---|
523 | TSet T = NULL, int tlength = -1); |
---|
524 | // test TObject |
---|
525 | BOOLEAN kTest_T(TObject* T, ring tailRing = NULL, int tpos = -1, char TN = '?'); |
---|
526 | // test set strat->SevS |
---|
527 | BOOLEAN kTest_S(kStrategy strat); |
---|
528 | #else |
---|
529 | #define kTest(A) ((void)0) |
---|
530 | #define kTest_TS(A) ((void)0) |
---|
531 | #define kTest_T(T) ((void)0) |
---|
532 | #define kTest_S(T) ((void)0) |
---|
533 | #define kTest_L(T) ((void)0) |
---|
534 | #endif |
---|
535 | |
---|
536 | |
---|
537 | /*************************************************************** |
---|
538 | * |
---|
539 | * From kstd2.cc |
---|
540 | * |
---|
541 | ***************************************************************/ |
---|
542 | poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing); |
---|
543 | ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat); |
---|
544 | poly kNF2 (ideal F, ideal Q, poly q, kStrategy strat, int lazyReduce); |
---|
545 | ideal kNF2 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce); |
---|
546 | void initBba(ideal F,kStrategy strat); |
---|
547 | |
---|
548 | /*************************************************************** |
---|
549 | * |
---|
550 | * From kSpolys.cc |
---|
551 | * |
---|
552 | ***************************************************************/ |
---|
553 | // Reduces PR with PW |
---|
554 | // Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR) |
---|
555 | // Changes: PR |
---|
556 | // Const: PW |
---|
557 | // If coef != NULL, then *coef is a/gcd(a,b), where a = LC(PR), b = LC(PW) |
---|
558 | // If strat != NULL, tailRing is changed if reduction would violate exp bound |
---|
559 | // of tailRing |
---|
560 | // Returns: 0 everything ok, no tailRing change |
---|
561 | // 1 tailRing has successfully changed (strat != NULL) |
---|
562 | // 2 no reduction performed, tailRing needs to be changed first |
---|
563 | // (strat == NULL) |
---|
564 | // -1 tailRing change could not be performed due to exceeding exp |
---|
565 | // bound of currRing |
---|
566 | int ksReducePoly(LObject* PR, |
---|
567 | TObject* PW, |
---|
568 | poly spNoether = NULL, |
---|
569 | number *coef = NULL, |
---|
570 | kStrategy strat = NULL); |
---|
571 | |
---|
572 | // Reduces PR at Current->next with PW |
---|
573 | // Assumes PR != NULL, Current contained in PR |
---|
574 | // Current->next != NULL, LM(PW) devides LM(Current->next) |
---|
575 | // Changes: PR |
---|
576 | // Const: PW |
---|
577 | // Return: see ksReducePoly |
---|
578 | int ksReducePolyTail(LObject* PR, |
---|
579 | TObject* PW, |
---|
580 | poly Current, |
---|
581 | poly spNoether = NULL); |
---|
582 | |
---|
583 | KINLINE int ksReducePolyTail(LObject* PR, TObject* PW, LObject* Red); |
---|
584 | |
---|
585 | // Creates S-Poly of Pair |
---|
586 | // Const: Pair->p1, Pair->p2 |
---|
587 | // Changes: Pair->p == S-Poly of p1, p2 |
---|
588 | // Assume: Pair->p1 != NULL && Pair->p2 |
---|
589 | void ksCreateSpoly(LObject* Pair, poly spNoether = NULL, |
---|
590 | int use_buckets=0, ring tailRing=currRing, |
---|
591 | poly m1 = NULL, poly m2 = NULL, TObject** R = NULL); |
---|
592 | |
---|
593 | /*2 |
---|
594 | * creates the leading term of the S-polynomial of p1 and p2 |
---|
595 | * do not destroy p1 and p2 |
---|
596 | * remarks: |
---|
597 | * 1. the coefficient is 0 (nNew) |
---|
598 | * 2. pNext is undefined |
---|
599 | */ |
---|
600 | poly ksCreateShortSpoly(poly p1, poly p2, ring tailRing); |
---|
601 | |
---|
602 | |
---|
603 | // old stuff |
---|
604 | KINLINE poly ksOldSpolyRed(poly p1, poly p2, poly spNoether = NULL); |
---|
605 | KINLINE poly ksOldSpolyRedNew(poly p1, poly p2, poly spNoether = NULL); |
---|
606 | KINLINE poly ksOldCreateSpoly(poly p1, poly p2, poly spNoether = NULL, ring r = currRing); |
---|
607 | KINLINE void ksOldSpolyTail(poly p1, poly q, poly q2, poly spNoether, ring r = currRing); |
---|
608 | |
---|
609 | /*************************************************************** |
---|
610 | * |
---|
611 | * Routines related for ring changes during std computations |
---|
612 | * |
---|
613 | ***************************************************************/ |
---|
614 | // return TRUE and set m1, m2 to k_GetLcmTerms, |
---|
615 | // if spoly creation of strat->P does not violate |
---|
616 | // exponent bound of strat->tailRing |
---|
617 | // FALSE, otherwise |
---|
618 | BOOLEAN kCheckSpolyCreation(LObject* L, kStrategy strat, poly &m1, poly &m2); |
---|
619 | #ifdef HAVE_RINGS |
---|
620 | // return TRUE if gcdpoly creation of R[atR] and S[atS] does not violate |
---|
621 | // exponent bound of strat->tailRing |
---|
622 | // FALSE, otherwise |
---|
623 | BOOLEAN kCheckStrongCreation(int atR, poly m1, int atS, poly m2, kStrategy strat); |
---|
624 | #endif |
---|
625 | // change strat->tailRing and adjust all data in strat, L, and T: |
---|
626 | // new tailRing has larger exponent bound |
---|
627 | // do nothing and return FALSE if exponent bound increase would result in |
---|
628 | // larger exponent bound that that of currRing |
---|
629 | BOOLEAN kStratChangeTailRing(kStrategy strat, |
---|
630 | LObject* L = NULL, TObject* T = NULL, |
---|
631 | // take this as new_expbound: if 0 |
---|
632 | // new expbound is 2*expbound of tailRing |
---|
633 | unsigned long new_expbound = 0); |
---|
634 | // initiate a change of the tailRing of strat -- should be called |
---|
635 | // right before main loop in bba |
---|
636 | void kStratInitChangeTailRing(kStrategy strat); |
---|
637 | |
---|
638 | /// Output some debug info about a given strategy |
---|
639 | void kDebugPrint(kStrategy strat); |
---|
640 | |
---|
641 | |
---|
642 | KINLINE void clearS (poly p, unsigned long p_sev, int* at, int* k, |
---|
643 | kStrategy strat); |
---|
644 | |
---|
645 | #include <kernel/kInline.h> |
---|
646 | |
---|
647 | /* shiftgb stuff */ |
---|
648 | #include <kernel/shiftgb.h> |
---|
649 | |
---|
650 | poly pMove2CurrTail(poly p, kStrategy strat); |
---|
651 | |
---|
652 | poly pMoveCurrTail2poly(poly p, kStrategy strat); |
---|
653 | |
---|
654 | poly pCopyL2p(LObject h, kStrategy strat); |
---|
655 | |
---|
656 | void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV); |
---|
657 | |
---|
658 | void initBuchMoraShift (ideal F,ideal Q,kStrategy strat); |
---|
659 | |
---|
660 | void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV); // ok |
---|
661 | |
---|
662 | void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV); |
---|
663 | |
---|
664 | void 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 |
---|
665 | |
---|
666 | void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV); |
---|
667 | |
---|
668 | void initenterpairsShift (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR,int uptodeg, int lV); |
---|
669 | |
---|
670 | void updateSShift(kStrategy strat,int uptodeg,int lV); |
---|
671 | |
---|
672 | void initBbaShift(ideal F,kStrategy strat); |
---|
673 | |
---|
674 | poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize); |
---|
675 | |
---|
676 | int redFirstShift (LObject* h,kStrategy strat); // ok |
---|
677 | |
---|
678 | ideal freegb(ideal I, int uptodeg, int lVblock); |
---|
679 | |
---|
680 | ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int uptodeg, int lV); |
---|
681 | // test syz strategy: // will be removed soon |
---|
682 | extern int (*test_PosInT)(const TSet T,const int tl,LObject &h); |
---|
683 | extern int (*test_PosInL)(const LSet set, const int length, |
---|
684 | LObject* L,const kStrategy strat); |
---|
685 | #endif |
---|