1 | /**************************************** |
---|
2 | *Â Computer Algebra System SINGULARÂ Â Â * |
---|
3 | ****************************************/ |
---|
4 | /* $Id: kutil.cc,v 1.97 2008-07-07 13:18:56 wienand Exp $ */ |
---|
5 | /* |
---|
6 | * ABSTRACT: kernel: utils for kStd |
---|
7 | */ |
---|
8 | |
---|
9 | #ifndef KUTIL_CC |
---|
10 | #define KUTIL_CC |
---|
11 | |
---|
12 | // #define PDEBUG 2 |
---|
13 | // #define PDIV_DEBUG |
---|
14 | #include <stdlib.h> |
---|
15 | #include <string.h> |
---|
16 | #include "mod2.h" |
---|
17 | #include <mylimits.h> |
---|
18 | #include "structs.h" |
---|
19 | #include "gring.h" |
---|
20 | #include "sca.h" |
---|
21 | #ifdef KDEBUG |
---|
22 | #undef KDEBUG |
---|
23 | #define KDEBUG 2 |
---|
24 | #endif |
---|
25 | |
---|
26 | #ifdef HAVE_RING2TOM |
---|
27 | #include "ideals.h" |
---|
28 | #endif |
---|
29 | |
---|
30 | // define if enterL, enterT should use memmove instead of doing it manually |
---|
31 | // on topgun, this is slightly faster (see monodromy_l.tst, homog_gonnet.sing) |
---|
32 | #ifndef SunOS_4 |
---|
33 | #define ENTER_USE_MEMMOVE |
---|
34 | #endif |
---|
35 | |
---|
36 | // define, if the my_memmove inlines should be used instead of |
---|
37 | // system memmove -- it does not seem to pay off, though |
---|
38 | // #define ENTER_USE_MYMEMMOVE |
---|
39 | |
---|
40 | #include "kutil.h" |
---|
41 | #include "febase.h" |
---|
42 | #include "omalloc.h" |
---|
43 | #include "numbers.h" |
---|
44 | #include "polys.h" |
---|
45 | #include "ring.h" |
---|
46 | #include "ideals.h" |
---|
47 | #include "timer.h" |
---|
48 | //#include "cntrlc.h" |
---|
49 | #include "stairc.h" |
---|
50 | #include "kstd1.h" |
---|
51 | #include "pShallowCopyDelete.h" |
---|
52 | |
---|
53 | /* shiftgb stuff */ |
---|
54 | #include "shiftgb.h" |
---|
55 | #include "prCopy.h" |
---|
56 | |
---|
57 | #ifdef KDEBUG |
---|
58 | #undef KDEBUG |
---|
59 | #define KDEBUG 2 |
---|
60 | #endif |
---|
61 | |
---|
62 | |
---|
63 | #ifdef ENTER_USE_MYMEMMOVE |
---|
64 | inline void _my_memmove_d_gt_s(unsigned long* d, unsigned long* s, long l) |
---|
65 | { |
---|
66 |  register unsigned long* _dl = (unsigned long*) d; |
---|
67 |  register unsigned long* _sl = (unsigned long*) s; |
---|
68 |  register long _i = l - 1; |
---|
69 | |
---|
70 | Â do |
---|
71 | Â { |
---|
72 | Â Â _dl[_i]Â =Â _sl[_i]; |
---|
73 | Â Â _i--; |
---|
74 | Â } |
---|
75 |  while (_i >= 0); |
---|
76 | } |
---|
77 | |
---|
78 | inline void _my_memmove_d_lt_s(unsigned long* d, unsigned long* s, long l) |
---|
79 | { |
---|
80 |  register long _ll = l; |
---|
81 |  register unsigned long* _dl = (unsigned long*) d; |
---|
82 |  register unsigned long* _sl = (unsigned long*) s; |
---|
83 |  register long _i = 0; |
---|
84 | |
---|
85 | Â do |
---|
86 | Â { |
---|
87 | Â Â _dl[_i]Â =Â _sl[_i]; |
---|
88 | Â Â _i++; |
---|
89 | Â } |
---|
90 |  while (_i < _ll); |
---|
91 | } |
---|
92 | |
---|
93 | inline void _my_memmove(void* d, void* s, long l) |
---|
94 | { |
---|
95 |  unsigned long _d = (unsigned long) d; |
---|
96 |  unsigned long _s = (unsigned long) s; |
---|
97 |  unsigned long _l = ((l) + SIZEOF_LONG - 1) >> LOG_SIZEOF_LONG; |
---|
98 | |
---|
99 |  if (_d > _s) _my_memmove_d_gt_s(_d, _s, _l); |
---|
100 |  else _my_memmove_d_lt_s(_d, _s, _l); |
---|
101 | } |
---|
102 | |
---|
103 | #undef memmove |
---|
104 | #define memmove(d,s,l) _my_memmove(d, s, l) |
---|
105 | #endif |
---|
106 | |
---|
107 | static poly redMora (poly h,int maxIndex,kStrategy strat); |
---|
108 | static poly redBba (poly h,int maxIndex,kStrategy strat); |
---|
109 | |
---|
110 | #ifdef HAVE_RINGS |
---|
111 | #define pDivComp_EQUAL 2 |
---|
112 | #define pDivComp_LESS 1 |
---|
113 | #define pDivComp_GREATER -1 |
---|
114 | #define pDivComp_INCOMP 0 |
---|
115 | /* Checks the relation of LM(p) and LM(q) |
---|
116 | Â Â Â LM(p) = LM(q) => return pDivComp_EQUAL |
---|
117 | Â Â Â LM(p) | LM(q) => return pDivComp_LESS |
---|
118 | Â Â Â LM(q) | LM(p) => return pDivComp_GREATER |
---|
119 | Â Â Â else return pDivComp_INCOMP */ |
---|
120 | static inline int pDivCompRing(poly p, poly q) |
---|
121 | { |
---|
122 |  if (pGetComp(p) == pGetComp(q)) |
---|
123 | Â { |
---|
124 |   BOOLEAN a=FALSE, b=FALSE; |
---|
125 |   int i; |
---|
126 |   unsigned long la, lb; |
---|
127 |   unsigned long divmask = currRing->divmask; |
---|
128 |   for (i=0; i<currRing->VarL_Size; i++) |
---|
129 | Â Â { |
---|
130 | Â Â Â la =Â p->exp[currRing->VarL_Offset[i]]; |
---|
131 | Â Â Â lb =Â q->exp[currRing->VarL_Offset[i]]; |
---|
132 |    if (la != lb) |
---|
133 | Â Â Â { |
---|
134 |     if (la < lb) |
---|
135 | Â Â Â Â { |
---|
136 |      if (b) return pDivComp_INCOMP; |
---|
137 |      if (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)) |
---|
138 |       return pDivComp_INCOMP; |
---|
139 | Â Â Â Â Â a =Â TRUE; |
---|
140 | Â Â Â Â } |
---|
141 | Â Â Â Â else |
---|
142 | Â Â Â Â { |
---|
143 |      if (a) return pDivComp_INCOMP; |
---|
144 |      if (((la & divmask) ^ (lb & divmask)) != ((la - lb) & divmask)) |
---|
145 |       return pDivComp_INCOMP; |
---|
146 | Â Â Â Â Â b =Â TRUE; |
---|
147 | Â Â Â Â } |
---|
148 | Â Â Â } |
---|
149 | Â Â } |
---|
150 |   if (a) return pDivComp_LESS; |
---|
151 |   if (b) return pDivComp_GREATER; |
---|
152 |   if (!a & !b) return pDivComp_EQUAL; |
---|
153 | Â } |
---|
154 |  return 0; |
---|
155 | } |
---|
156 | #endif |
---|
157 | |
---|
158 | static inline int pDivComp(poly p, poly q) |
---|
159 | { |
---|
160 |  if (pGetComp(p) == pGetComp(q)) |
---|
161 | Â { |
---|
162 |   BOOLEAN a=FALSE, b=FALSE; |
---|
163 |   int i; |
---|
164 |   unsigned long la, lb; |
---|
165 |   unsigned long divmask = currRing->divmask; |
---|
166 |   for (i=0; i<currRing->VarL_Size; i++) |
---|
167 | Â Â { |
---|
168 | Â Â Â la =Â p->exp[currRing->VarL_Offset[i]]; |
---|
169 | Â Â Â lb =Â q->exp[currRing->VarL_Offset[i]]; |
---|
170 |    if (la != lb) |
---|
171 | Â Â Â { |
---|
172 |     if (la < lb) |
---|
173 | Â Â Â Â { |
---|
174 |      if (b) return 0; |
---|
175 |      if (((la & divmask) ^ (lb & divmask)) != ((lb - la) & divmask)) |
---|
176 |       return 0; |
---|
177 | Â Â Â Â Â a =Â TRUE; |
---|
178 | Â Â Â Â } |
---|
179 | Â Â Â Â else |
---|
180 | Â Â Â Â { |
---|
181 |      if (a) return 0; |
---|
182 |      if (((la & divmask) ^ (lb & divmask)) != ((la - lb) & divmask)) |
---|
183 |       return 0; |
---|
184 | Â Â Â Â Â b =Â TRUE; |
---|
185 | Â Â Â Â } |
---|
186 | Â Â Â } |
---|
187 | Â Â } |
---|
188 |   if (a) return 1; |
---|
189 |   if (b) return -1; |
---|
190 | Â } |
---|
191 |  return 0; |
---|
192 | } |
---|
193 | |
---|
194 | |
---|
195 | BITSETÂ test=(BITSET)0; |
---|
196 | int   HCord; |
---|
197 | int   Kstd1_deg; |
---|
198 | int   mu=32000; |
---|
199 | |
---|
200 | /*2 |
---|
201 | *deletes higher monomial of p, re-compute ecart and length |
---|
202 | *works only for orderings with ecart =pFDeg(end)-pFDeg(start) |
---|
203 | */ |
---|
204 | void deleteHC(LObject *L, kStrategy strat, BOOLEAN fromNext) |
---|
205 | { |
---|
206 |  if (strat->kHEdgeFound) |
---|
207 | Â { |
---|
208 | Â Â kTest_L(L); |
---|
209 | Â Â poly p1; |
---|
210 | Â Â poly p =Â L->GetLmTailRing(); |
---|
211 |   int l = 1; |
---|
212 | Â Â kBucket_pt bucket =Â NULL; |
---|
213 |   if (L->bucket != NULL) |
---|
214 | Â Â { |
---|
215 |    kBucketClear(L->bucket, &pNext(p), &L->pLength); |
---|
216 | Â Â Â L->pLength++; |
---|
217 | Â Â Â bucket =Â L->bucket; |
---|
218 | Â Â Â L->bucket =Â NULL; |
---|
219 | Â Â Â L->last =Â NULL; |
---|
220 | Â Â } |
---|
221 | |
---|
222 |   if (!fromNext && p_Cmp(p,strat->kNoetherTail(), L->tailRing) == -1) |
---|
223 | Â Â { |
---|
224 | Â Â Â L->Delete(); |
---|
225 | Â Â Â L->Clear(); |
---|
226 | Â Â Â L->ecart =Â -1; |
---|
227 |    if (bucket != NULL) kBucketDestroy(&bucket); |
---|
228 | Â Â Â return; |
---|
229 | Â Â } |
---|
230 | Â Â p1 =Â p; |
---|
231 |   while (pNext(p1)!=NULL) |
---|
232 | Â Â { |
---|
233 |    if (p_LmCmp(pNext(p1), strat->kNoetherTail(), L->tailRing) == -1) |
---|
234 | Â Â Â { |
---|
235 | Â Â Â Â L->last =Â p1; |
---|
236 |     p_Delete(&pNext(p1), L->tailRing); |
---|
237 |     if (p1 == p) |
---|
238 | Â Â Â Â { |
---|
239 |      if (L->t_p != NULL) |
---|
240 | Â Â Â Â Â { |
---|
241 | Â Â Â Â Â Â assume(L->p !=Â NULLÂ &&Â p ==Â L->t_p); |
---|
242 | Â Â Â Â Â Â pNext(L->p)Â =Â NULL; |
---|
243 | Â Â Â Â Â } |
---|
244 |      L->max = NULL; |
---|
245 | Â Â Â Â } |
---|
246 |     else if (fromNext) |
---|
247 |      L->max = p_GetMaxExpP(pNext(L->p), L->tailRing ); // p1; |
---|
248 | Â Â Â Â //if (L->pLength != 0) |
---|
249 | Â Â Â Â L->pLength =Â l; |
---|
250 | Â Â Â Â // Hmmm when called from updateT, then only |
---|
251 | Â Â Â Â // reset ecart when cut |
---|
252 |     if (fromNext) |
---|
253 | Â Â Â Â Â L->ecart =Â L->pLDeg()Â -Â L->GetpFDeg(); |
---|
254 | Â Â Â Â break; |
---|
255 | Â Â Â } |
---|
256 | Â Â Â l++; |
---|
257 | Â Â Â pIter(p1); |
---|
258 | Â Â } |
---|
259 |   if (! fromNext) |
---|
260 | Â Â { |
---|
261 | Â Â Â L->SetpFDeg(); |
---|
262 | Â Â Â L->ecart =Â L->pLDeg(strat->LDegLast)Â -Â L->GetpFDeg(); |
---|
263 | Â Â } |
---|
264 |   if (bucket != NULL) |
---|
265 | Â Â { |
---|
266 |    if (L->pLength > 1) |
---|
267 | Â Â Â { |
---|
268 |     kBucketInit(bucket, pNext(p), L->pLength - 1); |
---|
269 | Â Â Â Â pNext(p)Â =Â NULL; |
---|
270 |     if (L->t_p != NULL) pNext(L->t_p) = NULL; |
---|
271 | Â Â Â Â L->pLength =Â 0; |
---|
272 | Â Â Â Â L->bucket =Â bucket; |
---|
273 | Â Â Â Â L->last =Â NULL; |
---|
274 | Â Â Â } |
---|
275 | Â Â Â else |
---|
276 | Â Â Â Â kBucketDestroy(&bucket); |
---|
277 | Â Â } |
---|
278 | Â Â kTest_L(L); |
---|
279 | Â } |
---|
280 | } |
---|
281 | |
---|
282 | void deleteHC(poly* p, int* e, int* l,kStrategy strat) |
---|
283 | { |
---|
284 |  LObject L(*p, currRing, strat->tailRing); |
---|
285 | |
---|
286 |  deleteHC(&L, strat); |
---|
287 | Â *p =Â L.p; |
---|
288 | Â *e =Â L.ecart; |
---|
289 | Â *l =Â L.length; |
---|
290 |  if (L.t_p != NULL) p_LmFree(L.t_p, strat->tailRing); |
---|
291 | } |
---|
292 | |
---|
293 | /*2 |
---|
294 | *tests if p.p=monomial*unit and cancels the unit |
---|
295 | */ |
---|
296 | void cancelunit (LObject* L,BOOLEAN inNF) |
---|
297 | { |
---|
298 |  int i; |
---|
299 | Â poly h; |
---|
300 | |
---|
301 | Â if(currRing->OrdSgn !=Â -1)Â return; |
---|
302 | Â if(TEST_OPT_CANCELUNIT)Â return; |
---|
303 | |
---|
304 | Â ring r =Â L->tailRing; |
---|
305 | Â poly p =Â L->GetLmTailRing(); |
---|
306 | |
---|
307 |  if(p_GetComp(p, r) != 0 && !p_OneComp(p, r)) return; |
---|
308 | |
---|
309 |  if (L->ecart != 0) |
---|
310 | Â { |
---|
311 | //Â Â for(i=r->N;i>0;i--) |
---|
312 | //Â Â { |
---|
313 | //Â Â Â if ((p_GetExp(p,i,r)>0) && (rIsPolyVar(i, r)==TRUE)) return; |
---|
314 | //Â Â } |
---|
315 | Â Â h =Â pNext(p); |
---|
316 | Â Â loop |
---|
317 | Â Â { |
---|
318 |    if (h==NULL) |
---|
319 | Â Â Â { |
---|
320 |     p_Delete(&pNext(p), r); |
---|
321 |     if (!inNF) |
---|
322 | Â Â Â Â { |
---|
323 | Â Â Â Â Â number eins=nInit(1); |
---|
324 |      if (L->p != NULL) pSetCoeff(L->p,eins); |
---|
325 |      else if (L->t_p != NULL) nDelete(&pGetCoeff(L->t_p)); |
---|
326 |      if (L->t_p != NULL) pSetCoeff0(L->t_p,eins); |
---|
327 | Â Â Â Â } |
---|
328 | Â Â Â Â L->ecart =Â 0; |
---|
329 | Â Â Â Â L->length =Â 1; |
---|
330 | Â Â Â Â //if (L->pLength > 0) |
---|
331 | Â Â Â Â L->pLength =Â 1; |
---|
332 |     if (L->last != NULL) L->last = p; |
---|
333 | |
---|
334 |     if (L->t_p != NULL && pNext(L->t_p) != NULL) |
---|
335 | Â Â Â Â Â pNext(L->t_p)Â =Â NULL; |
---|
336 |     if (L->p != NULL && pNext(L->p) != NULL) |
---|
337 | Â Â Â Â Â pNext(L->p)Â =Â NULL; |
---|
338 | Â Â Â Â return; |
---|
339 | Â Â Â } |
---|
340 | Â Â Â i =Â 0; |
---|
341 | Â Â Â loop |
---|
342 | Â Â Â { |
---|
343 | Â Â Â Â i++; |
---|
344 |     if (p_GetExp(p,i,r) > p_GetExp(h,i,r)) return ; // does not divide |
---|
345 |     if (i == r->N) break; // does divide, try next monom |
---|
346 | Â Â Â } |
---|
347 | Â Â Â pIter(h); |
---|
348 | Â Â } |
---|
349 | Â } |
---|
350 | } |
---|
351 | |
---|
352 | /*2 |
---|
353 | *pp is the new element in s |
---|
354 | *returns TRUE (in strat->kHEdgeFound) if |
---|
355 | *-HEcke is allowed |
---|
356 | *-we are in the last componente of the vector |
---|
357 | *-on all axis are monomials (all elements in NotUsedAxis are FALSE) |
---|
358 | *returns FALSE for pLexOrderings, |
---|
359 | *assumes in module case an ordering of type c* !! |
---|
360 | * HEckeTest is only called with strat->kHEdgeFound==FALSE ! |
---|
361 | */ |
---|
362 | void HEckeTest (poly pp,kStrategy strat) |
---|
363 | { |
---|
364 |  int  j,k,p; |
---|
365 | |
---|
366 | Â strat->kHEdgeFound=FALSE; |
---|
367 |  if (pLexOrder || currRing->MixedOrder) |
---|
368 | Â { |
---|
369 | Â Â return; |
---|
370 | Â } |
---|
371 |  if (strat->ak > 1)      /*we are in the module case*/ |
---|
372 | Â { |
---|
373 | Â Â return;Â // until .... |
---|
374 | Â Â //if (!pVectorOut)Â Â Â /*pVectorOut <=> order = c,* */ |
---|
375 | Â Â //Â return FALSE; |
---|
376 | Â Â //if (pGetComp(pp) < strat->ak) /* ak is the number of the last component */ |
---|
377 | Â Â //Â return FALSE; |
---|
378 | Â } |
---|
379 | Â k =Â 0; |
---|
380 | Â p=pIsPurePower(pp); |
---|
381 |  if (p!=0) strat->NotUsedAxis[p] = FALSE; |
---|
382 | Â /*- the leading term of pp is a power of the p-th variable -*/ |
---|
383 |  for (j=pVariables;j>0; j--) |
---|
384 | Â { |
---|
385 |   if (strat->NotUsedAxis[j]) |
---|
386 | Â Â { |
---|
387 | Â Â Â return; |
---|
388 | Â Â } |
---|
389 | Â } |
---|
390 | Â strat->kHEdgeFound=TRUE; |
---|
391 | } |
---|
392 | |
---|
393 | /*2 |
---|
394 | *utilities for TSet, LSet |
---|
395 | */ |
---|
396 | inline static intset initec (const int maxnr) |
---|
397 | { |
---|
398 |  return (intset)omAlloc(maxnr*sizeof(int)); |
---|
399 | } |
---|
400 | |
---|
401 | inline static unsigned long* initsevS (const int maxnr) |
---|
402 | { |
---|
403 |  return (unsigned long*)omAlloc0(maxnr*sizeof(unsigned long)); |
---|
404 | } |
---|
405 | inline static int* initS_2_R (const int maxnr) |
---|
406 | { |
---|
407 |  return (int*)omAlloc0(maxnr*sizeof(int)); |
---|
408 | } |
---|
409 | |
---|
410 | static inline void enlargeT (TSet &T, TObject** &R, unsigned long* &sevT, |
---|
411 |                int &length, const int incr) |
---|
412 | { |
---|
413 | Â assume(T!=NULL); |
---|
414 | Â assume(sevT!=NULL); |
---|
415 | Â assume(R!=NULL); |
---|
416 | Â assume((length+incr)Â >Â 0); |
---|
417 | |
---|
418 |  int i; |
---|
419 |  T = (TSet)omRealloc0Size(T, length*sizeof(TObject), |
---|
420 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â (length+incr)*sizeof(TObject)); |
---|
421 | |
---|
422 |  sevT = (unsigned long*) omReallocSize(sevT, length*sizeof(long*), |
---|
423 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â (length+incr)*sizeof(long*)); |
---|
424 | |
---|
425 | Â R =Â (TObject**)omRealloc0Size(R,length*sizeof(TObject*), |
---|
426 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (length+incr)*sizeof(TObject*)); |
---|
427 |  for (i=length-1;i>=0;i--) R[T[i].i_r] = &(T[i]); |
---|
428 | Â length +=Â incr; |
---|
429 | } |
---|
430 | |
---|
431 | void cleanT (kStrategy strat) |
---|
432 | { |
---|
433 |  int i,j; |
---|
434 |  poly p; |
---|
435 | Â assume(currRing ==Â strat->tailRing ||Â strat->tailRing !=Â NULL); |
---|
436 | |
---|
437 | Â pShallowCopyDeleteProc p_shallow_copy_delete = |
---|
438 | Â Â (strat->tailRing !=Â currRing ? |
---|
439 |    pGetShallowCopyDeleteProc(strat->tailRing, currRing) : |
---|
440 | Â Â Â NULL); |
---|
441 | |
---|
442 |  for (j=0; j<=strat->tl; j++) |
---|
443 | Â { |
---|
444 | Â Â p =Â strat->T[j].p; |
---|
445 | Â Â strat->T[j].p=NULL; |
---|
446 |   if (strat->T[j].max != NULL) |
---|
447 |    p_LmFree(strat->T[j].max, strat->tailRing); |
---|
448 | Â Â i =Â -1; |
---|
449 | Â Â loop |
---|
450 | Â Â { |
---|
451 | Â Â Â i++; |
---|
452 |    if (i>strat->sl) |
---|
453 | Â Â Â { |
---|
454 |     if (strat->T[j].t_p != NULL) |
---|
455 | Â Â Â Â { |
---|
456 |      p_Delete(&(strat->T[j].t_p), strat->tailRing); |
---|
457 |      p_LmFree(p, currRing); |
---|
458 | Â Â Â Â } |
---|
459 | Â Â Â Â else |
---|
460 | Â Â Â Â Â pDelete(&p); |
---|
461 | Â Â Â Â break; |
---|
462 | Â Â Â } |
---|
463 |    if (p == strat->S[i]) |
---|
464 | Â Â Â { |
---|
465 |     if (strat->T[j].t_p != NULL) |
---|
466 | Â Â Â Â { |
---|
467 | Â Â Â Â Â assume(p_shallow_copy_delete !=Â NULL); |
---|
468 | Â Â Â Â Â pNext(p)Â =Â p_shallow_copy_delete(pNext(p),strat->tailRing,currRing, |
---|
469 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â currRing->PolyBin); |
---|
470 |      p_LmFree(strat->T[j].t_p, strat->tailRing); |
---|
471 | Â Â Â Â } |
---|
472 | Â Â Â Â break; |
---|
473 | Â Â Â } |
---|
474 | Â Â } |
---|
475 | Â } |
---|
476 | Â strat->tl=-1; |
---|
477 | } |
---|
478 | |
---|
479 | //LSet initL () |
---|
480 | //{ |
---|
481 | //Â int i; |
---|
482 | //Â LSet l = (LSet)omAlloc(setmaxL*sizeof(LObject)); |
---|
483 | //Â return l; |
---|
484 | //} |
---|
485 | |
---|
486 | static inline void enlargeL (LSet* L,int* length,const int incr) |
---|
487 | { |
---|
488 | Â assume((*L)!=NULL); |
---|
489 | Â assume((length+incr)>0); |
---|
490 | |
---|
491 | Â *L =Â (LSet)omReallocSize((*L),(*length)*sizeof(LObject), |
---|
492 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ((*length)+incr)*sizeof(LObject)); |
---|
493 | Â (*length)Â +=Â incr; |
---|
494 | } |
---|
495 | |
---|
496 | void initPairtest(kStrategy strat) |
---|
497 | { |
---|
498 | Â strat->pairtest =Â (BOOLEAN *)omAlloc0((strat->sl+2)*sizeof(BOOLEAN)); |
---|
499 | } |
---|
500 | |
---|
501 | /*2 |
---|
502 | *test whether (p1,p2) or (p2,p1) is in L up position length |
---|
503 | *it returns TRUE if yes and the position k |
---|
504 | */ |
---|
505 | BOOLEAN isInPairsetL(int length,poly p1,poly p2,int* k,kStrategy strat) |
---|
506 | { |
---|
507 | Â LObject *p=&(strat->L[length]); |
---|
508 | |
---|
509 | Â *k =Â length; |
---|
510 | Â loop |
---|
511 | Â { |
---|
512 |   if ((*k) < 0) return FALSE; |
---|
513 |   if (((p1 == (*p).p1) && (p2 == (*p).p2)) |
---|
514 | Â Â ||Â ((p1 ==Â (*p).p2)Â &&Â (p2 ==Â (*p).p1))) |
---|
515 |    return TRUE; |
---|
516 | Â Â (*k)--; |
---|
517 | Â Â p--; |
---|
518 | Â } |
---|
519 | } |
---|
520 | |
---|
521 | /*2 |
---|
522 | *in B all pairs have the same element p on the right |
---|
523 | *it tests whether (q,p) is in B and returns TRUE if yes |
---|
524 | *and the position k |
---|
525 | */ |
---|
526 | BOOLEAN isInPairsetB(poly q,int*Â k,kStrategy strat) |
---|
527 | { |
---|
528 | Â LObject *p=&(strat->B[strat->Bl]); |
---|
529 | |
---|
530 | Â *k =Â strat->Bl; |
---|
531 | Â loop |
---|
532 | Â { |
---|
533 |   if ((*k) < 0) return FALSE; |
---|
534 |   if (q == (*p).p1) |
---|
535 |    return TRUE; |
---|
536 | Â Â (*k)--; |
---|
537 | Â Â p--; |
---|
538 | Â } |
---|
539 | } |
---|
540 | |
---|
541 | int kFindInT(poly p, TSet T, int tlength) |
---|
542 | { |
---|
543 |  int i; |
---|
544 | |
---|
545 |  for (i=0; i<=tlength; i++) |
---|
546 | Â { |
---|
547 |   if (T[i].p == p) return i; |
---|
548 | Â } |
---|
549 |  return -1; |
---|
550 | } |
---|
551 | |
---|
552 | int kFindInT(poly p, kStrategy strat) |
---|
553 | { |
---|
554 |  int i; |
---|
555 | Â do |
---|
556 | Â { |
---|
557 |   i = kFindInT(p, strat->T, strat->tl); |
---|
558 |   if (i >= 0) return i; |
---|
559 | Â Â strat =Â strat->next; |
---|
560 | Â } |
---|
561 |  while (strat != NULL); |
---|
562 |  return -1; |
---|
563 | } |
---|
564 | |
---|
565 | #ifdef KDEBUG |
---|
566 | |
---|
567 | void sTObject::wrp() |
---|
568 | { |
---|
569 |  if (t_p != NULL) p_wrp(t_p, tailRing); |
---|
570 |  else if (p != NULL) p_wrp(p, currRing, tailRing); |
---|
571 |  else ::wrp(NULL); |
---|
572 | } |
---|
573 | |
---|
574 | #define kFalseReturn(x) do { if (!x) return FALSE;} while (0) |
---|
575 | |
---|
576 | // check that Lm's of a poly from T are "equal" |
---|
577 | static const char* kTest_LmEqual(poly p, poly t_p, ring tailRing) |
---|
578 | { |
---|
579 |  int i; |
---|
580 |  for (i=1; i<=tailRing->N; i++) |
---|
581 | Â { |
---|
582 |   if (p_GetExp(p, i, currRing) != p_GetExp(t_p, i, tailRing)) |
---|
583 |    return "Lm[i] different"; |
---|
584 | Â } |
---|
585 |  if (p_GetComp(p, currRing) != p_GetComp(t_p, tailRing)) |
---|
586 |   return "Lm[0] different"; |
---|
587 |  if (pNext(p) != pNext(t_p)) |
---|
588 |   return "Lm.next different"; |
---|
589 |  if (pGetCoeff(p) != pGetCoeff(t_p)) |
---|
590 |   return "Lm.coeff different"; |
---|
591 |  return NULL; |
---|
592 | } |
---|
593 | |
---|
594 | static BOOLEAN sloppy_max = FALSE; |
---|
595 | BOOLEAN kTest_T(TObject * T, ring strat_tailRing, int i, char TN) |
---|
596 | { |
---|
597 | Â ring tailRing =Â T->tailRing; |
---|
598 |  if (strat_tailRing == NULL) strat_tailRing = tailRing; |
---|
599 | Â r_assume(strat_tailRing ==Â tailRing); |
---|
600 | |
---|
601 | Â poly p =Â T->p; |
---|
602 | Â ring r =Â currRing; |
---|
603 | |
---|
604 |  if (T->p == NULL && T->t_p == NULL && i >= 0) |
---|
605 |   return dReportError("%c[%d].poly is NULL", TN, i); |
---|
606 | |
---|
607 |  if (T->tailRing != currRing) |
---|
608 | Â { |
---|
609 |   if (T->t_p == NULL && i > 0) |
---|
610 |    return dReportError("%c[%d].t_p is NULL", TN, i); |
---|
611 |   pFalseReturn(p_Test(T->t_p, T->tailRing)); |
---|
612 |   if (T->p != NULL) pFalseReturn(p_LmTest(T->p, currRing)); |
---|
613 |   if (T->p != NULL && T->t_p != NULL) |
---|
614 | Â Â { |
---|
615 |    const char* msg = kTest_LmEqual(T->p, T->t_p, T->tailRing); |
---|
616 |    if (msg != NULL) |
---|
617 |     return dReportError("%c[%d] %s", TN, i, msg); |
---|
618 | Â Â Â r =Â T->tailRing; |
---|
619 | Â Â Â p =Â T->t_p; |
---|
620 | Â Â } |
---|
621 |   if (T->p == NULL) |
---|
622 | Â Â { |
---|
623 | Â Â Â p =Â T->t_p; |
---|
624 | Â Â Â r =Â T->tailRing; |
---|
625 | Â Â } |
---|
626 |   if (T->t_p != NULL && i >= 0 && TN == 'T') |
---|
627 | Â Â { |
---|
628 |    if (pNext(T->t_p) == NULL) |
---|
629 | Â Â Â { |
---|
630 |     if (T->max != NULL) |
---|
631 |      return dReportError("%c[%d].max is not NULL as it should be", TN, i); |
---|
632 | Â Â Â } |
---|
633 | Â Â Â else |
---|
634 | Â Â Â { |
---|
635 |     if (T->max == NULL) |
---|
636 |      return dReportError("%c[%d].max is NULL", TN, i); |
---|
637 |     if (pNext(T->max) != NULL) |
---|
638 |      return dReportError("pNext(%c[%d].max) != NULL", TN, i); |
---|
639 | |
---|
640 |     pFalseReturn(p_CheckPolyRing(T->max, tailRing)); |
---|
641 |     omCheckBinAddrSize(T->max, (tailRing->PolyBin->sizeW)*SIZEOF_LONG); |
---|
642 | #if KDEBUG > 0 |
---|
643 |     if (! sloppy_max) |
---|
644 | Â Â Â Â { |
---|
645 |      poly test_max = p_GetMaxExpP(pNext(T->t_p), tailRing); |
---|
646 |      p_Setm(T->max, tailRing); |
---|
647 |      p_Setm(test_max, tailRing); |
---|
648 |      BOOLEAN equal = p_ExpVectorEqual(T->max, test_max, tailRing); |
---|
649 |      if (! equal) |
---|
650 |       return dReportError("%c[%d].max out of sync", TN, i); |
---|
651 |      p_LmFree(test_max, tailRing); |
---|
652 | Â Â Â Â } |
---|
653 | #endif |
---|
654 | Â Â Â } |
---|
655 | Â Â } |
---|
656 | Â } |
---|
657 | Â else |
---|
658 | Â { |
---|
659 |   if (T->max != NULL) |
---|
660 |    return dReportError("%c[%d].max != NULL but tailRing == currRing",TN,i); |
---|
661 |   if (T->t_p != NULL) |
---|
662 |    return dReportError("%c[%d].t_p != NULL but tailRing == currRing",TN,i); |
---|
663 |   if (T->p == NULL && i > 0) |
---|
664 |    return dReportError("%c[%d].p is NULL", TN, i); |
---|
665 |   pFalseReturn(p_Test(T->p, currRing)); |
---|
666 | Â } |
---|
667 | |
---|
668 |  if (i >= 0 && T->pLength != 0 && T->pLength != pLength(p)) |
---|
669 | Â { |
---|
670 |   int l=T->pLength; |
---|
671 | Â Â T->pLength=pLength(p); |
---|
672 |   return dReportError("%c[%d] pLength error: has %d, specified to have %d", |
---|
673 |             TN, i , pLength(p), l); |
---|
674 | Â } |
---|
675 | |
---|
676 |  // check FDeg, for elements in L and T |
---|
677 |  if (i >= 0 && (TN == 'T' || TN == 'L')) |
---|
678 | Â { |
---|
679 | Â Â // FDeg has ir element from T of L set |
---|
680 |   if (T->FDeg != T->pFDeg()) |
---|
681 | Â Â { |
---|
682 |    int d=T->FDeg; |
---|
683 | Â Â Â T->FDeg=T->pFDeg(); |
---|
684 |    return dReportError("%c[%d] FDeg error: has %d, specified to have %d", |
---|
685 |              TN, i , T->pFDeg(), d); |
---|
686 | Â Â } |
---|
687 | Â } |
---|
688 | |
---|
689 | Â // check is_normalized for elements in T |
---|
690 |  if (i >= 0 && TN == 'T') |
---|
691 | Â { |
---|
692 |   if (T->is_normalized && ! nIsOne(pGetCoeff(p))) |
---|
693 |    return dReportError("T[%d] is_normalized error", i); |
---|
694 | |
---|
695 | Â } |
---|
696 |  return TRUE; |
---|
697 | } |
---|
698 | |
---|
699 | BOOLEAN kTest_L(LObject *L, ring strat_tailRing, |
---|
700 |         BOOLEAN testp, int lpos, TSet T, int tlength) |
---|
701 | { |
---|
702 |  if (testp) |
---|
703 | Â { |
---|
704 | Â Â poly pn =Â NULL; |
---|
705 |   if (L->bucket != NULL) |
---|
706 | Â Â { |
---|
707 | Â Â Â kFalseReturn(kbTest(L->bucket)); |
---|
708 | Â Â Â r_assume(L->bucket->bucket_ring ==Â L->tailRing); |
---|
709 |    if (L->p != NULL && pNext(L->p) != NULL) |
---|
710 | Â Â Â { |
---|
711 | Â Â Â Â pn =Â pNext(L->p); |
---|
712 | Â Â Â Â pNext(L->p)Â =Â NULL; |
---|
713 | Â Â Â } |
---|
714 | Â Â } |
---|
715 |   kFalseReturn(kTest_T(L, strat_tailRing, lpos, 'L')); |
---|
716 |   if (pn != NULL) |
---|
717 | Â Â Â pNext(L->p)Â =Â pn; |
---|
718 | |
---|
719 | Â Â ring r; |
---|
720 | Â Â poly p; |
---|
721 |   L->GetLm(p, r); |
---|
722 |   if (L->sev != 0 && p_GetShortExpVector(p, r) != L->sev) |
---|
723 | Â Â { |
---|
724 |    return dReportError("L[%d] wrong sev: has %o, specified to have %o", |
---|
725 |              lpos, p_GetShortExpVector(p, r), L->sev); |
---|
726 | Â Â } |
---|
727 |   if (lpos > 0 && L->last != NULL && pLast(p) != L->last) |
---|
728 | Â Â { |
---|
729 |    return dReportError("L[%d] last wrong: has %p specified to have %p", |
---|
730 |              lpos, pLast(p), L->last); |
---|
731 | Â Â } |
---|
732 | Â } |
---|
733 |  if (L->p1 == NULL) |
---|
734 | Â { |
---|
735 | Â Â // L->p2 either NULL or "normal" poly |
---|
736 |   pFalseReturn(pp_Test(L->p2, currRing, L->tailRing)); |
---|
737 | Â } |
---|
738 |  else if (tlength > 0 && T != NULL && (lpos >=0)) |
---|
739 | Â { |
---|
740 | Â Â // now p1 and p2 must be != NULL and must be contained in T |
---|
741 |   int i; |
---|
742 |   i = kFindInT(L->p1, T, tlength); |
---|
743 |   if (i < 0) |
---|
744 |    return dReportError("L[%d].p1 not in T",lpos); |
---|
745 |   i = kFindInT(L->p2, T, tlength); |
---|
746 |   if (i < 0) |
---|
747 |    return dReportError("L[%d].p2 not in T",lpos); |
---|
748 | Â } |
---|
749 |  return TRUE; |
---|
750 | } |
---|
751 | |
---|
752 | BOOLEAN kTest (kStrategy strat) |
---|
753 | { |
---|
754 |  int i; |
---|
755 | |
---|
756 | Â // test P |
---|
757 |  kFalseReturn(kTest_L(&(strat->P), strat->tailRing, |
---|
758 | Â Â Â Â Â Â Â Â Â Â Â Â (strat->P.p !=Â NULLÂ &&Â pNext(strat->P.p)!=strat->tail), |
---|
759 |             -1, strat->T, strat->tl)); |
---|
760 | |
---|
761 | Â // test T |
---|
762 |  if (strat->T != NULL) |
---|
763 | Â { |
---|
764 |   for (i=0; i<=strat->tl; i++) |
---|
765 | Â Â { |
---|
766 |    kFalseReturn(kTest_T(&(strat->T[i]), strat->tailRing, i, 'T')); |
---|
767 |    if (strat->sevT[i] != pGetShortExpVector(strat->T[i].p)) |
---|
768 |     return dReportError("strat->sevT[%d] out of sync", i); |
---|
769 | Â Â } |
---|
770 | Â } |
---|
771 | |
---|
772 | Â // test L |
---|
773 |  if (strat->L != NULL) |
---|
774 | Â { |
---|
775 |   for (i=0; i<=strat->Ll; i++) |
---|
776 | Â Â { |
---|
777 |    kFalseReturn(kTest_L(&(strat->L[i]), strat->tailRing, |
---|
778 |               strat->L[i].Next() != strat->tail, i, |
---|
779 |               strat->T, strat->tl)); |
---|
780 |    if (strat->use_buckets && strat->L[i].Next() != strat->tail && |
---|
781 | Â Â Â Â Â strat->L[i].Next()Â !=Â NULLÂ &&Â strat->L[i].p1 !=Â NULL) |
---|
782 | Â Â Â { |
---|
783 | Â Â Â Â assume(strat->L[i].bucket !=Â NULL); |
---|
784 | Â Â Â } |
---|
785 | Â Â } |
---|
786 | Â } |
---|
787 | |
---|
788 | Â // test S |
---|
789 |  if (strat->S != NULL) |
---|
790 | Â Â kFalseReturn(kTest_S(strat)); |
---|
791 | |
---|
792 |  return TRUE; |
---|
793 | } |
---|
794 | |
---|
795 | BOOLEAN kTest_S(kStrategy strat) |
---|
796 | { |
---|
797 |  int i; |
---|
798 | Â BOOLEAN ret =Â TRUE; |
---|
799 |  for (i=0; i<=strat->sl; i++) |
---|
800 | Â { |
---|
801 |   if (strat->S[i] != NULL && |
---|
802 | Â Â Â Â strat->sevS[i]Â !=Â pGetShortExpVector(strat->S[i])) |
---|
803 | Â Â { |
---|
804 |    return dReportError("S[%d] wrong sev: has %o, specified to have %o", |
---|
805 |              i , pGetShortExpVector(strat->S[i]), strat->sevS[i]); |
---|
806 | Â Â } |
---|
807 | Â } |
---|
808 |  return ret; |
---|
809 | } |
---|
810 | |
---|
811 | |
---|
812 | |
---|
813 | BOOLEAN kTest_TS(kStrategy strat) |
---|
814 | { |
---|
815 |  int i, j; |
---|
816 | Â BOOLEAN ret =Â TRUE; |
---|
817 | Â kFalseReturn(kTest(strat)); |
---|
818 | |
---|
819 | Â // test strat->R, strat->T[i].i_r |
---|
820 |  for (i=0; i<=strat->tl; i++) |
---|
821 | Â { |
---|
822 |   if (strat->T[i].i_r < 0 || strat->T[i].i_r > strat->tl) |
---|
823 |    return dReportError("strat->T[%d].i_r == %d out of bounds", i, |
---|
824 | Â Â Â Â Â Â Â Â Â Â Â Â Â strat->T[i].i_r); |
---|
825 |   if (strat->R[strat->T[i].i_r] != &(strat->T[i])) |
---|
826 |    return dReportError("T[%d].i_r with R out of sync", i); |
---|
827 | Â } |
---|
828 | Â // test containment of S inT |
---|
829 |  if (strat->S != NULL) |
---|
830 | Â { |
---|
831 |   for (i=0; i<=strat->sl; i++) |
---|
832 | Â Â { |
---|
833 |    j = kFindInT(strat->S[i], strat->T, strat->tl); |
---|
834 |    if (j < 0) |
---|
835 |     return dReportError("S[%d] not in T", i); |
---|
836 |    if (strat->S_2_R[i] != strat->T[j].i_r) |
---|
837 |     return dReportError("S_2_R[%d]=%d != T[%d].i_r=%d\n", |
---|
838 |               i, strat->S_2_R[i], j, strat->T[j].i_r); |
---|
839 | Â Â } |
---|
840 | Â } |
---|
841 | Â // test strat->L[i].i_r1 |
---|
842 |  for (i=0; i<=strat->Ll; i++) |
---|
843 | Â { |
---|
844 |   if (strat->L[i].p1 != NULL && strat->L[i].p2) |
---|
845 | Â Â { |
---|
846 |    if (strat->L[i].i_r1 < 0 || |
---|
847 | Â Â Â Â Â strat->L[i].i_r1 >Â strat->tl || |
---|
848 | Â Â Â Â Â strat->L[i].T_1(strat)->p !=Â strat->L[i].p1) |
---|
849 |     return dReportError("L[%d].i_r1 out of sync", i); |
---|
850 |    if (strat->L[i].i_r2 < 0 || |
---|
851 | Â Â Â Â Â strat->L[i].i_r2 >Â strat->tl || |
---|
852 | Â Â Â Â Â strat->L[i].T_2(strat)->p !=Â strat->L[i].p2); |
---|
853 | Â Â } |
---|
854 | Â Â else |
---|
855 | Â Â { |
---|
856 |    if (strat->L[i].i_r1 != -1) |
---|
857 |     return dReportError("L[%d].i_r1 out of sync", i); |
---|
858 |    if (strat->L[i].i_r2 != -1) |
---|
859 |     return dReportError("L[%d].i_r2 out of sync", i); |
---|
860 | Â Â } |
---|
861 |   if (strat->L[i].i_r != -1) |
---|
862 |    return dReportError("L[%d].i_r out of sync", i); |
---|
863 | Â } |
---|
864 |  return TRUE; |
---|
865 | } |
---|
866 | |
---|
867 | #endif // KDEBUG |
---|
868 | |
---|
869 | /*2 |
---|
870 | *cancels the i-th polynomial in the standardbase s |
---|
871 | */ |
---|
872 | void deleteInS (int i,kStrategy strat) |
---|
873 | { |
---|
874 | #ifdef ENTER_USE_MEMMOVE |
---|
875 |  memmove(&(strat->S[i]), &(strat->S[i+1]), (strat->sl - i)*sizeof(poly)); |
---|
876 | Â memmove(&(strat->ecartS[i]),&(strat->ecartS[i+1]),(strat->sl -Â i)*sizeof(int)); |
---|
877 | Â memmove(&(strat->sevS[i]),&(strat->sevS[i+1]),(strat->sl -Â i)*sizeof(long)); |
---|
878 | Â memmove(&(strat->S_2_R[i]),&(strat->S_2_R[i+1]),(strat->sl -Â i)*sizeof(int)); |
---|
879 | #else |
---|
880 |  int j; |
---|
881 |  for (j=i; j<strat->sl; j++) |
---|
882 | Â { |
---|
883 | Â Â strat->S[j]Â =Â strat->S[j+1]; |
---|
884 | Â Â strat->ecartS[j]Â =Â strat->ecartS[j+1]; |
---|
885 | Â Â strat->sevS[j]Â =Â strat->sevS[j+1]; |
---|
886 | Â Â strat->S_2_R[j]Â =Â strat->S_2_R[j+1]; |
---|
887 | Â } |
---|
888 | #endif |
---|
889 |  if (strat->lenS!=NULL) |
---|
890 | Â { |
---|
891 | #ifdef ENTER_USE_MEMMOVE |
---|
892 | Â Â memmove(&(strat->lenS[i]),&(strat->lenS[i+1]),(strat->sl -Â i)*sizeof(int)); |
---|
893 | #else |
---|
894 |   for (j=i; j<strat->sl; j++) strat->lenS[j] = strat->lenS[j+1]; |
---|
895 | #endif |
---|
896 | Â } |
---|
897 |  if (strat->lenSw!=NULL) |
---|
898 | Â { |
---|
899 | #ifdef ENTER_USE_MEMMOVE |
---|
900 | Â Â memmove(&(strat->lenSw[i]),&(strat->lenSw[i+1]),(strat->sl -Â i)*sizeof(wlen_type)); |
---|
901 | #else |
---|
902 |   for (j=i; j<strat->sl; j++) strat->lenSw[j] = strat->lenSw[j+1]; |
---|
903 | #endif |
---|
904 | Â } |
---|
905 |  if (strat->fromQ!=NULL) |
---|
906 | Â { |
---|
907 | #ifdef ENTER_USE_MEMMOVE |
---|
908 | Â Â memmove(&(strat->fromQ[i]),&(strat->fromQ[i+1]),(strat->sl -Â i)*sizeof(int)); |
---|
909 | #else |
---|
910 |   for (j=i; j<strat->sl; j++) |
---|
911 | Â Â { |
---|
912 | Â Â Â strat->fromQ[j]Â =Â strat->fromQ[j+1]; |
---|
913 | Â Â } |
---|
914 | #endif |
---|
915 | Â } |
---|
916 | Â strat->S[strat->sl]Â =Â NULL; |
---|
917 | Â strat->sl--; |
---|
918 | } |
---|
919 | |
---|
920 | /*2 |
---|
921 | *cancels the j-th polynomial in the set |
---|
922 | */ |
---|
923 | void deleteInL (LSet set, int *length, int j,kStrategy strat) |
---|
924 | { |
---|
925 |  if (set[j].lcm!=NULL) |
---|
926 | Â { |
---|
927 | #ifdef HAVE_RINGS |
---|
928 |   if (pGetCoeff(set[j].lcm) != NULL) |
---|
929 | Â Â Â pLmDelete(set[j].lcm); |
---|
930 | Â Â else |
---|
931 | #endif |
---|
932 | Â Â Â pLmFree(set[j].lcm); |
---|
933 | Â } |
---|
934 |  if (set[j].p!=NULL) |
---|
935 | Â { |
---|
936 |   if (pNext(set[j].p) == strat->tail) |
---|
937 | Â Â { |
---|
938 | #ifdef HAVE_RINGS |
---|
939 |    if (pGetCoeff(set[j].p) != NULL) |
---|
940 | Â Â Â Â pLmDelete(set[j].p); |
---|
941 | Â Â Â else |
---|
942 | #endif |
---|
943 | Â Â Â Â pLmFree(set[j].p); |
---|
944 | Â Â Â /*- tail belongs to several int spolys -*/ |
---|
945 | Â Â } |
---|
946 | Â Â else |
---|
947 | Â Â { |
---|
948 | Â Â Â // search p in T, if it is there, do not delete it |
---|
949 |    if (pOrdSgn != -1 || kFindInT(set[j].p, strat) < 0) |
---|
950 | Â Â Â { |
---|
951 | Â Â Â Â // assure that for global orderings kFindInT fails |
---|
952 |     assume(pOrdSgn == -1 || kFindInT(set[j].p, strat) < 0); |
---|
953 | Â Â Â Â set[j].Delete(); |
---|
954 | Â Â Â } |
---|
955 | Â Â } |
---|
956 | Â } |
---|
957 |  if (*length > 0 && j < *length) |
---|
958 | Â { |
---|
959 | #ifdef ENTER_USE_MEMMOVE |
---|
960 |   memmove(&(set[j]), &(set[j+1]), (*length - j)*sizeof(LObject)); |
---|
961 | #else |
---|
962 |   int i; |
---|
963 |   for (i=j; i < (*length); i++) |
---|
964 | Â Â Â set[i]Â =Â set[i+1]; |
---|
965 | #endif |
---|
966 | Â } |
---|
967 | #ifdef KDEBUG |
---|
968 | Â memset(&(set[*length]),0,sizeof(LObject)); |
---|
969 | #endif |
---|
970 | Â (*length)--; |
---|
971 | } |
---|
972 | |
---|
973 | /*2 |
---|
974 | *enters p at position at in L |
---|
975 | */ |
---|
976 | void enterL (LSet *set,int *length, int *LSetmax, LObject p,int at) |
---|
977 | { |
---|
978 | #ifdef PDEBUG |
---|
979 | Â /*Â zaehler++; */ |
---|
980 | #endif /*PDEBUG*/ |
---|
981 |  int i; |
---|
982 | Â // this should be corrected |
---|
983 | Â assume(p.FDeg ==Â p.pFDeg()); |
---|
984 | |
---|
985 |  if ((*length)>=0) |
---|
986 | Â { |
---|
987 |   if ((*length) == (*LSetmax)-1) enlargeL(set,LSetmax,setmaxLinc); |
---|
988 |   if (at <= (*length)) |
---|
989 | #ifdef ENTER_USE_MEMMOVE |
---|
990 |    memmove(&((*set)[at+1]), &((*set)[at]), ((*length)-at+1)*sizeof(LObject)); |
---|
991 | #else |
---|
992 |   for (i=(*length)+1; i>=at+1; i--) (*set)[i] = (*set)[i-1]; |
---|
993 | #endif |
---|
994 | Â } |
---|
995 |  else at = 0; |
---|
996 | Â (*set)[at]Â =Â p; |
---|
997 | Â (*length)++; |
---|
998 | } |
---|
999 | |
---|
1000 | /*2 |
---|
1001 | * computes the normal ecart; |
---|
1002 | * used in mora case and if pLexOrder & sugar in bba case |
---|
1003 | */ |
---|
1004 | void initEcartNormal (LObject* h) |
---|
1005 | { |
---|
1006 | Â h->FDeg =Â h->pFDeg(); |
---|
1007 | Â h->ecart =Â h->pLDeg()Â -Â h->FDeg; |
---|
1008 | Â // h->length is set by h->pLDeg |
---|
1009 | Â h->length=h->pLength=pLength(h->p); |
---|
1010 | } |
---|
1011 | |
---|
1012 | void initEcartBBA (LObject* h) |
---|
1013 | { |
---|
1014 | Â h->FDeg =Â h->pFDeg(); |
---|
1015 | Â (*h).ecart =Â 0; |
---|
1016 | Â h->length=h->pLength=pLength(h->p); |
---|
1017 | } |
---|
1018 | |
---|
1019 | void initEcartPairBba (LObject* Lp,poly f,poly g,int ecartF,int ecartG) |
---|
1020 | { |
---|
1021 | Â Lp->FDeg =Â Lp->pFDeg(); |
---|
1022 | Â (*Lp).ecart =Â 0; |
---|
1023 | Â (*Lp).length =Â 0; |
---|
1024 | } |
---|
1025 | |
---|
1026 | void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG) |
---|
1027 | { |
---|
1028 | Â Lp->FDeg =Â Lp->pFDeg(); |
---|
1029 | Â (*Lp).ecart =Â si_max(ecartF,ecartG); |
---|
1030 | Â (*Lp).ecart =Â (*Lp).ecart-Â (Lp->FDeg -pFDeg((*Lp).lcm,currRing)); |
---|
1031 | Â (*Lp).length =Â 0; |
---|
1032 | } |
---|
1033 | |
---|
1034 | /*2 |
---|
1035 | *if ecart1<=ecart2 it returns TRUE |
---|
1036 | */ |
---|
1037 | static inline BOOLEAN sugarDivisibleBy(int ecart1, int ecart2) |
---|
1038 | { |
---|
1039 |  return (ecart1 <= ecart2); |
---|
1040 | } |
---|
1041 | |
---|
1042 | #ifdef HAVE_RINGS |
---|
1043 | /*2 |
---|
1044 | * put the pair (s[i],p)Â into the set B, ecart=ecart(p) (ring case) |
---|
1045 | */ |
---|
1046 | void enterOnePairRing (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR = -1) |
---|
1047 | { |
---|
1048 | Â assume(i<=strat->sl); |
---|
1049 |  int   l,j,compare,compareCoeff; |
---|
1050 |  LObject Lp; |
---|
1051 | |
---|
1052 |  if (strat->interred_flag) return; |
---|
1053 | #ifdef KDEBUG |
---|
1054 | Â Lp.ecart=0;Â Lp.length=0; |
---|
1055 | #endif |
---|
1056 | Â /*- computes the lcm(s[i],p) -*/ |
---|
1057 | Â Lp.lcm =Â pInit(); |
---|
1058 |  pSetCoeff0(Lp.lcm, nLcm(pGetCoeff(p), pGetCoeff(strat->S[i]), currRing)); |
---|
1059 | Â // Lp.lcm == 0 |
---|
1060 |  if (nIsZero(pGetCoeff(Lp.lcm))) |
---|
1061 | Â { |
---|
1062 | #ifdef KDEBUG |
---|
1063 |    if (TEST_OPT_DEBUG) |
---|
1064 | Â Â Â { |
---|
1065 | Â Â Â Â PrintS("--- Lp.lcm == 0\n"); |
---|
1066 | Â Â Â Â PrintS("p:"); |
---|
1067 | Â Â Â Â wrp(p); |
---|
1068 |     Print(" strat->S[%d]:", i); |
---|
1069 | Â Â Â Â wrp(strat->S[i]); |
---|
1070 | Â Â Â Â PrintLn(); |
---|
1071 | Â Â Â } |
---|
1072 | #endif |
---|
1073 | Â Â Â strat->cp++; |
---|
1074 | Â Â Â pLmDelete(Lp.lcm); |
---|
1075 | Â Â Â return; |
---|
1076 | Â } |
---|
1077 | Â // basic product criterion |
---|
1078 | Â pLcm(p,strat->S[i],Lp.lcm); |
---|
1079 | Â pSetm(Lp.lcm); |
---|
1080 | Â assume(!strat->sugarCrit); |
---|
1081 |  if (pHasNotCF(p,strat->S[i]) && nIsUnit(pGetCoeff(p)) && nIsUnit(pGetCoeff(strat->S[i]))) |
---|
1082 | Â { |
---|
1083 | #ifdef KDEBUG |
---|
1084 |    if (TEST_OPT_DEBUG) |
---|
1085 | Â Â Â { |
---|
1086 | Â Â Â Â PrintS("--- product criterion func enterOnePairRing type 1\n"); |
---|
1087 | Â Â Â Â PrintS("p:"); |
---|
1088 | Â Â Â Â wrp(p); |
---|
1089 |     Print(" strat->S[%d]:", i); |
---|
1090 | Â Â Â Â wrp(strat->S[i]); |
---|
1091 | Â Â Â Â PrintLn(); |
---|
1092 | Â Â Â } |
---|
1093 | #endif |
---|
1094 | Â Â Â strat->cp++; |
---|
1095 | Â Â Â pLmDelete(Lp.lcm); |
---|
1096 | Â Â Â return; |
---|
1097 | Â } |
---|
1098 | Â assume(!strat->fromT); |
---|
1099 | Â /* |
---|
1100 | Â *the set B collects the pairs of type (S[j],p) |
---|
1101 | Â *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p) |
---|
1102 | Â *if the leading term of s devides lcm(r,p) then (r,p) will be canceled |
---|
1103 | Â *if the leading term of r devides lcm(s,p) then (s,p) will not enter B |
---|
1104 | Â */ |
---|
1105 | Â for(j =Â strat->Bl;j>=0;j--) |
---|
1106 | Â { |
---|
1107 | Â Â compare=pDivCompRing(strat->B[j].lcm,Lp.lcm); |
---|
1108 |   compareCoeff = nDivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(Lp.lcm)); |
---|
1109 |   if (compareCoeff == 0 || compare == compareCoeff) |
---|
1110 | Â Â { |
---|
1111 |    if (compare == 1) |
---|
1112 | Â Â Â { |
---|
1113 | Â Â Â Â strat->c3++; |
---|
1114 | #ifdef KDEBUG |
---|
1115 |     if (TEST_OPT_DEBUG) |
---|
1116 | Â Â Â Â { |
---|
1117 | Â Â Â Â Â PrintS("--- chain criterion type 1\n"); |
---|
1118 | Â Â Â Â Â PrintS("strat->B[j]:"); |
---|
1119 | Â Â Â Â Â wrp(strat->B[j].lcm); |
---|
1120 | Â Â Â Â Â PrintS("Â Lp.lcm:"); |
---|
1121 | Â Â Â Â Â wrp(Lp.lcm); |
---|
1122 | Â Â Â Â Â PrintLn(); |
---|
1123 | Â Â Â Â } |
---|
1124 | #endif |
---|
1125 |     if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0)) |
---|
1126 | Â Â Â Â { |
---|
1127 | Â Â Â Â Â pLmDelete(Lp.lcm); |
---|
1128 | Â Â Â Â Â return; |
---|
1129 | Â Â Â Â } |
---|
1130 | Â Â Â Â break; |
---|
1131 | Â Â Â } |
---|
1132 | Â Â Â else |
---|
1133 |    if (compare == -1) |
---|
1134 | Â Â Â { |
---|
1135 | #ifdef KDEBUG |
---|
1136 |     if (TEST_OPT_DEBUG) |
---|
1137 | Â Â Â Â { |
---|
1138 | Â Â Â Â Â PrintS("--- chain criterion type 2\n"); |
---|
1139 | Â Â Â Â Â Print("strat->B[%d].lcm:",j); |
---|
1140 | Â Â Â Â Â wrp(strat->B[j].lcm); |
---|
1141 | Â Â Â Â Â PrintS("Â Lp.lcm:"); |
---|
1142 | Â Â Â Â Â wrp(Lp.lcm); |
---|
1143 | Â Â Â Â Â PrintLn(); |
---|
1144 | Â Â Â Â } |
---|
1145 | #endif |
---|
1146 | Â Â Â Â deleteInL(strat->B,&strat->Bl,j,strat); |
---|
1147 | Â Â Â Â strat->c3++; |
---|
1148 | Â Â Â } |
---|
1149 | Â Â } |
---|
1150 |   if ((compare == pDivComp_EQUAL) && (compareCoeff != 2)) |
---|
1151 | Â Â { |
---|
1152 |    if (compareCoeff == pDivComp_LESS) |
---|
1153 | Â Â Â { |
---|
1154 | #ifdef KDEBUG |
---|
1155 |     if (TEST_OPT_DEBUG) |
---|
1156 | Â Â Â Â { |
---|
1157 | Â Â Â Â Â PrintS("--- chain criterion type 3\n"); |
---|
1158 |      Print("strat->B[%d].lcm:", j); |
---|
1159 | Â Â Â Â Â wrp(strat->B[j].lcm); |
---|
1160 | Â Â Â Â Â PrintS("Â Lp.lcm:"); |
---|
1161 | Â Â Â Â Â wrp(Lp.lcm); |
---|
1162 | Â Â Â Â Â PrintLn(); |
---|
1163 | Â Â Â Â } |
---|
1164 | #endif |
---|
1165 | Â Â Â Â strat->c3++; |
---|
1166 |     if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0)) |
---|
1167 | Â Â Â Â { |
---|
1168 | Â Â Â Â Â pLmDelete(Lp.lcm); |
---|
1169 | Â Â Â Â Â return; |
---|
1170 | Â Â Â Â } |
---|
1171 | Â Â Â Â break; |
---|
1172 | Â Â Â } |
---|
1173 | Â Â Â else |
---|
1174 | Â Â Â // Add hint for same LM and LC (later) (TODO Oliver) |
---|
1175 | Â Â Â // if (compareCoeff == pDivComp_GREATER) |
---|
1176 | Â Â Â { |
---|
1177 | #ifdef KDEBUG |
---|
1178 |     if (TEST_OPT_DEBUG) |
---|
1179 | Â Â Â Â { |
---|
1180 | Â Â Â Â Â PrintS("--- chain criterion type 4\n"); |
---|
1181 |      Print("strat->B[%d].lcm:", j); |
---|
1182 | Â Â Â Â Â wrp(strat->B[j].lcm); |
---|
1183 | Â Â Â Â Â PrintS("Â Lp.lcm:"); |
---|
1184 | Â Â Â Â Â wrp(Lp.lcm); |
---|
1185 | Â Â Â Â Â PrintLn(); |
---|
1186 | Â Â Â Â } |
---|
1187 | #endif |
---|
1188 | Â Â Â Â deleteInL(strat->B,&strat->Bl,j,strat); |
---|
1189 | Â Â Â Â strat->c3++; |
---|
1190 | Â Â Â } |
---|
1191 | Â Â } |
---|
1192 | Â } |
---|
1193 | Â /* |
---|
1194 | Â *the pair (S[i],p) enters B if the spoly != 0 |
---|
1195 | Â */ |
---|
1196 | Â /*-Â compute the short s-polynomial -*/ |
---|
1197 |  if ((strat->S[i]==NULL) || (p==NULL)) { |
---|
1198 | #ifdef KDEBUG |
---|
1199 |   if (TEST_OPT_DEBUG) |
---|
1200 | Â Â { |
---|
1201 | Â Â Â PrintS("--- spoly = NULL\n"); |
---|
1202 | Â Â } |
---|
1203 | #endif |
---|
1204 | Â Â pLmDelete(Lp.lcm); |
---|
1205 | Â Â return; |
---|
1206 | Â } |
---|
1207 |  if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0)) |
---|
1208 | Â { |
---|
1209 | Â Â // Is from a previous computed GB, therefore we know that spoly will |
---|
1210 | Â Â // reduce to zero. Oliver. |
---|
1211 | Â Â WarnS("Could we come here? 8738947389"); |
---|
1212 | Â Â Lp.p=NULL; |
---|
1213 | Â } |
---|
1214 | Â else |
---|
1215 | Â { |
---|
1216 |   Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing); |
---|
1217 | Â } |
---|
1218 |  if (Lp.p == NULL) |
---|
1219 | Â { |
---|
1220 | #ifdef KDEBUG |
---|
1221 |   if (TEST_OPT_DEBUG) |
---|
1222 | Â Â { |
---|
1223 | Â Â Â PrintS("--- spoly = NULL\n"); |
---|
1224 | Â Â } |
---|
1225 | #endif |
---|
1226 | Â Â /*- the case that the s-poly is 0 -*/ |
---|
1227 |   if (strat->pairtest==NULL) initPairtest(strat); |
---|
1228 | Â Â strat->pairtest[i]Â =Â TRUE;/*- hint for spoly(S^[i],p)=0 -*/ |
---|
1229 | Â Â strat->pairtest[strat->sl+1]Â =Â TRUE; |
---|
1230 | Â Â /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/ |
---|
1231 | Â Â /* |
---|
1232 | Â Â *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is |
---|
1233 | Â Â *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not |
---|
1234 | Â Â *devide lcm(r,p)). In the last case (s,r) can be canceled if the leading |
---|
1235 | Â Â *term of p devides the lcm(s,r) |
---|
1236 | Â Â *(this canceling should be done here because |
---|
1237 | Â Â *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit) |
---|
1238 | Â Â *the first case is handeled in chainCrit |
---|
1239 | Â Â */ |
---|
1240 | Â Â pLmDelete(Lp.lcm); |
---|
1241 | Â } |
---|
1242 | Â else |
---|
1243 | Â { |
---|
1244 | Â Â /*- the pair (S[i],p) enters B -*/ |
---|
1245 | Â Â Lp.p1 =Â strat->S[i]; |
---|
1246 | Â Â Lp.p2 =Â p; |
---|
1247 | |
---|
1248 | Â Â pNext(Lp.p)Â =Â strat->tail; |
---|
1249 | |
---|
1250 |   if (atR >= 0) |
---|
1251 | Â Â { |
---|
1252 | Â Â Â Lp.i_r2 =Â atR; |
---|
1253 | Â Â Â Lp.i_r1 =Â strat->S_2_R[i]; |
---|
1254 | Â Â } |
---|
1255 | Â Â strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart); |
---|
1256 | Â Â l =Â strat->posInL(strat->B,strat->Bl,&Lp,strat); |
---|
1257 | Â Â enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l); |
---|
1258 | Â } |
---|
1259 | } |
---|
1260 | |
---|
1261 | |
---|
1262 | /*2 |
---|
1263 | * put the lcm(s[i],p) into the set B |
---|
1264 | */ |
---|
1265 | |
---|
1266 | BOOLEAN enterOneStrongPoly (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR = -1) |
---|
1267 | { |
---|
1268 |  number d, s, t; |
---|
1269 | Â assume(i<=strat->sl); |
---|
1270 |  LObject Lp; |
---|
1271 |  poly m1, m2, erg, gcd; |
---|
1272 | |
---|
1273 |  d = nExtGcd(pGetCoeff(p), pGetCoeff(strat->S[i]), &s, &t); |
---|
1274 | |
---|
1275 |  if (nIsZero(s) || nIsZero(t)) // evtl. durch divBy tests ersetzen |
---|
1276 | Â { |
---|
1277 | Â Â nDelete(&d); |
---|
1278 | Â Â nDelete(&s); |
---|
1279 | Â Â nDelete(&t); |
---|
1280 |   return FALSE; |
---|
1281 | Â } |
---|
1282 | |
---|
1283 |  k_GetStrongLeadTerms(p, strat->S[i], currRing, m1, m2, gcd, strat->tailRing); |
---|
1284 | |
---|
1285 |  pSetCoeff0(m1, s); |
---|
1286 |  pSetCoeff0(m2, t); |
---|
1287 |  pSetCoeff0(gcd, d); |
---|
1288 | |
---|
1289 | |
---|
1290 | #ifdef KDEBUG |
---|
1291 |  if (TEST_OPT_DEBUG) |
---|
1292 | Â { |
---|
1293 |   Print("t = %d; s = %d; d = %d\n", nInt(t), nInt(s), nInt(d)); |
---|
1294 | Â Â PrintS("m1 = "); |
---|
1295 |   p_wrp(m1, strat->tailRing); |
---|
1296 | Â Â PrintS(" ; m2 = "); |
---|
1297 |   p_wrp(m2, strat->tailRing); |
---|
1298 | Â Â PrintS(" ; gcd = "); |
---|
1299 | Â Â wrp(gcd); |
---|
1300 | Â Â PrintS("\n--- create strong gcd poly: "); |
---|
1301 |   Print("\n p: ", i); |
---|
1302 | Â Â wrp(p); |
---|
1303 |   Print("\n strat->S[%d]: ", i); |
---|
1304 | Â Â wrp(strat->S[i]); |
---|
1305 | Â Â PrintS(" ---> "); |
---|
1306 | Â } |
---|
1307 | #endif |
---|
1308 | |
---|
1309 |  erg = p_Add_q(pp_Mult_mm(pNext(p), m1, strat->tailRing), pp_Mult_mm(pNext(strat->S[i]), m2, strat->tailRing), strat->tailRing); |
---|
1310 | Â pNext(gcd)Â =Â erg; |
---|
1311 | Â pLmDelete(m1); |
---|
1312 | Â pLmDelete(m2); |
---|
1313 | |
---|
1314 | #ifdef KDEBUG |
---|
1315 |   if (TEST_OPT_DEBUG) |
---|
1316 | Â Â { |
---|
1317 | Â Â Â wrp(gcd); |
---|
1318 | Â Â Â PrintLn(); |
---|
1319 | Â Â } |
---|
1320 | #endif |
---|
1321 | |
---|
1322 | Â LObject h; |
---|
1323 | Â h.p =Â gcd; |
---|
1324 | Â h.tailRing =Â strat->tailRing; |
---|
1325 |  int posx; |
---|
1326 |  if (h.p!=NULL) |
---|
1327 | Â { |
---|
1328 |   if (TEST_OPT_INTSTRATEGY) |
---|
1329 | Â Â { |
---|
1330 | Â Â Â h.pCleardenom();Â // also does a pContent |
---|
1331 | Â Â } |
---|
1332 | Â Â else |
---|
1333 | Â Â { |
---|
1334 | Â Â Â h.pNorm(); |
---|
1335 | Â Â } |
---|
1336 | Â Â strat->initEcart(&h); |
---|
1337 |   if (strat->Ll==-1) |
---|
1338 | Â Â Â posx =0; |
---|
1339 | Â Â else |
---|
1340 | Â Â Â posx =Â strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
1341 | Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
1342 |   h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing); |
---|
1343 |   if (pNext(p) != NULL) |
---|
1344 | Â Â { |
---|
1345 | Â Â Â // What does this? (Oliver) |
---|
1346 | Â Â Â // pShallowCopyDeleteProc p_shallow_copy_delete |
---|
1347 | Â Â Â //Â Â Â = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing); |
---|
1348 | Â Â Â // pNext(p) = p_shallow_copy_delete(pNext(p), |
---|
1349 | Â Â Â //Â Â Â Â Â Â Â currRing, strat->tailRing, strat->tailRing->PolyBin); |
---|
1350 | Â Â } |
---|
1351 | Â Â enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx); |
---|
1352 | Â } |
---|
1353 |  return TRUE; |
---|
1354 | } |
---|
1355 | #endif |
---|
1356 | |
---|
1357 | /*2 |
---|
1358 | * put the pair (s[i],p)Â into the set B, ecart=ecart(p) |
---|
1359 | */ |
---|
1360 | |
---|
1361 | |
---|
1362 | void enterOnePair (int i,poly p,int ecart, int isFromQ,kStrategy strat, int atR = -1) |
---|
1363 | { |
---|
1364 | Â assume(i<=strat->sl); |
---|
1365 |  if (strat->interred_flag) return; |
---|
1366 | |
---|
1367 |  int   l,j,compare; |
---|
1368 |  LObject Lp; |
---|
1369 | Â Lp.i_r =Â -1; |
---|
1370 | |
---|
1371 | #ifdef KDEBUG |
---|
1372 | Â Lp.ecart=0;Â Lp.length=0; |
---|
1373 | #endif |
---|
1374 | Â /*- computes the lcm(s[i],p) -*/ |
---|
1375 | Â Lp.lcm =Â pInit(); |
---|
1376 | |
---|
1377 | Â pLcm(p,strat->S[i],Lp.lcm); |
---|
1378 | Â pSetm(Lp.lcm); |
---|
1379 | |
---|
1380 | #define MYTEST 0 |
---|
1381 | |
---|
1382 | #ifdef HAVE_PLURAL |
---|
1383 |  const BOOLEAN bIsPluralRing = rIsPluralRing(currRing); |
---|
1384 |  const BOOLEAN bIsSCA    = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit |
---|
1385 |  const BOOLEAN bNCProdCrit  = ( !bIsPluralRing || bIsSCA ); // commutative or homogeneous SCA |
---|
1386 | |
---|
1387 | #else |
---|
1388 |  const BOOLEAN bIsPluralRing = FALSE; |
---|
1389 |  const BOOLEAN bIsSCA    = FALSE; |
---|
1390 |  const BOOLEAN bNCProdCrit  = TRUE; |
---|
1391 | #endif |
---|
1392 | |
---|
1393 | |
---|
1394 |  if (strat->sugarCrit && bNCProdCrit) |
---|
1395 | Â { |
---|
1396 | Â Â if((!((strat->ecartS[i]>0)&&(ecart>0))) |
---|
1397 | Â Â &&Â pHasNotCF(p,strat->S[i])) |
---|
1398 | Â Â { |
---|
1399 | Â Â /* |
---|
1400 | Â Â *the product criterion has applied for (s,p), |
---|
1401 | Â Â *i.e. lcm(s,p)=product of the leading terms of s and p. |
---|
1402 | Â Â *Suppose (s,r) is in L and the leading term |
---|
1403 | Â Â *of p divides lcm(s,r) |
---|
1404 | Â Â *(==> the leading term of p divides the leading term of r) |
---|
1405 | Â Â *but the leading term of s does not divide the leading term of r |
---|
1406 | Â Â *(notice that tis condition is automatically satisfied if r is still |
---|
1407 | Â Â *in S), then (s,r) can be cancelled. |
---|
1408 | Â Â *This should be done here because the |
---|
1409 | Â Â *case lcm(s,r)=lcm(s,p) is not covered by chainCrit. |
---|
1410 | Â Â * |
---|
1411 | Â Â *Moreover, skipping (s,r) holds also for the noncommutative case. |
---|
1412 | Â Â */ |
---|
1413 | Â Â Â strat->cp++; |
---|
1414 | Â Â Â pLmFree(Lp.lcm); |
---|
1415 | Â Â Â Lp.lcm=NULL; |
---|
1416 | Â Â Â return; |
---|
1417 | Â Â } |
---|
1418 | Â Â else |
---|
1419 | Â Â Â Lp.ecart =Â si_max(ecart,strat->ecartS[i]); |
---|
1420 |   if (strat->fromT && (strat->ecartS[i]>ecart)) |
---|
1421 | Â Â { |
---|
1422 | Â Â Â pLmFree(Lp.lcm); |
---|
1423 | Â Â Â Lp.lcm=NULL; |
---|
1424 | Â Â Â return; |
---|
1425 | Â Â Â /*the pair is (s[i],t[.]), discard it if the ecart is too big*/ |
---|
1426 | Â Â } |
---|
1427 | Â Â /* |
---|
1428 | Â Â *the set B collects the pairs of type (S[j],p) |
---|
1429 | Â Â *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p) |
---|
1430 | Â Â *if the leading term of s devides lcm(r,p) then (r,p) will be canceled |
---|
1431 | Â Â *if the leading term of r devides lcm(s,p) then (s,p) will not enter B |
---|
1432 | Â Â */ |
---|
1433 | Â Â { |
---|
1434 | Â Â Â j =Â strat->Bl; |
---|
1435 | Â Â Â loop |
---|
1436 | Â Â Â { |
---|
1437 |     if (j < 0) break; |
---|
1438 | Â Â Â Â compare=pDivComp(strat->B[j].lcm,Lp.lcm); |
---|
1439 |     if ((compare==1) |
---|
1440 | Â Â Â Â &&(sugarDivisibleBy(strat->B[j].ecart,Lp.ecart))) |
---|
1441 | Â Â Â Â { |
---|
1442 | Â Â Â Â Â strat->c3++; |
---|
1443 |      if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0)) |
---|
1444 | Â Â Â Â Â { |
---|
1445 | Â Â Â Â Â Â pLmFree(Lp.lcm); |
---|
1446 | Â Â Â Â Â Â return; |
---|
1447 | Â Â Â Â Â } |
---|
1448 | Â Â Â Â Â break; |
---|
1449 | Â Â Â Â } |
---|
1450 | Â Â Â Â else |
---|
1451 |     if ((compare ==-1) |
---|
1452 | Â Â Â Â &&Â sugarDivisibleBy(Lp.ecart,strat->B[j].ecart)) |
---|
1453 | Â Â Â Â { |
---|
1454 | Â Â Â Â Â deleteInL(strat->B,&strat->Bl,j,strat); |
---|
1455 | Â Â Â Â Â strat->c3++; |
---|
1456 | Â Â Â Â } |
---|
1457 | Â Â Â Â j--; |
---|
1458 | Â Â Â } |
---|
1459 | Â Â } |
---|
1460 | Â } |
---|
1461 |  else /*sugarcrit*/ |
---|
1462 | Â { |
---|
1463 |   if (bNCProdCrit) |
---|
1464 | Â Â { |
---|
1465 | Â Â Â // if currRing->nc_type!=quasi (or skew) |
---|
1466 | Â Â Â // TODO: enable productCrit for super commutative algebras... |
---|
1467 | Â Â Â if(/*(strat->ak==0) && productCrit(p,strat->S[i])*/ |
---|
1468 | Â Â Â pHasNotCF(p,strat->S[i])) |
---|
1469 | Â Â Â { |
---|
1470 | Â Â Â /* |
---|
1471 | Â Â Â *the product criterion has applied for (s,p), |
---|
1472 | Â Â Â *i.e. lcm(s,p)=product of the leading terms of s and p. |
---|
1473 | Â Â Â *Suppose (s,r) is in L and the leading term |
---|
1474 | Â Â Â *of p devides lcm(s,r) |
---|
1475 | Â Â Â *(==> the leading term of p devides the leading term of r) |
---|
1476 | Â Â Â *but the leading term of s does not devide the leading term of r |
---|
1477 | Â Â Â *(notice that tis condition is automatically satisfied if r is still |
---|
1478 | Â Â Â *in S), then (s,r) can be canceled. |
---|
1479 | Â Â Â *This should be done here because the |
---|
1480 | Â Â Â *case lcm(s,r)=lcm(s,p) is not covered by chainCrit. |
---|
1481 | Â Â Â */ |
---|
1482 | Â Â Â Â Â strat->cp++; |
---|
1483 | Â Â Â Â Â pLmFree(Lp.lcm); |
---|
1484 | Â Â Â Â Â Lp.lcm=NULL; |
---|
1485 | Â Â Â Â Â return; |
---|
1486 | Â Â Â } |
---|
1487 |    if (strat->fromT && (strat->ecartS[i]>ecart)) |
---|
1488 | Â Â Â { |
---|
1489 | Â Â Â Â pLmFree(Lp.lcm); |
---|
1490 | Â Â Â Â Lp.lcm=NULL; |
---|
1491 | Â Â Â Â return; |
---|
1492 | Â Â Â Â /*the pair is (s[i],t[.]), discard it if the ecart is too big*/ |
---|
1493 | Â Â Â } |
---|
1494 | Â Â Â /* |
---|
1495 | Â Â Â *the set B collects the pairs of type (S[j],p) |
---|
1496 | Â Â Â *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p)#lcm(r,p) |
---|
1497 | Â Â Â *if the leading term of s devides lcm(r,p) then (r,p) will be canceled |
---|
1498 | Â Â Â *if the leading term of r devides lcm(s,p) then (s,p) will not enter B |
---|
1499 | Â Â Â */ |
---|
1500 | Â Â Â for(j =Â strat->Bl;j>=0;j--) |
---|
1501 | Â Â Â { |
---|
1502 | Â Â Â Â compare=pDivComp(strat->B[j].lcm,Lp.lcm); |
---|
1503 |     if (compare==1) |
---|
1504 | Â Â Â Â { |
---|
1505 | Â Â Â Â Â strat->c3++; |
---|
1506 |      if ((strat->fromQ==NULL) || (isFromQ==0) || (strat->fromQ[i]==0)) |
---|
1507 | Â Â Â Â Â { |
---|
1508 | Â Â Â Â Â Â pLmFree(Lp.lcm); |
---|
1509 | Â Â Â Â Â Â return; |
---|
1510 | Â Â Â Â Â } |
---|
1511 | Â Â Â Â Â break; |
---|
1512 | Â Â Â Â } |
---|
1513 | Â Â Â Â else |
---|
1514 |     if (compare ==-1) |
---|
1515 | Â Â Â Â { |
---|
1516 | Â Â Â Â Â deleteInL(strat->B,&strat->Bl,j,strat); |
---|
1517 | Â Â Â Â Â strat->c3++; |
---|
1518 | Â Â Â Â } |
---|
1519 | Â Â Â } |
---|
1520 | Â Â } |
---|
1521 | Â } |
---|
1522 | Â /* |
---|
1523 | Â *the pair (S[i],p) enters B if the spoly != 0 |
---|
1524 | Â */ |
---|
1525 | Â /*-Â compute the short s-polynomial -*/ |
---|
1526 |  if (strat->fromT && !TEST_OPT_INTSTRATEGY) |
---|
1527 | Â Â pNorm(p); |
---|
1528 | |
---|
1529 |  if ((strat->S[i]==NULL) || (p==NULL)) |
---|
1530 | Â Â return; |
---|
1531 | |
---|
1532 |  if ((strat->fromQ!=NULL) && (isFromQ!=0) && (strat->fromQ[i]!=0)) |
---|
1533 | Â Â Lp.p=NULL; |
---|
1534 | Â else |
---|
1535 | Â { |
---|
1536 | Â Â #ifdef HAVE_PLURAL |
---|
1537 |   if ( bIsPluralRing ) |
---|
1538 | Â Â { |
---|
1539 |    if(pHasNotCF(p, strat->S[i])) |
---|
1540 | Â Â Â { |
---|
1541 | //Â Â Â Â Â if(ncRingType(currRing) == nc_lie) |
---|
1542 | //Â Â Â Â Â { |
---|
1543 | //Â Â Â Â Â Â Â // generalized prod-crit for lie-type |
---|
1544 | //Â Â Â Â Â Â Â strat->cp++; |
---|
1545 | //Â Â Â Â Â Â Â Lp.p = nc_p_Bracket_qq(pCopy(p),strat->S[i]); |
---|
1546 | //Â Â Â Â Â } |
---|
1547 | //Â Â Â Â Â else |
---|
1548 | Â Â Â Â if(Â bIsSCA ) |
---|
1549 | Â Â Â Â { |
---|
1550 | Â Â Â Â Â Â // product criterion for homogeneous case in SCA |
---|
1551 | Â Â Â Â Â Â strat->cp++; |
---|
1552 | Â Â Â Â Â Â Lp.p =Â NULL; |
---|
1553 | Â Â Â Â } |
---|
1554 | Â Â Â Â else |
---|
1555 | Â Â Â Â Â Lp.p =Â // nc_CreateSpoly(strat->S[i],p,currRing); |
---|
1556 |          nc_CreateShortSpoly(strat->S[i], p, currRing); |
---|
1557 | Â Â Â } |
---|
1558 | Â Â Â else |
---|
1559 | Â Â Â Â Lp.p =Â // nc_CreateSpoly(strat->S[i],p,currRing); |
---|
1560 |         nc_CreateShortSpoly(strat->S[i], p, currRing); |
---|
1561 | |
---|
1562 | Â Â Â |
---|
1563 | #if MYTEST |
---|
1564 |    if (TEST_OPT_DEBUG) |
---|
1565 | Â Â Â { |
---|
1566 | Â Â Â Â PrintS("strat->S[i]: ");Â pWrite(strat->S[i]); |
---|
1567 | Â Â Â Â PrintS("p: ");Â pWrite(p); |
---|
1568 | Â Â Â Â PrintS("SPoly: ");Â pWrite(Lp.p); |
---|
1569 | Â Â Â } |
---|
1570 | #endif   |
---|
1571 | Â Â Â |
---|
1572 | Â Â } |
---|
1573 | Â Â else |
---|
1574 | Â Â #endif |
---|
1575 | Â Â { |
---|
1576 | Â Â Â assume(!rIsPluralRing(currRing)); |
---|
1577 |    Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing); |
---|
1578 | #if MYTEST |
---|
1579 |    if (TEST_OPT_DEBUG) |
---|
1580 | Â Â Â { |
---|
1581 | Â Â Â Â PrintS("strat->S[i]: ");Â pWrite(strat->S[i]); |
---|
1582 | Â Â Â Â PrintS("p: ");Â pWrite(p); |
---|
1583 | Â Â Â Â PrintS("commutative SPoly: ");Â pWrite(Lp.p); |
---|
1584 | Â Â Â } |
---|
1585 | #endif   |
---|
1586 | |
---|
1587 | Â Â Â } |
---|
1588 | Â } |
---|
1589 |  if (Lp.p == NULL) |
---|
1590 | Â { |
---|
1591 | Â Â /*- the case that the s-poly is 0 -*/ |
---|
1592 |   if (strat->pairtest==NULL) initPairtest(strat); |
---|
1593 | Â Â strat->pairtest[i]Â =Â TRUE;/*- hint for spoly(S^[i],p)=0 -*/ |
---|
1594 | Â Â strat->pairtest[strat->sl+1]Â =Â TRUE; |
---|
1595 | Â Â /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/ |
---|
1596 | Â Â /* |
---|
1597 | Â Â *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is |
---|
1598 | Â Â *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not |
---|
1599 | Â Â *devide lcm(r,p)). In the last case (s,r) can be canceled if the leading |
---|
1600 | Â Â *term of p devides the lcm(s,r) |
---|
1601 | Â Â *(this canceling should be done here because |
---|
1602 | Â Â *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit) |
---|
1603 | Â Â *the first case is handeled in chainCrit |
---|
1604 | Â Â */ |
---|
1605 |   if (Lp.lcm!=NULL) pLmFree(Lp.lcm); |
---|
1606 | Â } |
---|
1607 | Â else |
---|
1608 | Â { |
---|
1609 | Â Â /*- the pair (S[i],p) enters B -*/ |
---|
1610 | Â Â Lp.p1 =Â strat->S[i]; |
---|
1611 | Â Â Lp.p2 =Â p; |
---|
1612 | |
---|
1613 | //Â Â if ( !bIsPluralRing ) // !!!! |
---|
1614 | Â Â assume(pNext(Lp.p)==NULL); |
---|
1615 | Â Â pNext(Lp.p)Â =Â strat->tail;Â // !!! |
---|
1616 | |
---|
1617 |   if (atR >= 0) |
---|
1618 | Â Â { |
---|
1619 | Â Â Â Lp.i_r1 =Â strat->S_2_R[i]; |
---|
1620 | Â Â Â Lp.i_r2 =Â atR; |
---|
1621 | Â Â } |
---|
1622 | Â Â else |
---|
1623 | Â Â { |
---|
1624 | Â Â Â Lp.i_r1 =Â -1; |
---|
1625 | Â Â Â Lp.i_r2 =Â -1; |
---|
1626 | Â Â } |
---|
1627 | Â Â strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart); |
---|
1628 | |
---|
1629 |   if (TEST_OPT_INTSTRATEGY) |
---|
1630 | Â Â { |
---|
1631 |    if (!bIsPluralRing) |
---|
1632 | Â Â Â Â nDelete(&(Lp.p->coef)); |
---|
1633 | Â Â } |
---|
1634 | |
---|
1635 | Â Â l =Â strat->posInL(strat->B,strat->Bl,&Lp,strat); |
---|
1636 | Â Â enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l); |
---|
1637 | Â } |
---|
1638 | } |
---|
1639 | |
---|
1640 | /*2 |
---|
1641 | * put the pair (s[i],p) into the set L, ecart=ecart(p) |
---|
1642 | * in the case that s forms a SB of (s) |
---|
1643 | */ |
---|
1644 | void enterOnePairSpecial (int i,poly p,int ecart,kStrategy strat, int atR = -1) |
---|
1645 | { |
---|
1646 | Â //PrintS("try ");wrp(strat->S[i]);PrintS(" and ");wrp(p);PrintLn(); |
---|
1647 | Â if(pHasNotCF(p,strat->S[i])) |
---|
1648 | Â { |
---|
1649 | Â Â //PrintS("prod-crit\n"); |
---|
1650 | Â Â #ifdef HAVE_PLURAL |
---|
1651 | Â Â if((!rIsPluralRing(currRing))Â ||Â (rIsSCA(currRing)Â &&Â strat->z2homog)) |
---|
1652 | Â Â #endif |
---|
1653 | Â Â { |
---|
1654 | Â Â Â //PrintS("prod-crit\n"); |
---|
1655 | Â Â Â strat->cp++; |
---|
1656 | Â Â Â return; |
---|
1657 | Â Â } |
---|
1658 | Â } |
---|
1659 | |
---|
1660 |  int   l,j,compare; |
---|
1661 |  LObject Lp; |
---|
1662 | Â Lp.i_r =Â -1; |
---|
1663 | |
---|
1664 | Â Lp.lcm =Â pInit(); |
---|
1665 | Â pLcm(p,strat->S[i],Lp.lcm); |
---|
1666 | Â pSetm(Lp.lcm); |
---|
1667 | Â for(j =Â strat->Ll;j>=0;j--) |
---|
1668 | Â { |
---|
1669 | Â Â compare=pDivComp(strat->L[j].lcm,Lp.lcm); |
---|
1670 |   if ((compare==1) || (pLmEqual(strat->L[j].lcm,Lp.lcm))) |
---|
1671 | Â Â { |
---|
1672 | Â Â Â //PrintS("c3-crit\n"); |
---|
1673 | Â Â Â strat->c3++; |
---|
1674 | Â Â Â pLmFree(Lp.lcm); |
---|
1675 | Â Â Â return; |
---|
1676 | Â Â } |
---|
1677 |   else if (compare ==-1) |
---|
1678 | Â Â { |
---|
1679 | Â Â Â //Print("c3-crit with L[%d]\n",j); |
---|
1680 | Â Â Â deleteInL(strat->L,&strat->Ll,j,strat); |
---|
1681 | Â Â Â strat->c3++; |
---|
1682 | Â Â } |
---|
1683 | Â } |
---|
1684 | Â /*-Â compute the short s-polynomial -*/ |
---|
1685 | |
---|
1686 | Â #ifdef HAVE_PLURAL |
---|
1687 |  if (rIsPluralRing(currRing)) |
---|
1688 | Â { |
---|
1689 | Â Â Lp.p =Â nc_CreateShortSpoly(strat->S[i],p);Â // ??? strat->tailRing? |
---|
1690 | Â } |
---|
1691 | Â else |
---|
1692 | Â #endif |
---|
1693 | Â Â Lp.p =Â ksCreateShortSpoly(strat->S[i],p,strat->tailRing); |
---|
1694 | |
---|
1695 |  if (Lp.p == NULL) |
---|
1696 | Â { |
---|
1697 | Â Â Â //PrintS("short spoly==NULL\n"); |
---|
1698 | Â Â Â pLmFree(Lp.lcm); |
---|
1699 | Â } |
---|
1700 | Â else |
---|
1701 | Â { |
---|
1702 | Â Â /*- the pair (S[i],p) enters L -*/ |
---|
1703 | Â Â Lp.p1 =Â strat->S[i]; |
---|
1704 | Â Â Lp.p2 =Â p; |
---|
1705 |   if (atR >= 0) |
---|
1706 | Â Â { |
---|
1707 | Â Â Â Lp.i_r1 =Â strat->S_2_R[i]; |
---|
1708 | Â Â Â Lp.i_r2 =Â atR; |
---|
1709 | Â Â } |
---|
1710 | Â Â else |
---|
1711 | Â Â { |
---|
1712 | Â Â Â Lp.i_r1 =Â -1; |
---|
1713 | Â Â Â Lp.i_r2 =Â -1; |
---|
1714 | Â Â } |
---|
1715 | Â Â assume(pNext(Lp.p)Â ==Â NULL); |
---|
1716 | Â Â pNext(Lp.p)Â =Â strat->tail; |
---|
1717 | Â Â strat->initEcartPair(&Lp,strat->S[i],p,strat->ecartS[i],ecart); |
---|
1718 |   if (TEST_OPT_INTSTRATEGY) |
---|
1719 | Â Â { |
---|
1720 | Â Â Â nDelete(&(Lp.p->coef)); |
---|
1721 | Â Â } |
---|
1722 | Â Â l =Â strat->posInL(strat->L,strat->Ll,&Lp,strat); |
---|
1723 | Â Â //Print("-> L[%d]\n",l); |
---|
1724 | Â Â enterL(&strat->L,&strat->Ll,&strat->Lmax,Lp,l); |
---|
1725 | Â } |
---|
1726 | } |
---|
1727 | |
---|
1728 | /*2 |
---|
1729 | *the pairset B of pairs of type (s[i],p) is complete now. It will be updated |
---|
1730 | *using the chain-criterion in B and L and enters B to L |
---|
1731 | */ |
---|
1732 | void chainCrit (poly p,int ecart,kStrategy strat) |
---|
1733 | { |
---|
1734 |  int i,j,l; |
---|
1735 | |
---|
1736 | Â /* |
---|
1737 | Â *pairtest[i] is TRUE if spoly(S[i],p) == 0. |
---|
1738 | Â *In this case all elements in B such |
---|
1739 | Â *that their lcm is divisible by the leading term of S[i] can be canceled |
---|
1740 | Â */ |
---|
1741 |  if (strat->pairtest!=NULL) |
---|
1742 | Â { |
---|
1743 | Â Â { |
---|
1744 | Â Â Â /*- i.e. there is an i with pairtest[i]==TRUE -*/ |
---|
1745 |    for (j=0; j<=strat->sl; j++) |
---|
1746 | Â Â Â { |
---|
1747 |     if (strat->pairtest[j]) |
---|
1748 | Â Â Â Â { |
---|
1749 |      for (i=strat->Bl; i>=0; i--) |
---|
1750 | Â Â Â Â Â { |
---|
1751 |       if (pDivisibleBy(strat->S[j],strat->B[i].lcm)) |
---|
1752 | Â Â Â Â Â Â { |
---|
1753 | Â Â Â Â Â Â Â deleteInL(strat->B,&strat->Bl,i,strat); |
---|
1754 | Â Â Â Â Â Â Â strat->c3++; |
---|
1755 | Â Â Â Â Â Â } |
---|
1756 | Â Â Â Â Â } |
---|
1757 | Â Â Â Â } |
---|
1758 | Â Â Â } |
---|
1759 | Â Â } |
---|
1760 | Â Â omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN)); |
---|
1761 | Â Â strat->pairtest=NULL; |
---|
1762 | Â } |
---|
1763 |  if (strat->Gebauer || strat->fromT) |
---|
1764 | Â { |
---|
1765 |   if (strat->sugarCrit) |
---|
1766 | Â Â { |
---|
1767 | Â Â /* |
---|
1768 | Â Â *suppose L[j] == (s,r) and p/lcm(s,r) |
---|
1769 | Â Â *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p) |
---|
1770 | Â Â *and in case the sugar is o.k. then L[j] can be canceled |
---|
1771 | Â Â */ |
---|
1772 |    for (j=strat->Ll; j>=0; j--) |
---|
1773 | Â Â Â { |
---|
1774 |     if (sugarDivisibleBy(ecart,strat->L[j].ecart) |
---|
1775 | Â Â Â Â &&Â ((pNext(strat->L[j].p)Â ==Â strat->tail)Â ||Â (pOrdSgn==1)) |
---|
1776 | Â Â Â Â &&Â pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm)) |
---|
1777 | Â Â Â Â { |
---|
1778 |      if (strat->L[j].p == strat->tail) |
---|
1779 | Â Â Â Â Â { |
---|
1780 | Â Â Â Â Â Â Â deleteInL(strat->L,&strat->Ll,j,strat); |
---|
1781 | Â Â Â Â Â Â Â strat->c3++; |
---|
1782 | Â Â Â Â Â } |
---|
1783 | Â Â Â Â } |
---|
1784 | Â Â Â } |
---|
1785 | Â Â Â /* |
---|
1786 | Â Â Â *this is GEBAUER-MOELLER: |
---|
1787 | Â Â Â *in B all elements with the same lcm except the "best" |
---|
1788 | Â Â Â *(i.e. the last one in B with this property) will be canceled |
---|
1789 | Â Â Â */ |
---|
1790 | Â Â Â j =Â strat->Bl; |
---|
1791 | Â Â Â loop /*cannot be changed into a for !!! */ |
---|
1792 | Â Â Â { |
---|
1793 |     if (j <= 0) break; |
---|
1794 | Â Â Â Â i =Â j-1; |
---|
1795 | Â Â Â Â loop |
---|
1796 | Â Â Â Â { |
---|
1797 |      if (i < 0) break; |
---|
1798 |      if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm)) |
---|
1799 | Â Â Â Â Â { |
---|
1800 | Â Â Â Â Â Â strat->c3++; |
---|
1801 |       if (sugarDivisibleBy(strat->B[j].ecart,strat->B[i].ecart)) |
---|
1802 | Â Â Â Â Â Â { |
---|
1803 | Â Â Â Â Â Â Â deleteInL(strat->B,&strat->Bl,i,strat); |
---|
1804 | Â Â Â Â Â Â Â j--; |
---|
1805 | Â Â Â Â Â Â } |
---|
1806 | Â Â Â Â Â Â else |
---|
1807 | Â Â Â Â Â Â { |
---|
1808 | Â Â Â Â Â Â Â deleteInL(strat->B,&strat->Bl,j,strat); |
---|
1809 | Â Â Â Â Â Â Â break; |
---|
1810 | Â Â Â Â Â Â } |
---|
1811 | Â Â Â Â Â } |
---|
1812 | Â Â Â Â Â i--; |
---|
1813 | Â Â Â Â } |
---|
1814 | Â Â Â Â j--; |
---|
1815 | Â Â Â } |
---|
1816 | Â Â } |
---|
1817 |   else /*sugarCrit*/ |
---|
1818 | Â Â { |
---|
1819 | Â Â Â /* |
---|
1820 | Â Â Â *suppose L[j] == (s,r) and p/lcm(s,r) |
---|
1821 | Â Â Â *and lcm(s,r)#lcm(s,p) and lcm(s,r)#lcm(r,p) |
---|
1822 | Â Â Â *and in case the sugar is o.k. then L[j] can be canceled |
---|
1823 | Â Â Â */ |
---|
1824 |    for (j=strat->Ll; j>=0; j--) |
---|
1825 | Â Â Â { |
---|
1826 |     if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm)) |
---|
1827 | Â Â Â Â { |
---|
1828 |      if ((pNext(strat->L[j].p) == strat->tail)||(pOrdSgn==1)) |
---|
1829 | Â Â Â Â Â { |
---|
1830 | Â Â Â Â Â Â deleteInL(strat->L,&strat->Ll,j,strat); |
---|
1831 | Â Â Â Â Â Â strat->c3++; |
---|
1832 | Â Â Â Â Â } |
---|
1833 | Â Â Â Â } |
---|
1834 | Â Â Â } |
---|
1835 | Â Â Â /* |
---|
1836 | Â Â Â *this is GEBAUER-MOELLER: |
---|
1837 | Â Â Â *in B all elements with the same lcm except the "best" |
---|
1838 | Â Â Â *(i.e. the last one in B with this property) will be canceled |
---|
1839 | Â Â Â */ |
---|
1840 | Â Â Â j =Â strat->Bl; |
---|
1841 |    loop  /*cannot be changed into a for !!! */ |
---|
1842 | Â Â Â { |
---|
1843 |     if (j <= 0) break; |
---|
1844 | Â Â Â Â for(i=j-1;Â i>=0;Â i--) |
---|
1845 | Â Â Â Â { |
---|
1846 |      if (pLmEqual(strat->B[j].lcm,strat->B[i].lcm)) |
---|
1847 | Â Â Â Â Â { |
---|
1848 | Â Â Â Â Â Â strat->c3++; |
---|
1849 | Â Â Â Â Â Â deleteInL(strat->B,&strat->Bl,i,strat); |
---|
1850 | Â Â Â Â Â Â j--; |
---|
1851 | Â Â Â Â Â } |
---|
1852 | Â Â Â Â } |
---|
1853 | Â Â Â Â j--; |
---|
1854 | Â Â Â } |
---|
1855 | Â Â } |
---|
1856 | Â Â /* |
---|
1857 | Â Â *the elements of B enter L/their order with respect to B is kept |
---|
1858 | Â Â *j = posInL(L,j,B[i]) would permutate the order |
---|
1859 | Â Â *if once B is ordered different from L |
---|
1860 | Â Â *then one should use j = posInL(L,Ll,B[i]) |
---|
1861 | Â Â */ |
---|
1862 | Â Â j =Â strat->Ll+1; |
---|
1863 |   for (i=strat->Bl; i>=0; i--) |
---|
1864 | Â Â { |
---|
1865 | Â Â Â j =Â strat->posInL(strat->L,j-1,&(strat->B[i]),strat); |
---|
1866 | Â Â Â enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j); |
---|
1867 | Â Â } |
---|
1868 | Â Â strat->Bl =Â -1; |
---|
1869 | Â } |
---|
1870 | Â else |
---|
1871 | Â { |
---|
1872 |   for (j=strat->Ll; j>=0; j--) |
---|
1873 | Â Â { |
---|
1874 |    if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm)) |
---|
1875 | Â Â Â { |
---|
1876 |     if ((pNext(strat->L[j].p) == strat->tail)||(pOrdSgn==1)) |
---|
1877 | Â Â Â Â { |
---|
1878 | Â Â Â Â Â deleteInL(strat->L,&strat->Ll,j,strat); |
---|
1879 | Â Â Â Â Â strat->c3++; |
---|
1880 | Â Â Â Â } |
---|
1881 | Â Â Â } |
---|
1882 | Â Â } |
---|
1883 | Â Â /* |
---|
1884 | Â Â *this is our MODIFICATION of GEBAUER-MOELLER: |
---|
1885 | Â Â *First the elements of B enter L, |
---|
1886 | Â Â *then we fix a lcm and the "best" element in L |
---|
1887 | Â Â *(i.e the last in L with this lcm and of type (s,p)) |
---|
1888 | Â Â *and cancel all the other elements of type (r,p) with this lcm |
---|
1889 | Â Â *except the case the element (s,r) has also the same lcm |
---|
1890 | Â Â *and is on the worst position with respect to (s,p) and (r,p) |
---|
1891 | Â Â */ |
---|
1892 | Â Â /* |
---|
1893 | Â Â *B enters to L/their order with respect to B is permutated for elements |
---|
1894 | Â Â *B[i].p with the same leading term |
---|
1895 | Â Â */ |
---|
1896 | Â Â j =Â strat->Ll; |
---|
1897 |   for (i=strat->Bl; i>=0; i--) |
---|
1898 | Â Â { |
---|
1899 | Â Â Â j =Â strat->posInL(strat->L,j,&(strat->B[i]),strat); |
---|
1900 | Â Â Â enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j); |
---|
1901 | Â Â } |
---|
1902 | Â Â strat->Bl =Â -1; |
---|
1903 | Â Â j =Â strat->Ll; |
---|
1904 |   loop /*cannot be changed into a for !!! */ |
---|
1905 | Â Â { |
---|
1906 |    if (j <= 0) |
---|
1907 | Â Â Â { |
---|
1908 | Â Â Â Â /*now L[0] cannot be canceled any more and the tail can be removed*/ |
---|
1909 |     if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p; |
---|
1910 | Â Â Â Â break; |
---|
1911 | Â Â Â } |
---|
1912 |    if (strat->L[j].p2 == p) |
---|
1913 | Â Â Â { |
---|
1914 | Â Â Â Â i =Â j-1; |
---|
1915 | Â Â Â Â loop |
---|
1916 | Â Â Â Â { |
---|
1917 |      if (i < 0) break; |
---|
1918 |      if ((strat->L[i].p2 == p) && pLmEqual(strat->L[j].lcm,strat->L[i].lcm)) |
---|
1919 | Â Â Â Â Â { |
---|
1920 | Â Â Â Â Â Â /*L[i] could be canceled but we search for a better one to cancel*/ |
---|
1921 | Â Â Â Â Â Â strat->c3++; |
---|
1922 |       if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat) |
---|
1923 | Â Â Â Â Â Â &&Â (pNext(strat->L[l].p)Â ==Â strat->tail) |
---|
1924 | Â Â Â Â Â Â &&Â (!pLmEqual(strat->L[i].p,strat->L[l].p)) |
---|
1925 | Â Â Â Â Â Â &&Â pDivisibleBy(p,strat->L[l].lcm)) |
---|
1926 | Â Â Â Â Â Â { |
---|
1927 | Â Â Â Â Â Â Â /* |
---|
1928 | Â Â Â Â Â Â Â *"NOT equal(...)" because in case of "equal" the element L[l] |
---|
1929 | Â Â Â Â Â Â Â *is "older" and has to be from theoretical point of view behind |
---|
1930 | Â Â Â Â Â Â Â *L[i], but we do not want to reorder L |
---|
1931 | Â Â Â Â Â Â Â */ |
---|
1932 | Â Â Â Â Â Â Â strat->L[i].p2 =Â strat->tail; |
---|
1933 | Â Â Â Â Â Â Â /* |
---|
1934 | Â Â Â Â Â Â Â *L[l] will be canceled, we cannot cancel L[i] later on, |
---|
1935 | Â Â Â Â Â Â Â *so we mark it with "tail" |
---|
1936 | Â Â Â Â Â Â Â */ |
---|
1937 | Â Â Â Â Â Â Â deleteInL(strat->L,&strat->Ll,l,strat); |
---|
1938 | Â Â Â Â Â Â Â i--; |
---|
1939 | Â Â Â Â Â Â } |
---|
1940 | Â Â Â Â Â Â else |
---|
1941 | Â Â Â Â Â Â { |
---|
1942 | Â Â Â Â Â Â Â deleteInL(strat->L,&strat->Ll,i,strat); |
---|
1943 | Â Â Â Â Â Â } |
---|
1944 | Â Â Â Â Â Â j--; |
---|
1945 | Â Â Â Â Â } |
---|
1946 | Â Â Â Â Â i--; |
---|
1947 | Â Â Â Â } |
---|
1948 | Â Â Â } |
---|
1949 |    else if (strat->L[j].p2 == strat->tail) |
---|
1950 | Â Â Â { |
---|
1951 | Â Â Â Â /*now L[j] cannot be canceled any more and the tail can be removed*/ |
---|
1952 | Â Â Â Â strat->L[j].p2 =Â p; |
---|
1953 | Â Â Â } |
---|
1954 | Â Â Â j--; |
---|
1955 | Â Â } |
---|
1956 | Â } |
---|
1957 | } |
---|
1958 | |
---|
1959 | /*2 |
---|
1960 | *(s[0],h),...,(s[k],h) will be put to the pairset L |
---|
1961 | */ |
---|
1962 | void initenterpairs (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR = -1) |
---|
1963 | { |
---|
1964 | |
---|
1965 |  if ((strat->syzComp==0) |
---|
1966 | Â ||Â (pGetComp(h)<=strat->syzComp)) |
---|
1967 | Â { |
---|
1968 |   int j; |
---|
1969 | Â Â BOOLEAN new_pair=FALSE; |
---|
1970 | |
---|
1971 |   if (pGetComp(h)==0) |
---|
1972 | Â Â { |
---|
1973 | Â Â Â /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/ |
---|
1974 |    if ((isFromQ)&&(strat->fromQ!=NULL)) |
---|
1975 | Â Â Â { |
---|
1976 |     for (j=0; j<=k; j++) |
---|
1977 | Â Â Â Â { |
---|
1978 |      if (!strat->fromQ[j]) |
---|
1979 | Â Â Â Â Â { |
---|
1980 | Â Â Â Â Â Â new_pair=TRUE; |
---|
1981 |       enterOnePair(j,h,ecart,isFromQ,strat, atR); |
---|
1982 | Â Â Â Â Â //Print("j:%d, Ll:%d\n",j,strat->Ll); |
---|
1983 | Â Â Â Â Â } |
---|
1984 | Â Â Â Â } |
---|
1985 | Â Â Â } |
---|
1986 | Â Â Â else |
---|
1987 | Â Â Â { |
---|
1988 | Â Â Â Â new_pair=TRUE; |
---|
1989 |     for (j=0; j<=k; j++) |
---|
1990 | Â Â Â Â { |
---|
1991 |      enterOnePair(j,h,ecart,isFromQ,strat, atR); |
---|
1992 | Â Â Â Â Â //Print("j:%d, Ll:%d\n",j,strat->Ll); |
---|
1993 | Â Â Â Â } |
---|
1994 | Â Â Â } |
---|
1995 | Â Â } |
---|
1996 | Â Â else |
---|
1997 | Â Â { |
---|
1998 |    for (j=0; j<=k; j++) |
---|
1999 | Â Â Â { |
---|
2000 |     if ((pGetComp(h)==pGetComp(strat->S[j])) |
---|
2001 | Â Â Â Â ||Â (pGetComp(strat->S[j])==0)) |
---|
2002 | Â Â Â Â { |
---|
2003 | Â Â Â Â Â new_pair=TRUE; |
---|
2004 |      enterOnePair(j,h,ecart,isFromQ,strat, atR); |
---|
2005 | Â Â Â Â //Print("j:%d, Ll:%d\n",j,strat->Ll); |
---|
2006 | Â Â Â Â } |
---|
2007 | Â Â Â } |
---|
2008 | Â Â } |
---|
2009 | |
---|
2010 |   if (new_pair) chainCrit(h,ecart,strat); |
---|
2011 | |
---|
2012 | Â } |
---|
2013 | } |
---|
2014 | |
---|
2015 | #ifdef HAVE_RINGS |
---|
2016 | /*2 |
---|
2017 | *the pairset B of pairs of type (s[i],p) is complete now. It will be updated |
---|
2018 | *using the chain-criterion in B and L and enters B to L |
---|
2019 | */ |
---|
2020 | void chainCritRing (poly p,int ecart,kStrategy strat) |
---|
2021 | { |
---|
2022 |  int i,j,l; |
---|
2023 | Â /* |
---|
2024 | Â *pairtest[i] is TRUE if spoly(S[i],p) == 0. |
---|
2025 | Â *In this case all elements in B such |
---|
2026 | Â *that their lcm is divisible by the leading term of S[i] can be canceled |
---|
2027 | Â */ |
---|
2028 |  if (strat->pairtest!=NULL) |
---|
2029 | Â { |
---|
2030 | Â Â { |
---|
2031 | Â Â Â /*- i.e. there is an i with pairtest[i]==TRUE -*/ |
---|
2032 |    for (j=0; j<=strat->sl; j++) |
---|
2033 | Â Â Â { |
---|
2034 |     if (strat->pairtest[j]) |
---|
2035 | Â Â Â Â { |
---|
2036 |      for (i=strat->Bl; i>=0; i--) |
---|
2037 | Â Â Â Â Â { |
---|
2038 |       if (pDivisibleBy(strat->S[j],strat->B[i].lcm)) |
---|
2039 | Â Â Â Â Â Â { |
---|
2040 | #ifdef KDEBUG |
---|
2041 |        if (TEST_OPT_DEBUG) |
---|
2042 | Â Â Â Â Â Â Â { |
---|
2043 | Â Â Â Â Â Â Â Â PrintS("--- chain criterion func chainCritRing type 1\n"); |
---|
2044 | Â Â Â Â Â Â Â Â PrintS("strat->S[j]:"); |
---|
2045 | Â Â Â Â Â Â Â Â wrp(strat->S[j]); |
---|
2046 | Â Â Â Â Â Â Â Â PrintS("Â strat->B[i].lcm:"); |
---|
2047 | Â Â Â Â Â Â Â Â wrp(strat->B[i].lcm); |
---|
2048 | Â Â Â Â Â Â Â Â PrintLn(); |
---|
2049 | Â Â Â Â Â Â Â } |
---|
2050 | #endif |
---|
2051 | Â Â Â Â Â Â Â deleteInL(strat->B,&strat->Bl,i,strat); |
---|
2052 | Â Â Â Â Â Â Â strat->c3++; |
---|
2053 | Â Â Â Â Â Â } |
---|
2054 | Â Â Â Â Â } |
---|
2055 | Â Â Â Â } |
---|
2056 | Â Â Â } |
---|
2057 | Â Â } |
---|
2058 | Â Â omFreeSize(strat->pairtest,(strat->sl+2)*sizeof(BOOLEAN)); |
---|
2059 | Â Â strat->pairtest=NULL; |
---|
2060 | Â } |
---|
2061 | Â assume(!(strat->Gebauer ||Â strat->fromT)); |
---|
2062 |  for (j=strat->Ll; j>=0; j--) |
---|
2063 | Â { |
---|
2064 |   if (strat->L[j].lcm != NULL && nDivBy(pGetCoeff(strat->L[j].lcm), pGetCoeff(p))) |
---|
2065 | Â Â { |
---|
2066 |    if (pCompareChain(p,strat->L[j].p1,strat->L[j].p2,strat->L[j].lcm)) |
---|
2067 | Â Â Â { |
---|
2068 |     if ((pNext(strat->L[j].p) == strat->tail) || (pOrdSgn==1)) |
---|
2069 | Â Â Â Â { |
---|
2070 | Â Â Â Â Â deleteInL(strat->L,&strat->Ll,j,strat); |
---|
2071 | Â Â Â Â Â strat->c3++; |
---|
2072 | #ifdef KDEBUG |
---|
2073 |        if (TEST_OPT_DEBUG) |
---|
2074 | Â Â Â Â Â Â Â { |
---|
2075 | Â Â Â Â Â Â Â Â PrintS("--- chain criterion func chainCritRing type 2\n"); |
---|
2076 | Â Â Â Â Â Â Â Â PrintS("strat->L[j].p:"); |
---|
2077 | Â Â Â Â Â Â Â Â wrp(strat->L[j].p); |
---|
2078 | Â Â Â Â Â Â Â Â PrintS("Â p:"); |
---|
2079 | Â Â Â Â Â Â Â Â wrp(p); |
---|
2080 | Â Â Â Â Â Â Â Â PrintLn(); |
---|
2081 | Â Â Â Â Â Â Â } |
---|
2082 | #endif |
---|
2083 | Â Â Â Â } |
---|
2084 | Â Â Â } |
---|
2085 | Â Â } |
---|
2086 | Â } |
---|
2087 | Â /* |
---|
2088 | Â *this is our MODIFICATION of GEBAUER-MOELLER: |
---|
2089 | Â *First the elements of B enter L, |
---|
2090 | Â *then we fix a lcm and the "best" element in L |
---|
2091 | Â *(i.e the last in L with this lcm and of type (s,p)) |
---|
2092 | Â *and cancel all the other elements of type (r,p) with this lcm |
---|
2093 | Â *except the case the element (s,r) has also the same lcm |
---|
2094 | Â *and is on the worst position with respect to (s,p) and (r,p) |
---|
2095 | Â */ |
---|
2096 | Â /* |
---|
2097 | Â *B enters to L/their order with respect to B is permutated for elements |
---|
2098 | Â *B[i].p with the same leading term |
---|
2099 | Â */ |
---|
2100 | Â j =Â strat->Ll; |
---|
2101 |  for (i=strat->Bl; i>=0; i--) |
---|
2102 | Â { |
---|
2103 | Â Â j =Â strat->posInL(strat->L,j,&(strat->B[i]),strat); |
---|
2104 | Â Â enterL(&strat->L,&strat->Ll,&strat->Lmax,strat->B[i],j); |
---|
2105 | Â } |
---|
2106 | Â strat->Bl =Â -1; |
---|
2107 | Â j =Â strat->Ll; |
---|
2108 |  loop /*cannot be changed into a for !!! */ |
---|
2109 | Â { |
---|
2110 |   if (j <= 0) |
---|
2111 | Â Â { |
---|
2112 | Â Â Â /*now L[0] cannot be canceled any more and the tail can be removed*/ |
---|
2113 |    if (strat->L[0].p2 == strat->tail) strat->L[0].p2 = p; |
---|
2114 | Â Â Â break; |
---|
2115 | Â Â } |
---|
2116 |   if (strat->L[j].p2 == p) // Was the element added from B? |
---|
2117 | Â Â { |
---|
2118 | Â Â Â i =Â j-1; |
---|
2119 | Â Â Â loop |
---|
2120 | Â Â Â { |
---|
2121 |     if (i < 0) break; |
---|
2122 | Â Â Â Â // Element is from B and has the same lcm as L[j] |
---|
2123 |     if ((strat->L[i].p2 == p) && nDivBy(pGetCoeff(strat->L[j].lcm), pGetCoeff(strat->L[i].lcm)) |
---|
2124 | Â Â Â Â Â Â Â &&Â pLmEqual(strat->L[j].lcm,strat->L[i].lcm)) |
---|
2125 | Â Â Â Â { |
---|
2126 | Â Â Â Â Â /*L[i] could be canceled but we search for a better one to cancel*/ |
---|
2127 | Â Â Â Â Â strat->c3++; |
---|
2128 | #ifdef KDEBUG |
---|
2129 |      if (TEST_OPT_DEBUG) |
---|
2130 | Â Â Â Â Â { |
---|
2131 | Â Â Â Â Â Â PrintS("--- chain criterion func chainCritRing type 3\n"); |
---|
2132 | Â Â Â Â Â Â PrintS("strat->L[j].lcm:"); |
---|
2133 | Â Â Â Â Â Â wrp(strat->L[j].lcm); |
---|
2134 | Â Â Â Â Â Â PrintS("Â strat->L[i].lcm:"); |
---|
2135 | Â Â Â Â Â Â wrp(strat->L[i].lcm); |
---|
2136 | Â Â Â Â Â Â PrintLn(); |
---|
2137 | Â Â Â Â Â } |
---|
2138 | #endif |
---|
2139 |      if (isInPairsetL(i-1,strat->L[j].p1,strat->L[i].p1,&l,strat) |
---|
2140 | Â Â Â Â Â &&Â (pNext(strat->L[l].p)Â ==Â strat->tail) |
---|
2141 | Â Â Â Â Â &&Â (!pLmEqual(strat->L[i].p,strat->L[l].p)) |
---|
2142 | Â Â Â Â Â &&Â pDivisibleBy(p,strat->L[l].lcm)) |
---|
2143 | Â Â Â Â Â { |
---|
2144 | Â Â Â Â Â Â /* |
---|
2145 | Â Â Â Â Â Â *"NOT equal(...)" because in case of "equal" the element L[l] |
---|
2146 | Â Â Â Â Â Â *is "older" and has to be from theoretical point of view behind |
---|
2147 | Â Â Â Â Â Â *L[i], but we do not want to reorder L |
---|
2148 | Â Â Â Â Â Â */ |
---|
2149 | Â Â Â Â Â Â strat->L[i].p2 =Â strat->tail; |
---|
2150 | Â Â Â Â Â Â /* |
---|
2151 | Â Â Â Â Â Â *L[l] will be canceled, we cannot cancel L[i] later on, |
---|
2152 | Â Â Â Â Â Â *so we mark it with "tail" |
---|
2153 | Â Â Â Â Â Â */ |
---|
2154 | Â Â Â Â Â Â deleteInL(strat->L,&strat->Ll,l,strat); |
---|
2155 | Â Â Â Â Â Â i--; |
---|
2156 | Â Â Â Â Â } |
---|
2157 | Â Â Â Â Â else |
---|
2158 | Â Â Â Â Â { |
---|
2159 | Â Â Â Â Â Â deleteInL(strat->L,&strat->Ll,i,strat); |
---|
2160 | Â Â Â Â Â } |
---|
2161 | Â Â Â Â Â j--; |
---|
2162 | Â Â Â Â } |
---|
2163 | Â Â Â Â i--; |
---|
2164 | Â Â Â } |
---|
2165 | Â Â } |
---|
2166 |   else if (strat->L[j].p2 == strat->tail) |
---|
2167 | Â Â { |
---|
2168 | Â Â Â /*now L[j] cannot be canceled any more and the tail can be removed*/ |
---|
2169 | Â Â Â strat->L[j].p2 =Â p; |
---|
2170 | Â Â } |
---|
2171 | Â Â j--; |
---|
2172 | Â } |
---|
2173 | } |
---|
2174 | #endif |
---|
2175 | |
---|
2176 | #ifdef HAVE_RING2TOM |
---|
2177 | long ind2(long arg) |
---|
2178 | { |
---|
2179 |  long ind = 0; |
---|
2180 |  if (arg <= 0) return 0; |
---|
2181 |  while (arg%2 == 0) |
---|
2182 | Â { |
---|
2183 | Â Â arg =Â arg /Â 2; |
---|
2184 | Â Â ind++; |
---|
2185 | Â } |
---|
2186 |  return ind; |
---|
2187 | } |
---|
2188 | |
---|
2189 | long ind_fact_2(long arg) |
---|
2190 | { |
---|
2191 |  long ind = 0; |
---|
2192 |  if (arg <= 0) return 0; |
---|
2193 |  if (arg%2 == 1) { arg--; } |
---|
2194 |  while (arg > 0) |
---|
2195 | Â { |
---|
2196 | Â Â ind +=Â ind2(arg); |
---|
2197 | Â Â arg =Â arg -Â 2; |
---|
2198 | Â } |
---|
2199 |  return ind; |
---|
2200 | } |
---|
2201 | #endif |
---|
2202 | |
---|
2203 | #ifdef HAVE_VANIDEAL |
---|
2204 | long twoPow(long arg) |
---|
2205 | { |
---|
2206 |  return 1L << arg; |
---|
2207 | } |
---|
2208 | |
---|
2209 | /*2 |
---|
2210 | * put the pair (p, f) in B and f in T |
---|
2211 | */ |
---|
2212 | void enterOneZeroPairRing (poly f, poly t_p, poly p, int ecart, kStrategy strat, int atR = -1) |
---|
2213 | { |
---|
2214 |  int   l,j,compare,compareCoeff; |
---|
2215 |  LObject Lp; |
---|
2216 | |
---|
2217 |  if (strat->interred_flag) return; |
---|
2218 | #ifdef KDEBUG |
---|
2219 | Â Lp.ecart=0;Â Lp.length=0; |
---|
2220 | #endif |
---|
2221 | Â /*- computes the lcm(s[i],p) -*/ |
---|
2222 | Â Lp.lcm =Â pInit(); |
---|
2223 | |
---|
2224 | Â pLcm(p,f,Lp.lcm); |
---|
2225 | Â pSetm(Lp.lcm); |
---|
2226 |  pSetCoeff(Lp.lcm, nLcm(pGetCoeff(p), pGetCoeff(f), currRing)); |
---|
2227 | Â assume(!strat->sugarCrit); |
---|
2228 | Â assume(!strat->fromT); |
---|
2229 | Â /* |
---|
2230 | Â *the set B collects the pairs of type (S[j],p) |
---|
2231 | Â *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p) |
---|
2232 | Â *if the leading term of s devides lcm(r,p) then (r,p) will be canceled |
---|
2233 | Â *if the leading term of r devides lcm(s,p) then (s,p) will not enter B |
---|
2234 | Â */ |
---|
2235 | Â for(j =Â strat->Bl;j>=0;j--) |
---|
2236 | Â { |
---|
2237 | Â Â compare=pDivCompRing(strat->B[j].lcm,Lp.lcm); |
---|
2238 |   compareCoeff = nDivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(Lp.lcm)); |
---|
2239 |   if (compareCoeff == 0 || compare == compareCoeff) |
---|
2240 | Â Â { |
---|
2241 |    if (compare == 1) |
---|
2242 | Â Â Â { |
---|
2243 | Â Â Â Â strat->c3++; |
---|
2244 | Â Â Â Â pLmDelete(Lp.lcm); |
---|
2245 | Â Â Â Â return; |
---|
2246 | Â Â Â } |
---|
2247 | Â Â Â else |
---|
2248 |    if (compare == -1) |
---|
2249 | Â Â Â { |
---|
2250 | Â Â Â Â deleteInL(strat->B,&strat->Bl,j,strat); |
---|
2251 | Â Â Â Â strat->c3++; |
---|
2252 | Â Â Â } |
---|
2253 | Â Â } |
---|
2254 |   if (compare == pDivComp_EQUAL) |
---|
2255 | Â Â { |
---|
2256 | Â Â Â // Add hint for same LM and direction of LC (later) (TODO Oliver) |
---|
2257 |    if (compareCoeff == 1) |
---|
2258 | Â Â Â { |
---|
2259 | Â Â Â Â strat->c3++; |
---|
2260 | Â Â Â Â pLmDelete(Lp.lcm); |
---|
2261 | Â Â Â Â return; |
---|
2262 | Â Â Â } |
---|
2263 | Â Â Â else |
---|
2264 |    if (compareCoeff == -1) |
---|
2265 | Â Â Â { |
---|
2266 | Â Â Â Â deleteInL(strat->B,&strat->Bl,j,strat); |
---|
2267 | Â Â Â Â strat->c3++; |
---|
2268 | Â Â Â } |
---|
2269 | Â Â } |
---|
2270 | Â } |
---|
2271 | Â /* |
---|
2272 | Â *the pair (S[i],p) enters B if the spoly != 0 |
---|
2273 | Â */ |
---|
2274 | Â /*-Â compute the short s-polynomial -*/ |
---|
2275 |  if ((f==NULL) || (p==NULL)) return; |
---|
2276 | Â pNorm(p); |
---|
2277 | Â { |
---|
2278 |   Lp.p = ksCreateShortSpoly(f, p, strat->tailRing); |
---|
2279 | Â } |
---|
2280 |  if (Lp.p == NULL) //deactivated, as we are adding pairs with zeropoly and not from S |
---|
2281 | Â { |
---|
2282 | Â Â /*- the case that the s-poly is 0 -*/ |
---|
2283 | //Â Â if (strat->pairtest==NULL) initPairtest(strat); |
---|
2284 | //Â Â strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/ |
---|
2285 | //Â Â strat->pairtest[strat->sl+1] = TRUE; |
---|
2286 | Â Â /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/ |
---|
2287 | Â Â /* |
---|
2288 | Â Â *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is |
---|
2289 | Â Â *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not |
---|
2290 | Â Â *devide lcm(r,p)). In the last case (s,r) can be canceled if the leading |
---|
2291 | Â Â *term of p devides the lcm(s,r) |
---|
2292 | Â Â *(this canceling should be done here because |
---|
2293 | Â Â *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit) |
---|
2294 | Â Â *the first case is handeled in chainCrit |
---|
2295 | Â Â */ |
---|
2296 |   if (Lp.lcm!=NULL) pLmDelete(Lp.lcm); |
---|
2297 | Â } |
---|
2298 | Â else |
---|
2299 | Â { |
---|
2300 | Â Â /*- the pair (S[i],p) enters B -*/ |
---|
2301 | Â Â Lp.p1 =Â f; |
---|
2302 | Â Â Lp.p2 =Â p; |
---|
2303 | |
---|
2304 | Â Â pNext(Lp.p)Â =Â strat->tail; |
---|
2305 | |
---|
2306 |   LObject tmp_h(f, currRing, strat->tailRing); |
---|
2307 | Â Â tmp_h.SetShortExpVector(); |
---|
2308 | Â Â strat->initEcart(&tmp_h); |
---|
2309 | Â Â tmp_h.sev =Â pGetShortExpVector(tmp_h.p); |
---|
2310 | Â Â tmp_h.t_p =Â t_p; |
---|
2311 | |
---|
2312 |   enterT(tmp_h, strat, strat->tl + 1); |
---|
2313 | |
---|
2314 |   if (atR >= 0) |
---|
2315 | Â Â { |
---|
2316 | Â Â Â Lp.i_r2 =Â atR; |
---|
2317 | Â Â Â Lp.i_r1 =Â strat->tl; |
---|
2318 | Â Â } |
---|
2319 | |
---|
2320 | Â Â strat->initEcartPair(&Lp,f,p,0/*strat->ecartS[i]*/,ecart);Â Â Â // Attention: TODO: break ecart |
---|
2321 | Â Â l =Â strat->posInL(strat->B,strat->Bl,&Lp,strat); |
---|
2322 |   enterL(&strat->B, &strat->Bl, &strat->Bmax, Lp, l); |
---|
2323 | Â } |
---|
2324 | } |
---|
2325 | |
---|
2326 | /* Helper for kCreateZeroPoly |
---|
2327 | Â * enumerating the exponents |
---|
2328 | ring r = 2^2, (a, b, c), lp; ideal G0 = system("createG0"); ideal G = interred(G0); ncols(G0); ncols(G); |
---|
2329 | Â */ |
---|
2330 | |
---|
2331 | int nextZeroSimplexExponent (long exp[], long ind[], long cexp[], long cind[], long* cabsind, long step[], long bound, long N) |
---|
2332 | /* gives the next exponent from the set H_1 */ |
---|
2333 | { |
---|
2334 |  long add = ind2(cexp[1] + 2); |
---|
2335 |  if ((*cabsind < bound) && (*cabsind - step[1] + add < bound)) |
---|
2336 | Â { |
---|
2337 | Â Â cexp[1]Â +=Â 2; |
---|
2338 | Â Â cind[1]Â +=Â add; |
---|
2339 | Â Â *cabsind +=Â add; |
---|
2340 | Â } |
---|
2341 | Â else |
---|
2342 | Â { |
---|
2343 | Â Â // cabsind >= habsind |
---|
2344 |   if (N == 1) return 0; |
---|
2345 |   int i = 1; |
---|
2346 |   while (exp[i] == cexp[i] && i <= N) i++; |
---|
2347 | Â Â cexp[i]Â =Â exp[i]; |
---|
2348 | Â Â *cabsind -=Â cind[i]; |
---|
2349 | Â Â cind[i]Â =Â ind[i]; |
---|
2350 | Â Â step[i]Â =Â 500000; |
---|
2351 | Â Â *cabsind +=Â cind[i]; |
---|
2352 | Â Â // Print("in: %d\n", *cabsind); |
---|
2353 | Â Â i +=Â 1; |
---|
2354 |   if (i > N) return 0; |
---|
2355 | Â Â do |
---|
2356 | Â Â { |
---|
2357 | Â Â Â step[1]Â =Â 500000; |
---|
2358 |    for (int j = i + 1; j <= N; j++) |
---|
2359 | Â Â Â { |
---|
2360 |     if (step[1] > step[j]) step[1] = step[j]; |
---|
2361 | Â Â Â } |
---|
2362 | Â Â Â add =Â ind2(cexp[i]Â +Â 2); |
---|
2363 |    if (*cabsind - step[1] + add >= bound) |
---|
2364 | Â Â Â { |
---|
2365 | Â Â Â Â cexp[i]Â =Â exp[i]; |
---|
2366 | Â Â Â Â *cabsind -=Â cind[i]; |
---|
2367 | Â Â Â Â cind[i]Â =Â ind[i]; |
---|
2368 | Â Â Â Â *cabsind +=Â cind[i]; |
---|
2369 | Â Â Â Â step[i]Â =Â 500000; |
---|
2370 | Â Â Â Â i +=Â 1; |
---|
2371 |     if (i > N) return 0; |
---|
2372 | Â Â Â } |
---|
2373 |    else step[1] = -1; |
---|
2374 |   } while (step[1] != -1); |
---|
2375 | Â Â step[1]Â =Â 500000; |
---|
2376 | Â Â cexp[i]Â +=Â 2; |
---|
2377 | Â Â cind[i]Â +=Â add; |
---|
2378 | Â Â *cabsind +=Â add; |
---|
2379 |   if (add < step[i]) step[i] = add; |
---|
2380 |   for (i = 2; i <= N; i++) |
---|
2381 | Â Â { |
---|
2382 |    if (step[1] > step[i]) step[1] = step[i]; |
---|
2383 | Â Â } |
---|
2384 | Â } |
---|
2385 |  return 1; |
---|
2386 | } |
---|
2387 | |
---|
2388 | /* |
---|
2389 | Â * Creates the zero Polynomial on position exp |
---|
2390 | Â * long exp[] : exponent of leading term |
---|
2391 |  * cabsind  : total 2-ind of exp (if -1 will be computed) |
---|
2392 |  * poly* t_p : will hold the LT in tailRing |
---|
2393 |  * leadRing  : ring for the LT |
---|
2394 |  * tailRing  : ring for the tail |
---|
2395 | Â */ |
---|
2396 | |
---|
2397 | poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing) |
---|
2398 | { |
---|
2399 | |
---|
2400 | Â poly zeroPoly =Â NULL; |
---|
2401 | |
---|
2402 | Â number tmp1; |
---|
2403 |  poly tmp2, tmp3; |
---|
2404 | |
---|
2405 |  if (cabsind == -1) |
---|
2406 | Â { |
---|
2407 | Â Â cabsind =Â 0; |
---|
2408 |   for (int i = 1; i <= leadRing->N; i++) |
---|
2409 | Â Â { |
---|
2410 | Â Â Â cabsind +=Â ind_fact_2(exp[i]); |
---|
2411 | Â Â } |
---|
2412 | //Â Â Print("cabsind: %d\n", cabsind); |
---|
2413 | Â } |
---|
2414 |  if (cabsind < leadRing->ch) |
---|
2415 | Â { |
---|
2416 |   zeroPoly = p_ISet(twoPow(leadRing->ch - cabsind), tailRing); |
---|
2417 | Â } |
---|
2418 | Â else |
---|
2419 | Â { |
---|
2420 |   zeroPoly = p_ISet(1, tailRing); |
---|
2421 | Â } |
---|
2422 |  for (int i = 1; i <= leadRing->N; i++) |
---|
2423 | Â { |
---|
2424 |   for (long j = 1; j <= exp[i]; j++) |
---|
2425 | Â Â { |
---|
2426 | Â Â Â tmp1 =Â nInit(j); |
---|
2427 |    tmp2 = p_ISet(1, tailRing); |
---|
2428 |    p_SetExp(tmp2, i, 1, tailRing); |
---|
2429 |    p_Setm(tmp2, tailRing); |
---|
2430 |    if (nIsZero(tmp1)) |
---|
2431 | Â Â Â {Â // should nowbe obsolet, test ! TODO OLIVER |
---|
2432 |     zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing); |
---|
2433 | Â Â Â } |
---|
2434 | Â Â Â else |
---|
2435 | Â Â Â { |
---|
2436 |     tmp3 = p_NSet(nCopy(tmp1), tailRing); |
---|
2437 |     zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing); |
---|
2438 | Â Â Â } |
---|
2439 | Â Â } |
---|
2440 | Â } |
---|
2441 |  tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing); |
---|
2442 |  for (int i = 1; i <= leadRing->N; i++) |
---|
2443 | Â { |
---|
2444 |   pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing)); |
---|
2445 | Â } |
---|
2446 |  p_Setm(tmp2, leadRing); |
---|
2447 | Â *t_p =Â zeroPoly; |
---|
2448 | Â zeroPoly =Â pNext(zeroPoly); |
---|
2449 | Â pNext(*t_p)Â =Â NULL; |
---|
2450 | Â pNext(tmp2)Â =Â zeroPoly; |
---|
2451 |  return tmp2; |
---|
2452 | } |
---|
2453 | |
---|
2454 | // #define OLI_DEBUG |
---|
2455 | |
---|
2456 | /* |
---|
2457 | Â * Generate the s-polynomial for the virtual set of zero-polynomials |
---|
2458 | Â */ |
---|
2459 | |
---|
2460 | void initenterzeropairsRing (poly p, int ecart, kStrategy strat, int atR) |
---|
2461 | { |
---|
2462 | Â // Initialize |
---|
2463 |  long exp[50];      // The exponent of \hat{X} (basepoint) |
---|
2464 |  long cexp[50];      // The current exponent for iterating over all |
---|
2465 |  long ind[50];      // The power of 2 in the i-th component of exp |
---|
2466 |  long cind[50];      // analog for cexp |
---|
2467 |  long mult[50];      // How to multiply the elements of G |
---|
2468 |  long cabsind = 0;    // The abs. index of cexp, i.e. the sum of cind |
---|
2469 |  long habsind = 0;    // The abs. index of the coefficient of h |
---|
2470 |  long step[50];      // The last increases |
---|
2471 |  for (int i = 1; i <= currRing->N; i++) |
---|
2472 | Â { |
---|
2473 |   exp[i] = p_GetExp(p, i, currRing); |
---|
2474 |   if (exp[i] & 1 != 0) |
---|
2475 | Â Â { |
---|
2476 | Â Â Â exp[i]Â =Â exp[i]Â -Â 1; |
---|
2477 | Â Â Â mult[i]Â =Â 1; |
---|
2478 | Â Â } |
---|
2479 | Â Â cexp[i]Â =Â exp[i]; |
---|
2480 | Â Â ind[i]Â =Â ind_fact_2(exp[i]); |
---|
2481 | Â Â cabsind +=Â ind[i]; |
---|
2482 | Â Â cind[i]Â =Â ind[i]; |
---|
2483 | Â Â step[i]Â =Â 500000; |
---|
2484 | Â } |
---|
2485 | Â step[1]Â =Â 500000; |
---|
2486 |  habsind = ind2((long) p_GetCoeff(p, currRing)); |
---|
2487 |  long bound = currRing->ch - habsind; |
---|
2488 | #ifdef OLI_DEBUG |
---|
2489 |  PrintS("-------------\npoly :"); |
---|
2490 | Â wrp(p); |
---|
2491 |  Print("\nexp  : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]); |
---|
2492 |  Print("cexp : (%d, %d)\n", cexp[1], cexp[2]); |
---|
2493 |  Print("cind : (%d, %d)\n", cind[1], cind[2]); |
---|
2494 |  Print("bound : %d\n", bound); |
---|
2495 |  Print("cind : %d\n", cabsind); |
---|
2496 | #endif |
---|
2497 |  if (cabsind == 0) |
---|
2498 | Â { |
---|
2499 |   if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N))) |
---|
2500 | Â Â { |
---|
2501 | Â Â Â return; |
---|
2502 | Â Â } |
---|
2503 | Â } |
---|
2504 | Â // Now the whole simplex |
---|
2505 | Â do |
---|
2506 | Â { |
---|
2507 | Â Â // Build s-polynomial |
---|
2508 | Â Â // 2**ind-def * mult * g - exp-def * h |
---|
2509 | Â Â poly t_p; |
---|
2510 |   poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, strat->tailRing); |
---|
2511 | #ifdef OLI_DEBUG |
---|
2512 |   Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]); |
---|
2513 | Â Â Print("zPoly : "); |
---|
2514 | Â Â wrp(zeroPoly); |
---|
2515 | Â Â Print("\n"); |
---|
2516 | #endif |
---|
2517 |   enterOneZeroPairRing(zeroPoly, t_p, p, ecart, strat, atR); |
---|
2518 | Â } |
---|
2519 |  while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N) ); |
---|
2520 | } |
---|
2521 | |
---|
2522 | /* |
---|
2523 | Â * Create the Groebner basis of the vanishing polynomials. |
---|
2524 | Â */ |
---|
2525 | |
---|
2526 | ideal createG0() |
---|
2527 | { |
---|
2528 | Â // Initialize |
---|
2529 |  long exp[50];      // The exponent of \hat{X} (basepoint) |
---|
2530 |  long cexp[50];      // The current exponent for iterating over all |
---|
2531 |  long ind[50];      // The power of 2 in the i-th component of exp |
---|
2532 |  long cind[50];      // analog for cexp |
---|
2533 |  long mult[50];      // How to multiply the elements of G |
---|
2534 |  long cabsind = 0;    // The abs. index of cexp, i.e. the sum of cind |
---|
2535 |  long habsind = 0;    // The abs. index of the coefficient of h |
---|
2536 |  long step[50];      // The last increases |
---|
2537 |  for (int i = 1; i <= currRing->N; i++) |
---|
2538 | Â { |
---|
2539 | Â Â exp[i]Â =Â 0; |
---|
2540 | Â Â cexp[i]Â =Â exp[i]; |
---|
2541 | Â Â ind[i]Â =Â 0; |
---|
2542 | Â Â step[i]Â =Â 500000; |
---|
2543 | Â Â cind[i]Â =Â ind[i]; |
---|
2544 | Â } |
---|
2545 |  long bound = currRing->ch; |
---|
2546 | Â step[1]Â =Â 500000; |
---|
2547 | #ifdef OLI_DEBUG |
---|
2548 |  PrintS("-------------\npoly :"); |
---|
2549 | //Â wrp(p); |
---|
2550 |  Print("\nexp  : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]); |
---|
2551 |  Print("cexp : (%d, %d)\n", cexp[1], cexp[2]); |
---|
2552 |  Print("cind : (%d, %d)\n", cind[1], cind[2]); |
---|
2553 |  Print("bound : %d\n", bound); |
---|
2554 |  Print("cind : %d\n", cabsind); |
---|
2555 | #endif |
---|
2556 |  if (cabsind == 0) |
---|
2557 | Â { |
---|
2558 |   if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N))) |
---|
2559 | Â Â { |
---|
2560 |    return idInit(1, 1); |
---|
2561 | Â Â } |
---|
2562 | Â } |
---|
2563 |  ideal G0 = idInit(1, 1); |
---|
2564 | Â // Now the whole simplex |
---|
2565 | Â do |
---|
2566 | Â { |
---|
2567 | Â Â // Build s-polynomial |
---|
2568 | Â Â // 2**ind-def * mult * g - exp-def * h |
---|
2569 | Â Â poly t_p; |
---|
2570 |   poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, currRing); |
---|
2571 | #ifdef OLI_DEBUG |
---|
2572 |   Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]); |
---|
2573 | Â Â Print("zPoly : "); |
---|
2574 | Â Â wrp(zeroPoly); |
---|
2575 | Â Â Print("\n"); |
---|
2576 | #endif |
---|
2577 | Â Â // Add to ideal |
---|
2578 |   pEnlargeSet(&(G0->m), IDELEMS(G0), 1); |
---|
2579 | Â Â IDELEMS(G0)Â +=Â 1; |
---|
2580 | Â Â G0->m[IDELEMS(G0)Â -Â 1]Â =Â zeroPoly; |
---|
2581 | Â } |
---|
2582 |  while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N) ); |
---|
2583 | Â idSkipZeroes(G0); |
---|
2584 |  return G0; |
---|
2585 | } |
---|
2586 | #endif |
---|
2587 | |
---|
2588 | #ifdef HAVE_RINGS |
---|
2589 | /*2 |
---|
2590 | *(s[0],h),...,(s[k],h) will be put to the pairset L |
---|
2591 | */ |
---|
2592 | void initenterpairsRing (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR = -1) |
---|
2593 | { |
---|
2594 | |
---|
2595 |  if ((strat->syzComp==0) || (pGetComp(h)<=strat->syzComp)) |
---|
2596 | Â { |
---|
2597 |   int j; |
---|
2598 | Â Â BOOLEAN new_pair=FALSE; |
---|
2599 | |
---|
2600 |   if (pGetComp(h)==0) |
---|
2601 | Â Â { |
---|
2602 | Â Â Â /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/ |
---|
2603 |    if ((isFromQ)&&(strat->fromQ!=NULL)) |
---|
2604 | Â Â Â { |
---|
2605 |     for (j=0; j<=k; j++) |
---|
2606 | Â Â Â Â { |
---|
2607 |      if (!strat->fromQ[j]) |
---|
2608 | Â Â Â Â Â { |
---|
2609 | Â Â Â Â Â Â new_pair=TRUE; |
---|
2610 | Â Â Â Â Â Â Print("TODO Oliver --- j:%d, Ll:%d\n",j,strat->Ll); |
---|
2611 |       enterOnePairRing(j,h,ecart,isFromQ,strat, atR); |
---|
2612 | Â Â Â Â Â } |
---|
2613 | Â Â Â Â } |
---|
2614 | Â Â Â } |
---|
2615 | Â Â Â else |
---|
2616 | Â Â Â { |
---|
2617 | Â Â Â Â new_pair=TRUE; |
---|
2618 |     for (j=0; j<=k; j++) |
---|
2619 | Â Â Â Â { |
---|
2620 | Â Â Â Â Â // Print("j:%d, Ll:%d\n",j,strat->Ll); |
---|
2621 |      enterOnePairRing(j,h,ecart,isFromQ,strat, atR); |
---|
2622 | Â Â Â Â } |
---|
2623 | Â Â Â } |
---|
2624 | Â Â } |
---|
2625 | Â Â else |
---|
2626 | Â Â { |
---|
2627 |    for (j=0; j<=k; j++) |
---|
2628 | Â Â Â { |
---|
2629 |     if ((pGetComp(h)==pGetComp(strat->S[j])) || (pGetComp(strat->S[j])==0)) |
---|
2630 | Â Â Â Â { |
---|
2631 | Â Â Â Â Â new_pair=TRUE; |
---|
2632 | Â Â Â Â Â Print("TODO Oliver --- j:%d, Ll:%d\n",j,strat->Ll); |
---|
2633 |      enterOnePairRing(j,h,ecart,isFromQ,strat, atR); |
---|
2634 | Â Â Â Â } |
---|
2635 | Â Â Â } |
---|
2636 | Â Â } |
---|
2637 | |
---|
2638 | #ifdef HAVE_VANGB |
---|
2639 | Â Â // initenterzeropairsRing(h, ecart, strat, atR); |
---|
2640 | #endif |
---|
2641 | |
---|
2642 |   if (new_pair) chainCritRing(h,ecart,strat); |
---|
2643 | |
---|
2644 | Â } |
---|
2645 | /* |
---|
2646 | ring r=256,(x,y,z),dp; |
---|
2647 | ideal I=12xz-133y, 2xy-z; |
---|
2648 | */ |
---|
2649 | |
---|
2650 | } |
---|
2651 | |
---|
2652 | /*2 |
---|
2653 | *(s[0],h),...,(s[k],h) will be put to the pairset L |
---|
2654 | */ |
---|
2655 | void initenterstrongPairs (poly h,int k,int ecart,int isFromQ,kStrategy strat, int atR = -1) |
---|
2656 | { |
---|
2657 | |
---|
2658 |  if (!nIsOne(pGetCoeff(h))) |
---|
2659 | Â { |
---|
2660 |   int j; |
---|
2661 | Â Â BOOLEAN new_pair=FALSE; |
---|
2662 | |
---|
2663 |   for (j=0; j<=k; j++) |
---|
2664 | Â Â { |
---|
2665 | Â Â Â // Print("j:%d, Ll:%d\n",j,strat->Ll); |
---|
2666 | //Â Â Â if (((unsigned long) pGetCoeff(h) % (unsigned long) pGetCoeff(strat->S[j]) != 0) && |
---|
2667 | //Â Â Â Â Â ((unsigned long) pGetCoeff(strat->S[j]) % (unsigned long) pGetCoeff(h) != 0)) |
---|
2668 | Â Â Â { |
---|
2669 |     if (enterOneStrongPoly(j,h,ecart,isFromQ,strat, atR)) |
---|
2670 | Â Â Â Â Â new_pair=TRUE; |
---|
2671 | Â Â Â } |
---|
2672 | Â Â } |
---|
2673 | Â } |
---|
2674 | /* |
---|
2675 | ring r=256,(x,y,z),dp; |
---|
2676 | ideal I=12xz-133y, 2xy-z; |
---|
2677 | */ |
---|
2678 | |
---|
2679 | } |
---|
2680 | |
---|
2681 | /*2 |
---|
2682 | * Generates spoly(0, h) if applicable. Assumes ring in Z/2^n. |
---|
2683 | */ |
---|
2684 | void enterExtendedSpoly(poly h,kStrategy strat) |
---|
2685 | { |
---|
2686 |  if (nIsOne(pGetCoeff(h))) return; |
---|
2687 | Â number gcd; |
---|
2688 |  bool go = false; |
---|
2689 |  if (nDivBy((number) 0, pGetCoeff(h))) |
---|
2690 | Â { |
---|
2691 |   gcd = nIntDiv((number) 0, pGetCoeff(h)); |
---|
2692 | Â Â go =Â true; |
---|
2693 | Â } |
---|
2694 | Â else |
---|
2695 |   gcd = nGcd((number) 0, pGetCoeff(h), strat->tailRing); |
---|
2696 |  if (go || !nIsOne(gcd)) |
---|
2697 | Â { |
---|
2698 | Â Â poly p =Â h->next; |
---|
2699 |   if (!go) |
---|
2700 | Â Â { |
---|
2701 | Â Â Â number tmp =Â gcd; |
---|
2702 |    gcd = nIntDiv(0, gcd); |
---|
2703 | Â Â Â nDelete(&tmp); |
---|
2704 | Â Â } |
---|
2705 |   p = pp_Mult_nn(p, gcd, strat->tailRing); |
---|
2706 | Â Â nDelete(&gcd); |
---|
2707 | |
---|
2708 |   if (p != NULL) |
---|
2709 | Â Â { |
---|
2710 |    if (TEST_OPT_PROT) |
---|
2711 | Â Â Â { |
---|
2712 | Â Â Â Â PrintS("Z"); |
---|
2713 | Â Â Â } |
---|
2714 | #ifdef KDEBUG |
---|
2715 |    if (TEST_OPT_DEBUG) |
---|
2716 | Â Â Â { |
---|
2717 | Â Â Â Â PrintS("--- create zero spoly: "); |
---|
2718 | Â Â Â Â wrp(h); |
---|
2719 | Â Â Â Â PrintS(" ---> "); |
---|
2720 | Â Â Â } |
---|
2721 | #endif |
---|
2722 | Â Â Â poly tmp =Â pInit(); |
---|
2723 |    pSetCoeff0(tmp, pGetCoeff(p)); |
---|
2724 |    for (int i = 1; i <= currRing->N; i++) |
---|
2725 | Â Â Â { |
---|
2726 |     pSetExp(tmp, i, p_GetExp(p, i, strat->tailRing)); |
---|
2727 | Â Â Â } |
---|
2728 |    p_Setm(tmp, currRing); |
---|
2729 |    p = p_LmFreeAndNext(p, strat->tailRing); |
---|
2730 | Â Â Â pNext(tmp)Â =Â p; |
---|
2731 | Â Â Â LObject h; |
---|
2732 | Â Â Â h.p =Â tmp; |
---|
2733 | Â Â Â h.tailRing =Â strat->tailRing; |
---|
2734 |    int posx; |
---|
2735 |    if (h.p!=NULL) |
---|
2736 | Â Â Â { |
---|
2737 |     if (TEST_OPT_INTSTRATEGY) |
---|
2738 | Â Â Â Â { |
---|
2739 | Â Â Â Â Â //pContent(h.p); |
---|
2740 | Â Â Â Â Â h.pCleardenom();Â // also does a pContent |
---|
2741 | Â Â Â Â } |
---|
2742 | Â Â Â Â else |
---|
2743 | Â Â Â Â { |
---|
2744 | Â Â Â Â Â h.pNorm(); |
---|
2745 | Â Â Â Â } |
---|
2746 | Â Â Â Â strat->initEcart(&h); |
---|
2747 |     if (strat->Ll==-1) |
---|
2748 | Â Â Â Â Â posx =0; |
---|
2749 | Â Â Â Â else |
---|
2750 | Â Â Â Â Â posx =Â strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
2751 | Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
2752 |     h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing); |
---|
2753 |     if (pNext(p) != NULL) |
---|
2754 | Â Â Â Â { |
---|
2755 | Â Â Â Â Â // What does this? (Oliver) |
---|
2756 | Â Â Â Â Â // pShallowCopyDeleteProc p_shallow_copy_delete |
---|
2757 | Â Â Â Â Â //Â Â Â = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing); |
---|
2758 | Â Â Â Â Â // pNext(p) = p_shallow_copy_delete(pNext(p), |
---|
2759 | Â Â Â Â Â //Â Â Â Â Â Â Â currRing, strat->tailRing, strat->tailRing->PolyBin); |
---|
2760 | Â Â Â Â } |
---|
2761 | #ifdef KDEBUG |
---|
2762 |     if (TEST_OPT_DEBUG) |
---|
2763 | Â Â Â Â { |
---|
2764 | Â Â Â Â Â wrp(tmp); |
---|
2765 | Â Â Â Â Â PrintLn(); |
---|
2766 | Â Â Â Â } |
---|
2767 | #endif |
---|
2768 | Â Â Â Â enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx); |
---|
2769 | Â Â Â } |
---|
2770 | Â Â } |
---|
2771 | Â } |
---|
2772 | Â nDelete(&gcd); |
---|
2773 | } |
---|
2774 | |
---|
2775 | void clearSbatch (poly h,int k,int pos,kStrategy strat) |
---|
2776 | { |
---|
2777 |  int j = pos; |
---|
2778 |  if ( (!strat->fromT) |
---|
2779 | Â &&Â (1//(strat->syzComp==0) |
---|
2780 | Â Â //||(pGetComp(h)<=strat->syzComp))) |
---|
2781 | Â )) |
---|
2782 | Â { |
---|
2783 | Â Â // Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl); |
---|
2784 |   unsigned long h_sev = pGetShortExpVector(h); |
---|
2785 | Â Â loop |
---|
2786 | Â Â { |
---|
2787 |    if (j > k) break; |
---|
2788 |    clearS(h,h_sev, &j,&k,strat); |
---|
2789 | Â Â Â j++; |
---|
2790 | Â Â } |
---|
2791 | Â Â // Print("end clearS sl=%d\n",strat->sl); |
---|
2792 | Â } |
---|
2793 | } |
---|
2794 | |
---|
2795 | /*2 |
---|
2796 | * Generates a sufficient set of spolys (maybe just a finite generating |
---|
2797 | * set of the syzygys) |
---|
2798 | */ |
---|
2799 | void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR) |
---|
2800 | { |
---|
2801 | Â Â assume (rField_is_Ring(currRing)); |
---|
2802 | Â Â // enter also zero divisor * poly, if this is non zero and of smaller degree |
---|
2803 |   if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); |
---|
2804 |   initenterpairsRing(h, k, ecart, 0, strat, atR); |
---|
2805 |   initenterstrongPairs(h, k, ecart, 0, strat, atR); |
---|
2806 |   clearSbatch(h, k, pos, strat); |
---|
2807 | } |
---|
2808 | #endif |
---|
2809 | |
---|
2810 | /*2 |
---|
2811 | *(s[0],h),...,(s[k],h) will be put to the pairset L(via initenterpairs) |
---|
2812 | *superfluous elements in S will be deleted |
---|
2813 | */ |
---|
2814 | void enterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR) |
---|
2815 | { |
---|
2816 |  int j=pos; |
---|
2817 | |
---|
2818 | #ifdef HAVE_RINGS |
---|
2819 | Â assume (!rField_is_Ring(currRing)); |
---|
2820 | #endif |
---|
2821 | |
---|
2822 |  initenterpairs(h,k,ecart,0,strat, atR); |
---|
2823 |  if ( (!strat->fromT) |
---|
2824 | Â &&Â ((strat->syzComp==0) |
---|
2825 | Â Â ||(pGetComp(h)<=strat->syzComp))) |
---|
2826 | Â { |
---|
2827 | Â Â //Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl); |
---|
2828 |   unsigned long h_sev = pGetShortExpVector(h); |
---|
2829 | Â Â loop |
---|
2830 | Â Â { |
---|
2831 |    if (j > k) break; |
---|
2832 |    clearS(h,h_sev, &j,&k,strat); |
---|
2833 | Â Â Â j++; |
---|
2834 | Â Â } |
---|
2835 | Â Â //Print("end clearS sl=%d\n",strat->sl); |
---|
2836 | Â } |
---|
2837 | Â // PrintS("end enterpairs\n"); |
---|
2838 | } |
---|
2839 | |
---|
2840 | /*2 |
---|
2841 | *(s[0],h),...,(s[k],h) will be put to the pairset L(via initenterpairs) |
---|
2842 | *superfluous elements in S will be deleted |
---|
2843 | */ |
---|
2844 | void enterpairsSpecial (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1) |
---|
2845 | { |
---|
2846 |  int j; |
---|
2847 | |
---|
2848 |  for (j=0; j<=k; j++) |
---|
2849 | Â { |
---|
2850 |   if ((pGetComp(h)==pGetComp(strat->S[j])) |
---|
2851 | Â Â ||Â (0==pGetComp(strat->S[j]))) |
---|
2852 | Â Â { |
---|
2853 |    enterOnePairSpecial(j,h,ecart,strat, atR); |
---|
2854 | Â Â } |
---|
2855 | Â } |
---|
2856 | //Â Â #ifdef HAVE_PLURAL |
---|
2857 |  if (!rIsPluralRing(currRing)) |
---|
2858 | //Â Â #endif |
---|
2859 | Â { |
---|
2860 | Â Â j=pos; |
---|
2861 | Â Â loop |
---|
2862 | Â Â { |
---|
2863 |    unsigned long h_sev = pGetShortExpVector(h); |
---|
2864 |    if (j > k) break; |
---|
2865 | Â Â Â clearS(h,h_sev,&j,&k,strat); |
---|
2866 | Â Â Â j++; |
---|
2867 | Â Â } |
---|
2868 | Â } |
---|
2869 | } |
---|
2870 | |
---|
2871 | /*2 |
---|
2872 | *reorders s with respect to posInS, |
---|
2873 | *suc is the first changed index or zero |
---|
2874 | */ |
---|
2875 | |
---|
2876 | void reorderS (int* suc,kStrategy strat) |
---|
2877 | { |
---|
2878 |  int i,j,at,ecart, s2r; |
---|
2879 |  int fq=0; |
---|
2880 |  unsigned long sev; |
---|
2881 |  poly p; |
---|
2882 |  int new_suc=strat->sl+1; |
---|
2883 | Â i=Â *suc; |
---|
2884 |  if (i<0) i=0; |
---|
2885 | |
---|
2886 |  for (; i<=strat->sl; i++) |
---|
2887 | Â { |
---|
2888 | Â Â at =Â posInS(strat,i-1,strat->S[i],strat->ecartS[i]); |
---|
2889 |   if (at != i) |
---|
2890 | Â Â { |
---|
2891 |    if (new_suc > at) new_suc = at; |
---|
2892 | Â Â Â p =Â strat->S[i]; |
---|
2893 | Â Â Â ecart =Â strat->ecartS[i]; |
---|
2894 | Â Â Â sev =Â strat->sevS[i]; |
---|
2895 | Â Â Â s2r =Â strat->S_2_R[i]; |
---|
2896 |    if (strat->fromQ!=NULL) fq=strat->fromQ[i]; |
---|
2897 |    for (j=i; j>=at+1; j--) |
---|
2898 | Â Â Â { |
---|
2899 | Â Â Â Â strat->S[j]Â =Â strat->S[j-1]; |
---|
2900 | Â Â Â Â strat->ecartS[j]Â =Â strat->ecartS[j-1]; |
---|
2901 | Â Â Â Â strat->sevS[j]Â =Â strat->sevS[j-1]; |
---|
2902 | Â Â Â Â strat->S_2_R[j]Â =Â strat->S_2_R[j-1]; |
---|
2903 | Â Â Â } |
---|
2904 | Â Â Â strat->S[at]Â =Â p; |
---|
2905 | Â Â Â strat->ecartS[at]Â =Â ecart; |
---|
2906 | Â Â Â strat->sevS[at]Â =Â sev; |
---|
2907 | Â Â Â strat->S_2_R[at]Â =Â s2r; |
---|
2908 |    if (strat->fromQ!=NULL) |
---|
2909 | Â Â Â { |
---|
2910 |     for (j=i; j>=at+1; j--) |
---|
2911 | Â Â Â Â { |
---|
2912 | Â Â Â Â Â strat->fromQ[j]Â =Â strat->fromQ[j-1]; |
---|
2913 | Â Â Â Â } |
---|
2914 | Â Â Â Â strat->fromQ[at]=fq; |
---|
2915 | Â Â Â } |
---|
2916 | Â Â } |
---|
2917 | Â } |
---|
2918 |  if (new_suc <= strat->sl) *suc=new_suc; |
---|
2919 |  else           *suc=-1; |
---|
2920 | } |
---|
2921 | |
---|
2922 | |
---|
2923 | /*2 |
---|
2924 | *looks up the position of p in set |
---|
2925 | *set[0] is the smallest with respect to the ordering-procedure deg/pComp |
---|
2926 | * Assumption: posInS only depends on the leading term |
---|
2927 | *Â Â Â Â Â Â Â otherwise, bba has to be changed |
---|
2928 | */ |
---|
2929 | int posInS (const kStrategy strat, const int length,const poly p, |
---|
2930 |       const int ecart_p) |
---|
2931 | { |
---|
2932 |  if(length==-1) return 0; |
---|
2933 | Â polyset set=strat->S; |
---|
2934 |  int i; |
---|
2935 |  int an = 0; |
---|
2936 |  int en = length; |
---|
2937 |  int cmp_int = pOrdSgn; |
---|
2938 |  int pc=pGetComp(p); |
---|
2939 |  if ((currRing->MixedOrder) |
---|
2940 | #if 0 |
---|
2941 | Â || ((strat->ak>0) && ((currRing->order[0]==ringorder_c)||((currRing->order[0]==ringorder_C)))) |
---|
2942 | #endif |
---|
2943 | Â ) |
---|
2944 | Â { |
---|
2945 |   int o=pWTotaldegree(p); |
---|
2946 |   int oo=pWTotaldegree(set[length]); |
---|
2947 | |
---|
2948 |   if ((oo<o) |
---|
2949 | Â Â ||Â ((o==oo)Â &&Â (pLmCmp(set[length],p)!=Â cmp_int))) |
---|
2950 |    return length+1; |
---|
2951 | |
---|
2952 | Â Â loop |
---|
2953 | Â Â { |
---|
2954 |    if (an >= en-1) |
---|
2955 | Â Â Â { |
---|
2956 |     if ((pWTotaldegree(set[an])>=o) && (pLmCmp(set[an],p) == cmp_int)) |
---|
2957 | Â Â Â Â { |
---|
2958 |      return an; |
---|
2959 | Â Â Â Â } |
---|
2960 |     return en; |
---|
2961 | Â Â Â } |
---|
2962 | Â Â Â i=(an+en)Â /Â 2; |
---|
2963 |    if ((pWTotaldegree(set[i])>=o) && (pLmCmp(set[i],p) == cmp_int)) en=i; |
---|
2964 |    else               an=i; |
---|
2965 | Â Â } |
---|
2966 | Â } |
---|
2967 | Â else |
---|
2968 | Â { |
---|
2969 | #ifdef HAVE_RINGS |
---|
2970 |   if (rField_is_Ring(currRing)) |
---|
2971 | Â Â { |
---|
2972 |    if (pLmCmp(set[length],p)== -cmp_int) |
---|
2973 |     return length+1; |
---|
2974 |    int cmp; |
---|
2975 | Â Â Â loop |
---|
2976 | Â Â Â { |
---|
2977 |     if (an >= en-1) |
---|
2978 | Â Â Â Â { |
---|
2979 | Â Â Â Â Â cmp =Â pLmCmp(set[an],p); |
---|
2980 |      if (cmp == cmp_int) return an; |
---|
2981 |      if (cmp == -cmp_int) return en; |
---|
2982 |      if (nDivBy(pGetCoeff(p), pGetCoeff(set[an]))) return en; |
---|
2983 |      return an; |
---|
2984 | Â Â Â Â } |
---|
2985 | Â Â Â Â i =Â (an+en)Â /Â 2; |
---|
2986 | Â Â Â Â cmp =Â pLmCmp(set[i],p); |
---|
2987 |     if (cmp == cmp_int)     en = i; |
---|
2988 |     else if (cmp == -cmp_int)  an = i; |
---|
2989 | Â Â Â Â else |
---|
2990 | Â Â Â Â { |
---|
2991 |      if (nDivBy(pGetCoeff(p), pGetCoeff(set[i]))) an = i; |
---|
2992 |      else en = i; |
---|
2993 | Â Â Â Â } |
---|
2994 | Â Â Â } |
---|
2995 | Â Â } |
---|
2996 | Â Â else |
---|
2997 | #endif |
---|
2998 |   if (pLmCmp(set[length],p)== -cmp_int) |
---|
2999 |    return length+1; |
---|
3000 | |
---|
3001 | Â Â loop |
---|
3002 | Â Â { |
---|
3003 |    if (an >= en-1) |
---|
3004 | Â Â Â { |
---|
3005 |     if (pLmCmp(set[an],p) == cmp_int) return an; |
---|
3006 |     if (pLmCmp(set[an],p) == -cmp_int) return en; |
---|
3007 |     if ((cmp_int!=1) |
---|
3008 | Â Â Â Â &&Â ((strat->ecartS[an])>ecart_p)) |
---|
3009 |      return an; |
---|
3010 |     return en; |
---|
3011 | Â Â Â } |
---|
3012 | Â Â Â i=(an+en)Â /Â 2; |
---|
3013 |    if (pLmCmp(set[i],p) == cmp_int) en=i; |
---|
3014 |    else if (pLmCmp(set[i],p) == -cmp_int) an=i; |
---|
3015 | Â Â Â else |
---|
3016 | Â Â Â { |
---|
3017 |     if ((cmp_int!=1) |
---|
3018 | Â Â Â Â &&((strat->ecartS[i])<ecart_p)) |
---|
3019 | Â Â Â Â Â en=i; |
---|
3020 | Â Â Â Â else |
---|
3021 | Â Â Â Â Â an=i; |
---|
3022 | Â Â Â } |
---|
3023 | Â Â } |
---|
3024 | Â } |
---|
3025 | } |
---|
3026 | |
---|
3027 | |
---|
3028 | /*2 |
---|
3029 | * looks up the position of p in set |
---|
3030 | * the position is the last one |
---|
3031 | */ |
---|
3032 | int posInT0 (const TSet set,const int length,LObject &p) |
---|
3033 | { |
---|
3034 |  return (length+1); |
---|
3035 | } |
---|
3036 | |
---|
3037 | |
---|
3038 | /*2 |
---|
3039 | * looks up the position of p in T |
---|
3040 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3041 | * pComp |
---|
3042 | */ |
---|
3043 | int posInT1 (const TSet set,const int length,LObject &p) |
---|
3044 | { |
---|
3045 |  if (length==-1) return 0; |
---|
3046 | |
---|
3047 |  if (pLmCmp(set[length].p,p.p)!= pOrdSgn) return length+1; |
---|
3048 | |
---|
3049 |  int i; |
---|
3050 |  int an = 0; |
---|
3051 |  int en= length; |
---|
3052 | |
---|
3053 | Â loop |
---|
3054 | Â { |
---|
3055 |   if (an >= en-1) |
---|
3056 | Â Â { |
---|
3057 |    if (pLmCmp(set[an].p,p.p) == pOrdSgn) return an; |
---|
3058 |    return en; |
---|
3059 | Â Â } |
---|
3060 | Â Â i=(an+en)Â /Â 2; |
---|
3061 |   if (pLmCmp(set[i].p,p.p) == pOrdSgn) en=i; |
---|
3062 |   else                 an=i; |
---|
3063 | Â } |
---|
3064 | } |
---|
3065 | |
---|
3066 | /*2 |
---|
3067 | * looks up the position of p in T |
---|
3068 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3069 | * length |
---|
3070 | */ |
---|
3071 | int posInT2 (const TSet set,const int length,LObject &p) |
---|
3072 | { |
---|
3073 |  if (length==-1) |
---|
3074 |   return 0; |
---|
3075 |  if (set[length].length<p.length) |
---|
3076 |   return length+1; |
---|
3077 | |
---|
3078 |  int i; |
---|
3079 |  int an = 0; |
---|
3080 |  int en= length; |
---|
3081 | |
---|
3082 | Â loop |
---|
3083 | Â { |
---|
3084 |   if (an >= en-1) |
---|
3085 | Â Â { |
---|
3086 |    if (set[an].length>p.length) return an; |
---|
3087 |    return en; |
---|
3088 | Â Â } |
---|
3089 | Â Â i=(an+en)Â /Â 2; |
---|
3090 |   if (set[i].length>p.length) en=i; |
---|
3091 |   else            an=i; |
---|
3092 | Â } |
---|
3093 | } |
---|
3094 | |
---|
3095 | /*2 |
---|
3096 | * looks up the position of p in T |
---|
3097 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3098 | * totaldegree,pComp |
---|
3099 | */ |
---|
3100 | int posInT11 (const TSet set,const int length,LObject &p) |
---|
3101 | /*{ |
---|
3102 |  * int j=0; |
---|
3103 |  * int o; |
---|
3104 | Â * |
---|
3105 | Â *Â o =Â p.GetpFDeg(); |
---|
3106 | Â *Â loop |
---|
3107 | Â *Â { |
---|
3108 |  *  if ((pFDeg(set[j].p) > o) |
---|
3109 | Â *Â Â ||Â ((pFDeg(set[j].p)Â ==Â o)Â &&Â (pLmCmp(set[j].p,p.p)Â ==Â pOrdSgn))) |
---|
3110 | Â *Â Â { |
---|
3111 |  *   return j; |
---|
3112 | Â *Â Â } |
---|
3113 | Â *Â Â j++; |
---|
3114 |  *  if (j > length) return j; |
---|
3115 | Â *Â } |
---|
3116 | Â *} |
---|
3117 | Â */ |
---|
3118 | { |
---|
3119 |  if (length==-1) return 0; |
---|
3120 | |
---|
3121 |  int o = p.GetpFDeg(); |
---|
3122 |  int op = set[length].GetpFDeg(); |
---|
3123 | |
---|
3124 |  if ((op < o) |
---|
3125 | Â ||Â ((op ==Â o)Â &&Â (pLmCmp(set[length].p,p.p)Â !=Â pOrdSgn))) |
---|
3126 |   return length+1; |
---|
3127 | |
---|
3128 |  int i; |
---|
3129 |  int an = 0; |
---|
3130 |  int en= length; |
---|
3131 | |
---|
3132 | Â loop |
---|
3133 | Â { |
---|
3134 |   if (an >= en-1) |
---|
3135 | Â Â { |
---|
3136 | Â Â Â op=Â set[an].GetpFDeg(); |
---|
3137 |    if ((op > o) |
---|
3138 | Â Â Â ||Â ((Â op ==Â o)Â &&Â (pLmCmp(set[an].p,p.p)Â ==Â pOrdSgn))) |
---|
3139 |     return an; |
---|
3140 |    return en; |
---|
3141 | Â Â } |
---|
3142 | Â Â i=(an+en)Â /Â 2; |
---|
3143 | Â Â op =Â set[i].GetpFDeg(); |
---|
3144 |   if (( op > o) |
---|
3145 | Â Â ||Â ((Â op ==Â o)Â &&Â (pLmCmp(set[i].p,p.p)Â ==Â pOrdSgn))) |
---|
3146 | Â Â Â en=i; |
---|
3147 | Â Â else |
---|
3148 | Â Â Â an=i; |
---|
3149 | Â } |
---|
3150 | } |
---|
3151 | |
---|
3152 | /*2 Pos for rings T: Here I am |
---|
3153 | * looks up the position of p in T |
---|
3154 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3155 | * totaldegree,pComp |
---|
3156 | */ |
---|
3157 | int posInTrg0 (const TSet set,const int length,LObject &p) |
---|
3158 | { |
---|
3159 |  if (length==-1) return 0; |
---|
3160 |  int o = p.GetpFDeg(); |
---|
3161 |  int op = set[length].GetpFDeg(); |
---|
3162 |  int i; |
---|
3163 |  int an = 0; |
---|
3164 |  int en = length; |
---|
3165 |  int cmp_int = pOrdSgn; |
---|
3166 |  if ((op < o) || (pLmCmp(set[length].p,p.p)== -cmp_int)) |
---|
3167 |   return length+1; |
---|
3168 |  int cmp; |
---|
3169 | Â loop |
---|
3170 | Â { |
---|
3171 |   if (an >= en-1) |
---|
3172 | Â Â { |
---|
3173 | Â Â Â op =Â set[an].GetpFDeg(); |
---|
3174 |    if (op > o) return an; |
---|
3175 |    if (op < 0) return en; |
---|
3176 | Â Â Â cmp =Â pLmCmp(set[an].p,p.p); |
---|
3177 |    if (cmp == cmp_int) return an; |
---|
3178 |    if (cmp == -cmp_int) return en; |
---|
3179 |    if (nGreater(pGetCoeff(p.p), pGetCoeff(set[an].p))) return en; |
---|
3180 |    return an; |
---|
3181 | Â Â } |
---|
3182 | Â Â i =Â (an +Â en)Â /Â 2; |
---|
3183 | Â Â op =Â set[i].GetpFDeg(); |
---|
3184 |   if (op > o)    en = i; |
---|
3185 |   else if (op < o) an = i; |
---|
3186 | Â Â else |
---|
3187 | Â Â { |
---|
3188 | Â Â Â cmp =Â pLmCmp(set[i].p,p.p); |
---|
3189 |    if (cmp == cmp_int)                   en = i; |
---|
3190 |    else if (cmp == -cmp_int)                an = i; |
---|
3191 |    else if (nGreater(pGetCoeff(p.p), pGetCoeff(set[i].p))) an = i; |
---|
3192 |    else                          en = i; |
---|
3193 | Â Â } |
---|
3194 | Â } |
---|
3195 | } |
---|
3196 | /* |
---|
3197 | Â int o = p.GetpFDeg(); |
---|
3198 | Â int op = set[length].GetpFDeg(); |
---|
3199 | |
---|
3200 | Â if ((op < o) |
---|
3201 | Â || ((op == o) && (pLmCmp(set[length].p,p.p) != pOrdSgn))) |
---|
3202 | Â Â return length+1; |
---|
3203 | |
---|
3204 | Â int i; |
---|
3205 | Â int an = 0; |
---|
3206 | Â int en= length; |
---|
3207 | |
---|
3208 | Â loop |
---|
3209 | Â { |
---|
3210 | Â Â if (an >= en-1) |
---|
3211 | Â Â { |
---|
3212 | Â Â Â op= set[an].GetpFDeg(); |
---|
3213 | Â Â Â if ((op > o) |
---|
3214 | Â Â Â || (( op == o) && (pLmCmp(set[an].p,p.p) == pOrdSgn))) |
---|
3215 | Â Â Â Â return an; |
---|
3216 | Â Â Â return en; |
---|
3217 | Â Â } |
---|
3218 | Â Â i=(an+en) / 2; |
---|
3219 | Â Â op = set[i].GetpFDeg(); |
---|
3220 | Â Â if (( op > o) |
---|
3221 | Â Â || (( op == o) && (pLmCmp(set[i].p,p.p) == pOrdSgn))) |
---|
3222 | Â Â Â en=i; |
---|
3223 | Â Â else |
---|
3224 | Â Â Â an=i; |
---|
3225 | Â } |
---|
3226 | } |
---|
3227 | Â */ |
---|
3228 | /*2 |
---|
3229 | * looks up the position of p in T |
---|
3230 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3231 | * totaldegree,pComp |
---|
3232 | */ |
---|
3233 | int posInT110 (const TSet set,const int length,LObject &p) |
---|
3234 | { |
---|
3235 |  if (length==-1) return 0; |
---|
3236 | |
---|
3237 |  int o = p.GetpFDeg(); |
---|
3238 |  int op = set[length].GetpFDeg(); |
---|
3239 | |
---|
3240 |  if (( op < o) |
---|
3241 | Â ||Â ((Â op ==Â o)Â &&Â (set[length].length<p.length)) |
---|
3242 | Â ||Â ((Â op ==Â o)Â &&Â (set[length].length ==Â p.length) |
---|
3243 | Â Â Â &&Â (pLmCmp(set[length].p,p.p)Â !=Â pOrdSgn))) |
---|
3244 |   return length+1; |
---|
3245 | |
---|
3246 |  int i; |
---|
3247 |  int an = 0; |
---|
3248 |  int en= length; |
---|
3249 | Â loop |
---|
3250 | Â { |
---|
3251 |   if (an >= en-1) |
---|
3252 | Â Â { |
---|
3253 | Â Â Â op =Â set[an].GetpFDeg(); |
---|
3254 |    if (( op > o) |
---|
3255 | Â Â Â ||Â ((Â op ==Â o)Â &&Â (set[an].length >Â p.length)) |
---|
3256 | Â Â Â ||Â ((Â op ==Â o)Â &&Â (set[an].length ==Â p.length) |
---|
3257 | Â Â Â Â Â &&Â (pLmCmp(set[an].p,p.p)Â ==Â pOrdSgn))) |
---|
3258 |     return an; |
---|
3259 |    return en; |
---|
3260 | Â Â } |
---|
3261 | Â Â i=(an+en)Â /Â 2; |
---|
3262 | Â Â op =Â set[i].GetpFDeg(); |
---|
3263 |   if (( op > o) |
---|
3264 | Â Â ||Â ((Â op ==Â o)Â &&Â (set[i].length >Â p.length)) |
---|
3265 | Â Â ||Â ((Â op ==Â o)Â &&Â (set[i].length ==Â p.length) |
---|
3266 | Â Â Â Â &&Â (pLmCmp(set[i].p,p.p)Â ==Â pOrdSgn))) |
---|
3267 | Â Â Â en=i; |
---|
3268 | Â Â else |
---|
3269 | Â Â Â an=i; |
---|
3270 | Â } |
---|
3271 | } |
---|
3272 | |
---|
3273 | /*2 |
---|
3274 | * looks up the position of p in set |
---|
3275 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3276 | * pFDeg |
---|
3277 | */ |
---|
3278 | int posInT13 (const TSet set,const int length,LObject &p) |
---|
3279 | { |
---|
3280 |  if (length==-1) return 0; |
---|
3281 | |
---|
3282 |  int o = p.GetpFDeg(); |
---|
3283 | |
---|
3284 |  if (set[length].GetpFDeg() <= o) |
---|
3285 |   return length+1; |
---|
3286 | |
---|
3287 |  int i; |
---|
3288 |  int an = 0; |
---|
3289 |  int en= length; |
---|
3290 | Â loop |
---|
3291 | Â { |
---|
3292 |   if (an >= en-1) |
---|
3293 | Â Â { |
---|
3294 |    if (set[an].GetpFDeg() > o) |
---|
3295 |     return an; |
---|
3296 |    return en; |
---|
3297 | Â Â } |
---|
3298 | Â Â i=(an+en)Â /Â 2; |
---|
3299 |   if (set[i].GetpFDeg() > o) |
---|
3300 | Â Â Â en=i; |
---|
3301 | Â Â else |
---|
3302 | Â Â Â an=i; |
---|
3303 | Â } |
---|
3304 | } |
---|
3305 | |
---|
3306 | // determines the position based on: 1.) Ecart 2.) pLength |
---|
3307 | int posInT_EcartpLength(const TSet set,const int length,LObject &p) |
---|
3308 | { |
---|
3309 |  if (length==-1) return 0; |
---|
3310 | |
---|
3311 |  int op=p.ecart; |
---|
3312 |  int ol = p.GetpLength(); |
---|
3313 | |
---|
3314 |  int oo=set[length].ecart; |
---|
3315 |  if ((oo < op) || ((oo==op) && (set[length].length < ol))) |
---|
3316 |   return length+1; |
---|
3317 | |
---|
3318 |  int i; |
---|
3319 |  int an = 0; |
---|
3320 |  int en= length; |
---|
3321 | Â loop |
---|
3322 | Â Â { |
---|
3323 |    if (an >= en-1) |
---|
3324 | Â Â Â { |
---|
3325 |     int oo=set[an].ecart; |
---|
3326 | Â Â Â Â if((oo >Â op) |
---|
3327 | Â Â Â Â Â Â ||Â ((oo==op)Â &&Â (set[an].pLength >Â ol))) |
---|
3328 |      return an; |
---|
3329 |     return en; |
---|
3330 | Â Â Â } |
---|
3331 | Â Â Â i=(an+en)Â /Â 2; |
---|
3332 |    int oo=set[i].ecart; |
---|
3333 |    if ((oo > op) |
---|
3334 | Â Â Â Â Â ||Â ((oo ==Â op)Â &&Â (set[i].pLength >Â ol))) |
---|
3335 | Â Â Â Â en=i; |
---|
3336 | Â Â Â else |
---|
3337 | Â Â Â Â an=i; |
---|
3338 | Â Â } |
---|
3339 | } |
---|
3340 | |
---|
3341 | /*2 |
---|
3342 | * looks up the position of p in set |
---|
3343 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3344 | * maximaldegree, pComp |
---|
3345 | */ |
---|
3346 | int posInT15 (const TSet set,const int length,LObject &p) |
---|
3347 | /*{ |
---|
3348 | Â *int j=0; |
---|
3349 | Â * int o; |
---|
3350 | Â * |
---|
3351 | Â * o = p.GetpFDeg()+p.ecart; |
---|
3352 | Â * loop |
---|
3353 | Â * { |
---|
3354 | Â *Â Â if ((set[j].GetpFDeg()+set[j].ecart > o) |
---|
3355 | Â *Â Â || ((set[j].GetpFDeg()+set[j].ecart == o) |
---|
3356 | Â *Â Â Â && (pLmCmp(set[j].p,p.p) == pOrdSgn))) |
---|
3357 | Â *Â Â { |
---|
3358 | Â *Â Â Â return j; |
---|
3359 | Â *Â Â } |
---|
3360 | Â *Â Â j++; |
---|
3361 | Â *Â Â if (j > length) return j; |
---|
3362 | Â * } |
---|
3363 | Â *} |
---|
3364 | Â */ |
---|
3365 | { |
---|
3366 |  if (length==-1) return 0; |
---|
3367 | |
---|
3368 |  int o = p.GetpFDeg() + p.ecart; |
---|
3369 |  int op = set[length].GetpFDeg()+set[length].ecart; |
---|
3370 | |
---|
3371 |  if ((op < o) |
---|
3372 | Â ||Â ((op ==Â o) |
---|
3373 | Â Â Â &&Â (pLmCmp(set[length].p,p.p)Â !=Â pOrdSgn))) |
---|
3374 |   return length+1; |
---|
3375 | |
---|
3376 |  int i; |
---|
3377 |  int an = 0; |
---|
3378 |  int en= length; |
---|
3379 | Â loop |
---|
3380 | Â { |
---|
3381 |   if (an >= en-1) |
---|
3382 | Â Â { |
---|
3383 | Â Â Â op =Â set[an].GetpFDeg()+set[an].ecart; |
---|
3384 |    if (( op > o) |
---|
3385 |    || (( op == o) && (pLmCmp(set[an].p,p.p) == pOrdSgn))) |
---|
3386 |     return an; |
---|
3387 |    return en; |
---|
3388 | Â Â } |
---|
3389 | Â Â i=(an+en)Â /Â 2; |
---|
3390 | Â Â op =Â set[i].GetpFDeg()+set[i].ecart; |
---|
3391 |   if (( op > o) |
---|
3392 | Â Â ||Â ((Â op ==Â o)Â &&Â (pLmCmp(set[i].p,p.p)Â ==Â pOrdSgn))) |
---|
3393 | Â Â Â en=i; |
---|
3394 | Â Â else |
---|
3395 | Â Â Â an=i; |
---|
3396 | Â } |
---|
3397 | } |
---|
3398 | |
---|
3399 | /*2 |
---|
3400 | * looks up the position of p in set |
---|
3401 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3402 | * pFDeg+ecart, ecart, pComp |
---|
3403 | */ |
---|
3404 | int posInT17 (const TSet set,const int length,LObject &p) |
---|
3405 | /* |
---|
3406 | *{ |
---|
3407 | * int j=0; |
---|
3408 | * int o; |
---|
3409 | * |
---|
3410 | *Â o = p.GetpFDeg()+p.ecart; |
---|
3411 | *Â loop |
---|
3412 | *Â { |
---|
3413 | *Â Â if ((pFDeg(set[j].p)+set[j].ecart > o) |
---|
3414 | *Â Â || (((pFDeg(set[j].p)+set[j].ecart == o) |
---|
3415 | *Â Â Â && (set[j].ecart < p.ecart))) |
---|
3416 | *Â Â || ((pFDeg(set[j].p)+set[j].ecart == o) |
---|
3417 | *Â Â Â && (set[j].ecart==p.ecart) |
---|
3418 | *Â Â Â && (pLmCmp(set[j].p,p.p)==pOrdSgn))) |
---|
3419 | *Â Â Â return j; |
---|
3420 | *Â Â j++; |
---|
3421 | *Â Â if (j > length) return j; |
---|
3422 | *Â } |
---|
3423 | * } |
---|
3424 | */ |
---|
3425 | { |
---|
3426 |  if (length==-1) return 0; |
---|
3427 | |
---|
3428 |  int o = p.GetpFDeg() + p.ecart; |
---|
3429 |  int op = set[length].GetpFDeg()+set[length].ecart; |
---|
3430 | |
---|
3431 |  if ((op < o) |
---|
3432 | Â ||Â ((Â op ==Â o)Â &&Â (set[length].ecart >Â p.ecart)) |
---|
3433 | Â ||Â ((Â op ==Â o)Â &&Â (set[length].ecart==p.ecart) |
---|
3434 | Â Â Â &&Â (pLmCmp(set[length].p,p.p)Â !=Â pOrdSgn))) |
---|
3435 |   return length+1; |
---|
3436 | |
---|
3437 |  int i; |
---|
3438 |  int an = 0; |
---|
3439 |  int en= length; |
---|
3440 | Â loop |
---|
3441 | Â { |
---|
3442 |   if (an >= en-1) |
---|
3443 | Â Â { |
---|
3444 | Â Â Â op =Â set[an].GetpFDeg()+set[an].ecart; |
---|
3445 |    if (( op > o) |
---|
3446 | Â Â Â ||Â ((Â op ==Â o)Â &&Â (set[an].ecart <Â p.ecart)) |
---|
3447 |    || (( op == o) && (set[an].ecart==p.ecart) |
---|
3448 | Â Â Â Â Â &&Â (pLmCmp(set[an].p,p.p)Â ==Â pOrdSgn))) |
---|
3449 |     return an; |
---|
3450 |    return en; |
---|
3451 | Â Â } |
---|
3452 | Â Â i=(an+en)Â /Â 2; |
---|
3453 | Â Â op =Â set[i].GetpFDeg()+set[i].ecart; |
---|
3454 |   if ((op > o) |
---|
3455 | Â Â ||Â ((Â op ==Â o)Â &&Â (set[i].ecart <Â p.ecart)) |
---|
3456 | Â Â ||Â ((Â op ==Â o)Â &&Â (set[i].ecart ==Â p.ecart) |
---|
3457 | Â Â Â Â &&Â (pLmCmp(set[i].p,p.p)Â ==Â pOrdSgn))) |
---|
3458 | Â Â Â en=i; |
---|
3459 | Â Â else |
---|
3460 | Â Â Â an=i; |
---|
3461 | Â } |
---|
3462 | } |
---|
3463 | /*2 |
---|
3464 | * looks up the position of p in set |
---|
3465 | * set[0] is the smallest with respect to the ordering-procedure |
---|
3466 | * pGetComp, pFDeg+ecart, ecart, pComp |
---|
3467 | */ |
---|
3468 | int posInT17_c (const TSet set,const int length,LObject &p) |
---|
3469 | { |
---|
3470 |  if (length==-1) return 0; |
---|
3471 | |
---|
3472 |  int cc = (-1+2*currRing->order[0]==ringorder_c); |
---|
3473 | Â /* cc==1 for (c,..), cc==-1 for (C,..) */ |
---|
3474 |  int o = p.GetpFDeg() + p.ecart; |
---|
3475 |  int c = pGetComp(p.p)*cc; |
---|
3476 | |
---|
3477 |  if (pGetComp(set[length].p)*cc < c) |
---|
3478 |   return length+1; |
---|
3479 |  if (pGetComp(set[length].p)*cc == c) |
---|
3480 | Â { |
---|
3481 |   int op = set[length].GetpFDeg()+set[length].ecart; |
---|
3482 |   if ((op < o) |
---|
3483 | Â Â ||Â ((op ==Â o)Â &&Â (set[length].ecart >Â p.ecart)) |
---|
3484 | Â Â ||Â ((op ==Â o)Â &&Â (set[length].ecart==p.ecart) |
---|
3485 | Â Â Â Â &&Â (pLmCmp(set[length].p,p.p)Â !=Â pOrdSgn))) |
---|
3486 |    return length+1; |
---|
3487 | Â } |
---|
3488 | |
---|
3489 |  int i; |
---|
3490 |  int an = 0; |
---|
3491 |  int en= length; |
---|
3492 | Â loop |
---|
3493 | Â { |
---|
3494 |   if (an >= en-1) |
---|
3495 | Â Â { |
---|
3496 |    if (pGetComp(set[an].p)*cc < c) |
---|
3497 |     return en; |
---|
3498 |    if (pGetComp(set[an].p)*cc == c) |
---|
3499 | Â Â Â { |
---|
3500 |     int op = set[an].GetpFDeg()+set[an].ecart; |
---|
3501 |     if ((op > o) |
---|
3502 | Â Â Â Â ||Â ((op ==Â o)Â &&Â (set[an].ecart <Â p.ecart)) |
---|
3503 | Â Â Â Â ||Â ((op ==Â o)Â &&Â (set[an].ecart==p.ecart) |
---|
3504 | Â Â Â Â Â Â &&Â (pLmCmp(set[an].p,p.p)Â ==Â pOrdSgn))) |
---|
3505 |      return an; |
---|
3506 | Â Â Â } |
---|
3507 |    return en; |
---|
3508 | Â Â } |
---|
3509 | Â Â i=(an+en)Â /Â 2; |
---|
3510 |   if (pGetComp(set[i].p)*cc > c) |
---|
3511 | Â Â Â en=i; |
---|
3512 |   else if (pGetComp(set[i].p)*cc == c) |
---|
3513 | Â Â { |
---|
3514 |    int op = set[i].GetpFDeg()+set[i].ecart; |
---|
3515 |    if ((op > o) |
---|
3516 | Â Â Â ||Â ((op ==Â o)Â &&Â (set[i].ecart <Â p.ecart)) |
---|
3517 | Â Â Â ||Â ((op ==Â o)Â &&Â (set[i].ecart ==Â p.ecart) |
---|
3518 | Â Â Â Â Â &&Â (pLmCmp(set[i].p,p.p)Â ==Â pOrdSgn))) |
---|
3519 | Â Â Â Â en=i; |
---|
3520 | Â Â Â else |
---|
3521 | Â Â Â Â an=i; |
---|
3522 | Â Â } |
---|
3523 | Â Â else |
---|
3524 | Â Â Â an=i; |
---|
3525 | Â } |
---|
3526 | } |
---|
3527 | |
---|
3528 | /*2 |
---|
3529 | * looks up the position of p in set |
---|
3530 | * set[0] is the smallest with respect to |
---|
3531 | * ecart, pFDeg, length |
---|
3532 | */ |
---|
3533 | int posInT19 (const TSet set,const int length,LObject &p) |
---|
3534 | { |
---|
3535 |  if (length==-1) return 0; |
---|
3536 | |
---|
3537 |  int o = p.ecart; |
---|
3538 |  int op=p.GetpFDeg(); |
---|
3539 | |
---|
3540 |  if (set[length].ecart < o) |
---|
3541 |   return length+1; |
---|
3542 |  if (set[length].ecart == o) |
---|
3543 | Â { |
---|
3544 |    int oo=set[length].GetpFDeg(); |
---|
3545 |    if ((oo < op) || ((oo==op) && (set[length].length < p.length))) |
---|
3546 |     return length+1; |
---|
3547 | Â } |
---|
3548 | |
---|
3549 |  int i; |
---|
3550 |  int an = 0; |
---|
3551 |  int en= length; |
---|
3552 | Â loop |
---|
3553 | Â { |
---|
3554 |   if (an >= en-1) |
---|
3555 | Â Â { |
---|
3556 |    if (set[an].ecart > o) |
---|
3557 |     return an; |
---|
3558 |    if (set[an].ecart == o) |
---|
3559 | Â Â Â { |
---|
3560 |      int oo=set[an].GetpFDeg(); |
---|
3561 | Â Â Â Â Â if((oo >Â op) |
---|
3562 | Â Â Â Â Â ||Â ((oo==op)Â &&Â (set[an].length >Â p.length))) |
---|
3563 |       return an; |
---|
3564 | Â Â Â } |
---|
3565 |    return en; |
---|
3566 | Â Â } |
---|
3567 | Â Â i=(an+en)Â /Â 2; |
---|
3568 |   if (set[i].ecart > o) |
---|
3569 | Â Â Â en=i; |
---|
3570 |   else if (set[i].ecart == o) |
---|
3571 | Â Â { |
---|
3572 |     int oo=set[i].GetpFDeg(); |
---|
3573 |     if ((oo > op) |
---|
3574 | Â Â Â Â ||Â ((oo ==Â op)Â &&Â (set[i].length >Â p.length))) |
---|
3575 | Â Â Â Â Â en=i; |
---|
3576 | Â Â Â Â else |
---|
3577 | Â Â Â Â an=i; |
---|
3578 | Â Â } |
---|
3579 | Â Â else |
---|
3580 | Â Â Â an=i; |
---|
3581 | Â } |
---|
3582 | } |
---|
3583 | |
---|
3584 | /*2 |
---|
3585 | *looks up the position of polynomial p in set |
---|
3586 | *set[length] is the smallest element in set with respect |
---|
3587 | *to the ordering-procedure pComp |
---|
3588 | */ |
---|
3589 | int posInLSpecial (const LSet set, const int length, |
---|
3590 |           LObject *p,const kStrategy strat) |
---|
3591 | { |
---|
3592 |  if (length<0) return 0; |
---|
3593 | |
---|
3594 |  int d=p->GetpFDeg(); |
---|
3595 |  int op=set[length].GetpFDeg(); |
---|
3596 | |
---|
3597 |  if ((op > d) |
---|
3598 | Â ||Â ((op ==Â d)Â &&Â (p->p1!=NULL)&&(set[length].p1==NULL)) |
---|
3599 | Â ||Â (pLmCmp(set[length].p,p->p)==Â pOrdSgn)) |
---|
3600 |    return length+1; |
---|
3601 | |
---|
3602 |  int i; |
---|
3603 |  int an = 0; |
---|
3604 |  int en= length; |
---|
3605 | Â loop |
---|
3606 | Â { |
---|
3607 |   if (an >= en-1) |
---|
3608 | Â Â { |
---|
3609 | Â Â Â op=set[an].GetpFDeg(); |
---|
3610 |    if ((op > d) |
---|
3611 | Â Â Â ||Â ((op ==Â d)Â &&Â (p->p1!=NULL)Â &&Â (set[an].p1==NULL)) |
---|
3612 | Â Â Â ||Â (pLmCmp(set[an].p,p->p)==Â pOrdSgn)) |
---|
3613 |      return en; |
---|
3614 |    return an; |
---|
3615 | Â Â } |
---|
3616 | Â Â i=(an+en)Â /Â 2; |
---|
3617 | Â Â op=set[i].GetpFDeg(); |
---|
3618 |   if ((op>d) |
---|
3619 | Â Â ||Â ((op==d)Â &&Â (p->p1!=NULL)Â &&Â (set[i].p1==NULL)) |
---|
3620 | Â Â ||Â (pLmCmp(set[i].p,p->p)Â ==Â pOrdSgn)) |
---|
3621 | Â Â Â an=i; |
---|
3622 | Â Â else |
---|
3623 | Â Â Â en=i; |
---|
3624 | Â } |
---|
3625 | } |
---|
3626 | |
---|
3627 | /*2 |
---|
3628 | *looks up the position of polynomial p in set |
---|
3629 | *set[length] is the smallest element in set with respect |
---|
3630 | *to the ordering-procedure pComp |
---|
3631 | */ |
---|
3632 | int posInL0 (const LSet set, const int length, |
---|
3633 |        LObject* p,const kStrategy strat) |
---|
3634 | { |
---|
3635 |  if (length<0) return 0; |
---|
3636 | |
---|
3637 |  if (pLmCmp(set[length].p,p->p)== pOrdSgn) |
---|
3638 |   return length+1; |
---|
3639 | |
---|
3640 |  int i; |
---|
3641 |  int an = 0; |
---|
3642 |  int en= length; |
---|
3643 | Â loop |
---|
3644 | Â { |
---|
3645 |   if (an >= en-1) |
---|
3646 | Â Â { |
---|
3647 |    if (pLmCmp(set[an].p,p->p) == pOrdSgn) return en; |
---|
3648 |    return an; |
---|
3649 | Â Â } |
---|
3650 | Â Â i=(an+en)Â /Â 2; |
---|
3651 |   if (pLmCmp(set[i].p,p->p) == pOrdSgn) an=i; |
---|
3652 |   else                 en=i; |
---|
3653 | Â Â /*aend. fuer lazy == in !=- machen */ |
---|
3654 | Â } |
---|
3655 | } |
---|
3656 | |
---|
3657 | /*2 |
---|
3658 | * looks up the position of polynomial p in set |
---|
3659 | * e is the ecart of p |
---|
3660 | * set[length] is the smallest element in set with respect |
---|
3661 | * to the ordering-procedure totaldegree,pComp |
---|
3662 | */ |
---|
3663 | int posInL11 (const LSet set, const int length, |
---|
3664 |        LObject* p,const kStrategy strat) |
---|
3665 | /*{ |
---|
3666 | Â * int j=0; |
---|
3667 | Â * int o; |
---|
3668 | Â * |
---|
3669 | Â * o = p->GetpFDeg(); |
---|
3670 | Â * loop |
---|
3671 | Â * { |
---|
3672 | Â *Â Â if (j > length)Â Â Â Â Â Â return j; |
---|
3673 | Â *Â Â if ((set[j].GetpFDeg() < o)) return j; |
---|
3674 | Â *Â Â if ((set[j].GetpFDeg() == o) && (pLmCmp(set[j].p,p->p) == -pOrdSgn)) |
---|
3675 | Â *Â Â { |
---|
3676 | Â *Â Â Â return j; |
---|
3677 | Â *Â Â } |
---|
3678 | Â *Â Â j++; |
---|
3679 | Â * } |
---|
3680 | Â *} |
---|
3681 | Â */ |
---|
3682 | { |
---|
3683 |  if (length<0) return 0; |
---|
3684 | |
---|
3685 |  int o = p->GetpFDeg(); |
---|
3686 |  int op = set[length].GetpFDeg(); |
---|
3687 | |
---|
3688 |  if ((op > o) |
---|
3689 | Â ||Â ((op ==Â o)Â &&Â (pLmCmp(set[length].p,p->p)Â !=Â -pOrdSgn))) |
---|
3690 |   return length+1; |
---|
3691 |  int i; |
---|
3692 |  int an = 0; |
---|
3693 |  int en= length; |
---|
3694 | Â loop |
---|
3695 | Â { |
---|
3696 |   if (an >= en-1) |
---|
3697 | Â Â { |
---|
3698 | Â Â Â op =Â set[an].GetpFDeg(); |
---|
3699 |    if ((op > o) |
---|
3700 | Â Â Â ||Â ((op ==Â o)Â &&Â (pLmCmp(set[an].p,p->p)Â !=Â -pOrdSgn))) |
---|
3701 |     return en; |
---|
3702 |    return an; |
---|
3703 | Â Â } |
---|
3704 | Â Â i=(an+en)Â /Â 2; |
---|
3705 | Â Â op =Â set[i].GetpFDeg(); |
---|
3706 |   if ((op > o) |
---|
3707 | Â Â ||Â ((op ==Â o)Â &&Â (pLmCmp(set[i].p,p->p)Â !=Â -pOrdSgn))) |
---|
3708 | Â Â Â an=i; |
---|
3709 | Â Â else |
---|
3710 | Â Â Â en=i; |
---|
3711 | Â } |
---|
3712 | } |
---|
3713 | |
---|
3714 | /*2 Position for rings L: Here I am |
---|
3715 | * looks up the position of polynomial p in set |
---|
3716 | * e is the ecart of p |
---|
3717 | * set[length] is the smallest element in set with respect |
---|
3718 | * to the ordering-procedure totaldegree,pComp |
---|
3719 | */ |
---|
3720 | inline int getIndexRng(long coeff) |
---|
3721 | { |
---|
3722 |  if (coeff == 0) return -1; |
---|
3723 |  long tmp = coeff; |
---|
3724 |  int ind = 0; |
---|
3725 |  while (tmp % 2 == 0) |
---|
3726 | Â { |
---|
3727 | Â Â tmp =Â tmp /Â 2; |
---|
3728 | Â Â ind++; |
---|
3729 | Â } |
---|
3730 |  return ind; |
---|
3731 | } |
---|
3732 | |
---|
3733 | int posInLrg0 (const LSet set, const int length, |
---|
3734 |        LObject* p,const kStrategy strat) |
---|
3735 | /*Â Â Â Â Â if (nGreater(pGetCoeff(p), pGetCoeff(set[an]))) return en; |
---|
3736 | Â Â Â Â if (pLmCmp(set[i],p) == cmp_int)Â Â Â Â Â en = i; |
---|
3737 | Â Â Â Â else if (pLmCmp(set[i],p) == -cmp_int)Â Â an = i; |
---|
3738 | Â Â Â Â else |
---|
3739 | Â Â Â Â { |
---|
3740 | Â Â Â Â Â if (nGreater(pGetCoeff(p), pGetCoeff(set[i]))) an = i; |
---|
3741 | Â Â Â Â Â else en = i; |
---|
3742 | Â Â Â Â }*/ |
---|
3743 | { |
---|
3744 |  if (length < 0) return 0; |
---|
3745 | |
---|
3746 |  int o = p->GetpFDeg(); |
---|
3747 |  int op = set[length].GetpFDeg(); |
---|
3748 | |
---|
3749 |  if ((op > o) || ((op == o) && (pLmCmp(set[length].p,p->p) != -pOrdSgn))) |
---|
3750 |   return length + 1; |
---|
3751 |  int i; |
---|
3752 |  int an = 0; |
---|
3753 |  int en = length; |
---|
3754 | Â loop |
---|
3755 | Â { |
---|
3756 |   if (an >= en - 1) |
---|
3757 | Â Â { |
---|
3758 | Â Â Â op =Â set[an].GetpFDeg(); |
---|
3759 |    if ((op > o) || ((op == o) && (pLmCmp(set[an].p,p->p) != -pOrdSgn))) |
---|
3760 |     return en; |
---|
3761 |    return an; |
---|
3762 | Â Â } |
---|
3763 | Â Â i =Â (an+en)Â /Â 2; |
---|
3764 | Â Â op =Â set[i].GetpFDeg(); |
---|
3765 |   if ((op > o) || ((op == o) && (pLmCmp(set[i].p,p->p) != -pOrdSgn))) |
---|
3766 | Â Â Â an =Â i; |
---|
3767 | Â Â else |
---|
3768 | Â Â Â en =Â i; |
---|
3769 | Â } |
---|
3770 | } |
---|
3771 | |
---|
3772 | /*{ |
---|
3773 | Â if (length < 0) return 0; |
---|
3774 | |
---|
3775 | Â int o = p->GetpFDeg(); |
---|
3776 | Â int op = set[length].GetpFDeg(); |
---|
3777 | |
---|
3778 | Â int inde = getIndexRng((unsigned long) pGetCoeff(set[length].p)); |
---|
3779 | Â int indp = getIndexRng((unsigned long) pGetCoeff(p->p)); |
---|
3780 | Â int inda; |
---|
3781 | Â int indi; |
---|
3782 | |
---|
3783 | Â if ((inda > indp) || ((inda == inde) && ((op > o) || ((op == o) && (pLmCmp(set[length].p,p->p) != -pOrdSgn))))) |
---|
3784 | Â Â return length + 1; |
---|
3785 | Â int i; |
---|
3786 | Â int an = 0; |
---|
3787 | Â inda = getIndexRng((unsigned long) pGetCoeff(set[an].p)); |
---|
3788 | Â int en = length; |
---|
3789 | Â loop |
---|
3790 | Â { |
---|
3791 | Â Â if (an >= en-1) |
---|
3792 | Â Â { |
---|
3793 | Â Â Â op = set[an].GetpFDeg(); |
---|
3794 | Â Â Â if ((indp > inda) || ((indp == inda) && ((op > o) || ((op == o) && (pLmCmp(set[an].p,p->p) != -pOrdSgn))))) |
---|
3795 | Â Â Â Â return en; |
---|
3796 | Â Â Â return an; |
---|
3797 | Â Â } |
---|
3798 | Â Â i = (an + en) / 2; |
---|
3799 | Â Â indi = getIndexRng((unsigned long) pGetCoeff(set[i].p)); |
---|
3800 | Â Â op = set[i].GetpFDeg(); |
---|
3801 | Â Â if ((indi > indp) || ((indi == indp) && ((op > o) || ((op == o) && (pLmCmp(set[i].p,p->p) != -pOrdSgn))))) |
---|
3802 | Â Â // if ((op > o) || ((op == o) && (pLmCmp(set[i].p,p->p) != -pOrdSgn))) |
---|
3803 | Â Â { |
---|
3804 | Â Â Â an = i; |
---|
3805 | Â Â Â inda = getIndexRng((unsigned long) pGetCoeff(set[an].p)); |
---|
3806 | Â Â } |
---|
3807 | Â Â else |
---|
3808 | Â Â Â en = i; |
---|
3809 | Â } |
---|
3810 | } */ |
---|
3811 | |
---|
3812 | /*2 |
---|
3813 | * looks up the position of polynomial p in set |
---|
3814 | * set[length] is the smallest element in set with respect |
---|
3815 | * to the ordering-procedure totaldegree,pLength0 |
---|
3816 | */ |
---|
3817 | int posInL110 (const LSet set, const int length, |
---|
3818 |         LObject* p,const kStrategy strat) |
---|
3819 | { |
---|
3820 |  if (length<0) return 0; |
---|
3821 | |
---|
3822 |  int o = p->GetpFDeg(); |
---|
3823 |  int op = set[length].GetpFDeg(); |
---|
3824 | |
---|
3825 |  if ((op > o) |
---|
3826 | Â ||Â ((op ==Â o)Â &&Â (set[length].length >p->length)) |
---|
3827 | Â ||Â ((op ==Â o)Â &&Â (set[length].length <=Â p->length) |
---|
3828 | Â Â Â &&Â (pLmCmp(set[length].p,p->p)Â !=Â -pOrdSgn))) |
---|
3829 |   return length+1; |
---|
3830 |  int i; |
---|
3831 |  int an = 0; |
---|
3832 |  int en= length; |
---|
3833 | Â loop |
---|
3834 | Â { |
---|
3835 |   if (an >= en-1) |
---|
3836 | Â Â { |
---|
3837 | Â Â Â op =Â set[an].GetpFDeg(); |
---|
3838 |    if ((op > o) |
---|
3839 | Â Â Â ||Â ((op ==Â o)Â &&Â (set[an].length >p->length)) |
---|
3840 | Â Â Â ||Â ((op ==Â o)Â &&Â (set[an].length <=p->length) |
---|
3841 | Â Â Â Â Â &&Â (pLmCmp(set[an].p,p->p)Â !=Â -pOrdSgn))) |
---|
3842 |     return en; |
---|
3843 |    return an; |
---|
3844 | Â Â } |
---|
3845 | Â Â i=(an+en)Â /Â 2; |
---|
3846 | Â Â op =Â set[i].GetpFDeg(); |
---|
3847 |   if ((op > o) |
---|
3848 | Â Â ||Â ((op ==Â o)Â &&Â (set[i].length >Â p->length)) |
---|
3849 | Â Â ||Â ((op ==Â o)Â &&Â (set[i].length <=Â p->length) |
---|
3850 | Â Â Â Â &&Â (pLmCmp(set[i].p,p->p)Â !=Â -pOrdSgn))) |
---|
3851 | Â Â Â an=i; |
---|
3852 | Â Â else |
---|
3853 | Â Â Â en=i; |
---|
3854 | Â } |
---|
3855 | } |
---|
3856 | |
---|
3857 | /*2 |
---|
3858 | * looks up the position of polynomial p in set |
---|
3859 | * e is the ecart of p |
---|
3860 | * set[length] is the smallest element in set with respect |
---|
3861 | * to the ordering-procedure totaldegree |
---|
3862 | */ |
---|
3863 | int posInL13 (const LSet set, const int length, |
---|
3864 |        LObject* p,const kStrategy strat) |
---|
3865 | { |
---|
3866 |  if (length<0) return 0; |
---|
3867 | |
---|
3868 |  int o = p->GetpFDeg(); |
---|
3869 | |
---|
3870 |  if (set[length].GetpFDeg() > o) |
---|
3871 |   return length+1; |
---|
3872 | |
---|
3873 |  int i; |
---|
3874 |  int an = 0; |
---|
3875 |  int en= length; |
---|
3876 | Â loop |
---|
3877 | Â { |
---|
3878 |   if (an >= en-1) |
---|
3879 | Â Â { |
---|
3880 |    if (set[an].GetpFDeg() >= o) |
---|
3881 |     return en; |
---|
3882 |    return an; |
---|
3883 | Â Â } |
---|
3884 | Â Â i=(an+en)Â /Â 2; |
---|
3885 |   if (set[i].GetpFDeg() >= o) |
---|
3886 | Â Â Â an=i; |
---|
3887 | Â Â else |
---|
3888 | Â Â Â en=i; |
---|
3889 | Â } |
---|
3890 | } |
---|
3891 | |
---|
3892 | /*2 |
---|
3893 | * looks up the position of polynomial p in set |
---|
3894 | * e is the ecart of p |
---|
3895 | * set[length] is the smallest element in set with respect |
---|
3896 | * to the ordering-procedure maximaldegree,pComp |
---|
3897 | */ |
---|
3898 | int posInL15 (const LSet set, const int length, |
---|
3899 |        LObject* p,const kStrategy strat) |
---|
3900 | /*{ |
---|
3901 | Â * int j=0; |
---|
3902 | Â * int o; |
---|
3903 | Â * |
---|
3904 | Â * o = p->ecart+p->GetpFDeg(); |
---|
3905 | Â * loop |
---|
3906 | Â * { |
---|
3907 | Â *Â Â if (j > length)Â Â Â Â Â Â Â Â Â Â Â Â return j; |
---|
3908 | Â *Â Â if (set[j].GetpFDeg()+set[j].ecart < o) return j; |
---|
3909 | Â *Â Â if ((set[j].GetpFDeg()+set[j].ecart == o) |
---|
3910 | Â *Â Â && (pLmCmp(set[j].p,p->p) == -pOrdSgn)) |
---|
3911 | Â *Â Â { |
---|
3912 | Â *Â Â Â return j; |
---|
3913 | Â *Â Â } |
---|
3914 | Â *Â Â j++; |
---|
3915 | Â * } |
---|
3916 | Â *} |
---|
3917 | Â */ |
---|
3918 | { |
---|
3919 |  if (length<0) return 0; |
---|
3920 | |
---|
3921 |  int o = p->GetpFDeg() + p->ecart; |
---|
3922 |  int op = set[length].GetpFDeg() + set[length].ecart; |
---|
3923 | |
---|
3924 |  if ((op > o) |
---|
3925 | Â ||Â ((op ==Â o)Â &&Â (pLmCmp(set[length].p,p->p)Â !=Â -pOrdSgn))) |
---|
3926 |   return length+1; |
---|
3927 |  int i; |
---|
3928 |  int an = 0; |
---|
3929 |  int en= length; |
---|
3930 | Â loop |
---|
3931 | Â { |
---|
3932 |   if (an >= en-1) |
---|
3933 | Â Â { |
---|
3934 | Â Â Â op =Â set[an].GetpFDeg()Â +Â set[an].ecart; |
---|
3935 |    if ((op > o) |
---|
3936 | Â Â Â ||Â ((op ==Â o)Â &&Â (pLmCmp(set[an].p,p->p)Â !=Â -pOrdSgn))) |
---|
3937 |     return en; |
---|
3938 |    return an; |
---|
3939 | Â Â } |
---|
3940 | Â Â i=(an+en)Â /Â 2; |
---|
3941 | Â Â op =Â set[i].GetpFDeg()Â +Â set[i].ecart; |
---|
3942 |   if ((op > o) |
---|
3943 | Â Â ||Â ((op ==Â o)Â &&Â (pLmCmp(set[i].p,p->p)Â !=Â -pOrdSgn))) |
---|
3944 | Â Â Â an=i; |
---|
3945 | Â Â else |
---|
3946 | Â Â Â en=i; |
---|
3947 | Â } |
---|
3948 | } |
---|
3949 | |
---|
3950 | /*2 |
---|
3951 | * looks up the position of polynomial p in set |
---|
3952 | * e is the ecart of p |
---|
3953 | * set[length] is the smallest element in set with respect |
---|
3954 | * to the ordering-procedure totaldegree |
---|
3955 | */ |
---|
3956 | int posInL17 (const LSet set, const int length, |
---|
3957 |        LObject* p,const kStrategy strat) |
---|
3958 | { |
---|
3959 |  if (length<0) return 0; |
---|
3960 | |
---|
3961 |  int o = p->GetpFDeg() + p->ecart; |
---|
3962 | |
---|
3963 |  if ((set[length].GetpFDeg() + set[length].ecart > o) |
---|
3964 | Â ||Â ((set[length].GetpFDeg()Â +Â set[length].ecart ==Â o) |
---|
3965 | Â Â Â &&Â (set[length].ecart >Â p->ecart)) |
---|
3966 | Â ||Â ((set[length].GetpFDeg()Â +Â set[length].ecart ==Â o) |
---|
3967 | Â Â Â &&Â (set[length].ecart ==Â p->ecart) |
---|
3968 | Â Â Â &&Â (pLmCmp(set[length].p,p->p)Â !=Â -pOrdSgn))) |
---|
3969 |   return length+1; |
---|
3970 |  int i; |
---|
3971 |  int an = 0; |
---|
3972 |  int en= length; |
---|
3973 | Â loop |
---|
3974 | Â { |
---|
3975 |   if (an >= en-1) |
---|
3976 | Â Â { |
---|
3977 |    if ((set[an].GetpFDeg() + set[an].ecart > o) |
---|
3978 | Â Â Â ||Â ((set[an].GetpFDeg()Â +Â set[an].ecart ==Â o) |
---|
3979 | Â Â Â Â Â &&Â (set[an].ecart >Â p->ecart)) |
---|
3980 | Â Â Â ||Â ((set[an].GetpFDeg()Â +Â set[an].ecart ==Â o) |
---|
3981 | Â Â Â Â Â &&Â (set[an].ecart ==Â p->ecart) |
---|
3982 | Â Â Â Â Â &&Â (pLmCmp(set[an].p,p->p)Â !=Â -pOrdSgn))) |
---|
3983 |     return en; |
---|
3984 |    return an; |
---|
3985 | Â Â } |
---|
3986 | Â Â i=(an+en)Â /Â 2; |
---|
3987 |   if ((set[i].GetpFDeg() + set[i].ecart > o) |
---|
3988 | Â Â ||Â ((set[i].GetpFDeg()Â +Â set[i].ecart ==Â o) |
---|
3989 | Â Â Â Â &&Â (set[i].ecart >Â p->ecart)) |
---|
3990 | Â Â ||Â ((set[i].GetpFDeg()Â +set[i].ecart ==Â o) |
---|
3991 | Â Â Â Â &&Â (set[i].ecart ==Â p->ecart) |
---|
3992 | Â Â Â Â &&Â (pLmCmp(set[i].p,p->p)Â !=Â -pOrdSgn))) |
---|
3993 | Â Â Â an=i; |
---|
3994 | Â Â else |
---|
3995 | Â Â Â en=i; |
---|
3996 | Â } |
---|
3997 | } |
---|
3998 | /*2 |
---|
3999 | * looks up the position of polynomial p in set |
---|
4000 | * e is the ecart of p |
---|
4001 | * set[length] is the smallest element in set with respect |
---|
4002 | * to the ordering-procedure pComp |
---|
4003 | */ |
---|
4004 | int posInL17_c (const LSet set, const int length, |
---|
4005 |         LObject* p,const kStrategy strat) |
---|
4006 | { |
---|
4007 |  if (length<0) return 0; |
---|
4008 | |
---|
4009 |  int cc = (-1+2*currRing->order[0]==ringorder_c); |
---|
4010 | Â /* cc==1 for (c,..), cc==-1 for (C,..) */ |
---|
4011 |  int c = pGetComp(p->p)*cc; |
---|
4012 |  int o = p->GetpFDeg() + p->ecart; |
---|
4013 | |
---|
4014 |  if (pGetComp(set[length].p)*cc > c) |
---|
4015 |   return length+1; |
---|
4016 |  if (pGetComp(set[length].p)*cc == c) |
---|
4017 | Â { |
---|
4018 |   if ((set[length].GetpFDeg() + set[length].ecart > o) |
---|
4019 | Â Â ||Â ((set[length].GetpFDeg()Â +Â set[length].ecart ==Â o) |
---|
4020 | Â Â Â Â &&Â (set[length].ecart >Â p->ecart)) |
---|
4021 | Â Â ||Â ((set[length].GetpFDeg()Â +Â set[length].ecart ==Â o) |
---|
4022 | Â Â Â Â &&Â (set[length].ecart ==Â p->ecart) |
---|
4023 | Â Â Â Â &&Â (pLmCmp(set[length].p,p->p)Â !=Â -pOrdSgn))) |
---|
4024 |    return length+1; |
---|
4025 | Â } |
---|
4026 |  int i; |
---|
4027 |  int an = 0; |
---|
4028 |  int en= length; |
---|
4029 | Â loop |
---|
4030 | Â { |
---|
4031 |   if (an >= en-1) |
---|
4032 | Â Â { |
---|
4033 |    if (pGetComp(set[an].p)*cc > c) |
---|
4034 |     return en; |
---|
4035 |    if (pGetComp(set[an].p)*cc == c) |
---|
4036 | Â Â Â { |
---|
4037 |     if ((set[an].GetpFDeg() + set[an].ecart > o) |
---|
4038 | Â Â Â Â ||Â ((set[an].GetpFDeg()Â +Â set[an].ecart ==Â o) |
---|
4039 | Â Â Â Â Â Â &&Â (set[an].ecart >Â p->ecart)) |
---|
4040 | Â Â Â Â ||Â ((set[an].GetpFDeg()Â +Â set[an].ecart ==Â o) |
---|
4041 | Â Â Â Â Â Â &&Â (set[an].ecart ==Â p->ecart) |
---|
4042 | Â Â Â Â Â Â &&Â (pLmCmp(set[an].p,p->p)Â !=Â -pOrdSgn))) |
---|
4043 |      return en; |
---|
4044 | Â Â Â } |
---|
4045 |    return an; |
---|
4046 | Â Â } |
---|
4047 | Â Â i=(an+en)Â /Â 2; |
---|
4048 |   if (pGetComp(set[i].p)*cc > c) |
---|
4049 | Â Â Â an=i; |
---|
4050 |   else if (pGetComp(set[i].p)*cc == c) |
---|
4051 | Â Â { |
---|
4052 |    if ((set[i].GetpFDeg() + set[i].ecart > o) |
---|
4053 | Â Â Â ||Â ((set[i].GetpFDeg()Â +Â set[i].ecart ==Â o) |
---|
4054 | Â Â Â Â Â &&Â (set[i].ecart >Â p->ecart)) |
---|
4055 | Â Â Â ||Â ((set[i].GetpFDeg()Â +set[i].ecart ==Â o) |
---|
4056 | Â Â Â Â Â &&Â (set[i].ecart ==Â p->ecart) |
---|
4057 | Â Â Â Â Â &&Â (pLmCmp(set[i].p,p->p)Â !=Â -pOrdSgn))) |
---|
4058 | Â Â Â Â an=i; |
---|
4059 | Â Â Â else |
---|
4060 | Â Â Â Â en=i; |
---|
4061 | Â Â } |
---|
4062 | Â Â else |
---|
4063 | Â Â Â en=i; |
---|
4064 | Â } |
---|
4065 | } |
---|
4066 | |
---|
4067 | /*************************************************************** |
---|
4068 | Â * |
---|
4069 | Â * Tail reductions |
---|
4070 | Â * |
---|
4071 | Â ***************************************************************/ |
---|
4072 | TObject* |
---|
4073 | kFindDivisibleByInS(kStrategy strat, int pos, LObject* L, TObject *T, |
---|
4074 |           long ecart) |
---|
4075 | { |
---|
4076 |  int j = 0; |
---|
4077 |  const unsigned long not_sev = ~L->sev; |
---|
4078 |  const unsigned long* sev = strat->sevS; |
---|
4079 | Â poly p; |
---|
4080 | Â ring r; |
---|
4081 |  L->GetLm(p, r); |
---|
4082 | |
---|
4083 |  assume(~not_sev == p_GetShortExpVector(p, r)); |
---|
4084 | |
---|
4085 |  if (r == currRing) |
---|
4086 | Â { |
---|
4087 | Â Â loop |
---|
4088 | Â Â { |
---|
4089 |    if (j > pos) return NULL; |
---|
4090 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
4091 |    if (p_LmShortDivisibleBy(strat->S[j], sev[j], p, not_sev, r) && |
---|
4092 | Â Â Â Â Â (ecart==Â LONG_MAX ||Â ecart>=Â strat->ecartS[j])) |
---|
4093 | Â Â Â Â break; |
---|
4094 | #else |
---|
4095 |    if (!(sev[j] & not_sev) && |
---|
4096 | Â Â Â Â Â (ecart==Â LONG_MAX ||Â ecart>=Â strat->ecartS[j])Â && |
---|
4097 |      p_LmDivisibleBy(strat->S[j], p, r)) |
---|
4098 | Â Â Â Â break; |
---|
4099 | |
---|
4100 | #endif |
---|
4101 | Â Â Â j++; |
---|
4102 | Â Â } |
---|
4103 | Â Â // if called from NF, T objects do not exist: |
---|
4104 |   if (strat->tl < 0 || strat->S_2_R[j] == -1) |
---|
4105 | Â Â { |
---|
4106 |    T->Set(strat->S[j], r, strat->tailRing); |
---|
4107 |    return T; |
---|
4108 | Â Â } |
---|
4109 | Â Â else |
---|
4110 | Â Â { |
---|
4111 | /////Â Â Â assume (j >= 0 && j <= strat->tl && strat->S_2_T(j) != NULL |
---|
4112 | /////Â Â Â && strat->S_2_T(j)->p == strat->S[j]); // wrong? |
---|
4113 | //Â Â Â assume (j >= 0 && j <= strat->sl && strat->S_2_T(j) != NULL && strat->S_2_T(j)->p == strat->S[j]); |
---|
4114 |    return strat->S_2_T(j); |
---|
4115 | Â Â } |
---|
4116 | Â } |
---|
4117 | Â else |
---|
4118 | Â { |
---|
4119 | Â Â TObject*Â t; |
---|
4120 | Â Â loop |
---|
4121 | Â Â { |
---|
4122 |    if (j > pos) return NULL; |
---|
4123 | Â Â Â assume(strat->S_2_R[j]Â !=Â -1); |
---|
4124 | #if defined(PDEBUG) || defined(PDIV_DEBUG) |
---|
4125 | Â Â Â t =Â strat->S_2_T(j); |
---|
4126 | Â Â Â assume(t !=Â NULLÂ &&Â t->t_p !=Â NULLÂ &&Â t->tailRing ==Â r); |
---|
4127 |    if (p_LmShortDivisibleBy(t->t_p, sev[j], p, not_sev, r) && |
---|
4128 | Â Â Â Â Â (ecart==Â LONG_MAX ||Â ecart>=Â strat->ecartS[j])) |
---|
4129 |     return t; |
---|
4130 | #else |
---|
4131 |    if (! (sev[j] & not_sev) && (ecart== LONG_MAX || ecart>= strat->ecartS[j])) |
---|
4132 | Â Â Â { |
---|
4133 | Â Â Â Â t =Â strat->S_2_T(j); |
---|
4134 | Â Â Â Â assume(t !=Â NULLÂ &&Â t->t_p !=Â NULLÂ &&Â t->tailRing ==Â r &&Â t->p ==Â strat->S[j]); |
---|
4135 |     if (p_LmDivisibleBy(t->t_p, p, r)) return t; |
---|
4136 | Â Â Â } |
---|
4137 | #endif |
---|
4138 | Â Â Â j++; |
---|
4139 | Â Â } |
---|
4140 | Â } |
---|
4141 | } |
---|
4142 | |
---|
4143 | poly redtail (LObject* L, int pos, kStrategy strat) |
---|
4144 | { |
---|
4145 |  poly h, hn; |
---|
4146 |  int j; |
---|
4147 |  unsigned long not_sev; |
---|
4148 | Â strat->redTailChange=FALSE; |
---|
4149 | |
---|
4150 | Â poly p =Â L->p; |
---|
4151 |  if (strat->noTailReduction || pNext(p) == NULL) |
---|
4152 |   return p; |
---|
4153 | |
---|
4154 | Â LObject Ln(strat->tailRing); |
---|
4155 | Â TObject*Â With; |
---|
4156 | Â // placeholder in case strat->tl < 0 |
---|
4157 |  TObject With_s(strat->tailRing); |
---|
4158 | Â h =Â p; |
---|
4159 | Â hn =Â pNext(h); |
---|
4160 |  long op = strat->tailRing->pFDeg(hn, strat->tailRing); |
---|
4161 |  long e; |
---|
4162 |  int l; |
---|
4163 | Â BOOLEAN save_HE=strat->kHEdgeFound; |
---|
4164 | Â strat->kHEdgeFound |= |
---|
4165 | Â Â ((Kstd1_deg>0)Â &&Â (op<=Kstd1_deg))Â ||Â TEST_OPT_INFREDTAIL; |
---|
4166 | |
---|
4167 | Â while(hn !=Â NULL) |
---|
4168 | Â { |
---|
4169 |   op = strat->tailRing->pFDeg(hn, strat->tailRing); |
---|
4170 |   if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done; |
---|
4171 |   e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op; |
---|
4172 | Â Â loop |
---|
4173 | Â Â { |
---|
4174 |    Ln.Set(hn, strat->tailRing); |
---|
4175 |    Ln.sev = p_GetShortExpVector(hn, strat->tailRing); |
---|
4176 |    if (strat->kHEdgeFound) |
---|
4177 |     With = kFindDivisibleByInS(strat, pos, &Ln, &With_s); |
---|
4178 | Â Â Â else |
---|
4179 |     With = kFindDivisibleByInS(strat, pos, &Ln, &With_s, e); |
---|
4180 |    if (With == NULL) break; |
---|
4181 | Â Â Â With->length=0; |
---|
4182 | Â Â Â With->pLength=0; |
---|
4183 | Â Â Â strat->redTailChange=TRUE; |
---|
4184 |    if (ksReducePolyTail(L, With, h, strat->kNoetherTail())) |
---|
4185 | Â Â Â { |
---|
4186 | Â Â Â Â // reducing the tail would violate the exp bound |
---|
4187 |     if (kStratChangeTailRing(strat, L)) |
---|
4188 | Â Â Â Â { |
---|
4189 | Â Â Â Â Â strat->kHEdgeFound =Â save_HE; |
---|
4190 |      return redtail(L, pos, strat); |
---|
4191 | Â Â Â Â } |
---|
4192 | Â Â Â Â else |
---|
4193 |      return NULL; |
---|
4194 | Â Â Â } |
---|
4195 | Â Â Â hn =Â pNext(h); |
---|
4196 |    if (hn == NULL) goto all_done; |
---|
4197 |    op = strat->tailRing->pFDeg(hn, strat->tailRing); |
---|
4198 |    if ((Kstd1_deg>0)&&(op>Kstd1_deg)) goto all_done; |
---|
4199 |    e = strat->tailRing->pLDeg(hn, &l, strat->tailRing) - op; |
---|
4200 | Â Â } |
---|
4201 | Â Â h =Â hn; |
---|
4202 | Â Â hn =Â pNext(h); |
---|
4203 | Â } |
---|
4204 | |
---|
4205 | Â all_done: |
---|
4206 |  if (strat->redTailChange) |
---|
4207 | Â { |
---|
4208 | Â Â L->last =Â 0; |
---|
4209 | Â Â L->pLength =Â 0; |
---|
4210 | Â } |
---|
4211 | Â strat->kHEdgeFound =Â save_HE; |
---|
4212 |  return p; |
---|
4213 | } |
---|
4214 | |
---|
4215 | poly redtail (poly p, int pos, kStrategy strat) |
---|
4216 | { |
---|
4217 |  LObject L(p, currRing); |
---|
4218 |  return redtail(&L, pos, strat); |
---|
4219 | } |
---|
4220 | |
---|
4221 | poly redtailBba (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize) |
---|
4222 | { |
---|
4223 | #define REDTAIL_CANONICALIZE 100 |
---|
4224 | Â strat->redTailChange=FALSE; |
---|
4225 |  if (strat->noTailReduction) return L->GetLmCurrRing(); |
---|
4226 |  poly h, p; |
---|
4227 | Â p =Â h =Â L->GetLmTailRing(); |
---|
4228 |  if ((h==NULL) || (pNext(h)==NULL)) |
---|
4229 |   return L->GetLmCurrRing(); |
---|
4230 | |
---|
4231 | Â TObject*Â With; |
---|
4232 | Â // placeholder in case strat->tl < 0 |
---|
4233 |  TObject With_s(strat->tailRing); |
---|
4234 | |
---|
4235 |  LObject Ln(pNext(h), strat->tailRing); |
---|
4236 | Â Ln.pLength =Â L->GetpLength()Â -Â 1; |
---|
4237 | |
---|
4238 | Â pNext(h)Â =Â NULL; |
---|
4239 |  if (L->p != NULL) pNext(L->p) = NULL; |
---|
4240 | Â L->pLength =Â 1; |
---|
4241 | |
---|
4242 | Â Ln.PrepareRed(strat->use_buckets); |
---|
4243 | |
---|
4244 |  int cnt=REDTAIL_CANONICALIZE; |
---|
4245 | Â while(!Ln.IsNull()) |
---|
4246 | Â { |
---|
4247 | Â Â loop |
---|
4248 | Â Â { |
---|
4249 | Â Â Â Ln.SetShortExpVector(); |
---|
4250 |    if (withT) |
---|
4251 | Â Â Â { |
---|
4252 |     int j; |
---|
4253 |     j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, &Ln); |
---|
4254 |     if (j < 0) break; |
---|
4255 | Â Â Â Â With =Â &(strat->T[j]); |
---|
4256 | Â Â Â } |
---|
4257 | Â Â Â else |
---|
4258 | Â Â Â { |
---|
4259 |     With = kFindDivisibleByInS(strat, pos, &Ln, &With_s); |
---|
4260 |     if (With == NULL) break; |
---|
4261 | Â Â Â } |
---|
4262 | Â Â Â cnt--; |
---|
4263 |    if (cnt==0) |
---|
4264 | Â Â Â { |
---|
4265 | Â Â Â Â cnt=REDTAIL_CANONICALIZE;Â |
---|
4266 | Â Â Â Â poly tmp=Ln.CanonicalizeP();Â |
---|
4267 |     if (normalize) |
---|
4268 | Â Â Â Â { |
---|
4269 | Â Â Â Â Â Ln.Normalize(); |
---|
4270 | Â Â Â Â Â //pNormalize(tmp); |
---|
4271 | Â Â Â Â Â //if (TEST_OPT_PROT) { PrintS("n"); mflush(); } |
---|
4272 | Â Â Â Â } |
---|
4273 | Â Â Â } |
---|
4274 |    if (normalize && (!TEST_OPT_INTSTRATEGY) && (!nIsOne(pGetCoeff(With->p)))) |
---|
4275 | Â Â Â { |
---|
4276 | Â Â Â Â With->pNorm(); |
---|
4277 | Â Â Â } |
---|
4278 | Â Â Â strat->redTailChange=TRUE; |
---|
4279 |    if (ksReducePolyTail(L, With, &Ln)) |
---|
4280 | Â Â Â { |
---|
4281 | Â Â Â Â // reducing the tail would violate the exp bound |
---|
4282 | Â Â Â Â //Â set a flag and hope for a retry (in bba) |
---|
4283 | Â Â Â Â strat->completeReduce_retry=TRUE; |
---|
4284 | Â Â Â Â do |
---|
4285 | Â Â Â Â { |
---|
4286 | Â Â Â Â Â pNext(h)Â =Â Ln.LmExtractAndIter(); |
---|
4287 | Â Â Â Â Â pIter(h); |
---|
4288 | Â Â Â Â Â L->pLength++; |
---|
4289 |     } while (!Ln.IsNull()); |
---|
4290 |     goto all_done; |
---|
4291 | Â Â Â } |
---|
4292 |    if (Ln.IsNull()) goto all_done; |
---|
4293 |    if (! withT) With_s.Init(currRing); |
---|
4294 | Â Â } |
---|
4295 | Â Â pNext(h)Â =Â Ln.LmExtractAndIter(); |
---|
4296 | Â Â pIter(h); |
---|
4297 | Â Â pNormalize(h); |
---|
4298 | Â Â L->pLength++; |
---|
4299 | Â } |
---|
4300 | |
---|
4301 | Â all_done: |
---|
4302 | Â Ln.Delete(); |
---|
4303 |  if (L->p != NULL) pNext(L->p) = pNext(p); |
---|
4304 | |
---|
4305 |  if (strat->redTailChange) |
---|
4306 | Â { |
---|
4307 | Â Â L->last =Â NULL; |
---|
4308 | Â Â L->length =Â 0; |
---|
4309 | Â } |
---|
4310 | |
---|
4311 | Â //if (TEST_OPT_PROT) { PrintS("N"); mflush(); } |
---|
4312 | Â //L->Normalize(); // HANNES: should have a test |
---|
4313 | Â kTest_L(L); |
---|
4314 |  return L->GetLmCurrRing(); |
---|
4315 | } |
---|
4316 | |
---|
4317 | /*2 |
---|
4318 | *checks the change degree and write progress report |
---|
4319 | */ |
---|
4320 | void message (int i,int* reduc,int* olddeg,kStrategy strat, int red_result) |
---|
4321 | { |
---|
4322 |  if (i != *olddeg) |
---|
4323 | Â { |
---|
4324 | Â Â Print("%d",i); |
---|
4325 | Â Â *olddeg =Â i; |
---|
4326 | Â } |
---|
4327 |  if (K_TEST_OPT_OLDSTD) |
---|
4328 | Â { |
---|
4329 |   if (strat->Ll != *reduc) |
---|
4330 | Â Â { |
---|
4331 |    if (strat->Ll != *reduc-1) |
---|
4332 | Â Â Â Â Print("(%d)",strat->Ll+1); |
---|
4333 | Â Â Â else |
---|
4334 | Â Â Â Â PrintS("-"); |
---|
4335 | Â Â Â *reduc =Â strat->Ll; |
---|
4336 | Â Â } |
---|
4337 | Â Â else |
---|
4338 | Â Â Â PrintS("."); |
---|
4339 | Â Â mflush(); |
---|
4340 | Â } |
---|
4341 | Â else |
---|
4342 | Â { |
---|
4343 |   if (red_result == 0) |
---|
4344 | Â Â Â PrintS("-"); |
---|
4345 |   else if (red_result < 0) |
---|
4346 | Â Â Â PrintS("."); |
---|
4347 |   if ((red_result > 0) || ((strat->Ll % 100)==99)) |
---|
4348 | Â Â { |
---|
4349 |    if (strat->Ll != *reduc && strat->Ll > 0) |
---|
4350 | Â Â Â { |
---|
4351 | Â Â Â Â Print("(%d)",strat->Ll+1); |
---|
4352 | Â Â Â Â *reduc =Â strat->Ll; |
---|
4353 | Â Â Â } |
---|
4354 | Â Â } |
---|
4355 | Â } |
---|
4356 | } |
---|
4357 | |
---|
4358 | /*2 |
---|
4359 | *statistics |
---|
4360 | */ |
---|
4361 | void messageStat (int srmax,int lrmax,int hilbcount,kStrategy strat) |
---|
4362 | { |
---|
4363 | Â //PrintS("\nUsage/Allocation of temporary storage:\n"); |
---|
4364 | Â //Print("%d/%d polynomials in standard base\n",srmax,IDELEMS(Shdl)); |
---|
4365 | Â //Print("%d/%d polynomials in set L (for lazy alg.)",lrmax+1,strat->Lmax); |
---|
4366 | Â Print("product criterion:%d chain criterion:%d\n",strat->cp,strat->c3); |
---|
4367 |  if (hilbcount!=0) Print("hilbert series criterion:%d\n",hilbcount); |
---|
4368 | Â /* in usual case strat->cv is 0, it gets changed only in shift routines */ |
---|
4369 |  if (strat->cv!=0) Print("shift V criterion:%d\n",strat->cv); |
---|
4370 | Â /*mflush();*/ |
---|
4371 | } |
---|
4372 | |
---|
4373 | #ifdef KDEBUG |
---|
4374 | /*2 |
---|
4375 | *debugging output: all internal sets, if changed |
---|
4376 | *for testing purpuse only/has to be changed for later use |
---|
4377 | */ |
---|
4378 | void messageSets (kStrategy strat) |
---|
4379 | { |
---|
4380 |  int i; |
---|
4381 |  if (strat->news) |
---|
4382 | Â { |
---|
4383 | Â Â PrintS("set S"); |
---|
4384 |   for (i=0; i<=strat->sl; i++) |
---|
4385 | Â Â { |
---|
4386 |    Print("\n %d:",i); |
---|
4387 |    p_wrp(strat->S[i], currRing, strat->tailRing); |
---|
4388 | Â Â } |
---|
4389 | Â Â strat->news =Â FALSE; |
---|
4390 | Â } |
---|
4391 |  if (strat->newt) |
---|
4392 | Â { |
---|
4393 | Â Â PrintS("\nset T"); |
---|
4394 |   for (i=0; i<=strat->tl; i++) |
---|
4395 | Â Â { |
---|
4396 |    Print("\n %d:",i); |
---|
4397 | Â Â Â strat->T[i].wrp(); |
---|
4398 | Â Â Â Print(" o:%d e:%d l:%d", |
---|
4399 | Â Â Â Â strat->T[i].pFDeg(),strat->T[i].ecart,strat->T[i].length); |
---|
4400 | Â Â } |
---|
4401 | Â Â strat->newt =Â FALSE; |
---|
4402 | Â } |
---|
4403 | Â PrintS("\nset L"); |
---|
4404 |  for (i=strat->Ll; i>=0; i--) |
---|
4405 | Â { |
---|
4406 | Â Â Print("\n%d:",i); |
---|
4407 |   p_wrp(strat->L[i].p1, currRing, strat->tailRing); |
---|
4408 | Â Â PrintS("Â "); |
---|
4409 |   p_wrp(strat->L[i].p2, currRing, strat->tailRing); |
---|
4410 |   PrintS(" lcm: ");p_wrp(strat->L[i].lcm, currRing); |
---|
4411 |   PrintS("\n p : "); |
---|
4412 | Â Â strat->L[i].wrp(); |
---|
4413 | Â Â Print("Â o:%d e:%d l:%d", |
---|
4414 | Â Â Â Â Â strat->L[i].pFDeg(),strat->L[i].ecart,strat->L[i].length); |
---|
4415 | Â } |
---|
4416 | Â PrintLn(); |
---|
4417 | } |
---|
4418 | |
---|
4419 | #endif |
---|
4420 | |
---|
4421 | |
---|
4422 | /*2 |
---|
4423 | *construct the set s from F |
---|
4424 | */ |
---|
4425 | void initS (ideal F, ideal Q,kStrategy strat) |
---|
4426 | { |
---|
4427 |  int  i,pos; |
---|
4428 | |
---|
4429 |  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc; |
---|
4430 |  else i=setmaxT; |
---|
4431 | Â strat->ecartS=initec(i); |
---|
4432 | Â strat->sevS=initsevS(i); |
---|
4433 | Â strat->S_2_R=initS_2_R(i); |
---|
4434 | Â strat->fromQ=NULL; |
---|
4435 | Â strat->Shdl=idInit(i,F->rank); |
---|
4436 | Â strat->S=strat->Shdl->m; |
---|
4437 | Â /*- put polys into S -*/ |
---|
4438 |  if (Q!=NULL) |
---|
4439 | Â { |
---|
4440 | Â Â strat->fromQ=initec(i); |
---|
4441 | Â Â memset(strat->fromQ,0,i*sizeof(int)); |
---|
4442 |   for (i=0; i<IDELEMS(Q); i++) |
---|
4443 | Â Â { |
---|
4444 |    if (Q->m[i]!=NULL) |
---|
4445 | Â Â Â { |
---|
4446 | Â Â Â Â LObject h; |
---|
4447 | Â Â Â Â h.p =Â pCopy(Q->m[i]); |
---|
4448 |     if (TEST_OPT_INTSTRATEGY) |
---|
4449 | Â Â Â Â { |
---|
4450 | Â Â Â Â Â //pContent(h.p); |
---|
4451 | Â Â Â Â Â h.pCleardenom();Â // also does a pContent |
---|
4452 | Â Â Â Â } |
---|
4453 | Â Â Â Â else |
---|
4454 | Â Â Â Â { |
---|
4455 | Â Â Â Â Â h.pNorm(); |
---|
4456 | Â Â Â Â } |
---|
4457 |     if (pOrdSgn==-1) |
---|
4458 | Â Â Â Â { |
---|
4459 |      deleteHC(&h, strat); |
---|
4460 | Â Â Â Â } |
---|
4461 |     if (h.p!=NULL) |
---|
4462 | Â Â Â Â { |
---|
4463 | Â Â Â Â Â strat->initEcart(&h); |
---|
4464 |      if (strat->sl==-1) |
---|
4465 | Â Â Â Â Â Â pos =0; |
---|
4466 | Â Â Â Â Â else |
---|
4467 | Â Â Â Â Â { |
---|
4468 | Â Â Â Â Â Â pos =Â posInS(strat,strat->sl,h.p,h.ecart); |
---|
4469 | Â Â Â Â Â } |
---|
4470 | Â Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
4471 | Â Â Â Â Â strat->enterS(h,pos,strat,-1); |
---|
4472 | Â Â Â Â Â strat->fromQ[pos]=1; |
---|
4473 | Â Â Â Â } |
---|
4474 | Â Â Â } |
---|
4475 | Â Â } |
---|
4476 | Â } |
---|
4477 |  for (i=0; i<IDELEMS(F); i++) |
---|
4478 | Â { |
---|
4479 |   if (F->m[i]!=NULL) |
---|
4480 | Â Â { |
---|
4481 | Â Â Â LObject h; |
---|
4482 | Â Â Â h.p =Â pCopy(F->m[i]); |
---|
4483 |    if (pOrdSgn==-1) |
---|
4484 | Â Â Â { |
---|
4485 | Â Â Â Â cancelunit(&h);Â /*- tries to cancel a unit -*/ |
---|
4486 |     deleteHC(&h, strat); |
---|
4487 | Â Â Â } |
---|
4488 |    if (TEST_OPT_INTSTRATEGY) |
---|
4489 | Â Â Â { |
---|
4490 | Â Â Â Â //pContent(h.p); |
---|
4491 | Â Â Â Â h.pCleardenom();Â // also does a pContent |
---|
4492 | Â Â Â } |
---|
4493 | Â Â Â else |
---|
4494 | Â Â Â { |
---|
4495 | Â Â Â Â h.pNorm(); |
---|
4496 | Â Â Â } |
---|
4497 |    if (h.p!=NULL) |
---|
4498 | Â Â Â { |
---|
4499 | Â Â Â Â strat->initEcart(&h); |
---|
4500 |     if (strat->sl==-1) |
---|
4501 | Â Â Â Â Â pos =0; |
---|
4502 | Â Â Â Â else |
---|
4503 | Â Â Â Â Â pos =Â posInS(strat,strat->sl,h.p,h.ecart); |
---|
4504 | Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
4505 | Â Â Â Â strat->enterS(h,pos,strat,-1); |
---|
4506 | Â Â Â } |
---|
4507 | Â Â } |
---|
4508 | Â } |
---|
4509 | Â /*- test, if a unit is in F -*/ |
---|
4510 |  if ((strat->sl>=0) |
---|
4511 | #ifdef HAVE_RINGS |
---|
4512 | Â Â Â Â &&Â nIsUnit(pGetCoeff(strat->S[0])) |
---|
4513 | #endif |
---|
4514 | Â Â Â Â &&Â pIsConstant(strat->S[0])) |
---|
4515 | Â { |
---|
4516 |   while (strat->sl>0) deleteInS(strat->sl,strat); |
---|
4517 | Â } |
---|
4518 | } |
---|
4519 | |
---|
4520 | void initSL (ideal F, ideal Q,kStrategy strat) |
---|
4521 | { |
---|
4522 |  int  i,pos; |
---|
4523 | |
---|
4524 |  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc; |
---|
4525 |  else i=setmaxT; |
---|
4526 | Â strat->ecartS=initec(i); |
---|
4527 | Â strat->sevS=initsevS(i); |
---|
4528 | Â strat->S_2_R=initS_2_R(i); |
---|
4529 | Â strat->fromQ=NULL; |
---|
4530 | Â strat->Shdl=idInit(i,F->rank); |
---|
4531 | Â strat->S=strat->Shdl->m; |
---|
4532 | Â /*- put polys into S -*/ |
---|
4533 |  if (Q!=NULL) |
---|
4534 | Â { |
---|
4535 | Â Â strat->fromQ=initec(i); |
---|
4536 | Â Â memset(strat->fromQ,0,i*sizeof(int)); |
---|
4537 |   for (i=0; i<IDELEMS(Q); i++) |
---|
4538 | Â Â { |
---|
4539 |    if (Q->m[i]!=NULL) |
---|
4540 | Â Â Â { |
---|
4541 | Â Â Â Â LObject h; |
---|
4542 | Â Â Â Â h.p =Â pCopy(Q->m[i]); |
---|
4543 |     if (pOrdSgn==-1) |
---|
4544 | Â Â Â Â { |
---|
4545 | Â Â Â Â Â deleteHC(&h,strat); |
---|
4546 | Â Â Â Â } |
---|
4547 |     if (TEST_OPT_INTSTRATEGY) |
---|
4548 | Â Â Â Â { |
---|
4549 | Â Â Â Â Â //pContent(h.p); |
---|
4550 | Â Â Â Â Â h.pCleardenom();Â // also does a pContent |
---|
4551 | Â Â Â Â } |
---|
4552 | Â Â Â Â else |
---|
4553 | Â Â Â Â { |
---|
4554 | Â Â Â Â Â h.pNorm(); |
---|
4555 | Â Â Â Â } |
---|
4556 |     if (h.p!=NULL) |
---|
4557 | Â Â Â Â { |
---|
4558 | Â Â Â Â Â strat->initEcart(&h); |
---|
4559 |      if (strat->sl==-1) |
---|
4560 | Â Â Â Â Â Â pos =0; |
---|
4561 | Â Â Â Â Â else |
---|
4562 | Â Â Â Â Â { |
---|
4563 | Â Â Â Â Â Â pos =Â posInS(strat,strat->sl,h.p,h.ecart); |
---|
4564 | Â Â Â Â Â } |
---|
4565 | Â Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
4566 | Â Â Â Â Â strat->enterS(h,pos,strat,-1); |
---|
4567 | Â Â Â Â Â strat->fromQ[pos]=1; |
---|
4568 | Â Â Â Â } |
---|
4569 | Â Â Â } |
---|
4570 | Â Â } |
---|
4571 | Â } |
---|
4572 |  for (i=0; i<IDELEMS(F); i++) |
---|
4573 | Â { |
---|
4574 |   if (F->m[i]!=NULL) |
---|
4575 | Â Â { |
---|
4576 | Â Â Â LObject h; |
---|
4577 | Â Â Â h.p =Â pCopy(F->m[i]); |
---|
4578 |    if (h.p!=NULL) |
---|
4579 | Â Â Â { |
---|
4580 |     if (pOrdSgn==-1) |
---|
4581 | Â Â Â Â { |
---|
4582 | Â Â Â Â Â cancelunit(&h);Â /*- tries to cancel a unit -*/ |
---|
4583 |      deleteHC(&h, strat); |
---|
4584 | Â Â Â Â } |
---|
4585 |     if (h.p!=NULL) |
---|
4586 | Â Â Â Â { |
---|
4587 |      if (TEST_OPT_INTSTRATEGY) |
---|
4588 | Â Â Â Â Â { |
---|
4589 | Â Â Â Â Â Â //pContent(h.p); |
---|
4590 | Â Â Â Â Â Â h.pCleardenom();Â // also does a pContent |
---|
4591 | Â Â Â Â Â } |
---|
4592 | Â Â Â Â Â else |
---|
4593 | Â Â Â Â Â { |
---|
4594 | Â Â Â Â Â Â h.pNorm(); |
---|
4595 | Â Â Â Â Â } |
---|
4596 | Â Â Â Â Â strat->initEcart(&h); |
---|
4597 |      if (strat->Ll==-1) |
---|
4598 | Â Â Â Â Â Â pos =0; |
---|
4599 | Â Â Â Â Â else |
---|
4600 | Â Â Â Â Â Â pos =Â strat->posInL(strat->L,strat->Ll,&h,strat); |
---|
4601 | Â Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
4602 | Â Â Â Â Â enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos); |
---|
4603 | Â Â Â Â } |
---|
4604 | Â Â Â } |
---|
4605 | Â Â } |
---|
4606 | Â } |
---|
4607 | Â /*- test, if a unit is in F -*/ |
---|
4608 | |
---|
4609 |  if ((strat->Ll>=0) |
---|
4610 | #ifdef HAVE_RINGS |
---|
4611 | Â Â Â Â &&Â nIsUnit(pGetCoeff(strat->L[strat->Ll].p)) |
---|
4612 | #endif |
---|
4613 | Â Â Â Â &&Â pIsConstant(strat->L[strat->Ll].p)) |
---|
4614 | Â { |
---|
4615 |   while (strat->Ll>0) deleteInL(strat->L,&strat->Ll,strat->Ll-1,strat); |
---|
4616 | Â } |
---|
4617 | } |
---|
4618 | |
---|
4619 | |
---|
4620 | /*2 |
---|
4621 | *construct the set s from F and {P} |
---|
4622 | */ |
---|
4623 | void initSSpecial (ideal F, ideal Q, ideal P,kStrategy strat) |
---|
4624 | { |
---|
4625 |  int  i,pos; |
---|
4626 | |
---|
4627 |  if (Q!=NULL) i=((IDELEMS(Q)+(setmaxTinc-1))/setmaxTinc)*setmaxTinc; |
---|
4628 |  else i=setmaxT; |
---|
4629 | Â i=((i+IDELEMS(F)+IDELEMS(P)+15)/16)*16; |
---|
4630 | Â strat->ecartS=initec(i); |
---|
4631 | Â strat->sevS=initsevS(i); |
---|
4632 | Â strat->S_2_R=initS_2_R(i); |
---|
4633 | Â strat->fromQ=NULL; |
---|
4634 | Â strat->Shdl=idInit(i,F->rank); |
---|
4635 | Â strat->S=strat->Shdl->m; |
---|
4636 | |
---|
4637 | Â /*- put polys into S -*/ |
---|
4638 |  if (Q!=NULL) |
---|
4639 | Â { |
---|
4640 | Â Â strat->fromQ=initec(i); |
---|
4641 | Â Â memset(strat->fromQ,0,i*sizeof(int)); |
---|
4642 |   for (i=0; i<IDELEMS(Q); i++) |
---|
4643 | Â Â { |
---|
4644 |    if (Q->m[i]!=NULL) |
---|
4645 | Â Â Â { |
---|
4646 | Â Â Â Â LObject h; |
---|
4647 | Â Â Â Â h.p =Â pCopy(Q->m[i]); |
---|
4648 | Â Â Â Â //if (TEST_OPT_INTSTRATEGY) |
---|
4649 | Â Â Â Â //{ |
---|
4650 | Â Â Â Â //Â //pContent(h.p); |
---|
4651 | Â Â Â Â //Â h.pCleardenom(); // also does a pContent |
---|
4652 | Â Â Â Â //} |
---|
4653 | Â Â Â Â //else |
---|
4654 | Â Â Â Â //{ |
---|
4655 | Â Â Â Â //Â h.pNorm(); |
---|
4656 | Â Â Â Â //} |
---|
4657 |     if (pOrdSgn==-1) |
---|
4658 | Â Â Â Â { |
---|
4659 | Â Â Â Â Â deleteHC(&h,strat); |
---|
4660 | Â Â Â Â } |
---|
4661 |     if (h.p!=NULL) |
---|
4662 | Â Â Â Â { |
---|
4663 | Â Â Â Â Â strat->initEcart(&h); |
---|
4664 |      if (strat->sl==-1) |
---|
4665 | Â Â Â Â Â Â pos =0; |
---|
4666 | Â Â Â Â Â else |
---|
4667 | Â Â Â Â Â { |
---|
4668 | Â Â Â Â Â Â pos =Â posInS(strat,strat->sl,h.p,h.ecart); |
---|
4669 | Â Â Â Â Â } |
---|
4670 | Â Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
4671 |      strat->enterS(h,pos,strat, strat->tl+1); |
---|
4672 |      enterT(h, strat); |
---|
4673 | Â Â Â Â Â strat->fromQ[pos]=1; |
---|
4674 | Â Â Â Â } |
---|
4675 | Â Â Â } |
---|
4676 | Â Â } |
---|
4677 | Â } |
---|
4678 | Â /*- put polys into S -*/ |
---|
4679 |  for (i=0; i<IDELEMS(F); i++) |
---|
4680 | Â { |
---|
4681 |   if (F->m[i]!=NULL) |
---|
4682 | Â Â { |
---|
4683 | Â Â Â LObject h; |
---|
4684 | Â Â Â h.p =Â pCopy(F->m[i]); |
---|
4685 |    if (pOrdSgn==-1) |
---|
4686 | Â Â Â { |
---|
4687 | Â Â Â Â deleteHC(&h,strat); |
---|
4688 | Â Â Â } |
---|
4689 | Â Â Â else |
---|
4690 | Â Â Â { |
---|
4691 | Â Â Â Â h.p=redtailBba(h.p,strat->sl,strat); |
---|
4692 | Â Â Â } |
---|
4693 |    if (h.p!=NULL) |
---|
4694 | Â Â Â { |
---|
4695 | Â Â Â Â strat->initEcart(&h); |
---|
4696 |     if (strat->sl==-1) |
---|
4697 | Â Â Â Â Â pos =0; |
---|
4698 | Â Â Â Â else |
---|
4699 | Â Â Â Â Â pos =Â posInS(strat,strat->sl,h.p,h.ecart); |
---|
4700 | Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
4701 |     strat->enterS(h,pos,strat, strat->tl+1); |
---|
4702 | Â Â Â Â enterT(h,strat); |
---|
4703 | Â Â Â } |
---|
4704 | Â Â } |
---|
4705 | Â } |
---|
4706 |  for (i=0; i<IDELEMS(P); i++) |
---|
4707 | Â { |
---|
4708 |   if (P->m[i]!=NULL) |
---|
4709 | Â Â { |
---|
4710 | Â Â Â LObject h; |
---|
4711 | Â Â Â h.p=pCopy(P->m[i]); |
---|
4712 |    if (TEST_OPT_INTSTRATEGY) |
---|
4713 | Â Â Â { |
---|
4714 | Â Â Â Â h.pCleardenom(); |
---|
4715 | Â Â Â } |
---|
4716 | Â Â Â else |
---|
4717 | Â Â Â { |
---|
4718 | Â Â Â Â h.pNorm(); |
---|
4719 | Â Â Â } |
---|
4720 | Â Â Â if(strat->sl>=0) |
---|
4721 | Â Â Â { |
---|
4722 |     if (pOrdSgn==1) |
---|
4723 | Â Â Â Â { |
---|
4724 | Â Â Â Â Â h.p=redBba(h.p,strat->sl,strat); |
---|
4725 |      if (h.p!=NULL) |
---|
4726 | Â Â Â Â Â { |
---|
4727 | Â Â Â Â Â Â h.p=redtailBba(h.p,strat->sl,strat); |
---|
4728 | Â Â Â Â Â } |
---|
4729 | Â Â Â Â } |
---|
4730 | Â Â Â Â else |
---|
4731 | Â Â Â Â { |
---|
4732 | Â Â Â Â Â h.p=redMora(h.p,strat->sl,strat); |
---|
4733 | Â Â Â Â } |
---|
4734 | Â Â Â Â if(h.p!=NULL) |
---|
4735 | Â Â Â Â { |
---|
4736 | Â Â Â Â Â strat->initEcart(&h); |
---|
4737 |      if (TEST_OPT_INTSTRATEGY) |
---|
4738 | Â Â Â Â Â { |
---|
4739 | Â Â Â Â Â Â h.pCleardenom(); |
---|
4740 | Â Â Â Â Â } |
---|
4741 | Â Â Â Â Â else |
---|
4742 | Â Â Â Â Â { |
---|
4743 | Â Â Â Â Â Â h.is_normalized =Â 0; |
---|
4744 | Â Â Â Â Â Â h.pNorm(); |
---|
4745 | Â Â Â Â Â } |
---|
4746 | Â Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
4747 | Â Â Â Â Â h.SetpFDeg(); |
---|
4748 | Â Â Â Â Â pos =Â posInS(strat,strat->sl,h.p,h.ecart); |
---|
4749 | Â Â Â Â Â enterpairsSpecial(h.p,strat->sl,h.ecart,pos,strat,strat->tl+1); |
---|
4750 |      strat->enterS(h,pos,strat, strat->tl+1); |
---|
4751 | Â Â Â Â Â enterT(h,strat); |
---|
4752 | Â Â Â Â } |
---|
4753 | Â Â Â } |
---|
4754 | Â Â Â else |
---|
4755 | Â Â Â { |
---|
4756 | Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
4757 | Â Â Â Â strat->initEcart(&h); |
---|
4758 |     strat->enterS(h,0,strat, strat->tl+1); |
---|
4759 | Â Â Â Â enterT(h,strat); |
---|
4760 | Â Â Â } |
---|
4761 | Â Â } |
---|
4762 | Â } |
---|
4763 | } |
---|
4764 | /*2 |
---|
4765 | * reduces h using the set S |
---|
4766 | * procedure used in cancelunit1 |
---|
4767 | */ |
---|
4768 | static poly redBba1 (poly h,int maxIndex,kStrategy strat) |
---|
4769 | { |
---|
4770 |  int j = 0; |
---|
4771 |  unsigned long not_sev = ~ pGetShortExpVector(h); |
---|
4772 | |
---|
4773 |  while (j <= maxIndex) |
---|
4774 | Â { |
---|
4775 |   if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j],h, not_sev)) |
---|
4776 |     return ksOldSpolyRedNew(strat->S[j],h,strat->kNoetherTail()); |
---|
4777 |   else j++; |
---|
4778 | Â } |
---|
4779 |  return h; |
---|
4780 | } |
---|
4781 | |
---|
4782 | /*2 |
---|
4783 | *tests if p.p=monomial*unit and cancels the unit |
---|
4784 | */ |
---|
4785 | void cancelunit1 (LObject* p,int *suc, int index,kStrategy strat ) |
---|
4786 | { |
---|
4787 |  int k; |
---|
4788 | Â poly r,h,h1,q; |
---|
4789 | |
---|
4790 |  if (!pIsVector((*p).p) && ((*p).ecart != 0)) |
---|
4791 | Â { |
---|
4792 | Â Â k =Â 0; |
---|
4793 | Â Â h1 =Â r =Â pCopy((*p).p); |
---|
4794 | Â Â h =pNext(r); |
---|
4795 | Â Â loop |
---|
4796 | Â Â { |
---|
4797 |    if (h==NULL) |
---|
4798 | Â Â Â { |
---|
4799 | Â Â Â Â pDelete(&r); |
---|
4800 | Â Â Â Â pDelete(&(pNext((*p).p))); |
---|
4801 | Â Â Â Â (*p).ecart =Â 0; |
---|
4802 | Â Â Â Â (*p).length =Â 1; |
---|
4803 | Â Â Â Â (*suc)=0; |
---|
4804 | Â Â Â Â return; |
---|
4805 | Â Â Â } |
---|
4806 |    if (!pDivisibleBy(r,h)) |
---|
4807 | Â Â Â { |
---|
4808 | Â Â Â Â q=redBba1(h,index ,strat); |
---|
4809 |     if (q != h) |
---|
4810 | Â Â Â Â { |
---|
4811 | Â Â Â Â Â k++; |
---|
4812 | Â Â Â Â Â pDelete(&h); |
---|
4813 | Â Â Â Â Â pNext(h1)Â =Â h =Â q; |
---|
4814 | Â Â Â Â } |
---|
4815 | Â Â Â Â else |
---|
4816 | Â Â Â Â { |
---|
4817 | Â Â Â Â Â pDelete(&r); |
---|
4818 | Â Â Â Â Â return; |
---|
4819 | Â Â Â Â } |
---|
4820 | Â Â Â } |
---|
4821 | Â Â Â else |
---|
4822 | Â Â Â { |
---|
4823 | Â Â Â Â h1 =Â h; |
---|
4824 | Â Â Â Â pIter(h); |
---|
4825 | Â Â Â } |
---|
4826 |    if (k > 10) |
---|
4827 | Â Â Â { |
---|
4828 | Â Â Â Â pDelete(&r); |
---|
4829 | Â Â Â Â return; |
---|
4830 | Â Â Â } |
---|
4831 | Â Â } |
---|
4832 | Â } |
---|
4833 | } |
---|
4834 | |
---|
4835 | #if 0 |
---|
4836 | /*2 |
---|
4837 | * reduces h using the elements from Q in the set S |
---|
4838 | * procedure used in updateS |
---|
4839 | * must not be used for elements of Q or elements of an ideal ! |
---|
4840 | */ |
---|
4841 | static poly redQ (poly h, int j, kStrategy strat) |
---|
4842 | { |
---|
4843 | Â int start; |
---|
4844 | Â unsigned long not_sev = ~ pGetShortExpVector(h); |
---|
4845 | Â while ((j <= strat->sl) && (pGetComp(strat->S[j])!=0)) j++; |
---|
4846 | Â start=j; |
---|
4847 | Â while (j<=strat->sl) |
---|
4848 | Â { |
---|
4849 | Â Â if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j], h, not_sev)) |
---|
4850 | Â Â { |
---|
4851 | Â Â Â h = ksOldSpolyRed(strat->S[j],h,strat->kNoetherTail()); |
---|
4852 | Â Â Â if (h==NULL) return NULL; |
---|
4853 | Â Â Â j = start; |
---|
4854 | Â Â Â not_sev = ~ pGetShortExpVector(h); |
---|
4855 | Â Â } |
---|
4856 | Â Â else j++; |
---|
4857 | Â } |
---|
4858 | Â return h; |
---|
4859 | } |
---|
4860 | #endif |
---|
4861 | |
---|
4862 | /*2 |
---|
4863 | * reduces h using the set S |
---|
4864 | * procedure used in updateS |
---|
4865 | */ |
---|
4866 | static poly redBba (poly h,int maxIndex,kStrategy strat) |
---|
4867 | { |
---|
4868 |  int j = 0; |
---|
4869 |  unsigned long not_sev = ~ pGetShortExpVector(h); |
---|
4870 | |
---|
4871 |  while (j <= maxIndex) |
---|
4872 | Â { |
---|
4873 |   if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j], h, not_sev)) |
---|
4874 | Â Â { |
---|
4875 | Â Â Â h =Â ksOldSpolyRed(strat->S[j],h,strat->kNoetherTail()); |
---|
4876 |    if (h==NULL) return NULL; |
---|
4877 | Â Â Â j =Â 0; |
---|
4878 | Â Â Â not_sev =Â ~Â pGetShortExpVector(h);Â Â } |
---|
4879 |   else j++; |
---|
4880 | Â } |
---|
4881 |  return h; |
---|
4882 | } |
---|
4883 | |
---|
4884 | /*2 |
---|
4885 | * reduces h using the set S |
---|
4886 | *e is the ecart of h |
---|
4887 | *procedure used in updateS |
---|
4888 | */ |
---|
4889 | static poly redMora (poly h,int maxIndex,kStrategy strat) |
---|
4890 | { |
---|
4891 |  int j=0; |
---|
4892 |  int e,l; |
---|
4893 |  unsigned long not_sev = ~ pGetShortExpVector(h); |
---|
4894 | |
---|
4895 |  if (maxIndex >= 0) |
---|
4896 | Â { |
---|
4897 | Â Â e =Â pLDeg(h,&l,currRing)-pFDeg(h,currRing); |
---|
4898 | Â Â do |
---|
4899 | Â Â { |
---|
4900 |    if (pLmShortDivisibleBy(strat->S[j],strat->sevS[j], h, not_sev) |
---|
4901 | Â Â Â &&Â ((e >=Â strat->ecartS[j])Â ||Â strat->kHEdgeFound)) |
---|
4902 | Â Â Â { |
---|
4903 | #ifdef KDEBUG |
---|
4904 |     if (TEST_OPT_DEBUG) |
---|
4905 | Â Â Â Â Â {PrintS("reduce ");wrp(h);Print(" with S[%d] (",j);wrp(strat->S[j]);} |
---|
4906 | #endif |
---|
4907 | Â Â Â Â h =Â ksOldSpolyRed(strat->S[j],h,strat->kNoetherTail()); |
---|
4908 | #ifdef KDEBUG |
---|
4909 | Â Â Â Â if(TEST_OPT_DEBUG) |
---|
4910 | Â Â Â Â Â {PrintS(")\nto ");Â wrp(h);Â PrintLn();} |
---|
4911 | #endif |
---|
4912 | Â Â Â Â // pDelete(&h); |
---|
4913 |     if (h == NULL) return NULL; |
---|
4914 | Â Â Â Â e =Â pLDeg(h,&l,currRing)-pFDeg(h,currRing); |
---|
4915 | Â Â Â Â j =Â 0; |
---|
4916 | Â Â Â Â not_sev =Â ~Â pGetShortExpVector(h); |
---|
4917 | Â Â Â } |
---|
4918 |    else j++; |
---|
4919 | Â Â } |
---|
4920 |   while (j <= maxIndex); |
---|
4921 | Â } |
---|
4922 |  return h; |
---|
4923 | } |
---|
4924 | |
---|
4925 | /*2 |
---|
4926 | *updates S: |
---|
4927 | *the result is a set of polynomials which are in |
---|
4928 | *normalform with respect to S |
---|
4929 | */ |
---|
4930 | void updateS(BOOLEAN toT,kStrategy strat) |
---|
4931 | { |
---|
4932 | Â LObject h; |
---|
4933 |  int i, suc=0; |
---|
4934 | Â poly redSi=NULL; |
---|
4935 | Â BOOLEAN change,any_change; |
---|
4936 | //Â Print("nach initS: updateS start mit sl=%d\n",(strat->sl)); |
---|
4937 | //Â for (i=0; i<=(strat->sl); i++) |
---|
4938 | //Â { |
---|
4939 | //Â Â Print("s%d:",i); |
---|
4940 | //Â Â if (strat->fromQ!=NULL) Print("(Q:%d) ",strat->fromQ[i]); |
---|
4941 | //Â Â pWrite(strat->S[i]); |
---|
4942 | //Â } |
---|
4943 | //Â Print("pOrdSgn=%d\n", pOrdSgn); |
---|
4944 | Â any_change=FALSE; |
---|
4945 |  if (pOrdSgn==1) |
---|
4946 | Â { |
---|
4947 |   while (suc != -1) |
---|
4948 | Â Â { |
---|
4949 | Â Â Â i=suc+1; |
---|
4950 |    while (i<=strat->sl) |
---|
4951 | Â Â Â { |
---|
4952 | Â Â Â Â change=FALSE; |
---|
4953 |     if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0)) |
---|
4954 | Â Â Â Â { |
---|
4955 | Â Â Â Â Â redSi =Â pHead(strat->S[i]); |
---|
4956 | Â Â Â Â Â strat->S[i]Â =Â redBba(strat->S[i],i-1,strat); |
---|
4957 | Â Â Â Â Â //if ((strat->ak!=0)&&(strat->S[i]!=NULL)) |
---|
4958 | Â Â Â Â Â //Â strat->S[i]=redQ(strat->S[i],i+1,strat); /*reduce S[i] mod Q*/ |
---|
4959 |      if (pCmp(redSi,strat->S[i])!=0) |
---|
4960 | Â Â Â Â Â { |
---|
4961 | Â Â Â Â Â Â change=TRUE; |
---|
4962 | Â Â Â Â Â Â any_change=TRUE; |
---|
4963 | Â Â Â Â Â Â #ifdef KDEBUG |
---|
4964 |       if (TEST_OPT_DEBUG) |
---|
4965 | Â Â Â Â Â Â { |
---|
4966 | Â Â Â Â Â Â Â PrintS("reduce:"); |
---|
4967 |        wrp(redSi);PrintS(" to ");p_wrp(strat->S[i], currRing, strat->tailRing);PrintLn(); |
---|
4968 | Â Â Â Â Â Â } |
---|
4969 | Â Â Â Â Â Â #endif |
---|
4970 |       if (TEST_OPT_PROT) |
---|
4971 | Â Â Â Â Â Â { |
---|
4972 |        if (strat->S[i]==NULL) |
---|
4973 | Â Â Â Â Â Â Â Â PrintS("V"); |
---|
4974 | Â Â Â Â Â Â Â else |
---|
4975 | Â Â Â Â Â Â Â Â PrintS("v"); |
---|
4976 | Â Â Â Â Â Â Â mflush(); |
---|
4977 | Â Â Â Â Â Â } |
---|
4978 | Â Â Â Â Â } |
---|
4979 | Â Â Â Â Â pDeleteLm(&redSi); |
---|
4980 |      if (strat->S[i]==NULL) |
---|
4981 | Â Â Â Â Â { |
---|
4982 | Â Â Â Â Â Â deleteInS(i,strat); |
---|
4983 | Â Â Â Â Â Â i--; |
---|
4984 | Â Â Â Â Â } |
---|
4985 |      else if (change) |
---|
4986 | Â Â Â Â Â { |
---|
4987 |       if (TEST_OPT_INTSTRATEGY) |
---|
4988 | Â Â Â Â Â Â { |
---|
4989 | Â Â Â Â Â Â Â //pContent(strat->S[i]); |
---|
4990 | Â Â Â Â Â Â Â pCleardenom(strat->S[i]);// also does a pContent |
---|
4991 | Â Â Â Â Â Â } |
---|
4992 | Â Â Â Â Â Â else |
---|
4993 | Â Â Â Â Â Â { |
---|
4994 | Â Â Â Â Â Â Â pNorm(strat->S[i]); |
---|
4995 | Â Â Â Â Â Â } |
---|
4996 | Â Â Â Â Â Â strat->sevS[i]Â =Â pGetShortExpVector(strat->S[i]); |
---|
4997 | Â Â Â Â Â } |
---|
4998 | Â Â Â Â } |
---|
4999 | Â Â Â Â i++; |
---|
5000 | Â Â Â } |
---|
5001 |    if (any_change) reorderS(&suc,strat); |
---|
5002 |    else break; |
---|
5003 | Â Â } |
---|
5004 |   if (toT) |
---|
5005 | Â Â { |
---|
5006 |    for (i=0; i<=strat->sl; i++) |
---|
5007 | Â Â Â { |
---|
5008 |     if ((strat->fromQ==NULL) || (strat->fromQ[i]==0)) |
---|
5009 | Â Â Â Â { |
---|
5010 | Â Â Â Â Â h.p =Â redtailBba(strat->S[i],i-1,strat); |
---|
5011 |      if (TEST_OPT_INTSTRATEGY) |
---|
5012 | Â Â Â Â Â { |
---|
5013 | Â Â Â Â Â Â pCleardenom(h.p);// also does a pContent |
---|
5014 | Â Â Â Â Â } |
---|
5015 | Â Â Â Â } |
---|
5016 | Â Â Â Â else |
---|
5017 | Â Â Â Â { |
---|
5018 | Â Â Â Â Â h.p =Â strat->S[i]; |
---|
5019 | Â Â Â Â } |
---|
5020 | Â Â Â Â strat->initEcart(&h); |
---|
5021 |     if (strat->honey) |
---|
5022 | Â Â Â Â { |
---|
5023 | Â Â Â Â Â strat->ecartS[i]Â =Â h.ecart; |
---|
5024 | Â Â Â Â } |
---|
5025 |     if (strat->sevS[i] == 0) {strat->sevS[i] = pGetShortExpVector(h.p);} |
---|
5026 |     else assume(strat->sevS[i] == pGetShortExpVector(h.p)); |
---|
5027 | Â Â Â Â h.sev =Â strat->sevS[i]; |
---|
5028 | Â Â Â Â /*puts the elements of S also to T*/ |
---|
5029 | Â Â Â Â enterT(h,strat); |
---|
5030 | Â Â Â Â strat->S_2_R[i]Â =Â strat->tl; |
---|
5031 | Â Â Â } |
---|
5032 | Â Â } |
---|
5033 | Â } |
---|
5034 | Â else |
---|
5035 | Â { |
---|
5036 |   while (suc != -1) |
---|
5037 | Â Â { |
---|
5038 | Â Â Â i=suc; |
---|
5039 |    while (i<=strat->sl) |
---|
5040 | Â Â Â { |
---|
5041 | Â Â Â Â change=FALSE; |
---|
5042 |     if (((strat->fromQ==NULL) || (strat->fromQ[i]==0)) && (i>0)) |
---|
5043 | Â Â Â Â { |
---|
5044 | Â Â Â Â Â redSi=pHead((strat->S)[i]); |
---|
5045 | Â Â Â Â Â (strat->S)[i]Â =Â redMora((strat->S)[i],i-1,strat); |
---|
5046 |      if ((strat->S)[i]==NULL) |
---|
5047 | Â Â Â Â Â { |
---|
5048 | Â Â Â Â Â Â deleteInS(i,strat); |
---|
5049 | Â Â Â Â Â Â i--; |
---|
5050 | Â Â Â Â Â } |
---|
5051 |      else if (pCmp((strat->S)[i],redSi)!=0) |
---|
5052 | Â Â Â Â Â { |
---|
5053 | Â Â Â Â Â Â any_change=TRUE; |
---|
5054 | Â Â Â Â Â Â h.p =Â strat->S[i]; |
---|
5055 | Â Â Â Â Â Â strat->initEcart(&h); |
---|
5056 | Â Â Â Â Â Â strat->ecartS[i]Â =Â h.ecart; |
---|
5057 |       if (TEST_OPT_INTSTRATEGY) |
---|
5058 | Â Â Â Â Â Â { |
---|
5059 | Â Â Â Â Â Â Â pCleardenom(strat->S[i]);// also does a pContent |
---|
5060 | Â Â Â Â Â Â } |
---|
5061 | Â Â Â Â Â Â else |
---|
5062 | Â Â Â Â Â Â { |
---|
5063 | Â Â Â Â Â Â Â pNorm(strat->S[i]);Â // == h.p |
---|
5064 | Â Â Â Â Â Â } |
---|
5065 | Â Â Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
5066 | Â Â Â Â Â Â strat->sevS[i]Â =Â h.sev; |
---|
5067 | Â Â Â Â Â } |
---|
5068 | Â Â Â Â Â pDeleteLm(&redSi); |
---|
5069 | Â Â Â Â Â kTest(strat); |
---|
5070 | Â Â Â Â } |
---|
5071 | Â Â Â Â i++; |
---|
5072 | Â Â Â } |
---|
5073 | #ifdef KDEBUG |
---|
5074 | Â Â Â kTest(strat); |
---|
5075 | #endif |
---|
5076 |    if (any_change) reorderS(&suc,strat); |
---|
5077 |    else { suc=-1; break; } |
---|
5078 |    if (h.p!=NULL) |
---|
5079 | Â Â Â { |
---|
5080 |     if (!strat->kHEdgeFound) |
---|
5081 | Â Â Â Â { |
---|
5082 | Â Â Â Â Â /*strat->kHEdgeFound =*/Â HEckeTest(h.p,strat); |
---|
5083 | Â Â Â Â } |
---|
5084 |     if (strat->kHEdgeFound) |
---|
5085 | Â Â Â Â Â newHEdge(strat->S,strat); |
---|
5086 | Â Â Â } |
---|
5087 | Â Â } |
---|
5088 |   for (i=0; i<=strat->sl; i++) |
---|
5089 | Â Â { |
---|
5090 |    if ((strat->fromQ==NULL) || (strat->fromQ[i]==0)) |
---|
5091 | Â Â Â { |
---|
5092 | Â Â Â Â strat->S[i]Â =Â h.p =Â redtail(strat->S[i],strat->sl,strat); |
---|
5093 | Â Â Â Â strat->initEcart(&h); |
---|
5094 | Â Â Â Â strat->ecartS[i]Â =Â h.ecart; |
---|
5095 | Â Â Â Â h.sev =Â pGetShortExpVector(h.p); |
---|
5096 | Â Â Â Â strat->sevS[i]Â =Â h.sev; |
---|
5097 | Â Â Â } |
---|
5098 | Â Â Â else |
---|
5099 | Â Â Â { |
---|
5100 | Â Â Â Â h.p =Â strat->S[i]; |
---|
5101 | Â Â Â Â h.ecart=strat->ecartS[i]; |
---|
5102 | Â Â Â Â h.sev =Â strat->sevS[i]; |
---|
5103 | Â Â Â Â h.length =Â h.pLength =Â pLength(h.p); |
---|
5104 | Â Â Â } |
---|
5105 |    if ((strat->fromQ==NULL) || (strat->fromQ[i]==0)) |
---|
5106 | Â Â Â Â cancelunit1(&h,&suc,strat->sl,strat); |
---|
5107 | Â Â Â h.SetpFDeg(); |
---|
5108 | Â Â Â /*puts the elements of S also to T*/ |
---|
5109 | Â Â Â enterT(h,strat); |
---|
5110 | Â Â Â strat->S_2_R[i]Â =Â strat->tl; |
---|
5111 | Â Â } |
---|
5112 |   if (suc!= -1) updateS(toT,strat); |
---|
5113 | Â } |
---|
5114 | #ifdef KDEBUG |
---|
5115 | Â kTest(strat); |
---|
5116 | #endif |
---|
5117 | } |
---|
5118 | |
---|
5119 | |
---|
5120 | /*2 |
---|
5121 | * -puts p to the standardbasis s at position at |
---|
5122 | * -saves the result in S |
---|
5123 | */ |
---|
5124 | void enterSBba (LObject p,int atS,kStrategy strat, int atR) |
---|
5125 | { |
---|
5126 |  int i; |
---|
5127 | Â strat->news =Â TRUE; |
---|
5128 | Â /*- puts p to the standardbasis s at position at -*/ |
---|
5129 |  if (strat->sl == IDELEMS(strat->Shdl)-1) |
---|
5130 | Â { |
---|
5131 |   strat->sevS = (unsigned long*) omRealloc0Size(strat->sevS, |
---|
5132 |                   IDELEMS(strat->Shdl)*sizeof(unsigned long), |
---|
5133 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (IDELEMS(strat->Shdl)+setmaxTinc) |
---|
5134 |                          *sizeof(unsigned long)); |
---|
5135 | Â Â strat->ecartS =Â (intset)omReallocSize(strat->ecartS, |
---|
5136 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IDELEMS(strat->Shdl)*sizeof(int), |
---|
5137 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (IDELEMS(strat->Shdl)+setmaxTinc) |
---|
5138 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *sizeof(int)); |
---|
5139 | Â Â strat->S_2_R =Â (int*)Â omRealloc0Size(strat->S_2_R, |
---|
5140 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IDELEMS(strat->Shdl)*sizeof(int), |
---|
5141 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (IDELEMS(strat->Shdl)+setmaxTinc) |
---|
5142 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *sizeof(int)); |
---|
5143 |   if (strat->lenS!=NULL) |
---|
5144 | Â Â Â strat->lenS=(int*)omRealloc0Size(strat->lenS, |
---|
5145 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IDELEMS(strat->Shdl)*sizeof(int), |
---|
5146 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (IDELEMS(strat->Shdl)+setmaxTinc) |
---|
5147 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *sizeof(int)); |
---|
5148 |   if (strat->lenSw!=NULL) |
---|
5149 | Â Â Â strat->lenSw=(wlen_type*)omRealloc0Size(strat->lenSw, |
---|
5150 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IDELEMS(strat->Shdl)*sizeof(wlen_type), |
---|
5151 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (IDELEMS(strat->Shdl)+setmaxTinc) |
---|
5152 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *sizeof(wlen_type)); |
---|
5153 |   if (strat->fromQ!=NULL) |
---|
5154 | Â Â { |
---|
5155 | Â Â Â strat->fromQ =Â (intset)omReallocSize(strat->fromQ, |
---|
5156 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IDELEMS(strat->Shdl)*sizeof(int), |
---|
5157 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (IDELEMS(strat->Shdl)+setmaxTinc)*sizeof(int)); |
---|
5158 | Â Â } |
---|
5159 | Â Â pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmaxTinc); |
---|
5160 | Â Â IDELEMS(strat->Shdl)+=setmaxTinc; |
---|
5161 | Â Â strat->Shdl->m=strat->S; |
---|
5162 | Â } |
---|
5163 |  if (atS <= strat->sl) |
---|
5164 | Â { |
---|
5165 | #ifdef ENTER_USE_MEMMOVE |
---|
5166 | // #if 0 |
---|
5167 |   memmove(&(strat->S[atS+1]), &(strat->S[atS]), |
---|
5168 | Â Â Â Â Â Â (strat->sl -Â atS +Â 1)*sizeof(poly)); |
---|
5169 |   memmove(&(strat->ecartS[atS+1]), &(strat->ecartS[atS]), |
---|
5170 | Â Â Â Â Â Â (strat->sl -Â atS +Â 1)*sizeof(int)); |
---|
5171 |   memmove(&(strat->sevS[atS+1]), &(strat->sevS[atS]), |
---|
5172 |       (strat->sl - atS + 1)*sizeof(unsigned long)); |
---|
5173 |   memmove(&(strat->S_2_R[atS+1]), &(strat->S_2_R[atS]), |
---|
5174 | Â Â Â Â Â Â (strat->sl -Â atS +Â 1)*sizeof(int)); |
---|
5175 |   if (strat->lenS!=NULL) |
---|
5176 |   memmove(&(strat->lenS[atS+1]), &(strat->lenS[atS]), |
---|
5177 | Â Â Â Â Â Â (strat->sl -Â atS +Â 1)*sizeof(int)); |
---|
5178 |   if (strat->lenSw!=NULL) |
---|
5179 |   memmove(&(strat->lenSw[atS+1]), &(strat->lenSw[atS]), |
---|
5180 | Â Â Â Â Â Â (strat->sl -Â atS +Â 1)*sizeof(wlen_type)); |
---|
5181 | #else |
---|
5182 |   for (i=strat->sl+1; i>=atS+1; i--) |
---|
5183 | Â Â { |
---|
5184 | Â Â Â strat->S[i]Â =Â strat->S[i-1]; |
---|
5185 | Â Â Â strat->ecartS[i]Â =Â strat->ecartS[i-1]; |
---|
5186 | Â Â Â strat->sevS[i]Â =Â strat->sevS[i-1]; |
---|
5187 | Â Â Â strat->S_2_R[i]Â =Â strat->S_2_R[i-1]; |
---|
5188 | Â Â } |
---|
5189 |   if (strat->lenS!=NULL) |
---|
5190 |   for (i=strat->sl+1; i>=atS+1; i--) |
---|
5191 | Â Â Â strat->lenS[i]Â =Â strat->lenS[i-1]; |
---|
5192 |   if (strat->lenSw!=NULL) |
---|
5193 |   for (i=strat->sl+1; i>=atS+1; i--) |
---|
5194 | Â Â Â strat->lenSw[i]Â =Â strat->lenSw[i-1]; |
---|
5195 | #endif |
---|
5196 | Â } |
---|
5197 |  if (strat->fromQ!=NULL) |
---|
5198 | Â { |
---|
5199 | #ifdef ENTER_USE_MEMMOVE |
---|
5200 |   memmove(&(strat->fromQ[atS+1]), &(strat->fromQ[atS]), |
---|
5201 | Â Â Â Â Â Â Â Â Â (strat->sl -Â atS +Â 1)*sizeof(int)); |
---|
5202 | #else |
---|
5203 |   for (i=strat->sl+1; i>=atS+1; i--) |
---|
5204 | Â Â { |
---|
5205 | Â Â Â strat->fromQ[i]Â =Â strat->fromQ[i-1]; |
---|
5206 | Â Â } |
---|
5207 | #endif |
---|
5208 | Â Â strat->fromQ[atS]=0; |
---|
5209 | Â } |
---|
5210 | |
---|
5211 | Â /*- save result -*/ |
---|
5212 | Â strat->S[atS]Â =Â p.p; |
---|
5213 |  if (strat->honey) strat->ecartS[atS] = p.ecart; |
---|
5214 |  if (p.sev == 0) |
---|
5215 | Â Â p.sev =Â pGetShortExpVector(p.p); |
---|
5216 | Â else |
---|
5217 | Â Â assume(p.sev ==Â pGetShortExpVector(p.p)); |
---|
5218 | Â strat->sevS[atS]Â =Â p.sev; |
---|
5219 | Â strat->ecartS[atS]Â =Â p.ecart; |
---|
5220 | Â strat->S_2_R[atS]Â =Â atR; |
---|
5221 | Â strat->sl++; |
---|
5222 | } |
---|
5223 | |
---|
5224 | /*2 |
---|
5225 | * puts p to the set T at position atT |
---|
5226 | */ |
---|
5227 | void enterT(LObject p, kStrategy strat, int atT) |
---|
5228 | { |
---|
5229 |  int i; |
---|
5230 | |
---|
5231 |  pp_Test(p.p, currRing, p.tailRing); |
---|
5232 | Â assume(strat->tailRing ==Â p.tailRing); |
---|
5233 | Â // redMoraNF complains about this -- but, we don't really |
---|
5234 | Â // neeed this so far |
---|
5235 | Â assume(p.pLength ==Â 0Â ||Â pLength(p.p)Â ==Â p.pLength); |
---|
5236 | Â assume(p.FDeg ==Â p.pFDeg()); |
---|
5237 | Â assume(!p.is_normalized ||Â nIsOne(pGetCoeff(p.p))); |
---|
5238 | |
---|
5239 | #ifdef KDEBUGÂ |
---|
5240 | Â // do not put an LObject twice into T: |
---|
5241 | Â for(i=strat->tl;i>=0;i--) |
---|
5242 | Â { |
---|
5243 |   if (p.p==strat->T[i].p) |
---|
5244 | Â Â { |
---|
5245 | Â Â Â printf("already in T at pos %d of %d, atT=%d\n",i,strat->tl,atT); |
---|
5246 | Â Â Â return; |
---|
5247 | Â Â } |
---|
5248 | Â } |
---|
5249 | #endif |
---|
5250 | Â strat->newt =Â TRUE; |
---|
5251 |  if (atT < 0) |
---|
5252 |   atT = strat->posInT(strat->T, strat->tl, p); |
---|
5253 |  if (strat->tl == strat->tmax-1) |
---|
5254 | Â Â enlargeT(strat->T,strat->R,strat->sevT,strat->tmax,setmaxTinc); |
---|
5255 |  if (atT <= strat->tl) |
---|
5256 | Â { |
---|
5257 | #ifdef ENTER_USE_MEMMOVE |
---|
5258 |   memmove(&(strat->T[atT+1]), &(strat->T[atT]), |
---|
5259 | Â Â Â Â Â Â (strat->tl-atT+1)*sizeof(TObject)); |
---|
5260 |   memmove(&(strat->sevT[atT+1]), &(strat->sevT[atT]), |
---|
5261 |       (strat->tl-atT+1)*sizeof(unsigned long)); |
---|
5262 | #endif |
---|
5263 |   for (i=strat->tl+1; i>=atT+1; i--) |
---|
5264 | Â Â { |
---|
5265 | #ifndef ENTER_USE_MEMMOVE |
---|
5266 | Â Â Â strat->T[i]Â =Â strat->T[i-1]; |
---|
5267 | Â Â Â strat->sevT[i]Â =Â strat->sevT[i-1]; |
---|
5268 | #endif |
---|
5269 | Â Â Â strat->R[strat->T[i].i_r]Â =Â &(strat->T[i]); |
---|
5270 | Â Â } |
---|
5271 | Â } |
---|
5272 | |
---|
5273 |  if (strat->tailBin != NULL && (pNext(p.p) != NULL)) |
---|
5274 | Â { |
---|
5275 | Â Â pNext(p.p)=p_ShallowCopyDelete(pNext(p.p), |
---|
5276 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (strat->tailRing !=Â NULLÂ ? |
---|
5277 |                   strat->tailRing : currRing), |
---|
5278 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â strat->tailBin); |
---|
5279 |   if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p); |
---|
5280 | Â } |
---|
5281 | Â strat->T[atT]Â =Â (TObject)Â p; |
---|
5282 | |
---|
5283 |  if (strat->tailRing != currRing && pNext(p.p) != NULL) |
---|
5284 |   strat->T[atT].max = p_GetMaxExpP(pNext(p.p), strat->tailRing); |
---|
5285 | Â else |
---|
5286 | Â Â strat->T[atT].max =Â NULL; |
---|
5287 | |
---|
5288 | Â strat->tl++; |
---|
5289 | Â strat->R[strat->tl]Â =Â &(strat->T[atT]); |
---|
5290 | Â strat->T[atT].i_r =Â strat->tl; |
---|
5291 | Â assume(p.sev ==Â 0Â ||Â pGetShortExpVector(p.p)Â ==Â p.sev); |
---|
5292 |  strat->sevT[atT] = (p.sev == 0 ? pGetShortExpVector(p.p) : p.sev); |
---|
5293 | Â kTest_T(&(strat->T[atT])); |
---|
5294 | } |
---|
5295 | |
---|
5296 | void initHilbCrit(ideal F, ideal Q, intvec **hilb,kStrategy strat) |
---|
5297 | { |
---|
5298 |  if (strat->homog!=isHomog) |
---|
5299 | Â { |
---|
5300 | Â Â *hilb=NULL; |
---|
5301 | Â } |
---|
5302 | } |
---|
5303 | |
---|
5304 | void initBuchMoraCrit(kStrategy strat) |
---|
5305 | { |
---|
5306 | Â strat->sugarCrit =Â Â Â Â TEST_OPT_SUGARCRIT; |
---|
5307 | Â // obachman: Hmm.. I need BTEST1(2) for notBuckets .. |
---|
5308 | Â //Â strat->Gebauer =Â Â Â Â Â BTEST1(2) || strat->homog || strat->sugarCrit; |
---|
5309 | Â strat->Gebauer =Â Â Â Â Â strat->homog ||Â strat->sugarCrit; |
---|
5310 | Â strat->honey =Â Â Â Â Â Â !strat->homog ||Â strat->sugarCrit ||Â TEST_OPT_WEIGHTM; |
---|
5311 |  if (TEST_OPT_NOT_SUGAR) strat->honey = FALSE; |
---|
5312 | Â strat->pairtest =Â NULL; |
---|
5313 | Â /* alway use tailreduction, except: |
---|
5314 | Â * - in local rings, - in lex order case, -in ring over extensions */ |
---|
5315 | Â strat->noTailReduction =Â !TEST_OPT_REDTAIL; |
---|
5316 | |
---|
5317 | #ifdef HAVE_PLURAL |
---|
5318 | Â // and r is plural_ring |
---|
5319 | Â if(Â rIsPluralRing(currRing)Â ||Â (rIsSCA(currRing)Â &&Â !strat->z2homog)Â ) |
---|
5320 | Â {Â Â //or it has non-quasi-comm type... later |
---|
5321 | Â Â strat->sugarCrit =Â FALSE; |
---|
5322 | Â Â strat->Gebauer =Â FALSE; |
---|
5323 | Â Â strat->honey =Â FALSE; |
---|
5324 | Â } |
---|
5325 | #endif |
---|
5326 | |
---|
5327 | #ifdef HAVE_RINGS |
---|
5328 | Â // Coefficient ring? |
---|
5329 |  if (rField_is_Ring(currRing)) |
---|
5330 | Â { |
---|
5331 | Â Â strat->sugarCrit =Â FALSE; |
---|
5332 | Â Â strat->Gebauer =Â FALSE ; |
---|
5333 | Â Â strat->honey =Â FALSE; |
---|
5334 | Â } |
---|
5335 | #endif |
---|
5336 | Â #ifdef KDEBUG |
---|
5337 |  if (TEST_OPT_DEBUG) |
---|
5338 | Â { |
---|
5339 |   if (strat->homog) PrintS("ideal/module is homogeneous\n"); |
---|
5340 |   else       PrintS("ideal/module is not homogeneous\n"); |
---|
5341 | Â } |
---|
5342 | Â #endif |
---|
5343 | } |
---|
5344 | |
---|
5345 | BOOLEAN kPosInLDependsOnLength(int (*pos_in_l) |
---|
5346 |                 (const LSet set, const int length, |
---|
5347 |                 LObject* L,const kStrategy strat)) |
---|
5348 | { |
---|
5349 |  if (pos_in_l == posInL110 || |
---|
5350 | Â Â Â pos_in_l ==Â posInL10) |
---|
5351 |   return TRUE; |
---|
5352 | |
---|
5353 |  return FALSE; |
---|
5354 | } |
---|
5355 | |
---|
5356 | void initBuchMoraPos (kStrategy strat) |
---|
5357 | { |
---|
5358 |  if (pOrdSgn==1) |
---|
5359 | Â { |
---|
5360 |   if (strat->honey) |
---|
5361 | Â Â { |
---|
5362 | Â Â Â strat->posInL =Â posInL15; |
---|
5363 | Â Â Â // ok -- here is the deal: from my experiments for Singular-2-0 |
---|
5364 | Â Â Â // I conclude that that posInT_EcartpLength is the best of |
---|
5365 | Â Â Â // posInT15, posInT_EcartFDegpLength, posInT_FDegLength, posInT_pLength |
---|
5366 | Â Â Â // see the table at the end of this file |
---|
5367 |    if (K_TEST_OPT_OLDSTD) |
---|
5368 | Â Â Â Â strat->posInT =Â posInT15; |
---|
5369 | Â Â Â else |
---|
5370 | Â Â Â Â strat->posInT =Â posInT_EcartpLength; |
---|
5371 | Â Â } |
---|
5372 |   else if (pLexOrder && !TEST_OPT_INTSTRATEGY) |
---|
5373 | Â Â { |
---|
5374 | Â Â Â strat->posInL =Â posInL11; |
---|
5375 | Â Â Â strat->posInT =Â posInT11; |
---|
5376 | Â Â } |
---|
5377 |   else if (TEST_OPT_INTSTRATEGY) |
---|
5378 | Â Â { |
---|
5379 | Â Â Â strat->posInL =Â posInL11; |
---|
5380 | Â Â Â strat->posInT =Â posInT11; |
---|
5381 | Â Â } |
---|
5382 | Â Â else |
---|
5383 | Â Â { |
---|
5384 | Â Â Â strat->posInL =Â posInL0; |
---|
5385 | Â Â Â strat->posInT =Â posInT0; |
---|
5386 | Â Â } |
---|
5387 | Â Â //if (strat->minim>0) strat->posInL =posInLSpecial; |
---|
5388 |   if (strat->homog) |
---|
5389 | Â Â { |
---|
5390 | Â Â Â Â strat->posInL =Â posInL110; |
---|
5391 | Â Â Â Â strat->posInT =Â posInT110; |
---|
5392 | Â Â } |
---|
5393 | Â } |
---|
5394 | Â else |
---|
5395 | Â { |
---|
5396 |   if (strat->homog) |
---|
5397 | Â Â { |
---|
5398 | Â Â Â strat->posInL =Â posInL11; |
---|
5399 | Â Â Â strat->posInT =Â posInT11; |
---|
5400 | Â Â } |
---|
5401 | Â Â else |
---|
5402 | Â Â { |
---|
5403 |    if ((currRing->order[0]==ringorder_c) |
---|
5404 | Â Â Â ||(currRing->order[0]==ringorder_C)) |
---|
5405 | Â Â Â { |
---|
5406 | Â Â Â Â strat->posInL =Â posInL17_c; |
---|
5407 | Â Â Â Â strat->posInT =Â posInT17_c; |
---|
5408 | Â Â Â } |
---|
5409 | Â Â Â else |
---|
5410 | Â Â Â { |
---|
5411 | Â Â Â Â strat->posInL =Â posInL17; |
---|
5412 | Â Â Â Â strat->posInT =Â posInT17; |
---|
5413 | Â Â Â } |
---|
5414 | Â Â } |
---|
5415 | Â } |
---|
5416 |  if (strat->minim>0) strat->posInL =posInLSpecial; |
---|
5417 | Â // for further tests only |
---|
5418 |  if ((BTEST1(11)) || (BTEST1(12))) |
---|
5419 | Â Â strat->posInL =Â posInL11; |
---|
5420 |  else if ((BTEST1(13)) || (BTEST1(14))) |
---|
5421 | Â Â strat->posInL =Â posInL13; |
---|
5422 |  else if ((BTEST1(15)) || (BTEST1(16))) |
---|
5423 | Â Â strat->posInL =Â posInL15; |
---|
5424 |  else if ((BTEST1(17)) || (BTEST1(18))) |
---|
5425 | Â Â strat->posInL =Â posInL17; |
---|
5426 |  if (BTEST1(11)) |
---|
5427 | Â Â strat->posInT =Â posInT11; |
---|
5428 |  else if (BTEST1(13)) |
---|
5429 | Â Â strat->posInT =Â posInT13; |
---|
5430 |  else if (BTEST1(15)) |
---|
5431 | Â Â strat->posInT =Â posInT15; |
---|
5432 |  else if ((BTEST1(17))) |
---|
5433 | Â Â strat->posInT =Â posInT17; |
---|
5434 |  else if ((BTEST1(19))) |
---|
5435 | Â Â strat->posInT =Â posInT19; |
---|
5436 |  else if (BTEST1(12) || BTEST1(14) || BTEST1(16) || BTEST1(18)) |
---|
5437 | Â Â strat->posInT =Â posInT1; |
---|
5438 | #ifdef HAVE_RINGS |
---|
5439 |  if (rField_is_Ring(currRing)) |
---|
5440 | Â { |
---|
5441 | Â Â strat->posInL =Â posInL11; |
---|
5442 | Â Â strat->posInT =Â posInT11; |
---|
5443 | Â } |
---|
5444 | #endif |
---|
5445 | Â strat->posInLDependsOnLength =Â kPosInLDependsOnLength(strat->posInL); |
---|
5446 | } |
---|
5447 | |
---|
5448 | void initBuchMora (ideal F,ideal Q,kStrategy strat) |
---|
5449 | { |
---|
5450 | Â strat->interpt =Â BTEST1(OPT_INTERRUPT); |
---|
5451 | Â strat->kHEdge=NULL; |
---|
5452 |  if (pOrdSgn==1) strat->kHEdgeFound=FALSE; |
---|
5453 | Â /*- creating temp data structures------------------- -*/ |
---|
5454 | Â strat->cp =Â 0; |
---|
5455 | Â strat->c3 =Â 0; |
---|
5456 | Â strat->tail =Â pInit(); |
---|
5457 | Â /*- set s -*/ |
---|
5458 | Â strat->sl =Â -1; |
---|
5459 | Â /*- set L -*/ |
---|
5460 | Â strat->Lmax =Â setmaxL; |
---|
5461 | Â strat->Ll =Â -1; |
---|
5462 | Â strat->L =Â initL(); |
---|
5463 | Â /*- set B -*/ |
---|
5464 | Â strat->Bmax =Â setmaxL; |
---|
5465 | Â strat->Bl =Â -1; |
---|
5466 | Â strat->B =Â initL(); |
---|
5467 | Â /*- set T -*/ |
---|
5468 | Â strat->tl =Â -1; |
---|
5469 | Â strat->tmax =Â setmaxT; |
---|
5470 | Â strat->T =Â initT(); |
---|
5471 | Â strat->R =Â initR(); |
---|
5472 | Â strat->sevT =Â initsevT(); |
---|
5473 | Â /*- init local data struct.---------------------------------------- -*/ |
---|
5474 | Â strat->P.ecart=0; |
---|
5475 | Â strat->P.length=0; |
---|
5476 |  if (pOrdSgn==-1) |
---|
5477 | Â { |
---|
5478 |   if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak); |
---|
5479 |   if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak); |
---|
5480 | Â } |
---|
5481 | Â if(TEST_OPT_SB_1) |
---|
5482 | Â { |
---|
5483 |   int i; |
---|
5484 | Â Â ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank); |
---|
5485 |   for (i=strat->newIdeal;i<IDELEMS(F);i++) |
---|
5486 | Â Â { |
---|
5487 | Â Â Â P->m[i-strat->newIdeal]Â =Â F->m[i]; |
---|
5488 | Â Â Â F->m[i]Â =Â NULL; |
---|
5489 | Â Â } |
---|
5490 | Â Â initSSpecial(F,Q,P,strat); |
---|
5491 |   for (i=strat->newIdeal;i<IDELEMS(F);i++) |
---|
5492 | Â Â { |
---|
5493 | Â Â Â F->m[i]Â =Â P->m[i-strat->newIdeal]; |
---|
5494 | Â Â Â P->m[i-strat->newIdeal]Â =Â NULL; |
---|
5495 | Â Â } |
---|
5496 | Â Â idDelete(&P); |
---|
5497 | Â } |
---|
5498 | Â else |
---|
5499 | Â { |
---|
5500 |   /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */ |
---|
5501 | Â Â // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */ |
---|
5502 | Â } |
---|
5503 | Â strat->kIdeal =Â NULL; |
---|
5504 | Â strat->fromT =Â FALSE; |
---|
5505 | Â strat->noTailReduction =Â !TEST_OPT_REDTAIL; |
---|
5506 |  if (!TEST_OPT_SB_1) |
---|
5507 | Â { |
---|
5508 | Â Â updateS(TRUE,strat); |
---|
5509 | Â } |
---|
5510 |  if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
5511 | Â strat->fromQ=NULL; |
---|
5512 | } |
---|
5513 | |
---|
5514 | void exitBuchMora (kStrategy strat) |
---|
5515 | { |
---|
5516 | Â /*- release temp data -*/ |
---|
5517 | Â cleanT(strat); |
---|
5518 | Â omFreeSize(strat->T,(strat->tmax)*sizeof(TObject)); |
---|
5519 | Â omFreeSize(strat->R,(strat->tmax)*sizeof(TObject*)); |
---|
5520 |  omFreeSize(strat->sevT, (strat->tmax)*sizeof(unsigned long)); |
---|
5521 | Â omFreeSize(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
5522 | Â omFreeSize(strat->sevS,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
5523 | Â omFreeSize(strat->S_2_R,IDELEMS(strat->Shdl)*sizeof(int)); |
---|
5524 | Â /*- set L: should be empty -*/ |
---|
5525 | Â omFreeSize(strat->L,(strat->Lmax)*sizeof(LObject)); |
---|
5526 | Â /*- set B: should be empty -*/ |
---|
5527 | Â omFreeSize(strat->B,(strat->Bmax)*sizeof(LObject)); |
---|
5528 | Â pDeleteLm(&strat->tail); |
---|
5529 | Â strat->syzComp=0; |
---|
5530 |  if (strat->kIdeal!=NULL) |
---|
5531 | Â { |
---|
5532 |   omFreeBin(strat->kIdeal, sleftv_bin); |
---|
5533 | Â Â strat->kIdeal=NULL; |
---|
5534 | Â } |
---|
5535 | } |
---|
5536 | |
---|
5537 | /*2 |
---|
5538 | * in the case of a standardbase of a module over a qring: |
---|
5539 | * replace polynomials in i by ak vectors, |
---|
5540 | * (the polynomial * unit vectors gen(1)..gen(ak) |
---|
5541 | * in every case (also for ideals:) |
---|
5542 | * deletes divisible vectors/polynomials |
---|
5543 | */ |
---|
5544 | void updateResult(ideal r,ideal Q, kStrategy strat) |
---|
5545 | { |
---|
5546 |  int l; |
---|
5547 |  if (strat->ak>0) |
---|
5548 | Â { |
---|
5549 |   for (l=IDELEMS(r)-1;l>=0;l--) |
---|
5550 | Â Â { |
---|
5551 |    if ((r->m[l]!=NULL) && (pGetComp(r->m[l])==0)) |
---|
5552 | Â Â Â { |
---|
5553 | Â Â Â Â pDelete(&r->m[l]);Â // and set it to NULL |
---|
5554 | Â Â Â } |
---|
5555 | Â Â } |
---|
5556 |   int q; |
---|
5557 | Â Â poly p; |
---|
5558 |   for (l=IDELEMS(r)-1;l>=0;l--) |
---|
5559 | Â Â { |
---|
5560 |    if ((r->m[l]!=NULL) |
---|
5561 | Â Â Â &&Â (strat->syzComp>0) |
---|
5562 | Â Â Â &&Â (pGetComp(r->m[l])<=strat->syzComp)) |
---|
5563 | Â Â Â { |
---|
5564 | Â Â Â Â for(q=IDELEMS(Q)-1;Â q>=0;q--) |
---|
5565 | Â Â Â Â { |
---|
5566 |      if ((Q->m[q]!=NULL) |
---|
5567 | Â Â Â Â Â &&(pLmDivisibleBy(Q->m[q],r->m[l]))) |
---|
5568 | Â Â Â Â Â { |
---|
5569 |       if (TEST_OPT_REDSB) |
---|
5570 | Â Â Â Â Â Â { |
---|
5571 | Â Â Â Â Â Â Â p=r->m[l]; |
---|
5572 | Â Â Â Â Â Â Â r->m[l]=kNF(Q,NULL,p); |
---|
5573 | Â Â Â Â Â Â Â pDelete(&p); |
---|
5574 | Â Â Â Â Â Â } |
---|
5575 | Â Â Â Â Â Â else |
---|
5576 | Â Â Â Â Â Â { |
---|
5577 | Â Â Â Â Â Â Â pDelete(&r->m[l]);Â // and set it to NULL |
---|
5578 | Â Â Â Â Â Â } |
---|
5579 | Â Â Â Â Â Â break; |
---|
5580 | Â Â Â Â Â } |
---|
5581 | Â Â Â Â } |
---|
5582 | Â Â Â } |
---|
5583 | Â Â } |
---|
5584 | Â } |
---|
5585 | Â else |
---|
5586 | Â { |
---|
5587 |   int q; |
---|
5588 | Â Â poly p; |
---|
5589 |   for (l=IDELEMS(r)-1;l>=0;l--) |
---|
5590 | Â Â { |
---|
5591 |    if (r->m[l]!=NULL) |
---|
5592 | Â Â Â { |
---|
5593 | Â Â Â Â for(q=IDELEMS(Q)-1;Â q>=0;q--) |
---|
5594 | Â Â Â Â { |
---|
5595 |      if ((Q->m[q]!=NULL) |
---|
5596 | Â Â Â Â Â &&(pLmEqual(r->m[l],Q->m[q]))) |
---|
5597 | Â Â Â Â Â { |
---|
5598 |       if (TEST_OPT_REDSB) |
---|
5599 | Â Â Â Â Â Â { |
---|
5600 | Â Â Â Â Â Â Â p=r->m[l]; |
---|
5601 | Â Â Â Â Â Â Â r->m[l]=kNF(Q,NULL,p); |
---|
5602 | Â Â Â Â Â Â Â pDelete(&p); |
---|
5603 | Â Â Â Â Â Â } |
---|
5604 | Â Â Â Â Â Â else |
---|
5605 | Â Â Â Â Â Â { |
---|
5606 | Â Â Â Â Â Â Â pDelete(&r->m[l]);Â // and set it to NULL |
---|
5607 | Â Â Â Â Â Â } |
---|
5608 | Â Â Â Â Â Â break; |
---|
5609 | Â Â Â Â Â } |
---|
5610 | Â Â Â Â } |
---|
5611 | Â Â Â } |
---|
5612 | Â Â } |
---|
5613 | Â } |
---|
5614 | Â idSkipZeroes(r); |
---|
5615 | } |
---|
5616 | |
---|
5617 | void completeReduce (kStrategy strat, BOOLEAN withT) |
---|
5618 | { |
---|
5619 |  int i; |
---|
5620 |  int low = (pOrdSgn == 1 ? 1 : 0); |
---|
5621 | Â LObject L; |
---|
5622 | |
---|
5623 | #ifdef KDEBUG |
---|
5624 | Â // need to set this: during tailreductions of T[i], T[i].max is out of |
---|
5625 | Â // sync |
---|
5626 | Â sloppy_max =Â TRUE; |
---|
5627 | #endif |
---|
5628 | |
---|
5629 | Â strat->noTailReduction =Â FALSE; |
---|
5630 |  if (TEST_OPT_PROT) |
---|
5631 | Â { |
---|
5632 | Â Â PrintLn(); |
---|
5633 |   if (timerv) writeTime("standard base computed:"); |
---|
5634 | Â } |
---|
5635 |  if (TEST_OPT_PROT) |
---|
5636 | Â { |
---|
5637 | Â Â Print("(S:%d)",strat->sl);mflush(); |
---|
5638 | Â } |
---|
5639 |  for (i=strat->sl; i>=low; i--) |
---|
5640 | Â { |
---|
5641 | Â Â TObject*Â T_j =Â strat->s_2_t(i); |
---|
5642 |   if (T_j != NULL) |
---|
5643 | Â Â { |
---|
5644 | Â Â Â L =Â *T_j; |
---|
5645 | Â Â Â poly p; |
---|
5646 |    if (pOrdSgn == 1) |
---|
5647 |     strat->S[i] = redtailBba(&L, i-1, strat, withT); |
---|
5648 | Â Â Â else |
---|
5649 |     strat->S[i] = redtail(&L, strat->sl, strat); |
---|
5650 | |
---|
5651 |    if (strat->redTailChange && strat->tailRing != currRing) |
---|
5652 | Â Â Â { |
---|
5653 |     if (T_j->max != NULL) p_LmFree(T_j->max, strat->tailRing); |
---|
5654 |     if (pNext(T_j->p) != NULL) |
---|
5655 |      T_j->max = p_GetMaxExpP(pNext(T_j->p), strat->tailRing); |
---|
5656 | Â Â Â Â else |
---|
5657 | Â Â Â Â Â T_j->max =Â NULL; |
---|
5658 | Â Â Â } |
---|
5659 |    if (TEST_OPT_INTSTRATEGY) |
---|
5660 | Â Â Â Â T_j->pCleardenom(); |
---|
5661 | Â Â } |
---|
5662 | Â Â else |
---|
5663 | Â Â { |
---|
5664 | Â Â Â assume(currRing ==Â strat->tailRing); |
---|
5665 |    if (pOrdSgn == 1) |
---|
5666 |     strat->S[i] = redtailBba(strat->S[i], i-1, strat, withT); |
---|
5667 | Â Â Â else |
---|
5668 |     strat->S[i] = redtail(strat->S[i], strat->sl, strat); |
---|
5669 |    if (TEST_OPT_INTSTRATEGY) |
---|
5670 | Â Â Â Â pCleardenom(strat->S[i]); |
---|
5671 | Â Â } |
---|
5672 |   if (TEST_OPT_PROT) |
---|
5673 | Â Â Â PrintS("-"); |
---|
5674 | Â } |
---|
5675 |  if (TEST_OPT_PROT) PrintLn(); |
---|
5676 | #ifdef KDEBUG |
---|
5677 | Â sloppy_max =Â FALSE; |
---|
5678 | #endif |
---|
5679 | } |
---|
5680 | |
---|
5681 | |
---|
5682 | /*2 |
---|
5683 | * computes the new strat->kHEdge and the new pNoether, |
---|
5684 | * returns TRUE, if pNoether has changed |
---|
5685 | */ |
---|
5686 | BOOLEAN newHEdge(polyset S, kStrategy strat) |
---|
5687 | { |
---|
5688 |  int i,j; |
---|
5689 | Â poly newNoether; |
---|
5690 | |
---|
5691 | #if 0 |
---|
5692 | Â if (currRing->weight_all_1) |
---|
5693 | Â Â scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing); |
---|
5694 | Â else |
---|
5695 | Â Â scComputeHCw(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing); |
---|
5696 | #else  |
---|
5697 |  scComputeHC(strat->Shdl,NULL,strat->ak,strat->kHEdge, strat->tailRing); |
---|
5698 | #endif |
---|
5699 |  if (strat->t_kHEdge != NULL) p_LmFree(strat->t_kHEdge, strat->tailRing); |
---|
5700 |  if (strat->tailRing != currRing) |
---|
5701 |   strat->t_kHEdge = k_LmInit_currRing_2_tailRing(strat->kHEdge, strat->tailRing); |
---|
5702 | Â /* compare old and new noether*/ |
---|
5703 | Â newNoether =Â pLmInit(strat->kHEdge); |
---|
5704 | Â j =Â pFDeg(newNoether,currRing); |
---|
5705 |  for (i=1; i<=pVariables; i++) |
---|
5706 | Â { |
---|
5707 |   if (pGetExp(newNoether, i) > 0) pDecrExp(newNoether,i); |
---|
5708 | Â } |
---|
5709 | Â pSetm(newNoether); |
---|
5710 |  if (j < strat->HCord) /*- statistics -*/ |
---|
5711 | Â { |
---|
5712 |   if (TEST_OPT_PROT) |
---|
5713 | Â Â { |
---|
5714 | Â Â Â Print("H(%d)",j); |
---|
5715 | Â Â Â mflush(); |
---|
5716 | Â Â } |
---|
5717 | Â Â strat->HCord=j; |
---|
5718 | Â Â #ifdef KDEBUG |
---|
5719 |   if (TEST_OPT_DEBUG) |
---|
5720 | Â Â { |
---|
5721 | Â Â Â Print("H(%d):",j); |
---|
5722 | Â Â Â wrp(strat->kHEdge); |
---|
5723 | Â Â Â PrintLn(); |
---|
5724 | Â Â } |
---|
5725 | Â Â #endif |
---|
5726 | Â } |
---|
5727 |  if (pCmp(strat->kNoether,newNoether)!=1) |
---|
5728 | Â { |
---|
5729 | Â Â pDelete(&strat->kNoether); |
---|
5730 | Â Â strat->kNoether=newNoether; |
---|
5731 |   if (strat->t_kNoether != NULL) p_LmFree(strat->t_kNoether, strat->tailRing); |
---|
5732 |   if (strat->tailRing != currRing) |
---|
5733 |    strat->t_kNoether = k_LmInit_currRing_2_tailRing(strat->kNoether, strat->tailRing); |
---|
5734 | |
---|
5735 |   return TRUE; |
---|
5736 | Â } |
---|
5737 | Â pLmFree(newNoether); |
---|
5738 |  return FALSE; |
---|
5739 | } |
---|
5740 | |
---|
5741 | /*************************************************************** |
---|
5742 | Â * |
---|
5743 | Â * Routines related for ring changes during std computations |
---|
5744 | Â * |
---|
5745 | Â ***************************************************************/ |
---|
5746 | BOOLEAN kCheckSpolyCreation(LObject *L, kStrategy strat, poly &m1, poly &m2) |
---|
5747 | { |
---|
5748 | Â assume(L->p1 !=Â NULLÂ &&Â L->p2 !=Â NULL); |
---|
5749 | Â // shift changes: from 0 to -1 |
---|
5750 | Â assume(L->i_r1 >=Â -1Â &&Â L->i_r1 <=Â strat->tl); |
---|
5751 | Â assume(L->i_r2 >=Â -1Â &&Â L->i_r2 <=Â strat->tl); |
---|
5752 | Â assume(strat->tailRing !=Â currRing); |
---|
5753 | |
---|
5754 |  if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing)) |
---|
5755 |   return FALSE; |
---|
5756 | Â // shift changes: extra case inserted |
---|
5757 |  if ((L->i_r1 == -1) || (L->i_r2 == -1) ) |
---|
5758 | Â { |
---|
5759 |   return TRUE; |
---|
5760 | Â } |
---|
5761 | Â poly p1_max =Â (strat->R[L->i_r1])->max; |
---|
5762 | Â poly p2_max =Â (strat->R[L->i_r2])->max; |
---|
5763 | |
---|
5764 |  if ((p1_max != NULL && !p_LmExpVectorAddIsOk(m1, p1_max, strat->tailRing)) || |
---|
5765 |    (p2_max != NULL && !p_LmExpVectorAddIsOk(m2, p2_max, strat->tailRing))) |
---|
5766 | Â { |
---|
5767 |   p_LmFree(m1, strat->tailRing); |
---|
5768 |   p_LmFree(m2, strat->tailRing); |
---|
5769 | Â Â m1 =Â NULL; |
---|
5770 | Â Â m2 =Â NULL; |
---|
5771 |   return FALSE; |
---|
5772 | Â } |
---|
5773 |  return TRUE; |
---|
5774 | } |
---|
5775 | |
---|
5776 | BOOLEAN kStratChangeTailRing(kStrategy strat, LObject *L, TObject* T, unsigned long expbound) |
---|
5777 | { |
---|
5778 |  if (expbound == 0) expbound = strat->tailRing->bitmask << 1; |
---|
5779 |  if (expbound >= currRing->bitmask) return FALSE; |
---|
5780 | Â ring new_tailRing =Â rModifyRing(currRing, |
---|
5781 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // Hmmm .. the condition pFDeg == pDeg |
---|
5782 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â // might be too strong |
---|
5783 | #ifdef HAVE_RINGS |
---|
5784 |                  (strat->homog && pFDeg == pDeg && !(rField_is_Ring(currRing))), // TODO Oliver |
---|
5785 | #else |
---|
5786 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (strat->homog &&Â pFDeg ==Â pDeg), |
---|
5787 | #endif |
---|
5788 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â !strat->ak, |
---|
5789 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â expbound); |
---|
5790 |  if (new_tailRing == currRing) return TRUE; |
---|
5791 | |
---|
5792 | Â strat->pOrigFDeg_TailRing =Â new_tailRing->pFDeg; |
---|
5793 | Â strat->pOrigLDeg_TailRing =Â new_tailRing->pLDeg; |
---|
5794 | |
---|
5795 |  if (currRing->pFDeg != currRing->pFDegOrig) |
---|
5796 | Â { |
---|
5797 | Â Â new_tailRing->pFDeg =Â currRing->pFDeg; |
---|
5798 | Â Â new_tailRing->pLDeg =Â currRing->pLDeg; |
---|
5799 | Â } |
---|
5800 | |
---|
5801 |  if (TEST_OPT_PROT) |
---|
5802 |   Print("[%lu:%d", (unsigned long) new_tailRing->bitmask, new_tailRing->ExpL_Size); |
---|
5803 | Â kTest_TS(strat); |
---|
5804 | Â assume(new_tailRing !=Â strat->tailRing); |
---|
5805 | Â pShallowCopyDeleteProc p_shallow_copy_delete |
---|
5806 |   = pGetShallowCopyDeleteProc(strat->tailRing, new_tailRing); |
---|
5807 | |
---|
5808 | Â omBin new_tailBin =Â omGetStickyBinOfBin(new_tailRing->PolyBin); |
---|
5809 | |
---|
5810 |  int i; |
---|
5811 |  for (i=0; i<=strat->tl; i++) |
---|
5812 | Â { |
---|
5813 |   strat->T[i].ShallowCopyDelete(new_tailRing, new_tailBin, |
---|
5814 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â p_shallow_copy_delete); |
---|
5815 | Â } |
---|
5816 |  for (i=0; i<=strat->Ll; i++) |
---|
5817 | Â { |
---|
5818 | Â Â assume(strat->L[i].p !=Â NULL); |
---|
5819 |   if (pNext(strat->L[i].p) != strat->tail) |
---|
5820 |    strat->L[i].ShallowCopyDelete(new_tailRing, p_shallow_copy_delete); |
---|
5821 | Â } |
---|
5822 |  if (strat->P.t_p != NULL || |
---|
5823 | Â Â Â (strat->P.p !=Â NULLÂ &&Â pNext(strat->P.p)Â !=Â strat->tail)) |
---|
5824 |   strat->P.ShallowCopyDelete(new_tailRing, p_shallow_copy_delete); |
---|
5825 | |
---|
5826 |  if (L != NULL && L->tailRing != new_tailRing) |
---|
5827 | Â { |
---|
5828 |   if (L->i_r < 0) |
---|
5829 |    L->ShallowCopyDelete(new_tailRing, p_shallow_copy_delete); |
---|
5830 | Â Â else |
---|
5831 | Â Â { |
---|
5832 | Â Â Â assume(L->i_r <=Â strat->tl); |
---|
5833 | Â Â Â TObject*Â t_l =Â strat->R[L->i_r]; |
---|
5834 | Â Â Â assume(t_l !=Â NULL); |
---|
5835 | Â Â Â L->tailRing =Â new_tailRing; |
---|
5836 | Â Â Â L->p =Â t_l->p; |
---|
5837 | Â Â Â L->t_p =Â t_l->t_p; |
---|
5838 | Â Â Â L->max =Â t_l->max; |
---|
5839 | Â Â } |
---|
5840 | Â } |
---|
5841 | |
---|
5842 |  if (T != NULL && T->tailRing != new_tailRing && T->i_r < 0) |
---|
5843 |   T->ShallowCopyDelete(new_tailRing, new_tailBin, p_shallow_copy_delete); |
---|
5844 | |
---|
5845 |  omMergeStickyBinIntoBin(strat->tailBin, strat->tailRing->PolyBin); |
---|
5846 |  if (strat->tailRing != currRing) |
---|
5847 | Â Â rKillModifiedRing(strat->tailRing); |
---|
5848 | |
---|
5849 | Â strat->tailRing =Â new_tailRing; |
---|
5850 | Â strat->tailBin =Â new_tailBin; |
---|
5851 | Â strat->p_shallow_copy_delete |
---|
5852 |   = pGetShallowCopyDeleteProc(currRing, new_tailRing); |
---|
5853 | |
---|
5854 |  if (strat->kHEdge != NULL) |
---|
5855 | Â { |
---|
5856 |   if (strat->t_kHEdge != NULL) |
---|
5857 |    p_LmFree(strat->t_kHEdge, strat->tailRing); |
---|
5858 |   strat->t_kHEdge=k_LmInit_currRing_2_tailRing(strat->kHEdge, new_tailRing); |
---|
5859 | Â } |
---|
5860 | |
---|
5861 |  if (strat->kNoether != NULL) |
---|
5862 | Â { |
---|
5863 |   if (strat->t_kNoether != NULL) |
---|
5864 |    p_LmFree(strat->t_kNoether, strat->tailRing); |
---|
5865 | Â Â strat->t_kNoether=k_LmInit_currRing_2_tailRing(strat->kNoether, |
---|
5866 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â new_tailRing); |
---|
5867 | Â } |
---|
5868 | Â kTest_TS(strat); |
---|
5869 |  if (TEST_OPT_PROT) |
---|
5870 | Â Â PrintS("]"); |
---|
5871 |  return TRUE; |
---|
5872 | } |
---|
5873 | |
---|
5874 | void kStratInitChangeTailRing(kStrategy strat) |
---|
5875 | { |
---|
5876 |  unsigned long l = 0; |
---|
5877 |  int i; |
---|
5878 | Â Exponent_t e; |
---|
5879 | Â ring new_tailRing; |
---|
5880 | |
---|
5881 | Â assume(strat->tailRing ==Â currRing); |
---|
5882 | |
---|
5883 |  for (i=0; i<= strat->Ll; i++) |
---|
5884 | Â { |
---|
5885 |   l = p_GetMaxExpL(strat->L[i].p, currRing, l); |
---|
5886 | Â } |
---|
5887 |  for (i=0; i<=strat->tl; i++) |
---|
5888 | Â { |
---|
5889 | Â Â // Hmm ... this we could do in one Step |
---|
5890 |   l = p_GetMaxExpL(strat->T[i].p, currRing, l); |
---|
5891 | Â } |
---|
5892 |  if (rField_is_Ring(currRing)) |
---|
5893 | Â { |
---|
5894 | Â Â l +=Â 20;Â // TEMP, TODO OLI |
---|
5895 | Â Â l *=Â 2; |
---|
5896 | Â } |
---|
5897 |  e = p_GetMaxExp(l, currRing); |
---|
5898 |  if (e <= 1) e = 2; |
---|
5899 | |
---|
5900 |  kStratChangeTailRing(strat, NULL, NULL, e); |
---|
5901 | } |
---|
5902 | |
---|
5903 | skStrategy::skStrategy() |
---|
5904 | { |
---|
5905 |  memset(this, 0, sizeof(skStrategy)); |
---|
5906 | #ifndef NDEBUG |
---|
5907 | Â strat_nr++; |
---|
5908 | Â nr=strat_nr; |
---|
5909 |  if (strat_fac_debug) Print("s(%d) created\n",nr); |
---|
5910 | #endif |
---|
5911 | Â tailRing =Â currRing; |
---|
5912 | Â P.tailRing =Â currRing; |
---|
5913 | Â tl =Â -1; |
---|
5914 | Â sl =Â -1; |
---|
5915 | #ifdef HAVE_LM_BIN |
---|
5916 | Â lmBin =Â omGetStickyBinOfBin(currRing->PolyBin); |
---|
5917 | #endif |
---|
5918 | #ifdef HAVE_TAIL_BIN |
---|
5919 | Â tailBin =Â omGetStickyBinOfBin(currRing->PolyBin); |
---|
5920 | #endif |
---|
5921 | Â pOrigFDeg =Â pFDeg; |
---|
5922 | Â pOrigLDeg =Â pLDeg; |
---|
5923 | } |
---|
5924 | |
---|
5925 | |
---|
5926 | skStrategy::~skStrategy() |
---|
5927 | { |
---|
5928 |  if (lmBin != NULL) |
---|
5929 |   omMergeStickyBinIntoBin(lmBin, currRing->PolyBin); |
---|
5930 |  if (tailBin != NULL) |
---|
5931 | Â Â omMergeStickyBinIntoBin(tailBin, |
---|
5932 |               (tailRing != NULL ? tailRing->PolyBin: |
---|
5933 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â currRing->PolyBin)); |
---|
5934 |  if (t_kHEdge != NULL) |
---|
5935 |   p_LmFree(t_kHEdge, tailRing); |
---|
5936 |  if (t_kNoether != NULL) |
---|
5937 |   p_LmFree(t_kNoether, tailRing); |
---|
5938 | |
---|
5939 |  if (currRing != tailRing) |
---|
5940 | Â Â rKillModifiedRing(tailRing); |
---|
5941 |  pRestoreDegProcs(pOrigFDeg, pOrigLDeg); |
---|
5942 | } |
---|
5943 | |
---|
5944 | #if 0 |
---|
5945 | Timings for the different possibilities of posInT: |
---|
5946 | Â Â Â Â Â Â T15Â Â Â Â Â Â EDLÂ Â Â Â Â DLÂ Â Â Â Â ELÂ Â Â Â Â Â LÂ Â Â Â Â 1-2-3 |
---|
5947 | Gonnet   43.26    42.30    38.34    41.98    38.40   100.04 |
---|
5948 | Hairer_2_1Â Â 1.11Â Â Â Â 1.15Â Â Â Â 1.04Â Â Â Â 1.22Â Â Â Â 1.08Â Â Â Â 4.7 |
---|
5949 | Twomat3Â Â Â 1.62Â Â Â Â 1.69Â Â Â Â 1.70Â Â Â Â 1.65Â Â Â Â 1.54Â Â Â Â 11.32 |
---|
5950 | ahml     4.48    4.03    4.03    4.38    4.96    26.50 |
---|
5951 | c7Â Â Â Â Â 15.02Â Â Â Â 13.98Â Â Â Â 15.16Â Â Â Â 13.24Â Â Â Â 17.31Â Â Â Â 47.89 |
---|
5952 | c8Â Â Â Â Â 505.09Â Â Â 407.46Â Â Â 852.76Â Â Â 413.21Â Â Â 499.19Â Â Â Â n/a |
---|
5953 | f855Â Â Â Â 12.65Â Â Â Â 9.27Â Â Â Â 14.97Â Â Â Â 8.78Â Â Â Â 14.23Â Â Â Â 33.12 |
---|
5954 | gametwo6Â Â 11.47Â Â Â Â 11.35Â Â Â Â 14.57Â Â Â Â 11.20Â Â Â Â 12.02Â Â Â Â 35.07 |
---|
5955 | gerhard_3Â Â 2.73Â Â Â Â 2.83Â Â Â Â 2.93Â Â Â Â 2.64Â Â Â Â 3.12Â Â Â Â 6.24 |
---|
5956 | ilias13Â Â Â 22.89Â Â Â Â 22.46Â Â Â Â 24.62Â Â Â Â 20.60Â Â Â Â 23.34Â Â Â Â 53.86 |
---|
5957 | noon8Â Â Â Â 40.68Â Â Â Â 37.02Â Â Â Â 37.99Â Â Â Â 36.82Â Â Â Â 35.59Â Â Â 877.16 |
---|
5958 | rcyclic_19Â 48.22Â Â Â Â 42.29Â Â Â Â 43.99Â Â Â Â 45.35Â Â Â Â 51.51Â Â Â 204.29 |
---|
5959 | rkat9Â Â Â Â 82.37Â Â Â Â 79.46Â Â Â Â 77.20Â Â Â Â 77.63Â Â Â Â 82.54Â Â Â 267.92 |
---|
5960 | schwarz_11Â 16.46Â Â Â Â 16.81Â Â Â Â 16.76Â Â Â Â 16.81Â Â Â Â 16.72Â Â Â Â 35.56 |
---|
5961 | test016Â Â Â 16.39Â Â Â Â 14.17Â Â Â Â 14.40Â Â Â Â 13.50Â Â Â Â 14.26Â Â Â Â 34.07 |
---|
5962 | test017Â Â Â 34.70Â Â Â Â 36.01Â Â Â Â 33.16Â Â Â Â 35.48Â Â Â Â 32.75Â Â Â Â 71.45 |
---|
5963 | test042Â Â Â 10.76Â Â Â Â 10.99Â Â Â Â 10.27Â Â Â Â 11.57Â Â Â Â 10.45Â Â Â Â 23.04 |
---|
5964 | test058Â Â Â 6.78Â Â Â Â 6.75Â Â Â Â 6.51Â Â Â Â 6.95Â Â Â Â 6.22Â Â Â Â 9.47 |
---|
5965 | test066Â Â Â 10.71Â Â Â Â 10.94Â Â Â Â 10.76Â Â Â Â 10.61Â Â Â Â 10.56Â Â Â Â 19.06 |
---|
5966 | test073Â Â Â 10.75Â Â Â Â 11.11Â Â Â Â 10.17Â Â Â Â 10.79Â Â Â Â 8.63Â Â Â Â 58.10 |
---|
5967 | test086Â Â Â 12.23Â Â Â Â 11.81Â Â Â Â 12.88Â Â Â Â 12.24Â Â Â Â 13.37Â Â Â Â 66.68 |
---|
5968 | test103Â Â Â 5.05Â Â Â Â 4.80Â Â Â Â 5.47Â Â Â Â 4.64Â Â Â Â 4.89Â Â Â Â 11.90 |
---|
5969 | test154Â Â Â 12.96Â Â Â Â 11.64Â Â Â Â 13.51Â Â Â Â 12.46Â Â Â Â 14.61Â Â Â Â 36.35 |
---|
5970 | test162Â Â Â 65.27Â Â Â Â 64.01Â Â Â Â 67.35Â Â Â Â 59.79Â Â Â Â 67.54Â Â Â 196.46 |
---|
5971 | test164Â Â Â 7.50Â Â Â Â 6.50Â Â Â Â 7.68Â Â Â Â 6.70Â Â Â Â 7.96Â Â Â Â 17.13 |
---|
5972 | virasoro   3.39    3.50    3.35    3.47    3.70    7.66 |
---|
5973 | #endif |
---|
5974 | |
---|
5975 | |
---|
5976 | #ifdef HAVE_MORE_POS_IN_T |
---|
5977 | // determines the position based on: 1.) Ecart 2.) FDeg 3.) pLength |
---|
5978 | int posInT_EcartFDegpLength(const TSet set,const int length,LObject &p) |
---|
5979 | { |
---|
5980 | |
---|
5981 |  if (length==-1) return 0; |
---|
5982 | |
---|
5983 |  int o = p.ecart; |
---|
5984 |  int op=p.GetpFDeg(); |
---|
5985 |  int ol = p.GetpLength(); |
---|
5986 | |
---|
5987 |  if (set[length].ecart < o) |
---|
5988 |   return length+1; |
---|
5989 |  if (set[length].ecart == o) |
---|
5990 | Â { |
---|
5991 |    int oo=set[length].GetpFDeg(); |
---|
5992 |    if ((oo < op) || ((oo==op) && (set[length].length < ol))) |
---|
5993 |     return length+1; |
---|
5994 | Â } |
---|
5995 | |
---|
5996 |  int i; |
---|
5997 |  int an = 0; |
---|
5998 |  int en= length; |
---|
5999 | Â loop |
---|
6000 | Â { |
---|
6001 |   if (an >= en-1) |
---|
6002 | Â Â { |
---|
6003 |    if (set[an].ecart > o) |
---|
6004 |     return an; |
---|
6005 |    if (set[an].ecart == o) |
---|
6006 | Â Â Â { |
---|
6007 |      int oo=set[an].GetpFDeg(); |
---|
6008 | Â Â Â Â Â if((oo >Â op) |
---|
6009 | Â Â Â Â Â ||Â ((oo==op)Â &&Â (set[an].pLength >Â ol))) |
---|
6010 |       return an; |
---|
6011 | Â Â Â } |
---|
6012 |    return en; |
---|
6013 | Â Â } |
---|
6014 | Â Â i=(an+en)Â /Â 2; |
---|
6015 |   if (set[i].ecart > o) |
---|
6016 | Â Â Â en=i; |
---|
6017 |   else if (set[i].ecart == o) |
---|
6018 | Â Â { |
---|
6019 |     int oo=set[i].GetpFDeg(); |
---|
6020 |     if ((oo > op) |
---|
6021 | Â Â Â Â ||Â ((oo ==Â op)Â &&Â (set[i].pLength >Â ol))) |
---|
6022 | Â Â Â Â Â en=i; |
---|
6023 | Â Â Â Â else |
---|
6024 | Â Â Â Â an=i; |
---|
6025 | Â Â } |
---|
6026 | Â Â else |
---|
6027 | Â Â Â an=i; |
---|
6028 | Â } |
---|
6029 | } |
---|
6030 | |
---|
6031 | // determines the position based on: 1.) FDeg 2.) pLength |
---|
6032 | int posInT_FDegpLength(const TSet set,const int length,LObject &p) |
---|
6033 | { |
---|
6034 | |
---|
6035 |  if (length==-1) return 0; |
---|
6036 | |
---|
6037 |  int op=p.GetpFDeg(); |
---|
6038 |  int ol = p.GetpLength(); |
---|
6039 | |
---|
6040 |  int oo=set[length].GetpFDeg(); |
---|
6041 |  if ((oo < op) || ((oo==op) && (set[length].length < ol))) |
---|
6042 |   return length+1; |
---|
6043 | |
---|
6044 |  int i; |
---|
6045 |  int an = 0; |
---|
6046 |  int en= length; |
---|
6047 | Â loop |
---|
6048 | Â Â { |
---|
6049 |    if (an >= en-1) |
---|
6050 | Â Â Â { |
---|
6051 |     int oo=set[an].GetpFDeg(); |
---|
6052 | Â Â Â Â if((oo >Â op) |
---|
6053 | Â Â Â Â Â Â ||Â ((oo==op)Â &&Â (set[an].pLength >Â ol))) |
---|
6054 |      return an; |
---|
6055 | Â |
---|