source: git/kernel/GBEngine/sca.cc @ 24bc73

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