My Project
Loading...
Searching...
No Matches
sca.cc
Go to the documentation of this file.
1#define PLURAL_INTERNAL_DECLARATIONS
2
3#include "kernel/mod2.h"
4
5#include "misc/options.h"
6
8#include "polys/prCopy.h"
9
10#include "polys/nc/sca.h"
11#include "polys/nc/gb_hack.h"
12
13#include "kernel/polys.h"
14#include "kernel/ideals.h"
17
18#include "kernel/GBEngine/nc.h"
19
20/// nc_gr_initBba is needed for sca_gr_bba and gr_bba.
21void nc_gr_initBba(ideal F, kStrategy strat); // from gr_kstd2.cc!
22
24{
25 if(h.IsNull()) return;
26
27 strat->initEcart(&h);
28 h.sev=0; // pGetShortExpVector(h.p);
29
30 // add h into S and L
31 int pos=posInS(strat, strat->sl, h.p, h.ecart);
32
33 if ( (pos <= strat->sl) && (p_ComparePolys(h.p, strat->S[pos], currRing)) )
34 {
35 if (TEST_OPT_PROT)
36 PrintS("d\n");
37 }
38 else
39 {
41 {
43 }
44 else
45 {
46 pNorm(h.p);
47 }
48
49 if ((strat->syzComp==0)||(!strat->homog))
50 {
51 h.p = redtailBba(h.p,pos-1,strat);
52
54 {
56 }
57 else
58 {
59 pNorm(h.p);
60 }
61 }
62
63 if(h.IsNull()) return;
64
65 // statistic
66 if (TEST_OPT_PROT)
67 {
68 PrintS("s\n");
69 }
70
71#ifdef KDEBUG
73 {
74 PrintS("new s:");
75 wrp(h.p);
76 PrintLn();
77 }
78#endif
79
80 enterpairs(h.p, strat->sl, h.ecart, 0, strat);
81
82 pos=0;
83
84 if (strat->sl!=-1) pos = posInS(strat, strat->sl, h.p, h.ecart);
85 strat->enterS(&h, pos, strat, -1);
86// enterT(&h, strat); // ?!
87
88 kDeleteLcm(&h);
89 }
90
91
92}
93
94
95ideal k_sca_gr_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
96{
97 const ring save = currRing;
98 if( currRing != _currRing ) rChangeCurrRing(_currRing);
99 assume( currRing == _currRing );
100
101
102#if MYTEST
103 PrintS("<sca_gr_bba>\n");
104#endif
105
107
108#ifndef SING_NDEBUG
109 idTest(F);
110 idTest(Q);
111#endif
112
113#ifdef HAVE_PLURAL
114#if MYTEST
115 PrintS("currRing: \n");
117#ifdef RDEBUG
119#endif
120
121 PrintS("F: \n");
122 idPrint(F);
123 PrintS("Q: \n");
124 idPrint(Q);
125#endif
126#endif
127
128
129 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
130 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
131
132 ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing);
133 ideal tempQ = Q;
134
135 if(Q == currRing->qideal)
136 tempQ = SCAQuotient(currRing);
137
138 strat->z2homog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL!
139 // redo: no_prod_crit
140 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
141 strat->no_prod_crit = ! bIsSCA;
142
143// strat->homog = strat->homog && strat->z2homog; // ?
144
145#if MYTEST
146 {
147 PrintS("ideal tempF: \n");
148 idPrint(tempF);
149 PrintS("ideal tempQ: \n");
150 idPrint(tempQ);
151 }
152#endif
153
154 int olddeg, reduc;
155 int red_result = 1;
156// int hilbeledeg = 1, minimcnt = 0;
157 int hilbcount = 0;
158
159 initBuchMoraCrit(strat); // set Gebauer, honey, sugarCrit
160
161 nc_gr_initBba(tempF,strat); // set enterS, red, initEcart, initEcartPair
162
163 initBuchMoraPos(strat);
164
165
166 // ?? set spSpolyShort, reduce ???
167
168 initBuchMora(tempF, tempQ, strat); // SCAQuotient(currRing) instead of Q == squares!!!!!!!
169
170 strat->posInT=posInT110; // !!!
171
172 reduc = olddeg = 0;
173
174
175 // compute-------------------------------------------------------
176 for(; strat->Ll >= 0;
177#ifdef KDEBUG
178 strat->P.lcm = NULL,
179#endif
180 kTest(strat)
181 )
182 {
183#ifdef KDEBUG
184 if (TEST_OPT_DEBUG) messageSets(strat);
185#endif
186
187 if (strat->Ll== 0) strat->interpt=TRUE;
188
190 && ((strat->honey
191 && (strat->L[strat->Ll].ecart+ currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
192 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
193 {
194 // stops computation if
195 // 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
196 // a predefined number Kstd1_deg
197 while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
198 break;
199 }
200
201 // picks the last element from the lazyset L
202 strat->P = strat->L[strat->Ll];
203 strat->Ll--;
204
205 //kTest(strat);
206
207// assume(pNext(strat->P.p) != strat->tail); // !???
208 if(strat->P.IsNull()) continue;
209
210
211 if( pNext(strat->P.p) == strat->tail )
212 {
213 // deletes the int spoly and computes SPoly
214 pLmFree(strat->P.p); // ???
215 strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing);
216 }
217
218 if(strat->P.IsNull()) continue;
219
220// poly save = NULL;
221//
222// if(pNext(strat->P.p) != NULL)
223// save = p_Copy(strat->P.p, currRing);
224
225 strat->initEcart(&strat->P); // remove it?
226
227 if (TEST_OPT_PROT)
228 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(), &olddeg,&reduc,strat, red_result);
229
230 // reduction of the element chosen from L wrt S
231 strat->red(&strat->P,strat);
232
233 if(strat->P.IsNull()) continue;
234
235 addLObject(strat->P, strat);
236
237 const poly save = strat->P.p;
238
239#ifdef PDEBUG
240 p_Test(save, currRing);
241#endif
242 assume( save != NULL );
243
244 // SCA Specials:
245
246 {
247 const poly p_next = pNext(save);
248
249 if( p_next != NULL )
250 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
251 if( p_GetExp(save, i, currRing) != 0 )
252 {
253 assume(p_GetExp(save, i, currRing) == 1);
254
255 const poly tt = sca_pp_Mult_xi_pp(i, p_next, currRing);
256
257#ifdef PDEBUG
258 p_Test(tt, currRing);
259#endif
260
261 if( tt == NULL) continue;
262
263 LObject h(tt); // h = x_i * P
264
266 {
267 h.pCleardenom(); // also removes Content
268 }
269 else
270 {
271 h.pNorm();
272 }
273
274 strat->initEcart(&h);
275
276
277// if (pOrdSgn==-1)
278// {
279// cancelunit(&h); // tries to cancel a unit
280// deleteHC(&h, strat);
281// }
282
283// if(h.IsNull()) continue;
284
285// if (TEST_OPT_PROT)
286// message((strat->honey ? h.ecart : 0) + h.pFDeg(), &olddeg, &reduc, strat, red_result);
287
288// strat->red(&h, strat); // wrt S
289// if(h.IsNull()) continue;
290
291// poly save = p_Copy(h.p, currRing);
292
293 int pos;
294
295 if (strat->Ll==-1)
296 pos =0;
297 else
298 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
299
300 h.sev = pGetShortExpVector(h.p);
301 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
302
303 // h.p = save;
304 // addLObject(h, strat);
305 }
306
307 // p_Delete( &save, currRing );
308 }
309
310
311 } // for(;;)
312
313
314#ifdef KDEBUG
315 if (TEST_OPT_DEBUG) messageSets(strat);
316#endif
317
318 if (TEST_OPT_REDSB){
319 completeReduce(strat); // ???
320 }
321
322 // release temp data--------------------------------
323 exitBuchMora(strat);
324
325// if (TEST_OPT_WEIGHTM)
326// {
327// pRestoreDegProcs(currRing,pFDegOld, pLDegOld);
328// if (ecartWeights)
329// {
330// omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(int));
331// ecartWeights=NULL;
332// }
333// }
334
335 if (TEST_OPT_PROT) messageStat(hilbcount,strat);
336
337 if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat);
338
339 id_Delete(&tempF, currRing);
340
341
342 // complete reduction of the standard basis---------
343 if (TEST_OPT_REDSB){
344 ideal I = strat->Shdl;
345 ideal erg = kInterRedOld(I,tempQ);
346 assume(I!=erg);
347 id_Delete(&I, currRing);
348 strat->Shdl = erg;
349 }
350
351
352#if MYTEST
353// PrintS("</sca_gr_bba>\n");
354#endif
355
356 if( currRing != save ) rChangeCurrRing(save);
357
358 return (strat->Shdl);
359}
360
361
362
363///////////////////////////////////////////////////////////////////////////////////////
364//************* SCA BBA *************************************************************//
365///////////////////////////////////////////////////////////////////////////////////////
366
367// Under development!!!
368ideal k_sca_bba (const ideal F, const ideal Q, const intvec */*w*/, const bigintmat * /*hilb*/, kStrategy strat, const ring _currRing)
369{
370 const ring save = currRing;
371 if( currRing != _currRing ) rChangeCurrRing(_currRing);
372 assume( currRing == _currRing );
373
374#if MYTEST
375 PrintS("\n\n<sca_bba>\n\n");
376#endif
377
379
380#ifndef SING_NDEBUG
381 idTest(F);
382 idTest(Q);
383#endif
384
385#if MYTEST
386 PrintS("\ncurrRing: \n");
388#ifdef RDEBUG
389// rDebugPrint(currRing);
390#endif
391
392 PrintS("\n\nF: \n");
393 idPrint(F);
394 PrintS("\n\nQ: \n");
395 idPrint(Q);
396
397 PrintLn();
398#endif
399
400
401 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
402 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
403
404 ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing);
405
406 ideal tempQ = Q;
407
408 if(Q == currRing->qideal)
409 tempQ = SCAQuotient(currRing);
410
411 // Q or tempQ will not be used below :(((
412
413
414#if MYTEST
415
416 PrintS("tempF: \n");
417 idPrint(tempF);
418 PrintS("tempQ: \n");
419 idPrint(tempQ);
420#endif
421
422 strat->z2homog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL!
423 // redo no_prod_crit:
424 const BOOLEAN bIsSCA = rIsSCA(currRing) && strat->z2homog; // for Z_2 prod-crit
425 strat->no_prod_crit = ! bIsSCA;
426
427// strat->homog = strat->homog && strat->z2homog; // ?
428
429 int red_result = 1;
430 int olddeg, reduc;
431
432// int hilbeledeg = 1, minimcnt = 0;
433 int hilbcount = 0;
434
435 BOOLEAN withT = FALSE;
436
437 initBuchMoraCrit(strat); // sets Gebauer, honey, sugarCrit // sca - ok???
438 initBuchMoraPos(strat); // sets strat->posInL, strat->posInT // check!! (Plural's: )
439
440// initHilbCrit(F, Q, &hilb, strat);
441
442// nc_gr_initBba(F,strat);
443 initBba(strat); // set enterS, red, initEcart, initEcartPair
444
445 // set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair
446 // ?? set spSpolyShort, reduce ???
447 initBuchMora(tempF, tempQ, strat); // tempQ = Q without squares!!!
448
449// if (strat->minim>0) strat->M = idInit(IDELEMS(F),F->rank);
450
451 reduc = olddeg = 0;
452
453#define NO_BUCKETS
454
455#ifndef NO_BUCKETS
457 strat->use_buckets = 1;
458#endif
459
460 // redtailBBa against T for inhomogeneous input
461 if (!TEST_OPT_OLDSTD)
462 withT = ! strat->homog;
463
464 // strat->posInT = posInT_pLength;
465 kTest_TS(strat);
466
467#undef HAVE_TAIL_RING
468
469#ifdef HAVE_TAIL_RING
470 if(!idIs0(F) &&(!rField_is_Ring())) // create strong gcd poly computes with tailring and S[i] ->to be fixed
472#endif
473
474 ///////////////////////////////////////////////////////////////
475 // SCA:
476
477 // due to std( SB, p).
478 // Note that after initBuchMora :: initSSpecial all these additional
479 // elements are in S and T (and some pairs are in L, which also has no initial
480 // elements!!!)
481 if(TEST_OPT_SB_1)
482 {
483 // For all additional elements...
484 for (int iNewElement = strat->newIdeal; iNewElement < IDELEMS(tempF); iNewElement++)
485 {
486 const poly pSave = tempF->m[iNewElement];
487
488 if( pSave != NULL )
489 {
490// tempF->m[iNewElement] = NULL;
491
492 const poly p_next = pNext(pSave);
493
494 if(p_next != NULL)
495 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
496 if( p_GetExp(pSave, i, currRing) != 0 )
497 {
498 assume(p_GetExp(pSave, i, currRing) == 1);
499
500 const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing);
501
502#ifdef PDEBUG
504#endif
505
506 if( p_new == NULL) continue;
507
508 LObject h(p_new); // h = x_i * strat->P
509 h.is_special = TRUE;
510
512 h.pCleardenom(); // also removes Content
513 else
514 h.pNorm();
515
516 strat->initEcart(&h);
517 h.sev = pGetShortExpVector(h.p);
518
519 int pos = 0;
520
521 if (strat->Ll != -1)
522 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
523
524 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
525 }
526 }
527 }
528 }
529
530 // compute-------------------------------------------------------
531 while (strat->Ll >= 0)
532 {
533#ifdef KDEBUG
534 if (TEST_OPT_DEBUG) messageSets(strat);
535#endif
536
537 if (strat->Ll== 0) strat->interpt=TRUE;
538
540 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
541 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
542 {
543
544#ifdef KDEBUG
545// if (TEST_OPT_DEBUG){PrintS("^^^^?");}
546#endif
547
548 // *stops computation if
549 // * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
550 // *a predefined number Kstd1_deg
551 while ((strat->Ll >= 0)
552 && ( (strat->homog==isHomog) || strat->L[strat->Ll].is_special || ((strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)) )
553 && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
554 || ((!strat->honey) && (currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg)))
555 )
556 {
557#ifdef KDEBUG
558// if (TEST_OPT_DEBUG){PrintS("^^^^^^^^^^^^!!!!");}
559#endif
560 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
561// if (TEST_OPT_PROT) PrintS("^!");
562 }
563 if (strat->Ll<0) break;
564 else strat->noClearS=TRUE;
565 }
566
567 // picks the last element from the lazyset L
568 strat->P = strat->L[strat->Ll];
569 strat->Ll--;
570
571
572// assume(pNext(strat->P.p) != strat->tail);
573
574 if(strat->P.IsNull()) continue;
575
576 if (pNext(strat->P.p) == strat->tail)
577 {
578 // deletes the short spoly
579 pLmFree(strat->P.p);
580
581 strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing);
582 if (strat->P.p!=NULL) strat->initEcart(&strat->P);
583 }// else
584
585
586 if(strat->P.IsNull()) continue;
587
588 if (strat->P.p1 == NULL)
589 {
590// if (strat->minim > 0)
591// strat->P.p2=p_Copy(strat->P.p, currRing, strat->tailRing);
592
593
594 // for input polys, prepare reduction
595 strat->P.PrepareRed(strat->use_buckets);
596 }
597
598 if (TEST_OPT_PROT)
599 message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
600 &olddeg,&reduc,strat, red_result);
601
602 // reduction of the element chosen from L
603 red_result = strat->red(&strat->P,strat);
604
605
606 // reduction to non-zero new poly
607 if (red_result == 1)
608 {
609 // statistic
610 if (TEST_OPT_PROT) PrintS("s");
611
612 // get the polynomial (canonicalize bucket, make sure P.p is set)
613 strat->P.GetP(strat->lmBin);
614
615 int pos = posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
616
617 // reduce the tail and normalize poly
619 {
620 strat->P.pCleardenom();
622 {
623 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT); // !!!
624 strat->P.pCleardenom();
625 }
626 }
627 else
628 {
629 strat->P.pNorm();
631 strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
632 }
633 strat->P.is_normalized=nIsOne(pGetCoeff(strat->P.p));
634
635#ifdef KDEBUG
636 if (TEST_OPT_DEBUG){PrintS(" ns:");p_wrp(strat->P.p,currRing);PrintLn();}
637#endif
638
639// // min_std stuff
640// if ((strat->P.p1==NULL) && (strat->minim>0))
641// {
642// if (strat->minim==1)
643// {
644// strat->M->m[minimcnt]=p_Copy(strat->P.p,currRing,strat->tailRing);
645// p_Delete(&strat->P.p2, currRing, strat->tailRing);
646// }
647// else
648// {
649// strat->M->m[minimcnt]=strat->P.p2;
650// strat->P.p2=NULL;
651// }
652// if (strat->tailRing!=currRing && pNext(strat->M->m[minimcnt])!=NULL)
653// pNext(strat->M->m[minimcnt])
654// = strat->p_shallow_copy_delete(pNext(strat->M->m[minimcnt]),
655// strat->tailRing, currRing,
656// currRing->PolyBin);
657// minimcnt++;
658// }
659
660 // enter into S, L, and T
661 //if(withT)
662 {
663 strat->P.SetpFDeg();
664 enterT(&strat->P, strat);
665 }
666
667 // L
668 enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
669
670 // posInS only depends on the leading term
671 strat->enterS(&strat->P, pos, strat, strat->tl);
672
673// if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
674
675// Print("[%d]",hilbeledeg);
676 kDeleteLcm(&strat->P);
677
678 // //////////////////////////////////////////////////////////
679 // SCA:
680 const poly pSave = strat->P.p;
681 const poly p_next = pNext(pSave);
682
683// if(0)
684 if( p_next != NULL )
685 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
686 if( p_GetExp(pSave, i, currRing) != 0 )
687 {
688 assume(p_GetExp(pSave, i, currRing) == 1);
689 const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing);
690
691#ifdef PDEBUG
693#endif
694
695 if( p_new == NULL) continue;
696
697 LObject h(p_new); // h = x_i * strat->P
698
699 h.is_special = TRUE;
700
702 {
703 h.pCleardenom(); // also removes Content
704 }
705 else
706 {
707 h.pNorm();
708 }
709
710 strat->initEcart(&h);
711 h.sev = pGetShortExpVector(h.p);
712
713 int pos = 0;
714
715 if (strat->Ll != -1)
716 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
717
718 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
719
720
721
722
723#if 0
724 h.sev = pGetShortExpVector(h.p);
725 strat->initEcart(&h);
726
727 h.PrepareRed(strat->use_buckets);
728
729 // reduction of the element chosen from L(?)
730 red_result = strat->red(&h,strat);
731
732 // reduction to non-zero new poly
733 if (red_result != 1) continue;
734
735
736 int pos = posInS(strat,strat->sl,h.p,h.ecart);
737
738 // reduce the tail and normalize poly
740 {
741 h.pCleardenom();
743 {
744 h.p = redtailBba(&(h),pos-1,strat, withT); // !!!
745 h.pCleardenom();
746 }
747 }
748 else
749 {
750 h.pNorm();
752 h.p = redtailBba(&(h),pos-1,strat, withT);
753 }
754
755#ifdef KDEBUG
756 if (TEST_OPT_DEBUG){PrintS(" N:");h.wrp();PrintLn();}
757#endif
758
759// h.PrepareRed(strat->use_buckets); // ???
760
761 h.sev = pGetShortExpVector(h.p);
762 strat->initEcart(&h);
763
764 if (strat->Ll==-1)
765 pos = 0;
766 else
767 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
768
769 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
770// the end of "#if 0" (comment)
771#endif
772
773 } // for all x_i \in Ann(lm(P))
774 } // if red(P) != NULL
775
776// else if (strat->P.p1 == NULL && strat->minim > 0)
777// {
778// p_Delete(&strat->P.p2, currRing, strat->tailRing);
779// }
780
781#ifdef KDEBUG
782// memset(&(strat->P), 0, sizeof(strat->P));
783#endif
784
785 kTest_TS(strat); // even of T is not used!
786
787// Print("\n$\n");
788
789 }
790
791#ifdef KDEBUG
792 if (TEST_OPT_DEBUG) messageSets(strat);
793#endif
794
795 // complete reduction of the standard basis---------
796
797 if (TEST_OPT_REDSB)
798 {
799 completeReduce(strat);
800 }
801
802 //release temp data--------------------------------
803
804 exitBuchMora(strat); // cleanT!
805
806 id_Delete(&tempF, currRing);
807
808// if (TEST_OPT_WEIGHTM)
809// {
810// pRestoreDegProcs(currRing, pFDegOld, pLDegOld);
811// if (ecartWeights)
812// {
813// omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(short));
814// ecartWeights=NULL;
815// }
816// }
817
818 if (TEST_OPT_PROT) messageStat(hilbcount,strat);
819
820
821
822 if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat);
823
824
825 if (TEST_OPT_REDSB) // ???
826 {
827 // must be at the very end (after exitBuchMora) as it changes the S set!!!
828 ideal I = strat->Shdl;
829 ideal erg = kInterRedOld(I,tempQ);
830 assume(I!=erg);
831 id_Delete(&I, currRing);
832 strat->Shdl = erg;
833 }
834
835#if MYTEST
836 PrintS("\n\n</sca_bba>\n\n");
837#endif
838
839 if( currRing != save ) rChangeCurrRing(save);
840
841 return (strat->Shdl);
842}
843
844// //////////////////////////////////////////////////////////////////////////////
845// sca mora...
846
847// returns TRUE if mora should use buckets, false otherwise
848#ifdef MORA_USE_BUCKETS
849static BOOLEAN kMoraUseBucket(kStrategy strat)
850#else
852#endif
853{
854#ifdef MORA_USE_BUCKETS
856 return FALSE;
857 if (strat->red == redFirst)
858 {
859#ifdef NO_LDEG
860 if (!strat->syzComp)
861 return TRUE;
862#else
863 if ((strat->homog || strat->honey) && !strat->syzComp)
864 return TRUE;
865#endif
866 }
867 else
868 {
869 assume(strat->red == redEcart);
870 if (strat->honey && !strat->syzComp)
871 return TRUE;
872 }
873#endif
874 return FALSE;
875}
876
877// ideal sca_mora (ideal F, ideal Q, intvec *w, intvec *, kStrategy strat)
878ideal k_sca_mora(const ideal F, const ideal Q, const intvec */*w*/, const bigintmat *, kStrategy strat, const ring _currRing)
879{
880 const ring save = currRing;
881 if( currRing != _currRing ) rChangeCurrRing(_currRing);
882 assume( currRing == _currRing );
883
885
886 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
887 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
888
889 ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing);
890
891 ideal tempQ = Q;
892
893 if(Q == currRing->qideal)
894 tempQ = SCAQuotient(currRing);
895
896 bool bIdHomog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL!
897
898 assume( !bIdHomog || strat->homog ); // bIdHomog =====[implies]>>>>> strat->homog
899
900 strat->homog = strat->homog && bIdHomog;
901
902#ifdef PDEBUG
903 assume( strat->homog == bIdHomog );
904#endif
905
906 strat->update = TRUE;
907 //- setting global variables ------------------- -
908 initBuchMoraCrit(strat);
909// initHilbCrit(F,NULL,&hilb,strat); // no Q!
910 initMora(tempF, strat);
911 initBuchMoraPos(strat);
912 //Shdl=
913 initBuchMora(tempF, tempQ, strat); // temp Q, F!
914 // updateS in initBuchMora has Hecketest
915 // * and could have put strat->kHEdgdeFound FALSE
916 strat->use_buckets = kMoraUseBucket(strat);
917
918 kTest_TS(strat);
919
920
921 int olddeg = 0;
922 int reduc = 0;
923 int red_result = 1;
924// int hilbeledeg=1;
925 int hilbcount=0;
926
927
928 //- compute-------------------------------------------
929
930#undef HAVE_TAIL_RING
931
932#ifdef HAVE_TAIL_RING
933// if (strat->homog && strat->red == redFirst)
934// kStratInitChangeTailRing(strat);
935#endif
936
937
938
939
940
941// due to std( SB, p)
942 if(TEST_OPT_SB_1)
943 {
944 for (int iNewElement = strat->newIdeal; iNewElement < IDELEMS(tempF); iNewElement++)
945 {
946
947 const poly pSave = tempF->m[iNewElement];
948
949 if( pSave != NULL )
950 {
951// tempF->m[iNewElement] = NULL;
952
953 const poly p_next = pNext(pSave);
954
955 if(p_next != NULL)
956 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
957 if( p_GetExp(pSave, i, currRing) != 0 )
958 {
959
960 assume(p_GetExp(pSave, i, currRing) == 1);
961
962 const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing);
963
964#ifdef PDEBUG
966#endif
967
968 if( p_new == NULL) continue;
969
970 LObject h(p_new); // h = x_i * strat->P
971
973 h.pCleardenom(); // also removes Content
974 else
975 h.pNorm();
976
977 strat->initEcart(&h);
978 h.sev = pGetShortExpVector(h.p);
979
980 int pos = 0;
981
982 if (strat->Ll != -1)
983 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
984
985 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
986 }
987 }
988
989 }
990 }
991
992 while (strat->Ll >= 0)
993 {
994 //test_int_std(strat->kIdeal);
995#ifdef KDEBUG
996 if (TEST_OPT_DEBUG) messageSets(strat);
997#endif
999 && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg))
1000 {
1001 // * stops computation if
1002 // * - 24 (degBound)
1003 // * && upper degree is bigger than Kstd1_deg
1004 while ((strat->Ll >= 0)
1005 && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
1006 && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)
1007 )
1008 {
1009 deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1010 //if (TEST_OPT_PROT)
1011 //{
1012 // PrintS("D"); mflush();
1013 //}
1014 }
1015 if (strat->Ll<0) break;
1016 else strat->noClearS=TRUE;
1017 }
1018 strat->P = strat->L[strat->Ll];// - picks the last element from the lazyset L -
1019 if (strat->Ll==0) strat->interpt=TRUE;
1020 strat->Ll--;
1021
1022 // create the real Spoly
1023// assume(pNext(strat->P.p) != strat->tail);
1024
1025 if(strat->P.IsNull()) continue;
1026
1027
1028 if( pNext(strat->P.p) == strat->tail )
1029 {
1030 // deletes the int spoly and computes SPoly
1031 pLmFree(strat->P.p); // ???
1032 strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing);
1033 }
1034
1035
1036
1037 if (strat->P.p1 == NULL)
1038 {
1039 // for input polys, prepare reduction (buckets !)
1040 strat->P.SetLength(strat->length_pLength);
1041 strat->P.PrepareRed(strat->use_buckets);
1042 }
1043
1044 if (!strat->P.IsNull())
1045 {
1046 // might be NULL from noether !!!
1047 if (TEST_OPT_PROT)
1048 message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat, red_result);
1049 // reduce
1050 red_result = strat->red(&strat->P,strat);
1051 }
1052
1053 if (! strat->P.IsNull())
1054 {
1055 strat->P.GetP();
1056 // statistics
1057 if (TEST_OPT_PROT) PrintS("s");
1058 // normalization
1060 strat->P.pNorm();
1061 // tailreduction
1062 strat->P.p = redtail(&(strat->P),strat->sl,strat);
1063 // set ecart -- might have changed because of tail reductions
1064 if ((!strat->noTailReduction) && (!strat->honey))
1065 strat->initEcart(&strat->P);
1066 // cancel unit
1067 cancelunit(&strat->P);
1068 // for char 0, clear denominators
1070 strat->P.pCleardenom();
1071
1072 // put in T
1073 enterT(&strat->P,strat);
1074 // build new pairs
1075 enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
1076 // put in S
1077 strat->enterS(&strat->P,
1078 posInS(strat,strat->sl,strat->P.p, strat->P.ecart),
1079 strat, strat->tl);
1080
1081
1082 // clear strat->P
1083 kDeleteLcm(&strat->P);
1084
1085 // //////////////////////////////////////////////////////////
1086 // SCA:
1087 const poly pSave = strat->P.p;
1088 const poly p_next = pNext(pSave);
1089
1090 if(p_next != NULL)
1091 for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
1092 if( p_GetExp(pSave, i, currRing) != 0 )
1093 {
1094
1095 assume(p_GetExp(pSave, i, currRing) == 1);
1096
1097 const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing);
1098
1099#ifdef PDEBUG
1101#endif
1102
1103 if( p_new == NULL) continue;
1104
1105 LObject h(p_new); // h = x_i * strat->P
1106
1108 h.pCleardenom(); // also removes Content
1109 else
1110 h.pNorm();
1111
1112 strat->initEcart(&h);
1113 h.sev = pGetShortExpVector(h.p);
1114
1115 int pos = 0;
1116
1117 if (strat->Ll != -1)
1118 pos = strat->posInL(strat->L,strat->Ll,&h,strat);
1119
1120 enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
1121 }
1122
1123#ifdef KDEBUG
1124 // make sure kTest_TS does not complain about strat->P
1125 strat->P.Init();
1126#endif
1127 }
1128#if 0
1129 if (strat->kHEdgeFound)
1130 {
1131 if ((TEST_OPT_FINDET)
1132 || ((TEST_OPT_MULTBOUND) && (scMult0Int((strat->Shdl)) < mu)))
1133 {
1134 // obachman: is this still used ???
1135 // * stops computation if strat->kHEdgeFound and
1136 // * - 27 (finiteDeterminacyTest)
1137 // * or
1138 // * - 23
1139 // * (multBound)
1140 // * && multiplicity of the ideal is smaller then a predefined number mu
1141 while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1142 }
1143 }
1144#endif
1145 kTest_TS(strat);
1146 }
1147 // - complete reduction of the standard basis------------------------ -
1148 if (TEST_OPT_REDSB) completeReduce(strat);
1149 // - release temp data------------------------------- -
1150 exitBuchMora(strat);
1151 // - polynomials used for HECKE: HC, noether -
1152 if (TEST_OPT_FINDET)
1153 {
1154 if (strat->kNoether!=NULL)
1155 Kstd1_mu=currRing->pFDeg(strat->kNoether,currRing);
1156 else
1157 Kstd1_mu=-1;
1158 }
1159 if(strat->kNoether!=NULL) pLmFree(&strat->kNoether);
1160 strat->update = TRUE; //???
1161 strat->lastAxis = 0; //???
1162 omFreeSize((ADDRESS)strat->NotUsedAxis,(rVar(currRing)+1)*sizeof(BOOLEAN));
1163 if (TEST_OPT_PROT) messageStat(hilbcount,strat);
1164// if (TEST_OPT_WEIGHTM)
1165// {
1166// pRestoreDegProcs(currRing, pFDegOld, pLDegOld);
1167// if (ecartWeights)
1168// {
1169// omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(short));
1170// ecartWeights=NULL;
1171// }
1172// }
1173 if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat);
1174 idTest(strat->Shdl);
1175
1176 id_Delete( &tempF, currRing);
1177
1178 if( currRing != save ) rChangeCurrRing(save);
1179
1180 return (strat->Shdl);
1181}
1182
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
void * ADDRESS
Definition auxiliary.h:120
int i
Definition cfEzgcd.cc:132
Matrices of numbers.
Definition bigintmat.h:51
int syzComp
Definition kutil.h:353
char noTailReduction
Definition kutil.h:375
int Ll
Definition kutil.h:350
omBin lmBin
Definition kutil.h:343
char honey
Definition kutil.h:374
polyset S
Definition kutil.h:305
poly kNoether
Definition kutil.h:328
BOOLEAN * NotUsedAxis
Definition kutil.h:331
int lastAxis
Definition kutil.h:354
int tl
Definition kutil.h:349
poly tail
Definition kutil.h:333
int(* posInL)(const LSet set, const int length, LObject *L, const kStrategy strat)
Definition kutil.h:283
ideal Shdl
Definition kutil.h:302
void(* enterS)(LObject *h, int pos, kStrategy strat, int atR)
Definition kutil.h:285
char use_buckets
Definition kutil.h:380
char interpt
Definition kutil.h:368
int newIdeal
Definition kutil.h:355
void(* initEcart)(TObject *L)
Definition kutil.h:281
LObject P
Definition kutil.h:301
char noClearS
Definition kutil.h:399
int Lmax
Definition kutil.h:350
char z2homog
Definition kutil.h:371
char no_prod_crit
Definition kutil.h:391
LSet L
Definition kutil.h:326
char length_pLength
Definition kutil.h:384
int(* posInT)(const TSet T, const int tl, LObject &h)
Definition kutil.h:282
int(* red)(LObject *L, kStrategy strat)
Definition kutil.h:279
int sl
Definition kutil.h:347
char homog
Definition kutil.h:369
char update
Definition kutil.h:378
static std::vector< std::vector< int > > p_new(ideal Xo, ideal Sigma)
Definition cohomo.cc:3303
long scMult0Int(ideal S, ideal Q)
Definition hdegree.cc:924
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
#define idPrint(id)
Definition ideals.h:46
#define idTest(id)
Definition ideals.h:47
STATIC_VAR Poly * h
Definition janet.cc:971
KINLINE poly redtailBba(poly p, int pos, kStrategy strat, BOOLEAN normalize)
Definition kInline.h:1212
static BOOLEAN kMoraUseBucket(kStrategy)
Definition sca.cc:851
void nc_gr_initBba(ideal F, kStrategy strat)
nc_gr_initBba is needed for sca_gr_bba and gr_bba.
Definition gr_kstd2.cc:950
ideal k_sca_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Buchberger's algorithm.
Definition sca.cc:368
void addLObject(LObject &h, kStrategy &strat)
Definition sca.cc:23
ideal k_sca_gr_bba(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified Plural's Buchberger's algorithmus.
Definition sca.cc:95
ideal k_sca_mora(const ideal F, const ideal Q, const intvec *, const bigintmat *, kStrategy strat, const ring _currRing)
Modified modern Sinuglar Mora's algorithm.
Definition sca.cc:878
void initMora(ideal F, kStrategy strat)
Definition kstd1.cc:1820
int redFirst(LObject *h, kStrategy strat)
Definition kstd1.cc:794
int redEcart(LObject *h, kStrategy strat)
Definition kstd1.cc:168
void initBba(kStrategy strat)
Definition kstd1.cc:1690
ideal kInterRedOld(ideal F, const ideal Q)
Definition kstd1.cc:3457
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:70
EXTERN_VAR int Kstd1_mu
Definition kstd1.h:70
poly redtail(LObject *L, int end_pos, kStrategy strat)
Definition kutil.cc:6836
void initBuchMora(ideal F, ideal Q, kStrategy strat)
Definition kutil.cc:9749
void message(int i, int *olddeg, int *reduc, kStrategy strat, int red_result)
Definition kutil.cc:7463
BOOLEAN kTest(kStrategy strat)
Definition kutil.cc:1004
BOOLEAN kTest_TS(kStrategy strat)
Definition kutil.cc:1067
void enterL(LSet *set, int *length, int *LSetmax, LObject p, int at)
Definition kutil.cc:1269
void enterpairs(poly h, int k, int ecart, int pos, kStrategy strat, int atR)
Definition kutil.cc:4487
void initBuchMoraPos(kStrategy strat)
Definition kutil.cc:9580
void exitBuchMora(kStrategy strat)
Definition kutil.cc:9837
int posInS(const kStrategy strat, const int length, const poly p, const int ecart_p)
Definition kutil.cc:4663
void enterT(LObject *p, kStrategy strat, int atT)
Definition kutil.cc:9143
int posInT110(const TSet set, const int length, LObject &p)
Definition kutil.cc:5029
void updateResult(ideal r, ideal Q, kStrategy strat)
Definition kutil.cc:10051
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition kutil.cc:1208
void kStratInitChangeTailRing(kStrategy strat)
Definition kutil.cc:11036
void initBuchMoraCrit(kStrategy strat)
Definition kutil.cc:9435
void completeReduce(kStrategy strat, BOOLEAN withT)
Definition kutil.cc:10257
void messageSets(kStrategy strat)
Definition kutil.cc:7536
void messageStat(int hilbcount, kStrategy strat)
Definition kutil.cc:7504
void cancelunit(LObject *L, BOOLEAN inNF)
Definition kutil.cc:365
static void kDeleteLcm(LObject *P)
Definition kutil.h:876
class sLObject LObject
Definition kutil.h:59
static bool rIsSCA(const ring r)
Definition nc.h:190
static poly nc_CreateSpoly(const poly p1, const poly p2, const ring r)
Definition nc.h:241
ideal id_KillSquares(const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)
Definition sca.cc:1518
poly sca_pp_Mult_xi_pp(short i, const poly pPoly, const ring rRing)
Definition sca.cc:1201
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2028
#define assume(x)
Definition mod2.h:389
#define pNext(p)
Definition monomials.h:36
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
#define nIsOne(n)
Definition numbers.h:25
#define omFreeSize(addr, size)
#define NULL
Definition omList.c:12
#define TEST_OPT_INTSTRATEGY
Definition options.h:112
#define TEST_OPT_REDTAIL
Definition options.h:118
#define TEST_OPT_FINDET
Definition options.h:113
#define TEST_OPT_OLDSTD
Definition options.h:125
#define TEST_OPT_REDSB
Definition options.h:106
#define TEST_OPT_DEGBOUND
Definition options.h:115
#define TEST_OPT_SB_1
Definition options.h:121
#define TEST_OPT_MULTBOUND
Definition options.h:116
#define TEST_OPT_PROT
Definition options.h:105
#define TEST_OPT_DEBUG
Definition options.h:110
#define TEST_OPT_NOT_BUCKETS
Definition options.h:107
BOOLEAN p_ComparePolys(poly p1, poly p2, const ring r)
returns TRUE if p1 is a skalar multiple of p2 assume p1 != NULL and p2 != NULL
Definition p_polys.cc:4743
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2893
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471
#define p_Test(p, r)
Definition p_polys.h:161
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:373
void rChangeCurrRing(ring r)
Definition polys.cc:16
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
Compatibility layer for legacy polynomial operations (over currRing).
void pNorm(poly p)
Definition polys.h:363
#define pGetShortExpVector(a)
returns the "Short Exponent Vector" – used to speed up divisibility tests (see polys-impl....
Definition polys.h:153
void wrp(poly p)
Definition polys.h:311
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:71
void PrintS(const char *s)
Definition reporter.cc:288
void PrintLn()
Definition reporter.cc:314
void rWrite(ring r, BOOLEAN details)
Definition ring.cc:227
void rDebugPrint(const ring r)
Definition ring.cc:4214
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:603
#define rField_is_Ring(R)
Definition ring.h:491
ideal SCAQuotient(const ring r)
Definition sca.h:10
static short scaLastAltVar(ring r)
Definition sca.h:25
static short scaFirstAltVar(ring r)
Definition sca.h:18
static bool id_IsSCAHomogeneous(const ideal id, const intvec *wCx, const intvec *wCy, const ring r)
Definition sca.h:115
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define IDELEMS(i)
#define Q
Definition sirandom.c:26
@ isHomog
Definition structs.h:33
skStrategy * kStrategy
Definition structs.h:54