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