source: git/kernel/sca.cc @ e4e36c

spielwiese
Last change on this file since e4e36c was 2e4ec14, checked in by Yue Ren <ren@…>, 11 years ago
fix: -Wunused-parameter warnings
  • Property mode set to 100644
File size: 29.4 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
869#ifdef MORA_USE_BUCKETS
870static BOOLEAN kMoraUseBucket(kStrategy strat)
871#else
872static BOOLEAN kMoraUseBucket(kStrategy)
873#endif
874{
875#ifdef MORA_USE_BUCKETS
876  if (TEST_OPT_NOT_BUCKETS)
877    return FALSE;
878  if (strat->red == redFirst)
879  {
880#ifdef NO_LDEG
881    if (!strat->syzComp)
882      return TRUE;
883#else
884    if ((strat->homog || strat->honey) && !strat->syzComp)
885      return TRUE;
886#endif
887  }
888  else
889  {
890    assume(strat->red == redEcart);
891    if (strat->honey && !strat->syzComp)
892      return TRUE;
893  }
894#endif
895  return FALSE;
896}
897
898#ifdef HAVE_ASSUME
899static int sca_mora_count = 0;
900static int sca_mora_loop_count;
901#endif
902
903// ideal sca_mora (ideal F, ideal Q, intvec *w, intvec *, kStrategy strat)
904ideal sca_mora(const ideal F, const ideal Q, const intvec */*w*/, const intvec *, kStrategy strat, const ring _currRing)
905{
906  const ring save = currRing;
907  if( currRing != _currRing ) rChangeCurrRing(_currRing);
908  assume( currRing == _currRing );
909
910  assume(rIsSCA(currRing));
911
912  const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
913  const unsigned int m_iLastAltVar  = scaLastAltVar(currRing);
914
915  ideal tempF = id_KillSquares(F, m_iFirstAltVar, m_iLastAltVar, currRing);
916
917  ideal tempQ = Q;
918
919  if(Q == currQuotient)
920    tempQ = SCAQuotient(currRing);
921
922  bool bIdHomog = id_IsSCAHomogeneous(tempF, NULL, NULL, currRing); // wCx == wCy == NULL!
923
924  assume( !bIdHomog || strat->homog ); //  bIdHomog =====[implies]>>>>> strat->homog
925
926  strat->homog = strat->homog && bIdHomog;
927
928#ifdef PDEBUG
929  assume( strat->homog == bIdHomog );
930#endif
931
932#ifdef HAVE_ASSUME
933  sca_mora_count++;
934  sca_mora_loop_count = 0;
935#endif
936
937#ifdef KDEBUG
938  om_Opts.MinTrack = 5;
939#endif
940
941
942  strat->update = TRUE;
943  //- setting global variables ------------------- -
944  initBuchMoraCrit(strat);
945//   initHilbCrit(F,NULL,&hilb,strat); // no Q!
946  initMora(tempF, strat);
947  initBuchMoraPos(strat);
948  //Shdl=
949    initBuchMora(tempF, tempQ, strat); // temp Q, F!
950//   if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat);
951  // updateS in initBuchMora has Hecketest
952  // * and could have put strat->kHEdgdeFound FALSE
953#if 0
954  if (ppNoether!=NULL)
955  {
956    strat->kHEdgeFound = TRUE;
957  }
958  if (strat->kHEdgeFound && strat->update)
959  {
960    firstUpdate(strat);
961    updateLHC(strat);
962    reorderL(strat);
963  }
964  if (TEST_OPT_FASTHC && (strat->lastAxis) && strat->posInLOldFlag)
965  {
966    strat->posInLOld = strat->posInL;
967    strat->posInLOldFlag = FALSE;
968    strat->posInL = posInL10;
969    updateL(strat);
970    reorderL(strat);
971  }
972#endif
973  strat->use_buckets = kMoraUseBucket(strat);
974
975  assume(kTest_TS(strat));
976
977
978  int olddeg = 0;
979  int reduc = 0;
980  int red_result = 1;
981//  int hilbeledeg=1;
982  int hilbcount=0;
983
984
985  //- compute-------------------------------------------
986
987#undef HAVE_TAIL_RING
988
989#ifdef HAVE_TAIL_RING
990//  if (strat->homog && strat->red == redFirst)
991//     kStratInitChangeTailRing(strat);
992#endif
993
994
995
996
997
998//  due to std( SB, p)
999  if(TEST_OPT_SB_1)
1000  {
1001    for (int iNewElement = strat->newIdeal; iNewElement < IDELEMS(tempF); iNewElement++)
1002    {
1003
1004      const poly pSave = tempF->m[iNewElement];
1005
1006      if( pSave != NULL )
1007      {
1008//        tempF->m[iNewElement] = NULL;
1009
1010        const poly p_next = pNext(pSave);
1011
1012        if(p_next != NULL)
1013          for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
1014            if( p_GetExp(pSave, i, currRing) != 0 )
1015            {
1016
1017              assume(p_GetExp(pSave, i, currRing) == 1);
1018
1019              const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing);
1020
1021#ifdef PDEBUG
1022              p_Test(p_new, currRing);
1023#endif
1024
1025              if( p_new == NULL) continue;
1026
1027              LObject h(p_new); // h = x_i * strat->P
1028
1029              if (TEST_OPT_INTSTRATEGY)
1030                h.pCleardenom(); // also does a p_Content
1031              else
1032                h.pNorm();
1033
1034              strat->initEcart(&h);
1035              h.sev = pGetShortExpVector(h.p);
1036
1037              int pos = 0;
1038
1039              if (strat->Ll != -1)
1040                pos = strat->posInL(strat->L,strat->Ll,&h,strat);
1041
1042              enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
1043            }
1044      }
1045
1046    }
1047  }
1048
1049
1050
1051
1052  while (strat->Ll >= 0)
1053  {
1054#ifdef HAVE_ASSUME
1055    sca_mora_loop_count++;
1056#endif
1057    //test_int_std(strat->kIdeal);
1058#ifdef KDEBUG
1059    if (TEST_OPT_DEBUG) messageSets(strat);
1060#endif
1061    if (TEST_OPT_DEGBOUND
1062    && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg))
1063    {
1064      // * stops computation if
1065      // * - 24 (degBound)
1066      // *   && upper degree is bigger than Kstd1_deg
1067      while ((strat->Ll >= 0)
1068        && (strat->L[strat->Ll].p1!=NULL) && (strat->L[strat->Ll].p2!=NULL)
1069        && (strat->L[strat->Ll].ecart+strat->L[strat->Ll].GetpFDeg()> Kstd1_deg)
1070      )
1071      {
1072        deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1073        //if (TEST_OPT_PROT)
1074        //{
1075        //   PrintS("D"); mflush();
1076        //}
1077      }
1078      if (strat->Ll<0) break;
1079      else strat->noClearS=TRUE;
1080    }
1081    strat->P = strat->L[strat->Ll];// - picks the last element from the lazyset L -
1082    if (strat->Ll==0) strat->interpt=TRUE;
1083    strat->Ll--;
1084
1085    // create the real Spoly
1086//    assume(pNext(strat->P.p) != strat->tail);
1087
1088    if(strat->P.IsNull()) continue;
1089
1090
1091    if( pNext(strat->P.p) == strat->tail )
1092    {
1093      // deletes the int spoly and computes SPoly
1094      pLmFree(strat->P.p); // ???
1095      strat->P.p = nc_CreateSpoly(strat->P.p1, strat->P.p2, currRing);
1096    }
1097
1098
1099
1100    if (strat->P.p1 == NULL)
1101    {
1102      // for input polys, prepare reduction (buckets !)
1103      strat->P.SetLength(strat->length_pLength);
1104      strat->P.PrepareRed(strat->use_buckets);
1105    }
1106
1107    if (!strat->P.IsNull())
1108    {
1109      // might be NULL from noether !!!
1110      if (TEST_OPT_PROT)
1111        message(strat->P.ecart+strat->P.GetpFDeg(),&olddeg,&reduc,strat, red_result);
1112      // reduce
1113      red_result = strat->red(&strat->P,strat);
1114    }
1115
1116    if (! strat->P.IsNull())
1117    {
1118      strat->P.GetP();
1119      // statistics
1120      if (TEST_OPT_PROT) PrintS("s");
1121      // normalization
1122      if (!TEST_OPT_INTSTRATEGY)
1123        strat->P.pNorm();
1124      // tailreduction
1125      strat->P.p = redtail(&(strat->P),strat->sl,strat);
1126      // set ecart -- might have changed because of tail reductions
1127      if ((!strat->noTailReduction) && (!strat->honey))
1128        strat->initEcart(&strat->P);
1129      // cancel unit
1130      cancelunit(&strat->P);
1131      // for char 0, clear denominators
1132      if (TEST_OPT_INTSTRATEGY)
1133        strat->P.pCleardenom();
1134
1135      // put in T
1136      enterT(strat->P,strat);
1137      // build new pairs
1138      enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat, strat->tl);
1139      // put in S
1140      strat->enterS(strat->P,
1141                    posInS(strat,strat->sl,strat->P.p, strat->P.ecart),
1142                    strat, strat->tl);
1143
1144
1145      // clear strat->P
1146      if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
1147      strat->P.lcm=NULL;
1148
1149      // //////////////////////////////////////////////////////////
1150      // SCA:
1151      const poly pSave = strat->P.p;
1152      const poly p_next = pNext(pSave);
1153
1154      if(p_next != NULL)
1155      for( unsigned int i = m_iFirstAltVar; i <= m_iLastAltVar; i++ )
1156      if( p_GetExp(pSave, i, currRing) != 0 )
1157      {
1158
1159        assume(p_GetExp(pSave, i, currRing) == 1);
1160
1161        const poly p_new = sca_pp_Mult_xi_pp(i, p_next, currRing);
1162
1163#ifdef PDEBUG
1164        p_Test(p_new, currRing);
1165#endif
1166
1167        if( p_new == NULL) continue;
1168
1169        LObject h(p_new); // h = x_i * strat->P
1170
1171        if (TEST_OPT_INTSTRATEGY)
1172           h.pCleardenom(); // also does a p_Content
1173        else
1174          h.pNorm();
1175
1176        strat->initEcart(&h);
1177        h.sev = pGetShortExpVector(h.p);
1178
1179        int pos = 0;
1180
1181        if (strat->Ll != -1)
1182          pos = strat->posInL(strat->L,strat->Ll,&h,strat);
1183
1184        enterL(&strat->L,&strat->Ll,&strat->Lmax,h,pos);
1185      }
1186
1187#ifdef KDEBUG
1188      // make sure kTest_TS does not complain about strat->P
1189      memset(&strat->P,0,sizeof(strat->P));
1190#endif
1191    }
1192#if 0
1193    if (strat->kHEdgeFound)
1194    {
1195      if ((TEST_OPT_FINDET)
1196      || ((TEST_OPT_MULTBOUND) && (scMult0Int((strat->Shdl)) < mu)))
1197      {
1198        // obachman: is this still used ???
1199        // * stops computation if strat->kHEdgeFound and
1200        // * - 27 (finiteDeterminacyTest)
1201        // * or
1202        // * - 23
1203        // *   (multBound)
1204        // *   && multiplicity of the ideal is smaller then a predefined number mu
1205        while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1206      }
1207    }
1208#endif
1209    assume(kTest_TS(strat));
1210  }
1211  // - complete reduction of the standard basis------------------------ -
1212  if (TEST_OPT_REDSB) completeReduce(strat);
1213  // - release temp data------------------------------- -
1214  exitBuchMora(strat);
1215  // - polynomials used for HECKE: HC, noether -
1216  if (TEST_OPT_FINDET)
1217  {
1218    if (strat->kHEdge!=NULL)
1219      Kstd1_mu=currRing->pFDeg(strat->kHEdge,currRing);
1220    else
1221      Kstd1_mu=-1;
1222  }
1223  pDelete(&strat->kHEdge);
1224  strat->update = TRUE; //???
1225  strat->lastAxis = 0; //???
1226  pDelete(&strat->kNoether);
1227  omFreeSize((ADDRESS)strat->NotUsedAxis,(rVar(currRing)+1)*sizeof(BOOLEAN));
1228  if (TEST_OPT_PROT) messageStat(hilbcount,strat);
1229//  if (TEST_OPT_WEIGHTM)
1230//  {
1231//    pRestoreDegProcs(currRing, pFDegOld, pLDegOld);
1232//     if (ecartWeights)
1233//     {
1234//       omFreeSize((ADDRESS)ecartWeights,(rVar(currRing)+1)*sizeof(short));
1235//       ecartWeights=NULL;
1236//     }
1237//  }
1238  if (tempQ!=NULL) updateResult(strat->Shdl,tempQ,strat);
1239  idTest(strat->Shdl);
1240
1241  id_Delete( &tempF, currRing);
1242
1243  if( currRing != save )     rChangeCurrRing(save);
1244 
1245  return (strat->Shdl);
1246}
1247
Note: See TracBrowser for help on using the repository browser.