source: git/kernel/sca.cc @ 31f1850

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