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