1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /* |
---|
5 | * ABSTRACT - Kernel: noncomm. alg. of Buchberger |
---|
6 | */ |
---|
7 | #define PLURAL_INTERNAL_DECLARATIONS |
---|
8 | |
---|
9 | #include "config.h" |
---|
10 | #include "mod2.h" |
---|
11 | |
---|
12 | #ifdef HAVE_PLURAL |
---|
13 | |
---|
14 | |
---|
15 | #include <omalloc/omalloc.h> |
---|
16 | #include <misc/options.h> |
---|
17 | #include <misc/intvec.h> |
---|
18 | |
---|
19 | #include <polys/weight.h> |
---|
20 | #include <kernel/polys.h> |
---|
21 | #include <polys/monomials/ring.h> |
---|
22 | |
---|
23 | #include <polys/nc/gb_hack.h> |
---|
24 | #include <polys/nc/nc.h> |
---|
25 | #include <polys/nc/sca.h> |
---|
26 | |
---|
27 | |
---|
28 | #include <kernel/febase.h> |
---|
29 | #include <kernel/ideals.h> |
---|
30 | #include <kernel/kstd1.h> |
---|
31 | #include <kernel/khstd.h> |
---|
32 | //#include "spolys.h" |
---|
33 | //#include "cntrlc.h" |
---|
34 | #include <kernel/ratgring.h> |
---|
35 | #include <kernel/kutil.h> |
---|
36 | |
---|
37 | #include <kernel/nc.h> |
---|
38 | |
---|
39 | #if 0 |
---|
40 | /*3 |
---|
41 | * reduction of p2 with p1 |
---|
42 | * do not destroy p1 and p2 |
---|
43 | * p1 divides p2 -> for use in NF algorithm |
---|
44 | */ |
---|
45 | poly gnc_ReduceSpolyNew(const poly p1, poly p2/*,poly spNoether*/, const ring r) |
---|
46 | { |
---|
47 | return(nc_ReduceSPoly(p1,p_Copy(p2,r)/*,spNoether*/,r)); |
---|
48 | } |
---|
49 | #endif |
---|
50 | |
---|
51 | /*2 |
---|
52 | *reduces h with elements from T choosing the first possible |
---|
53 | * element in t with respect to the given pDivisibleBy |
---|
54 | */ |
---|
55 | int redGrFirst (LObject* h,kStrategy strat) |
---|
56 | { |
---|
57 | int at,reddeg,d,i; |
---|
58 | int pass = 0; |
---|
59 | int j = 0; |
---|
60 | |
---|
61 | d = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
62 | reddeg = strat->LazyDegree+d; |
---|
63 | loop |
---|
64 | { |
---|
65 | if (j > strat->sl) |
---|
66 | { |
---|
67 | #ifdef KDEBUG |
---|
68 | if (TEST_OPT_DEBUG) PrintLn(); |
---|
69 | #endif |
---|
70 | return 0; |
---|
71 | } |
---|
72 | #ifdef KDEBUG |
---|
73 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
74 | #endif |
---|
75 | if (pDivisibleBy(strat->S[j],(*h).p)) |
---|
76 | { |
---|
77 | #ifdef KDEBUG |
---|
78 | if (TEST_OPT_DEBUG) PrintS("+\n"); |
---|
79 | #endif |
---|
80 | /* |
---|
81 | * the polynomial to reduce with is; |
---|
82 | * T[j].p |
---|
83 | */ |
---|
84 | if (!TEST_OPT_INTSTRATEGY) |
---|
85 | pNorm(strat->S[j]); |
---|
86 | #ifdef KDEBUG |
---|
87 | if (TEST_OPT_DEBUG) |
---|
88 | { |
---|
89 | wrp(h->p); |
---|
90 | PrintS(" with "); |
---|
91 | wrp(strat->S[j]); |
---|
92 | } |
---|
93 | #endif |
---|
94 | (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p, currRing); |
---|
95 | //spSpolyRed(strat->T[j].p,(*h).p,strat->kNoether); |
---|
96 | |
---|
97 | #ifdef KDEBUG |
---|
98 | if (TEST_OPT_DEBUG) |
---|
99 | { |
---|
100 | PrintS(" to "); |
---|
101 | wrp(h->p); |
---|
102 | } |
---|
103 | #endif |
---|
104 | if ((*h).p == NULL) |
---|
105 | { |
---|
106 | if (h->lcm!=NULL) p_LmFree((*h).lcm, currRing); |
---|
107 | return 0; |
---|
108 | } |
---|
109 | if (TEST_OPT_INTSTRATEGY) |
---|
110 | { |
---|
111 | if (rField_is_Zp_a(currRing)) p_Content(h->p,currRing); |
---|
112 | else h->pCleardenom();// also does a p_Content |
---|
113 | } |
---|
114 | /*computes the ecart*/ |
---|
115 | d = currRing->pLDeg((*h).p,&((*h).length),currRing); |
---|
116 | (*h).FDeg=currRing->pFDeg((*h).p,currRing); |
---|
117 | (*h).ecart = d-(*h).FDeg; /*pFDeg((*h).p);*/ |
---|
118 | if ((strat->syzComp!=0) && !strat->honey) |
---|
119 | { |
---|
120 | if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
121 | { |
---|
122 | #ifdef KDEBUG |
---|
123 | if (TEST_OPT_DEBUG) PrintS(" > sysComp\n"); |
---|
124 | #endif |
---|
125 | return 0; |
---|
126 | } |
---|
127 | } |
---|
128 | /*- try to reduce the s-polynomial -*/ |
---|
129 | pass++; |
---|
130 | /* |
---|
131 | *test whether the polynomial should go to the lazyset L |
---|
132 | *-if the degree jumps |
---|
133 | *-if the number of pre-defined reductions jumps |
---|
134 | */ |
---|
135 | if ((strat->Ll >= 0) |
---|
136 | && ((d >= reddeg) || (pass > strat->LazyPass)) |
---|
137 | && !strat->homog) |
---|
138 | { |
---|
139 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
140 | if (at <= strat->Ll) |
---|
141 | { |
---|
142 | i=strat->sl+1; |
---|
143 | do |
---|
144 | { |
---|
145 | i--; |
---|
146 | if (i<0) return 0; |
---|
147 | } while (!pDivisibleBy(strat->S[i],(*h).p)); |
---|
148 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
149 | #ifdef KDEBUG |
---|
150 | if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at); |
---|
151 | #endif |
---|
152 | (*h).p = NULL; |
---|
153 | return 0; |
---|
154 | } |
---|
155 | } |
---|
156 | if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg)) |
---|
157 | { |
---|
158 | reddeg = d+1; |
---|
159 | Print(".%d",d);mflush(); |
---|
160 | } |
---|
161 | j = 0; |
---|
162 | #ifdef KDEBUG |
---|
163 | if TEST_OPT_DEBUG PrintLn(); |
---|
164 | #endif |
---|
165 | } |
---|
166 | else |
---|
167 | { |
---|
168 | #ifdef KDEBUG |
---|
169 | if (TEST_OPT_DEBUG) PrintS("-"); |
---|
170 | #endif |
---|
171 | j++; |
---|
172 | } |
---|
173 | } |
---|
174 | } |
---|
175 | void ratGB_divide_out(poly p) |
---|
176 | { |
---|
177 | /* extracts monomial content from localized expression */ |
---|
178 | /* searches for an m (monomial in var 1.. real_var_start-1) |
---|
179 | * such that m divides p and divides p by this m if it exist*/ |
---|
180 | if (p==NULL) return; |
---|
181 | poly root=p; |
---|
182 | assume(rIsRatGRing(currRing)); |
---|
183 | poly f=pHead(p); |
---|
184 | int i; |
---|
185 | for (i=currRing->real_var_start;i<=currRing->real_var_end;i++) |
---|
186 | { |
---|
187 | pSetExp(f,i,0); |
---|
188 | } |
---|
189 | loop |
---|
190 | { |
---|
191 | pIter(p); |
---|
192 | if (p==NULL) { pSetm(f); break;} |
---|
193 | for (i=1;i<=rVar(currRing);i++) |
---|
194 | { |
---|
195 | pSetExp(f,i,si_min(pGetExp(f,i),pGetExp(p,i))); |
---|
196 | } |
---|
197 | } |
---|
198 | if (!pIsConstant(f)) |
---|
199 | { |
---|
200 | #ifdef KDEBUG |
---|
201 | if (TEST_OPT_DEBUG) |
---|
202 | { |
---|
203 | PrintS("divide out:");p_wrp(f,currRing); |
---|
204 | PrintS(" from ");pWrite(root); |
---|
205 | } |
---|
206 | #endif |
---|
207 | p=root; |
---|
208 | loop |
---|
209 | { |
---|
210 | if (p==NULL) break; |
---|
211 | for (i=1;i<=rVar(currRing);i++) |
---|
212 | { |
---|
213 | pSetExp(p,i,pGetExp(p,i)-pGetExp(f,i)); |
---|
214 | } |
---|
215 | pSetm(p); |
---|
216 | pIter(p); |
---|
217 | } |
---|
218 | } |
---|
219 | pDelete(&f); |
---|
220 | } |
---|
221 | |
---|
222 | #ifdef HAVE_RATGRING |
---|
223 | /*2 |
---|
224 | *reduces h with elements from T choosing the first possible |
---|
225 | * element in t with respect to the given pDivisibleBy |
---|
226 | * for use in ratGB |
---|
227 | */ |
---|
228 | int redGrRatGB (LObject* h,kStrategy strat) |
---|
229 | { |
---|
230 | int at,reddeg,d,i; |
---|
231 | int pass = 0; |
---|
232 | int j = 0; |
---|
233 | int c_j=-1, c_e=-2; |
---|
234 | poly c_p=NULL; |
---|
235 | assume(strat->tailRing==currRing); |
---|
236 | |
---|
237 | ratGB_divide_out((*h).p); |
---|
238 | d = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
239 | reddeg = strat->LazyDegree+d; |
---|
240 | if (!TEST_OPT_INTSTRATEGY) |
---|
241 | { |
---|
242 | if (rField_is_Zp_a(currRing)) p_Content(h->p,currRing); |
---|
243 | else h->pCleardenom();// also does a pContentRat |
---|
244 | } |
---|
245 | loop |
---|
246 | { |
---|
247 | if (j > strat->sl) |
---|
248 | { |
---|
249 | if (c_j>=0) |
---|
250 | { |
---|
251 | /* |
---|
252 | * the polynomial to reduce with is; |
---|
253 | * S[c_j] |
---|
254 | */ |
---|
255 | if (!TEST_OPT_INTSTRATEGY) |
---|
256 | pNorm(strat->S[c_j]); |
---|
257 | #ifdef KDEBUG |
---|
258 | if (TEST_OPT_DEBUG) |
---|
259 | if (TEST_OPT_DEBUG) |
---|
260 | { |
---|
261 | wrp(h->p); |
---|
262 | Print(" with S[%d]= ",c_j); |
---|
263 | wrp(strat->S[c_j]); |
---|
264 | } |
---|
265 | #endif |
---|
266 | //poly hh = nc_CreateSpoly(strat->S[c_j],(*h).p, currRing); |
---|
267 | // Print("vor nc_rat_ReduceSpolyNew (ce:%d) ",c_e);wrp(h->p);PrintLn(); |
---|
268 | //if(c_e==-1) |
---|
269 | // c_p = nc_CreateSpoly(pCopy(strat->S[c_j]),pCopy((*h).p), currRing); |
---|
270 | //else |
---|
271 | // c_p=nc_rat_ReduceSpolyNew(strat->S[c_j],pCopy((*h).p), currRing->real_var_start-1,currRing); |
---|
272 | // Print("nach nc_rat_ReduceSpolyNew ");wrp(c_p);PrintLn(); |
---|
273 | // pDelete(&((*h).p)); |
---|
274 | |
---|
275 | c_p=nc_rat_ReduceSpolyNew(strat->S[c_j],(*h).p, currRing->real_var_start-1,currRing); |
---|
276 | (*h).p=c_p; |
---|
277 | if (!TEST_OPT_INTSTRATEGY) |
---|
278 | { |
---|
279 | if (rField_is_Zp_a(currRing)) p_Content(h->p,currRing); |
---|
280 | else h->pCleardenom();// also does a p_Content |
---|
281 | } |
---|
282 | |
---|
283 | #ifdef KDEBUG |
---|
284 | if (TEST_OPT_DEBUG) |
---|
285 | { |
---|
286 | PrintS(" to "); |
---|
287 | wrp(h->p); |
---|
288 | PrintLn(); |
---|
289 | } |
---|
290 | #endif |
---|
291 | if ((*h).p == NULL) |
---|
292 | { |
---|
293 | if (h->lcm!=NULL) p_LmFree((*h).lcm, currRing); |
---|
294 | return 0; |
---|
295 | } |
---|
296 | ratGB_divide_out((*h).p); |
---|
297 | d = currRing->pLDeg((*h).p,&((*h).length),currRing); |
---|
298 | (*h).FDeg=currRing->pFDeg((*h).p,currRing); |
---|
299 | (*h).ecart = d-(*h).FDeg; /*pFDeg((*h).p);*/ |
---|
300 | /*- try to reduce the s-polynomial again -*/ |
---|
301 | pass++; |
---|
302 | j=0; |
---|
303 | c_j=-1; c_e=-2; c_p=NULL; |
---|
304 | } |
---|
305 | else |
---|
306 | { // nothing found |
---|
307 | return 0; |
---|
308 | } |
---|
309 | } |
---|
310 | // first try usal division |
---|
311 | if (p_LmDivisibleBy(strat->S[j],(*h).p,currRing)) |
---|
312 | { |
---|
313 | #ifdef KDEBUG |
---|
314 | if(TEST_OPT_DEBUG) |
---|
315 | { |
---|
316 | p_wrp(h->p,currRing); Print(" divisible by S[%d]=",j); |
---|
317 | p_wrp(strat->S[j],currRing); PrintS(" e=-1\n"); |
---|
318 | } |
---|
319 | #endif |
---|
320 | if ((c_j<0)||(c_e>=0)) |
---|
321 | { |
---|
322 | c_e=-1; c_j=j; |
---|
323 | } |
---|
324 | } |
---|
325 | else |
---|
326 | if (p_LmDivisibleByPart(strat->S[j],(*h).p,currRing, |
---|
327 | currRing->real_var_start,currRing->real_var_end)) |
---|
328 | { |
---|
329 | int a_e=(p_Totaldegree(strat->S[j],currRing)-currRing->pFDeg(strat->S[j],currRing)); |
---|
330 | #ifdef KDEBUG |
---|
331 | if(TEST_OPT_DEBUG) |
---|
332 | { |
---|
333 | p_wrp(h->p,currRing); Print(" divisibly by S[%d]=",j); |
---|
334 | p_wrp(strat->S[j],currRing); Print(" e=%d\n",a_e); |
---|
335 | } |
---|
336 | #endif |
---|
337 | if ((c_j<0)||(c_e>a_e)) |
---|
338 | { |
---|
339 | c_e=a_e; c_j=j; |
---|
340 | //c_p = nc_CreateSpoly(pCopy(strat->S[c_j]),pCopy((*h).p), currRing); |
---|
341 | } |
---|
342 | /*computes the ecart*/ |
---|
343 | if ((strat->syzComp!=0) && !strat->honey) |
---|
344 | { |
---|
345 | if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
346 | { |
---|
347 | #ifdef KDEBUG |
---|
348 | if (TEST_OPT_DEBUG) PrintS(" > sysComp\n"); |
---|
349 | #endif |
---|
350 | return 0; |
---|
351 | } |
---|
352 | } |
---|
353 | } |
---|
354 | else |
---|
355 | { |
---|
356 | #ifdef KDEBUG |
---|
357 | if(TEST_OPT_DEBUG) |
---|
358 | { |
---|
359 | p_wrp(h->p,currRing); Print(" not divisibly by S[%d]=",j); |
---|
360 | p_wrp(strat->S[j],currRing); PrintLn(); |
---|
361 | } |
---|
362 | #endif |
---|
363 | } |
---|
364 | j++; |
---|
365 | } |
---|
366 | } |
---|
367 | #endif |
---|
368 | |
---|
369 | /*2 |
---|
370 | * reduction procedure for the homogeneous case |
---|
371 | * and the case of a degree-ordering |
---|
372 | */ |
---|
373 | static int nc_redHomog (LObject* h,kStrategy strat) |
---|
374 | { |
---|
375 | if (strat->tl<0) |
---|
376 | { |
---|
377 | enterT((*h),strat); |
---|
378 | return 1; |
---|
379 | } |
---|
380 | |
---|
381 | int j = 0; |
---|
382 | |
---|
383 | if (TEST_OPT_DEBUG) |
---|
384 | { |
---|
385 | PrintS("red:"); |
---|
386 | wrp(h->p); |
---|
387 | PrintS(" "); |
---|
388 | } |
---|
389 | loop |
---|
390 | { |
---|
391 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
392 | if (pDivisibleBy(strat->S[j],(*h).p)) |
---|
393 | { |
---|
394 | if (TEST_OPT_DEBUG) |
---|
395 | { |
---|
396 | PrintS("+\nwith "); |
---|
397 | wrp(strat->S[j]); |
---|
398 | } |
---|
399 | /*- compute the s-polynomial -*/ |
---|
400 | (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p,currRing); |
---|
401 | if ((*h).p == NULL) |
---|
402 | { |
---|
403 | if (TEST_OPT_DEBUG) PrintS(" to 0\n"); |
---|
404 | if (h->lcm!=NULL) pLmFree((*h).lcm); |
---|
405 | (*h).lcm=NULL; |
---|
406 | return 0; |
---|
407 | } |
---|
408 | /* |
---|
409 | * else if (strat->syzComp) |
---|
410 | * { |
---|
411 | * if (pMinComp((*h).p) > strat->syzComp) |
---|
412 | * { |
---|
413 | * enterT((*h),strat); |
---|
414 | * return; |
---|
415 | * } |
---|
416 | * } |
---|
417 | */ |
---|
418 | /*- try to reduce the s-polynomial -*/ |
---|
419 | j = 0; |
---|
420 | } |
---|
421 | else |
---|
422 | { |
---|
423 | if (j >= strat->sl) |
---|
424 | { |
---|
425 | enterT((*h),strat); |
---|
426 | return 1; |
---|
427 | } |
---|
428 | j++; |
---|
429 | } |
---|
430 | } |
---|
431 | } |
---|
432 | |
---|
433 | #if 0 |
---|
434 | /*2 |
---|
435 | * reduction procedure for the homogeneous case |
---|
436 | * and the case of a degree-ordering |
---|
437 | */ |
---|
438 | static int nc_redHomog0 (LObject* h,kStrategy strat) |
---|
439 | { |
---|
440 | if (strat->tl<0) |
---|
441 | { |
---|
442 | enterT((*h),strat); |
---|
443 | return 0; |
---|
444 | } |
---|
445 | |
---|
446 | int j = 0; |
---|
447 | int k = 0; |
---|
448 | |
---|
449 | if (TEST_OPT_DEBUG) |
---|
450 | { |
---|
451 | PrintS("red:"); |
---|
452 | wrp(h->p); |
---|
453 | PrintS(" "); |
---|
454 | } |
---|
455 | loop |
---|
456 | { |
---|
457 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
458 | if (pDivisibleBy(strat->T[j].p,(*h).p)) |
---|
459 | { |
---|
460 | if (TEST_OPT_DEBUG) |
---|
461 | { |
---|
462 | PrintS("+\nwith "); |
---|
463 | wrp(strat->S[j]); |
---|
464 | } |
---|
465 | /*- compute the s-polynomial -*/ |
---|
466 | (*h).p = nc_ReduceSpoly(strat->T[j].p,(*h).p,strat->kNoether,currRing); |
---|
467 | if ((*h).p == NULL) |
---|
468 | { |
---|
469 | if (TEST_OPT_DEBUG) PrintS(" to 0\n"); |
---|
470 | if (h->lcm!=NULL) pLmFree((*h).lcm); |
---|
471 | (*h).lcm=NULL; |
---|
472 | return 0; |
---|
473 | } |
---|
474 | else |
---|
475 | { |
---|
476 | if (TEST_OPT_INTSTRATEGY) |
---|
477 | { |
---|
478 | if (rField_is_Zp_a(currRing)) p_Content(h->p,currRing); |
---|
479 | else h->pCleardenom();// also does a pContent |
---|
480 | } |
---|
481 | if (strat->syzComp!=0) |
---|
482 | { |
---|
483 | if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
484 | { |
---|
485 | /* |
---|
486 | * (*h).length=pLength0((*h).p); |
---|
487 | */ |
---|
488 | enterT((*h),strat); |
---|
489 | return 0; |
---|
490 | } |
---|
491 | } |
---|
492 | } |
---|
493 | /*- try to reduce the s-polynomial -*/ |
---|
494 | j = 0; |
---|
495 | } |
---|
496 | else |
---|
497 | { |
---|
498 | if (j >= strat->tl) |
---|
499 | { |
---|
500 | if (TEST_OPT_INTSTRATEGY) |
---|
501 | { |
---|
502 | if (rField_is_Zp_a(currRing)) p_Content(h->p,currRing); |
---|
503 | else h->pCleardenom();// also does a p_Content |
---|
504 | } |
---|
505 | /* |
---|
506 | * (*h).length=pLength0((*h).p); |
---|
507 | */ |
---|
508 | enterT((*h),strat); |
---|
509 | return 0; |
---|
510 | } |
---|
511 | j++; |
---|
512 | } |
---|
513 | } |
---|
514 | } |
---|
515 | |
---|
516 | /*2 |
---|
517 | * reduction procedure for the inhomogeneous case |
---|
518 | * and not a degree-ordering |
---|
519 | */ |
---|
520 | static int nc_redLazy (LObject* h,kStrategy strat) |
---|
521 | { |
---|
522 | if (strat->tl<0) |
---|
523 | { |
---|
524 | enterT((*h),strat); |
---|
525 | return 0; |
---|
526 | } |
---|
527 | |
---|
528 | int at,d,i; |
---|
529 | int j = 0; |
---|
530 | int pass = 0; |
---|
531 | int reddeg = currRing->pFDeg((*h).p,currRing); |
---|
532 | |
---|
533 | if (TEST_OPT_DEBUG) |
---|
534 | { |
---|
535 | PrintS("red:"); |
---|
536 | wrp(h->p); |
---|
537 | PrintS(" "); |
---|
538 | } |
---|
539 | loop |
---|
540 | { |
---|
541 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
542 | if (pDivisibleBy(strat->S[j],(*h).p)) |
---|
543 | { |
---|
544 | if (TEST_OPT_DEBUG) |
---|
545 | { |
---|
546 | PrintS("+\nwith "); |
---|
547 | wrp(strat->S[j]); |
---|
548 | } |
---|
549 | /*- compute the s-polynomial -*/ |
---|
550 | (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p,strat->kNoether,currRing); |
---|
551 | if ((*h).p == NULL) |
---|
552 | { |
---|
553 | if (TEST_OPT_DEBUG) PrintS(" to 0\n"); |
---|
554 | if (h->lcm!=NULL) pLmFree((*h).lcm); |
---|
555 | (*h).lcm=NULL; |
---|
556 | return 0; |
---|
557 | } |
---|
558 | // else if (strat->syzComp) |
---|
559 | // { |
---|
560 | // if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
561 | // { |
---|
562 | // if (TEST_OPT_DEBUG) PrintS(" > syzComp\n"); |
---|
563 | // if (TEST_OPT_INTSTRATEGY) p_Content(h->p,currRing); |
---|
564 | // enterTBba((*h),strat->tl+1,strat); |
---|
565 | // return; |
---|
566 | // } |
---|
567 | // } |
---|
568 | else |
---|
569 | { |
---|
570 | if (TEST_OPT_DEBUG) |
---|
571 | { |
---|
572 | PrintS("to:"); |
---|
573 | wrp((*h).p); |
---|
574 | PrintLn(); |
---|
575 | } |
---|
576 | if (TEST_OPT_INTSTRATEGY) |
---|
577 | { |
---|
578 | p_Content(h->p,currRing); |
---|
579 | //pCleardenom(h->p);// also does a p_Content |
---|
580 | } |
---|
581 | } |
---|
582 | /*- try to reduce the s-polynomial -*/ |
---|
583 | pass++; |
---|
584 | d = currRing->pFDeg((*h).p,currRing); |
---|
585 | if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) |
---|
586 | { |
---|
587 | at = posInL11(strat->L,strat->Ll,h,strat); |
---|
588 | if (at <= strat->Ll) |
---|
589 | { |
---|
590 | i=strat->sl+1; |
---|
591 | do |
---|
592 | { |
---|
593 | i--; |
---|
594 | if (i<0) |
---|
595 | { |
---|
596 | enterT((*h),strat); |
---|
597 | return 0; |
---|
598 | } |
---|
599 | } |
---|
600 | while (!pDivisibleBy(strat->S[i],(*h).p)); |
---|
601 | if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at); |
---|
602 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
603 | (*h).p = NULL; |
---|
604 | return 0; |
---|
605 | } |
---|
606 | } |
---|
607 | else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d != reddeg)) |
---|
608 | { |
---|
609 | Print(".%d",d);mflush(); |
---|
610 | reddeg = d; |
---|
611 | } |
---|
612 | j = 0; |
---|
613 | } |
---|
614 | else |
---|
615 | { |
---|
616 | if (TEST_OPT_DEBUG) PrintS("-"); |
---|
617 | if (j >= strat->sl) |
---|
618 | { |
---|
619 | if (TEST_OPT_DEBUG) PrintLn(); |
---|
620 | if (TEST_OPT_INTSTRATEGY) |
---|
621 | { |
---|
622 | if (rField_is_Zp_a(currRing)) p_Content(h->p,currRing); |
---|
623 | else h->pCleardenom();// also does a p_Content |
---|
624 | } |
---|
625 | enterT((*h),strat); |
---|
626 | return 0; |
---|
627 | } |
---|
628 | j++; |
---|
629 | } |
---|
630 | } |
---|
631 | } |
---|
632 | |
---|
633 | /*2 |
---|
634 | * reduction procedure for the sugar-strategy (honey) |
---|
635 | * reduces h with elements from T choosing first possible |
---|
636 | * element in T with respect to the given ecart |
---|
637 | */ |
---|
638 | static int nc_redHoney (LObject* h,kStrategy strat) |
---|
639 | { |
---|
640 | if (strat->tl<0) |
---|
641 | { |
---|
642 | enterT((*h),strat); |
---|
643 | return 0; |
---|
644 | } |
---|
645 | |
---|
646 | poly pi; |
---|
647 | int i,j,at,reddeg,d,pass,ei; |
---|
648 | |
---|
649 | pass = j = 0; |
---|
650 | d = reddeg = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
651 | if (TEST_OPT_DEBUG) |
---|
652 | { |
---|
653 | PrintS("red:"); |
---|
654 | wrp((*h).p); |
---|
655 | } |
---|
656 | loop |
---|
657 | { |
---|
658 | if (TEST_OPT_DEBUG) Print("%d",j); |
---|
659 | if (pDivisibleBy(strat->T[j].p,(*h).p)) |
---|
660 | { |
---|
661 | if (TEST_OPT_DEBUG) PrintS("+"); |
---|
662 | pi = strat->T[j].p; |
---|
663 | ei = strat->T[j].ecart; |
---|
664 | /* |
---|
665 | * the polynomial to reduce with (up to the moment) is; |
---|
666 | * pi with ecart ei |
---|
667 | */ |
---|
668 | i = j; |
---|
669 | loop |
---|
670 | { |
---|
671 | /*- takes the first possible with respect to ecart -*/ |
---|
672 | i++; |
---|
673 | if (i > strat->tl) |
---|
674 | break; |
---|
675 | if ((!BTEST1(20)) && (ei <= (*h).ecart)) |
---|
676 | break; |
---|
677 | if (TEST_OPT_DEBUG) Print("%d",i); |
---|
678 | if ((strat->T[i].ecart < ei) && pDivisibleBy(strat->T[i].p,(*h).p)) |
---|
679 | { |
---|
680 | if (TEST_OPT_DEBUG) PrintS("+"); |
---|
681 | /* |
---|
682 | * the polynomial to reduce with is now; |
---|
683 | */ |
---|
684 | pi = strat->T[i].p; |
---|
685 | ei = strat->T[i].ecart; |
---|
686 | } |
---|
687 | else if (TEST_OPT_DEBUG) PrintS("-"); |
---|
688 | } |
---|
689 | |
---|
690 | /* |
---|
691 | * end of search: have to reduce with pi |
---|
692 | */ |
---|
693 | if (ei > (*h).ecart) |
---|
694 | { |
---|
695 | /* |
---|
696 | * It is not possible to reduce h with smaller ecart; |
---|
697 | * if possible h goes to the lazy-set L,i.e |
---|
698 | * if its position in L would be not the last one |
---|
699 | */ |
---|
700 | if (strat->Ll >= 0) /* L is not empty */ |
---|
701 | { |
---|
702 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
703 | if(at <= strat->Ll) |
---|
704 | /*- h will not become the next element to reduce -*/ |
---|
705 | { |
---|
706 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
707 | if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at); |
---|
708 | (*h).p = NULL; |
---|
709 | return 0; |
---|
710 | } |
---|
711 | } |
---|
712 | } |
---|
713 | if (TEST_OPT_DEBUG) |
---|
714 | { |
---|
715 | PrintS("\nwith "); |
---|
716 | wrp(pi); |
---|
717 | } |
---|
718 | if (strat->fromT) |
---|
719 | { |
---|
720 | strat->fromT=FALSE; |
---|
721 | (*h).p = nc_ReduceSpoly(pi,(*h).p,strat->kNoether,currRing); |
---|
722 | } |
---|
723 | else |
---|
724 | (*h).p = nc_ReduceSpoly(pi,(*h).p,strat->kNoether,currRing); |
---|
725 | if (TEST_OPT_DEBUG) |
---|
726 | { |
---|
727 | PrintS(" to "); |
---|
728 | wrp((*h).p); |
---|
729 | PrintLn(); |
---|
730 | } |
---|
731 | if ((*h).p == NULL) |
---|
732 | { |
---|
733 | if (h->lcm!=NULL) pLmFree((*h).lcm); |
---|
734 | (*h).lcm=NULL; |
---|
735 | return 0; |
---|
736 | } |
---|
737 | if (TEST_OPT_INTSTRATEGY) |
---|
738 | { |
---|
739 | h->pCleardenom();// also does a p_Content |
---|
740 | } |
---|
741 | /* compute the ecart */ |
---|
742 | if (ei <= (*h).ecart) |
---|
743 | (*h).ecart = d-currRing->pFDeg((*h).p,currRing); |
---|
744 | else |
---|
745 | (*h).ecart = d-currRing->pFDeg((*h).p,currRing)+ei-(*h).ecart; |
---|
746 | // if (strat->syzComp) |
---|
747 | // { |
---|
748 | // if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
749 | // { |
---|
750 | // if (TEST_OPT_DEBUG) |
---|
751 | // PrintS(" >syzComp\n"); |
---|
752 | // if (TEST_OPT_INTSTRATEGY) p_Content(h->p,currRing); |
---|
753 | // at=strat->posInT(strat->T,strat->tl,(*h)); |
---|
754 | // enterTBba((*h),at,strat); |
---|
755 | // return; |
---|
756 | // } |
---|
757 | // } |
---|
758 | /* |
---|
759 | * try to reduce the s-polynomial h |
---|
760 | *test first whether h should go to the lazyset L |
---|
761 | *-if the degree jumps |
---|
762 | *-if the number of pre-defined reductions jumps |
---|
763 | */ |
---|
764 | pass++; |
---|
765 | d = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
766 | if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass))) |
---|
767 | { |
---|
768 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
769 | if (at <= strat->Ll) |
---|
770 | { |
---|
771 | /*test if h is already standardbasis element*/ |
---|
772 | i=strat->sl+1; |
---|
773 | do |
---|
774 | { |
---|
775 | i--; |
---|
776 | if (i<0) |
---|
777 | { |
---|
778 | enterT((*h),strat); |
---|
779 | return 0; |
---|
780 | } |
---|
781 | } while (!pDivisibleBy(strat->S[i],(*h).p)); |
---|
782 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
783 | if (TEST_OPT_DEBUG) |
---|
784 | Print(" degree jumped: -> L%d\n",at); |
---|
785 | (*h).p = NULL; |
---|
786 | return 0; |
---|
787 | } |
---|
788 | } |
---|
789 | else if (TEST_OPT_PROT && (strat->Ll < 0) && (d > reddeg)) |
---|
790 | { |
---|
791 | reddeg = d; |
---|
792 | Print(".%d",d); mflush(); |
---|
793 | } |
---|
794 | j = 0; |
---|
795 | } |
---|
796 | else |
---|
797 | { |
---|
798 | if (TEST_OPT_DEBUG) PrintS("-"); |
---|
799 | if (j >= strat->tl) |
---|
800 | { |
---|
801 | if (TEST_OPT_DEBUG) PrintLn(); |
---|
802 | if (TEST_OPT_INTSTRATEGY) |
---|
803 | { |
---|
804 | h->pCleardenom();// also does a p_Content |
---|
805 | } |
---|
806 | enterT((*h),strat); |
---|
807 | return 0; |
---|
808 | } |
---|
809 | j++; |
---|
810 | } |
---|
811 | } |
---|
812 | } |
---|
813 | |
---|
814 | /*2 |
---|
815 | * reduction procedure for tests only |
---|
816 | * reduces with elements from T and chooses the best possible |
---|
817 | */ |
---|
818 | static int nc_redBest (LObject* h,kStrategy strat) |
---|
819 | { |
---|
820 | if (strat->tl<0) |
---|
821 | { |
---|
822 | enterT((*h),strat); |
---|
823 | return 0; |
---|
824 | } |
---|
825 | |
---|
826 | int j,jbest,at,reddeg,d,pass; |
---|
827 | poly p,ph; |
---|
828 | pass = j = 0; |
---|
829 | |
---|
830 | if (strat->honey) |
---|
831 | reddeg = currRing->pFDeg((*h).p,currRing)+(*h).ecart; |
---|
832 | else |
---|
833 | reddeg = currRing->pFDeg((*h).p,currRing); |
---|
834 | loop |
---|
835 | { |
---|
836 | if (pDivisibleBy(strat->T[j].p,(*h).p)) |
---|
837 | { |
---|
838 | /* compute the s-polynomial */ |
---|
839 | if (!TEST_OPT_INTSTRATEGY) pNorm((*h).p); |
---|
840 | #ifdef SDRING |
---|
841 | // spSpolyShortBba will not work in the SRING case |
---|
842 | if (pSDRING) |
---|
843 | { |
---|
844 | p=spSpolyCreate(strat->T[j].p,(*h).p,strat->kNoether); |
---|
845 | if (p!=NULL) pDelete(&pNext(p)); |
---|
846 | } |
---|
847 | else |
---|
848 | #endif |
---|
849 | p = nc_CreateShortSpoly(strat->T[j].p,(*h).p); |
---|
850 | /* computes only the first monomial of the spoly */ |
---|
851 | if (p) |
---|
852 | { |
---|
853 | jbest = j; |
---|
854 | /* looking for the best possible reduction */ |
---|
855 | if ((strat->syzComp==0) || (pMinComp(p) <= strat->syzComp)) |
---|
856 | { |
---|
857 | loop |
---|
858 | { |
---|
859 | j++; |
---|
860 | if (j > strat->tl) |
---|
861 | break; |
---|
862 | if (pDivisibleBy(strat->T[j].p,(*h).p)) |
---|
863 | { |
---|
864 | #ifdef SDRING |
---|
865 | // spSpolyShortBba will not work in the SRING case |
---|
866 | if (pSDRING) |
---|
867 | { |
---|
868 | ph=spSpolyCreate(strat->T[j].p,(*h).p,strat->kNoether); |
---|
869 | if (ph!=NULL) pDelete(&pNext(ph)); |
---|
870 | } |
---|
871 | else |
---|
872 | #endif |
---|
873 | ph = nc_CreateShortSpoly(strat->T[j].p,(*h).p); |
---|
874 | if (ph==NULL) |
---|
875 | { |
---|
876 | pLmFree(p); |
---|
877 | pDelete(&((*h).p)); |
---|
878 | if (h->lcm!=NULL) |
---|
879 | { |
---|
880 | pLmFree((*h).lcm); |
---|
881 | (*h).lcm=NULL; |
---|
882 | } |
---|
883 | return 0; |
---|
884 | } |
---|
885 | else if (pLmCmp(ph,p) == -1) |
---|
886 | { |
---|
887 | pLmFree(p); |
---|
888 | p = ph; |
---|
889 | jbest = j; |
---|
890 | } |
---|
891 | else |
---|
892 | { |
---|
893 | pLmFree(ph); |
---|
894 | } |
---|
895 | } |
---|
896 | } |
---|
897 | } |
---|
898 | pLmFree(p); |
---|
899 | (*h).p = nc_ReduceSpoly(strat->T[jbest].p,(*h).p,strat->kNoether,currRing); |
---|
900 | } |
---|
901 | else |
---|
902 | { |
---|
903 | if (h->lcm!=NULL) |
---|
904 | { |
---|
905 | pLmFree((*h).lcm); |
---|
906 | (*h).lcm=NULL; |
---|
907 | } |
---|
908 | (*h).p = NULL; |
---|
909 | return 0; |
---|
910 | } |
---|
911 | if (strat->honey && currRing->pLexOrder) |
---|
912 | strat->initEcart(h); |
---|
913 | /* h.length:=l; */ |
---|
914 | /* try to reduce the s-polynomial */ |
---|
915 | // if (strat->syzComp) |
---|
916 | // { |
---|
917 | // if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp)) |
---|
918 | // { |
---|
919 | // if (TEST_OPT_DEBUG) |
---|
920 | // PrintS(" >syzComp\n"); |
---|
921 | // if (TEST_OPT_INTSTRATEGY) p_Content(h->p,currRing); |
---|
922 | // at=strat->posInT(strat->T,strat->tl,(*h)); |
---|
923 | // enterTBba((*h),at,strat); |
---|
924 | // return; |
---|
925 | // } |
---|
926 | // } |
---|
927 | if (strat->honey || currRing->pLexOrder) |
---|
928 | { |
---|
929 | pass++; |
---|
930 | d = currRing->pFDeg((*h).p,currRing); |
---|
931 | if (strat->honey) |
---|
932 | d += (*h).ecart; |
---|
933 | if ((strat->Ll >= 0) && ((pass > strat->LazyPass) || (d > reddeg))) |
---|
934 | { |
---|
935 | at = strat->posInL(strat->L,strat->Ll,h,strat); |
---|
936 | if (at <= strat->Ll) |
---|
937 | { |
---|
938 | enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at); |
---|
939 | (*h).p = NULL; |
---|
940 | return 0; |
---|
941 | } |
---|
942 | } |
---|
943 | else if (TEST_OPT_PROT && (strat->Ll < 0) && (d != reddeg)) |
---|
944 | { |
---|
945 | reddeg = d; |
---|
946 | Print("%d."); |
---|
947 | mflush(); |
---|
948 | } |
---|
949 | } |
---|
950 | j = 0; |
---|
951 | } |
---|
952 | else |
---|
953 | { |
---|
954 | if (j >= strat->tl) |
---|
955 | { |
---|
956 | if (TEST_OPT_INTSTRATEGY) |
---|
957 | { |
---|
958 | h->pCleardenom();// also does a p_Content |
---|
959 | } |
---|
960 | enterT((*h),strat); |
---|
961 | return 0; |
---|
962 | } |
---|
963 | j++; |
---|
964 | } |
---|
965 | } |
---|
966 | } |
---|
967 | |
---|
968 | #endif |
---|
969 | |
---|
970 | void nc_gr_initBba(ideal F, kStrategy strat) |
---|
971 | { |
---|
972 | assume(rIsPluralRing(currRing)); |
---|
973 | |
---|
974 | // int i; |
---|
975 | // idhdl h; |
---|
976 | /* setting global variables ------------------- */ |
---|
977 | strat->enterS = enterSBba; |
---|
978 | |
---|
979 | /* |
---|
980 | if ((BTEST1(20)) && (!strat->honey)) |
---|
981 | strat->red = nc_redBest; |
---|
982 | else if (strat->honey) |
---|
983 | strat->red = nc_redHoney; |
---|
984 | else if (currRing->pLexOrder && !strat->homog) |
---|
985 | strat->red = nc_redLazy; |
---|
986 | else if (TEST_OPT_INTSTRATEGY && strat->homog) |
---|
987 | strat->red = nc_redHomog0; |
---|
988 | else |
---|
989 | strat->red = nc_redHomog; |
---|
990 | */ |
---|
991 | |
---|
992 | // if (rIsPluralRing(currRing)) |
---|
993 | strat->red = redGrFirst; |
---|
994 | #ifdef HAVE_RATGRING |
---|
995 | if (rIsRatGRing(currRing)) |
---|
996 | { |
---|
997 | int ii=IDELEMS(F)-1; |
---|
998 | int jj; |
---|
999 | BOOLEAN is_rat_id=FALSE; |
---|
1000 | for(;ii>=0;ii--) |
---|
1001 | { |
---|
1002 | for(jj=currRing->real_var_start;jj<=currRing->real_var_end;jj++) |
---|
1003 | { |
---|
1004 | if(pGetExp(F->m[ii],jj)>0) { is_rat_id=TRUE; break; } |
---|
1005 | } |
---|
1006 | if (is_rat_id) break; |
---|
1007 | } |
---|
1008 | if (is_rat_id) strat->red=redGrRatGB; |
---|
1009 | } |
---|
1010 | #endif |
---|
1011 | |
---|
1012 | if (currRing->pLexOrder && strat->honey) |
---|
1013 | strat->initEcart = initEcartNormal; |
---|
1014 | else |
---|
1015 | strat->initEcart = initEcartBBA; |
---|
1016 | if (strat->honey) |
---|
1017 | strat->initEcartPair = initEcartPairMora; |
---|
1018 | else |
---|
1019 | strat->initEcartPair = initEcartPairBba; |
---|
1020 | // if ((TEST_OPT_WEIGHTM)&&(F!=NULL)) |
---|
1021 | // { |
---|
1022 | // //interred machen Aenderung |
---|
1023 | // pFDegOld=currRing->pFDeg; |
---|
1024 | // pLDegOld=currRing->pLDeg; |
---|
1025 | // // h=ggetid("ecart"); |
---|
1026 | // // if ((h!=NULL) && (IDTYP(h)==INTVEC_CMD)) |
---|
1027 | // // { |
---|
1028 | // // ecartWeights=iv2array(IDINTVEC(h)); |
---|
1029 | // // } |
---|
1030 | // // else |
---|
1031 | // { |
---|
1032 | // ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short)); |
---|
1033 | // /*uses automatic computation of the ecartWeights to set them*/ |
---|
1034 | // kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights); |
---|
1035 | // } |
---|
1036 | // currRing->pFDeg=totaldegreeWecart; |
---|
1037 | // currRing->pLDeg=maxdegreeWecart; |
---|
1038 | // for(i=1; i<=(currRing->N); i++) |
---|
1039 | // Print(" %d",ecartWeights[i]); |
---|
1040 | // PrintLn(); |
---|
1041 | // mflush(); |
---|
1042 | // } |
---|
1043 | } |
---|
1044 | |
---|
1045 | #define MYTEST 0 |
---|
1046 | |
---|
1047 | ideal gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing) |
---|
1048 | { |
---|
1049 | const ring save = currRing; if( currRing != _currRing ) rChangeCurrRing(_currRing); |
---|
1050 | |
---|
1051 | #if MYTEST |
---|
1052 | PrintS("<gnc_gr_bba>\n"); |
---|
1053 | #endif |
---|
1054 | |
---|
1055 | #ifdef HAVE_PLURAL |
---|
1056 | #if MYTEST |
---|
1057 | PrintS("currRing: \n"); |
---|
1058 | rWrite(currRing); |
---|
1059 | #ifdef RDEBUG |
---|
1060 | rDebugPrint(currRing); |
---|
1061 | #endif |
---|
1062 | |
---|
1063 | PrintS("F: \n"); |
---|
1064 | idPrint(F); |
---|
1065 | PrintS("Q: \n"); |
---|
1066 | idPrint(Q); |
---|
1067 | #endif |
---|
1068 | #endif |
---|
1069 | |
---|
1070 | assume(currRing->OrdSgn != -1); // no mora!!! it terminates only for global ordering!!! (?) |
---|
1071 | |
---|
1072 | // intvec *w=NULL; |
---|
1073 | // intvec *hilb=NULL; |
---|
1074 | int olddeg,reduc; |
---|
1075 | int red_result=1; |
---|
1076 | int /*hilbeledeg=1,*/hilbcount=0/*,minimcnt=0*/; |
---|
1077 | |
---|
1078 | initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/ |
---|
1079 | // initHilbCrit(F,Q,&hilb,strat); |
---|
1080 | /* in plural we don't need Hilb yet */ |
---|
1081 | nc_gr_initBba(F,strat); |
---|
1082 | initBuchMoraPos(strat); |
---|
1083 | if (rIsRatGRing(currRing)) |
---|
1084 | { |
---|
1085 | strat->posInL=posInL0; // by pCmp of lcm |
---|
1086 | } |
---|
1087 | /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/ |
---|
1088 | /*Shdl=*/initBuchMora(F, Q,strat); |
---|
1089 | strat->posInT=posInT110; |
---|
1090 | reduc = olddeg = 0; |
---|
1091 | |
---|
1092 | /* compute------------------------------------------------------- */ |
---|
1093 | while (strat->Ll >= 0) |
---|
1094 | { |
---|
1095 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
1096 | |
---|
1097 | if (strat->Ll== 0) strat->interpt=TRUE; |
---|
1098 | if (TEST_OPT_DEGBOUND |
---|
1099 | && ((strat->honey |
---|
1100 | && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)) |
---|
1101 | || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))) |
---|
1102 | { |
---|
1103 | /* |
---|
1104 | *stops computation if |
---|
1105 | * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then |
---|
1106 | *a predefined number Kstd1_deg |
---|
1107 | */ |
---|
1108 | while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat); |
---|
1109 | break; |
---|
1110 | } |
---|
1111 | /* picks the last element from the lazyset L */ |
---|
1112 | strat->P = strat->L[strat->Ll]; |
---|
1113 | strat->Ll--; |
---|
1114 | //kTest(strat); |
---|
1115 | |
---|
1116 | if (strat->P.p != NULL) |
---|
1117 | if (pNext(strat->P.p) == strat->tail) |
---|
1118 | { |
---|
1119 | /* deletes the short spoly and computes */ |
---|
1120 | pLmFree(strat->P.p); |
---|
1121 | /* the real one */ |
---|
1122 | // if (ncRingType(currRing)==nc_lie) /* prod crit */ |
---|
1123 | // if(pHasNotCF(strat->P.p1,strat->P.p2)) |
---|
1124 | // { |
---|
1125 | // strat->cp++; |
---|
1126 | // /* prod.crit itself in nc_CreateSpoly */ |
---|
1127 | // } |
---|
1128 | |
---|
1129 | |
---|
1130 | if( ! rIsRatGRing(currRing) ) |
---|
1131 | { |
---|
1132 | strat->P.p = nc_CreateSpoly(strat->P.p1,strat->P.p2,currRing); |
---|
1133 | } |
---|
1134 | #ifdef HAVE_RATGRING |
---|
1135 | else |
---|
1136 | { |
---|
1137 | /* rational case */ |
---|
1138 | strat->P.p = nc_rat_CreateSpoly(strat->P.p1,strat->P.p2,currRing->real_var_start-1,currRing); |
---|
1139 | } |
---|
1140 | #endif |
---|
1141 | |
---|
1142 | |
---|
1143 | #ifdef PDEBUG |
---|
1144 | p_Test(strat->P.p, currRing); |
---|
1145 | #endif |
---|
1146 | |
---|
1147 | #if MYTEST |
---|
1148 | if (TEST_OPT_DEBUG) |
---|
1149 | { |
---|
1150 | PrintS("p1: "); pWrite(strat->P.p1); |
---|
1151 | PrintS("p2: "); pWrite(strat->P.p2); |
---|
1152 | PrintS("SPoly: "); pWrite(strat->P.p); |
---|
1153 | } |
---|
1154 | #endif |
---|
1155 | } |
---|
1156 | |
---|
1157 | |
---|
1158 | if (strat->P.p != NULL) |
---|
1159 | { |
---|
1160 | if (TEST_OPT_PROT) |
---|
1161 | message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), |
---|
1162 | &olddeg,&reduc,strat, red_result); |
---|
1163 | |
---|
1164 | #if MYTEST |
---|
1165 | if (TEST_OPT_DEBUG) |
---|
1166 | { |
---|
1167 | PrintS("p1: "); pWrite(strat->P.p1); |
---|
1168 | PrintS("p2: "); pWrite(strat->P.p2); |
---|
1169 | PrintS("SPoly before: "); pWrite(strat->P.p); |
---|
1170 | } |
---|
1171 | #endif |
---|
1172 | |
---|
1173 | /* reduction of the element chosen from L */ |
---|
1174 | strat->red(&strat->P,strat); |
---|
1175 | |
---|
1176 | #if MYTEST |
---|
1177 | if (TEST_OPT_DEBUG) |
---|
1178 | { |
---|
1179 | PrintS("red SPoly: "); pWrite(strat->P.p); |
---|
1180 | } |
---|
1181 | #endif |
---|
1182 | } |
---|
1183 | if (strat->P.p != NULL) |
---|
1184 | { |
---|
1185 | if (TEST_OPT_PROT) |
---|
1186 | { |
---|
1187 | PrintS("s\n"); |
---|
1188 | } |
---|
1189 | /* enter P.p into s and L */ |
---|
1190 | { |
---|
1191 | /* quick unit detection in the rational case */ |
---|
1192 | #ifdef HAVE_RATGRING |
---|
1193 | if( rIsRatGRing(currRing) ) |
---|
1194 | { |
---|
1195 | if ( p_LmIsConstantRat(strat->P.p, currRing) ) |
---|
1196 | { |
---|
1197 | #ifdef PDEBUG |
---|
1198 | Print("unit element detected:"); |
---|
1199 | p_wrp(strat->P.p,currRing); |
---|
1200 | #endif |
---|
1201 | p_Delete(&strat->P.p,currRing, strat->tailRing); |
---|
1202 | strat->P.p = pOne(); |
---|
1203 | } |
---|
1204 | } |
---|
1205 | #endif |
---|
1206 | strat->P.sev=0; |
---|
1207 | int pos=posInS(strat,strat->sl,strat->P.p, strat->P.ecart); |
---|
1208 | { |
---|
1209 | if (TEST_OPT_INTSTRATEGY) |
---|
1210 | { |
---|
1211 | if ((strat->syzComp==0)||(!strat->homog)) |
---|
1212 | { |
---|
1213 | #ifdef HAVE_RATGRING |
---|
1214 | if(!rIsRatGRing(currRing)) |
---|
1215 | #endif |
---|
1216 | strat->P.p = redtailBba(strat->P.p,pos-1,strat); |
---|
1217 | } |
---|
1218 | |
---|
1219 | strat->P.p=p_Cleardenom(strat->P.p, currRing); |
---|
1220 | } |
---|
1221 | else |
---|
1222 | { |
---|
1223 | pNorm(strat->P.p); |
---|
1224 | if ((strat->syzComp==0)||(!strat->homog)) |
---|
1225 | { |
---|
1226 | strat->P.p = redtailBba(strat->P.p,pos-1,strat); |
---|
1227 | } |
---|
1228 | } |
---|
1229 | if (TEST_OPT_DEBUG) |
---|
1230 | { |
---|
1231 | PrintS("new s:"); wrp(strat->P.p); |
---|
1232 | PrintLn(); |
---|
1233 | #if MYTEST |
---|
1234 | Print("s: "); pWrite(strat->P.p); |
---|
1235 | #endif |
---|
1236 | |
---|
1237 | } |
---|
1238 | // kTest(strat); |
---|
1239 | // |
---|
1240 | enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat); |
---|
1241 | |
---|
1242 | if (strat->sl==-1) pos=0; |
---|
1243 | else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart); |
---|
1244 | |
---|
1245 | strat->enterS(strat->P,pos,strat,-1); |
---|
1246 | } |
---|
1247 | // if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat); |
---|
1248 | } |
---|
1249 | if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm); |
---|
1250 | } |
---|
1251 | #ifdef KDEBUG |
---|
1252 | strat->P.lcm=NULL; |
---|
1253 | #endif |
---|
1254 | //kTest(strat); |
---|
1255 | } |
---|
1256 | if (TEST_OPT_DEBUG) messageSets(strat); |
---|
1257 | |
---|
1258 | /* complete reduction of the standard basis--------- */ |
---|
1259 | if (TEST_OPT_SB_1) |
---|
1260 | { |
---|
1261 | int k=1; |
---|
1262 | int j; |
---|
1263 | while(k<=strat->sl) |
---|
1264 | { |
---|
1265 | j=0; |
---|
1266 | loop |
---|
1267 | { |
---|
1268 | if (j>=k) break; |
---|
1269 | clearS(strat->S[j],strat->sevS[j],&k,&j,strat); |
---|
1270 | j++; |
---|
1271 | } |
---|
1272 | k++; |
---|
1273 | } |
---|
1274 | } |
---|
1275 | |
---|
1276 | if (TEST_OPT_REDSB) |
---|
1277 | completeReduce(strat); |
---|
1278 | /* release temp data-------------------------------- */ |
---|
1279 | exitBuchMora(strat); |
---|
1280 | // if (TEST_OPT_WEIGHTM) |
---|
1281 | // { |
---|
1282 | // currRing->pFDeg=pFDegOld; |
---|
1283 | // currRing->pLDeg=pLDegOld; |
---|
1284 | // if (ecartWeights) |
---|
1285 | // { |
---|
1286 | // omFreeSize((ADDRESS)ecartWeights,((currRing->N)+1)*sizeof(short)); |
---|
1287 | // ecartWeights=NULL; |
---|
1288 | // } |
---|
1289 | // } |
---|
1290 | if (TEST_OPT_PROT) messageStat(hilbcount,strat); |
---|
1291 | if (Q!=NULL) updateResult(strat->Shdl,Q,strat); |
---|
1292 | |
---|
1293 | |
---|
1294 | #ifdef PDEBUG |
---|
1295 | /* for counting number of pairs [enterL] in Plural */ |
---|
1296 | /* extern int zaehler; */ |
---|
1297 | /* Print("Total pairs considered:%d\n",zaehler); zaehler=0; */ |
---|
1298 | #endif /*PDEBUG*/ |
---|
1299 | |
---|
1300 | #if MYTEST |
---|
1301 | PrintS("</gnc_gr_bba>\n"); |
---|
1302 | #endif |
---|
1303 | |
---|
1304 | if( currRing != save ) rChangeCurrRing(save); |
---|
1305 | |
---|
1306 | return (strat->Shdl); |
---|
1307 | } |
---|
1308 | |
---|
1309 | ideal gnc_gr_mora(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat, const ring _currRing) |
---|
1310 | { |
---|
1311 | #ifndef NDEBUG |
---|
1312 | // Not yet! |
---|
1313 | WarnS("Sorry, non-commutative mora is not yet implemented!"); |
---|
1314 | #endif |
---|
1315 | |
---|
1316 | return gnc_gr_bba(F, Q, NULL, NULL, strat, _currRing); |
---|
1317 | } |
---|
1318 | |
---|
1319 | #endif |
---|
1320 | |
---|