source: git/kernel/sca.cc @ 80ca3c

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