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