source: git/kernel/sca.cc @ 4da485

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