source: git/kernel/gr_kstd2.cc @ b687a3

spielwiese
Last change on this file since b687a3 was 626431, checked in by Hans Schönemann <hannes@…>, 19 years ago
8hannes; debug stuff git-svn-id: file:///usr/local/Singular/svn/trunk@7788 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 23.2 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: gr_kstd2.cc,v 1.7 2005-03-17 14:15:40 Singular Exp $ */
5/*
6*  ABSTRACT -  Kernel: noncomm. alg. of Buchberger
7*/
8
9#include "mod2.h"
10#ifdef HAVE_PLURAL
11#include "omalloc.h"
12#include "polys.h"
13#include "ideals.h"
14#include "febase.h"
15#include "kutil.h"
16#include "kstd1.h"
17#include "khstd.h"
18//#include "spolys.h"
19//#include "cntrlc.h"
20#include "weight.h"
21#include "intvec.h"
22#include "structs.h"
23#include "gring.h"
24
25/*2
26* consider the part above syzComp:
27* (assume the polynomial comes from a syz computation)
28* - it is a constant term: return a copy of it
29* - else: return NULL
30*/
31static poly kFromInput(poly p,kStrategy strat)
32{
33  poly q=p;
34
35  if (pGetComp(q)>strat->syzComp) return NULL;
36  while ((q!=NULL) && (pGetComp(q)<=strat->syzComp)) pIter(q);
37  if (pIsConstantComp(q))
38    return pHead(q);
39  return NULL;
40}
41
42/*2
43*reduces h with elements from T choosing  the first possible
44* element in t with respect to the given pDivisibleBy
45*/
46int redGrFirst (LObject* h,kStrategy strat)
47{
48  int at,reddeg,d,i;
49  int pass = 0;
50  int j = 0;
51
52  d = pFDeg((*h).p,currRing)+(*h).ecart;
53  reddeg = strat->LazyDegree+d;
54  loop
55  {
56    if (j > strat->sl)
57    {
58      if (TEST_OPT_DEBUG) PrintLn();
59      return 0;
60    }
61    if (TEST_OPT_DEBUG) Print("%d",j);
62    if (pDivisibleBy(strat->S[j],(*h).p))
63    {
64      if (TEST_OPT_DEBUG) PrintS("+\n");
65      /*
66      * the polynomial to reduce with is;
67      * T[j].p
68      */
69      if (!TEST_OPT_INTSTRATEGY)
70        pNorm(strat->S[j]);
71      if (TEST_OPT_DEBUG)
72      {
73        wrp(h->p);
74        PrintS(" with ");
75        wrp(strat->S[j]);
76      }
77      (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p, NULL, currRing);
78      //spSpolyRed(strat->T[j].p,(*h).p,strat->kNoether);
79
80      if (TEST_OPT_DEBUG)
81      {
82        PrintS(" to ");
83        wrp(h->p);
84      }
85      if ((*h).p == NULL)
86      {
87        if (h->lcm!=NULL) p_LmFree((*h).lcm, currRing);
88        return 0;
89      }
90      if (TEST_OPT_INTSTRATEGY)
91      {
92        if (rField_is_Zp_a()) pContent(h->p);
93        else pCleardenom(h->p);// also does a pContent
94      }
95      /*computes the ecart*/
96      d = pLDeg((*h).p,&((*h).length),currRing);
97      (*h).FDeg=pFDeg((*h).p,currRing);
98      (*h).ecart = d-(*h).FDeg; /*pFDeg((*h).p);*/
99      if ((strat->syzComp!=0) && !strat->honey)
100      {
101        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
102        {
103          if (TEST_OPT_DEBUG) PrintS(" > sysComp\n");
104          return 0;
105        }
106      }
107      /*- try to reduce the s-polynomial -*/
108      pass++;
109      /*
110      *test whether the polynomial should go to the lazyset L
111      *-if the degree jumps
112      *-if the number of pre-defined reductions jumps
113      */
114      if ((strat->Ll >= 0)
115      && ((d >= reddeg) || (pass > strat->LazyPass))
116      && !strat->homog)
117      {
118        at = strat->posInL(strat->L,strat->Ll,h,strat);
119        if (at <= strat->Ll)
120        {
121          i=strat->sl+1;
122          do
123          {
124            i--;
125            if (i<0) return 0;
126          } while (!pDivisibleBy(strat->S[i],(*h).p));
127          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
128          if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
129          (*h).p = NULL;
130          return 0;
131        }
132      }
133      if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
134      {
135        reddeg = d+1;
136        Print(".%d",d);mflush();
137      }
138      j = 0;
139      if TEST_OPT_DEBUG PrintLn();
140    }
141    else
142    {
143      if (TEST_OPT_DEBUG) PrintS("-");
144      j++;
145    }
146  }
147}
148
149/*2
150*  reduction procedure for the homogeneous case
151*  and the case of a degree-ordering
152*/
153static int nc_redHomog (LObject* h,kStrategy strat)
154{
155  if (strat->tl<0)
156  {
157    enterT((*h),strat);
158    return 1;
159  }
160
161  int j = 0;
162
163  if (TEST_OPT_DEBUG)
164  {
165    PrintS("red:");
166    wrp(h->p);
167    PrintS(" ");
168  }
169  loop
170  {
171    if (TEST_OPT_DEBUG) Print("%d",j);
172    if (pDivisibleBy(strat->S[j],(*h).p))
173    {
174      if (TEST_OPT_DEBUG)
175      {
176        PrintS("+\nwith ");
177        wrp(strat->S[j]);
178      }
179      /*- compute the s-polynomial -*/
180      (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p,strat->kNoether,currRing);
181      if ((*h).p == NULL)
182      {
183        if (TEST_OPT_DEBUG) PrintS(" to 0\n");
184        if (h->lcm!=NULL) pLmFree((*h).lcm);
185        (*h).lcm=NULL;
186        return 0;
187      }
188/*
189*      else if (strat->syzComp)
190*      {
191*        if (pMinComp((*h).p) > strat->syzComp)
192*        {
193*          enterT((*h),strat);
194*          return;
195*        }
196*      }
197*/
198      /*- try to reduce the s-polynomial -*/
199      j = 0;
200    }
201    else
202    {
203      if (j >= strat->sl)
204      {
205        enterT((*h),strat);
206        return 1;
207      }
208      j++;
209    }
210  }
211}
212
213/*2
214*  reduction procedure for the homogeneous case
215*  and the case of a degree-ordering
216*/
217static int nc_redHomog0 (LObject* h,kStrategy strat)
218{
219  if (strat->tl<0)
220  {
221    enterT((*h),strat);
222    return 0;
223  }
224
225  int j = 0;
226  int k = 0;
227
228  if (TEST_OPT_DEBUG)
229  {
230    PrintS("red:");
231    wrp(h->p);
232    PrintS(" ");
233  }
234  loop
235  {
236    if (TEST_OPT_DEBUG) Print("%d",j);
237    if (pDivisibleBy(strat->T[j].p,(*h).p))
238    {
239      if (TEST_OPT_DEBUG)
240      {
241        PrintS("+\nwith ");
242        wrp(strat->S[j]);
243      }
244      /*- compute the s-polynomial -*/
245      (*h).p = nc_ReduceSpoly(strat->T[j].p,(*h).p,strat->kNoether,currRing);
246      if ((*h).p == NULL)
247      {
248        if (TEST_OPT_DEBUG) PrintS(" to 0\n");
249        if (h->lcm!=NULL) pLmFree((*h).lcm);
250        (*h).lcm=NULL;
251        return 0;
252      }
253      else
254      {
255        if (TEST_OPT_INTSTRATEGY)
256        {
257          if (rField_is_Zp_a()) pContent(h->p);
258          else pCleardenom(h->p);// also does a pContent
259        }
260        if (strat->syzComp!=0)
261        {
262          if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
263          {
264/*
265*           (*h).length=pLength0((*h).p);
266*/
267            enterT((*h),strat);
268            return 0;
269          }
270        }
271      }
272      /*- try to reduce the s-polynomial -*/
273      j = 0;
274    }
275    else
276    {
277      if (j >= strat->tl)
278      {
279        if (TEST_OPT_INTSTRATEGY)
280        {
281          if (rField_is_Zp_a()) pContent(h->p);
282          else pCleardenom(h->p);// also does a pContent
283        }
284/*
285*       (*h).length=pLength0((*h).p);
286*/
287        enterT((*h),strat);
288        return 0;
289      }
290      j++;
291    }
292  }
293}
294
295/*2
296*  reduction procedure for the inhomogeneous case
297*  and not a degree-ordering
298*/
299static int nc_redLazy (LObject* h,kStrategy strat)
300{
301  if (strat->tl<0)
302  {
303    enterT((*h),strat);
304    return 0;
305  }
306
307  int at,d,i;
308  int j = 0;
309  int pass = 0;
310  int reddeg = pFDeg((*h).p,currRing);
311
312  if (TEST_OPT_DEBUG)
313  {
314    PrintS("red:");
315    wrp(h->p);
316    PrintS(" ");
317  }
318  loop
319  {
320    if (TEST_OPT_DEBUG) Print("%d",j);
321    if (pDivisibleBy(strat->S[j],(*h).p))
322    {
323      if (TEST_OPT_DEBUG)
324      {
325        PrintS("+\nwith ");
326        wrp(strat->S[j]);
327      }
328      /*- compute the s-polynomial -*/
329      (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p,strat->kNoether,currRing);
330      if ((*h).p == NULL)
331      {
332        if (TEST_OPT_DEBUG) PrintS(" to 0\n");
333        if (h->lcm!=NULL) pLmFree((*h).lcm);
334        (*h).lcm=NULL;
335        return 0;
336      }
337//      else if (strat->syzComp)
338//      {
339//        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
340//        {
341//          if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
342//          if (TEST_OPT_INTSTRATEGY) pContent(h->p);
343//          enterTBba((*h),strat->tl+1,strat);
344//          return;
345//        }
346//      }
347      else
348      {
349        if (TEST_OPT_DEBUG)
350        {
351          PrintS("to:");
352          wrp((*h).p);
353          PrintLn();
354        }
355        if (TEST_OPT_INTSTRATEGY)
356        {
357          pContent(h->p);
358          //pCleardenom(h->p);// also does a pContent
359        }
360      }
361      /*- try to reduce the s-polynomial -*/
362      pass++;
363      d = pFDeg((*h).p,currRing);
364      if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
365      {
366        at = posInL11(strat->L,strat->Ll,h,strat);
367        if (at <= strat->Ll)
368        {
369          i=strat->sl+1;
370          do
371          {
372            i--;
373            if (i<0)
374            {
375              enterT((*h),strat);
376              return 0;
377            }
378          }
379          while (!pDivisibleBy(strat->S[i],(*h).p));
380          if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
381          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
382          (*h).p = NULL;
383          return 0;
384        }
385      }
386      else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d != reddeg))
387      {
388        Print(".%d",d);mflush();
389        reddeg = d;
390      }
391      j = 0;
392    }
393    else
394    {
395      if (TEST_OPT_DEBUG) PrintS("-");
396      if (j >= strat->sl)
397      {
398        if (TEST_OPT_DEBUG) PrintLn();
399        if (TEST_OPT_INTSTRATEGY)
400        {
401          if (rField_is_Zp_a()) pContent(h->p);
402          else pCleardenom(h->p);// also does a pContent
403        }
404        enterT((*h),strat);
405        return 0;
406      }
407      j++;
408    }
409  }
410}
411
412/*2
413*  reduction procedure for the sugar-strategy (honey)
414* reduces h with elements from T choosing first possible
415* element in T with respect to the given ecart
416*/
417static int nc_redHoney (LObject*  h,kStrategy strat)
418{
419  if (strat->tl<0)
420  {
421    enterT((*h),strat);
422    return 0;
423  }
424
425  poly pi;
426  int i,j,at,reddeg,d,pass,ei;
427
428  pass = j = 0;
429  d = reddeg = pFDeg((*h).p,currRing)+(*h).ecart;
430  if (TEST_OPT_DEBUG)
431  {
432    PrintS("red:");
433    wrp((*h).p);
434  }
435  loop
436  {
437    if (TEST_OPT_DEBUG) Print("%d",j);
438    if (pDivisibleBy(strat->T[j].p,(*h).p))
439    {
440      if (TEST_OPT_DEBUG) PrintS("+");
441      pi = strat->T[j].p;
442      ei = strat->T[j].ecart;
443      /*
444      * the polynomial to reduce with (up to the moment) is;
445      * pi with ecart ei
446      */
447      i = j;
448      loop
449      {
450        /*- takes the first possible with respect to ecart -*/
451        i++;
452        if (i > strat->tl)
453          break;
454        if ((!BTEST1(20)) && (ei <= (*h).ecart))
455          break;
456        if (TEST_OPT_DEBUG) Print("%d",i);
457        if ((strat->T[i].ecart < ei) && pDivisibleBy(strat->T[i].p,(*h).p))
458        {
459          if (TEST_OPT_DEBUG) PrintS("+");
460          /*
461          * the polynomial to reduce with is now;
462          */
463          pi = strat->T[i].p;
464          ei = strat->T[i].ecart;
465        }
466        else if (TEST_OPT_DEBUG) PrintS("-");
467      }
468
469      /*
470      * end of search: have to reduce with pi
471      */
472      if (ei > (*h).ecart)
473      {
474        /*
475        * It is not possible to reduce h with smaller ecart;
476        * if possible h goes to the lazy-set L,i.e
477        * if its position in L would be not the last one
478        */
479        if (strat->Ll >= 0) /* L is not empty */
480        {
481          at = strat->posInL(strat->L,strat->Ll,h,strat);
482          if(at <= strat->Ll)
483          /*- h will not become the next element to reduce -*/
484          {
485            enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
486            if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at);
487            (*h).p = NULL;
488            return 0;
489          }
490        }
491      }
492      if (TEST_OPT_DEBUG)
493      {
494        PrintS("\nwith ");
495        wrp(pi);
496      }
497      if (strat->fromT)
498      {
499        strat->fromT=FALSE;
500        (*h).p = nc_ReduceSpolyNew(pi,(*h).p,strat->kNoether,currRing);
501      }
502      else
503        (*h).p = nc_ReduceSpoly(pi,(*h).p,strat->kNoether,currRing);
504      if (TEST_OPT_DEBUG)
505      {
506        PrintS(" to ");
507        wrp((*h).p);
508        PrintLn();
509      }
510      if ((*h).p == NULL)
511      {
512        if (h->lcm!=NULL) pLmFree((*h).lcm);
513        (*h).lcm=NULL;
514        return 0;
515      }
516      if (TEST_OPT_INTSTRATEGY)
517      {
518        //pContent(h->p);
519        pCleardenom(h->p);// also does a pContent
520      }
521      /* compute the ecart */
522      if (ei <= (*h).ecart)
523        (*h).ecart = d-pFDeg((*h).p,currRing);
524      else
525        (*h).ecart = d-pFDeg((*h).p,currRing)+ei-(*h).ecart;
526//      if (strat->syzComp)
527//      {
528//        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
529//        {
530//          if (TEST_OPT_DEBUG)
531//            PrintS("  >syzComp\n");
532//          if (TEST_OPT_INTSTRATEGY) pContent(h->p);
533//          at=strat->posInT(strat->T,strat->tl,(*h));
534//          enterTBba((*h),at,strat);
535//          return;
536//        }
537//      }
538      /*
539      * try to reduce the s-polynomial h
540      *test first whether h should go to the lazyset L
541      *-if the degree jumps
542      *-if the number of pre-defined reductions jumps
543      */
544      pass++;
545      d = pFDeg((*h).p,currRing)+(*h).ecart;
546      if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
547      {
548        at = strat->posInL(strat->L,strat->Ll,h,strat);
549        if (at <= strat->Ll)
550        {
551          /*test if h is already standardbasis element*/
552          i=strat->sl+1;
553          do
554          {
555            i--;
556            if (i<0)
557            {
558              enterT((*h),strat);
559              return 0;
560            }
561          } while (!pDivisibleBy(strat->S[i],(*h).p));
562          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
563          if (TEST_OPT_DEBUG)
564            Print(" degree jumped: -> L%d\n",at);
565          (*h).p = NULL;
566          return 0;
567        }
568      }
569      else if (TEST_OPT_PROT && (strat->Ll < 0) && (d > reddeg))
570      {
571        reddeg = d;
572        Print(".%d",d); mflush();
573      }
574      j = 0;
575    }
576    else
577    {
578      if (TEST_OPT_DEBUG) PrintS("-");
579      if (j >= strat->tl)
580      {
581        if (TEST_OPT_DEBUG) PrintLn();
582        if (TEST_OPT_INTSTRATEGY)
583        {
584          //pContent(h->p);
585          pCleardenom(h->p);// also does a pContent
586        }
587        enterT((*h),strat);
588        return 0;
589      }
590      j++;
591    }
592  }
593}
594
595/*2
596*  reduction procedure for tests only
597*  reduces with elements from T and chooses the best possible
598*/
599static int nc_redBest (LObject*  h,kStrategy strat)
600{
601  if (strat->tl<0)
602  {
603    enterT((*h),strat);
604    return 0;
605  }
606
607  int j,jbest,at,reddeg,d,pass;
608  poly     p,ph;
609  pass = j = 0;
610
611  if (strat->honey)
612    reddeg = pFDeg((*h).p,currRing)+(*h).ecart;
613  else
614    reddeg = pFDeg((*h).p,currRing);
615  loop
616  {
617    if (pDivisibleBy(strat->T[j].p,(*h).p))
618    {
619      /* compute the s-polynomial */
620      if (!TEST_OPT_INTSTRATEGY) pNorm((*h).p);
621#ifdef SDRING
622      // spSpolyShortBba will not work in the SRING case
623      if (pSDRING)
624      {
625        p=spSpolyCreate(strat->T[j].p,(*h).p,strat->kNoether);
626        if (p!=NULL) pDelete(&pNext(p));
627      }
628      else
629#endif
630      p = nc_CreateShortSpoly(strat->T[j].p,(*h).p);
631      /* computes only the first monomial of the spoly  */
632      if (p)
633      {
634        jbest = j;
635        /* looking for the best possible reduction */
636        if ((strat->syzComp==0) || (pMinComp(p) <= strat->syzComp))
637        {
638          loop
639          {
640            j++;
641            if (j > strat->tl)
642              break;
643            if (pDivisibleBy(strat->T[j].p,(*h).p))
644            {
645#ifdef SDRING
646              // spSpolyShortBba will not work in the SRING case
647              if (pSDRING)
648              {
649                ph=spSpolyCreate(strat->T[j].p,(*h).p,strat->kNoether);
650                if (ph!=NULL) pDelete(&pNext(ph));
651              }
652              else
653#endif
654              ph = nc_CreateShortSpoly(strat->T[j].p,(*h).p);
655              if (ph==NULL)
656              {
657                pLmFree(p);
658                pDelete(&((*h).p));
659                if (h->lcm!=NULL)
660                {
661                  pLmFree((*h).lcm);
662                  (*h).lcm=NULL;
663                }
664                return 0;
665              }
666              else if (pLmCmp(ph,p) == -1)
667              {
668                pLmFree(p);
669                p = ph;
670                jbest = j;
671              }
672              else
673              {
674                pLmFree(ph);
675              }
676            }
677          }
678        }
679        pLmFree(p);
680        (*h).p = nc_ReduceSpoly(strat->T[jbest].p,(*h).p,strat->kNoether,currRing);
681      }
682      else
683      {
684        if (h->lcm!=NULL)
685        {
686          pLmFree((*h).lcm);
687          (*h).lcm=NULL;
688        }
689        (*h).p = NULL;
690        return 0;
691      }
692      if (strat->honey && pLexOrder)
693        strat->initEcart(h);
694      /* h.length:=l; */
695      /* try to reduce the s-polynomial */
696//      if (strat->syzComp)
697//      {
698//        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
699//        {
700//          if (TEST_OPT_DEBUG)
701//            PrintS(" >syzComp\n");
702//          if (TEST_OPT_INTSTRATEGY) pContent(h->p);
703//          at=strat->posInT(strat->T,strat->tl,(*h));
704//          enterTBba((*h),at,strat);
705//          return;
706//        }
707//      }
708      if (strat->honey || pLexOrder)
709      {
710        pass++;
711        d = pFDeg((*h).p,currRing);
712        if (strat->honey)
713          d += (*h).ecart;
714        if ((strat->Ll >= 0) && ((pass > strat->LazyPass) || (d > reddeg)))
715        {
716          at = strat->posInL(strat->L,strat->Ll,h,strat);
717          if (at <= strat->Ll)
718          {
719            enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
720            (*h).p = NULL;
721            return 0;
722          }
723        }
724        else if (TEST_OPT_PROT && (strat->Ll < 0) && (d != reddeg))
725        {
726          reddeg = d;
727          Print("%d.");
728          mflush();
729        }
730      }
731      j = 0;
732    }
733    else
734    {
735      if (j >= strat->tl)
736      {
737        if (TEST_OPT_INTSTRATEGY)
738        {
739          //pContent(h->p);
740          pCleardenom(h->p);// also does a pContent
741        }
742        enterT((*h),strat);
743        return 0;
744      }
745      j++;
746    }
747  }
748}
749
750static void gr_initBba(ideal F,kStrategy strat)
751{
752  int i;
753  idhdl h;
754 /* setting global variables ------------------- */
755  strat->enterS = enterSBba;
756  if ((BTEST1(20)) && (!strat->honey))
757    strat->red = nc_redBest;
758  else if (strat->honey)
759    strat->red = nc_redHoney;
760  else if (pLexOrder && !strat->homog)
761    strat->red = nc_redLazy;
762  else if (TEST_OPT_INTSTRATEGY && strat->homog)
763    strat->red = nc_redHomog0;
764  else
765    strat->red = nc_redHomog;
766  if (rIsPluralRing(currRing))
767  {
768    strat->red = redGrFirst;
769  }
770  if (pLexOrder && strat->honey)
771    strat->initEcart = initEcartNormal;
772  else
773    strat->initEcart = initEcartBBA;
774  if (strat->honey)
775    strat->initEcartPair = initEcartPairMora;
776  else
777    strat->initEcartPair = initEcartPairBba;
778  strat->kIdeal = NULL;
779  //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
780  //else              strat->kIdeal->rtyp=MODUL_CMD;
781  //strat->kIdeal->data=(void *)strat->Shdl;
782  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
783  {
784     //interred  machen   Aenderung
785     pFDegOld=pFDeg;
786     pLDegOld=pLDeg;
787  //   h=ggetid("ecart");
788  //   if ((h!=NULL) && (IDTYP(h)==INTVEC_CMD))
789  //   {
790  //     ecartWeights=iv2array(IDINTVEC(h));
791  //   }
792  //   else
793    {
794      ecartWeights=(short *)omAlloc((pVariables+1)*sizeof(short));
795      /*uses automatic computation of the ecartWeights to set them*/
796      kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
797    }
798    pFDeg=totaldegreeWecart;
799    pLDeg=maxdegreeWecart;
800    for(i=1; i<=pVariables; i++)
801      Print(" %d",ecartWeights[i]);
802    PrintLn();
803    mflush();
804  }
805}
806
807ideal gr_bba (ideal F, ideal Q, kStrategy strat)
808{
809  intvec *w=NULL;
810  intvec *hilb=NULL;
811  int   srmax,lrmax;
812  int   olddeg,reduc;
813  int red_result=1;
814  int hilbeledeg=1,hilbcount=0,minimcnt=0;
815
816  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
817  // initHilbCrit(F,Q,&hilb,strat);
818  /* in plural we don't need Hilb yet */
819  gr_initBba(F,strat);
820  initBuchMoraPos(strat);
821  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
822  /*Shdl=*/initBuchMora(F, Q,strat);
823  strat->posInT=posInT110;
824  srmax = strat->sl;
825  reduc = olddeg = lrmax = 0;
826  /* compute------------------------------------------------------- */
827  while (strat->Ll >= 0)
828  {
829    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
830    if (TEST_OPT_DEBUG) messageSets(strat);
831    if (strat->Ll== 0) strat->interpt=TRUE;
832    if (TEST_OPT_DEGBOUND
833    && ((strat->honey
834    && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
835       || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
836    {
837      /*
838      *stops computation if
839      * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
840      *a predefined number Kstd1_deg
841      */
842      while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
843      break;
844    }
845    /* picks the last element from the lazyset L */
846    strat->P = strat->L[strat->Ll];
847    strat->Ll--;
848    //kTest(strat);
849    if (pNext(strat->P.p) == strat->tail)
850    {
851      /* deletes the short spoly and computes */
852      pLmFree(strat->P.p);
853      /* the real one */
854      if ((currRing->nc->type==nc_lie) && pHasNotCF(strat->P.p1,strat->P.p2)) /* prod crit */
855      {
856        strat->cp++;
857        /* prod.crit itself in nc_CreateSpoly */
858      }
859      strat->P.p = nc_CreateSpoly(strat->P.p1,strat->P.p2,strat->kNoether,currRing);
860    }
861    if (strat->P.p != NULL)
862    {
863      if (TEST_OPT_PROT)
864      message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
865              &olddeg,&reduc,strat, red_result);
866      /* reduction of the element chosen from L */
867      strat->red(&strat->P,strat);
868    }
869    if (strat->P.p != NULL)
870    {
871          /* statistic */
872          if (TEST_OPT_PROT)
873          {
874            PrintS("s\n");
875          }
876          /* enter P.p into s and L */
877          {
878            strat->P.sev=0;
879            int pos=posInS(strat,strat->sl,strat->P.p, strat->P.ecart);
880            {
881              if (TEST_OPT_INTSTRATEGY)
882              {
883                if ((strat->syzComp==0)||(!strat->homog))
884                {
885                  strat->P.p = redtailBba(strat->P.p,pos-1,strat);
886                }
887                pCleardenom(strat->P.p);
888              }
889              else
890              {
891                pNorm(strat->P.p);
892                if ((strat->syzComp==0)||(!strat->homog))
893                {
894                  strat->P.p = redtailBba(strat->P.p,pos-1,strat);
895                }
896              }
897              // PLURAL debug
898              /* should be used only internally!!! */
899
900              //pWrite(strat->P.p);
901
902              if (TEST_OPT_DEBUG)
903              {
904                PrintS("new s:");
905                wrp(strat->P.p);
906                PrintLn();
907              }
908              // kTest(strat);
909              //
910              enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat);
911              if (strat->sl==-1) pos=0;
912              else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
913              strat->enterS(strat->P,pos,strat,-1);
914            }
915            if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
916          }
917          if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
918      if (strat->sl>srmax) srmax = strat->sl;
919    }
920#ifdef KDEBUG
921    strat->P.lcm=NULL;
922#endif
923    //kTest(strat);
924  }
925  if (TEST_OPT_DEBUG) messageSets(strat);
926  /* complete reduction of the standard basis--------- */
927  if (TEST_OPT_REDSB) completeReduce(strat);
928  /* release temp data-------------------------------- */
929  exitBuchMora(strat);
930  if (TEST_OPT_WEIGHTM)
931  {
932    pFDeg=pFDegOld;
933    pLDeg=pLDegOld;
934    if (ecartWeights)
935    {
936      omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
937      ecartWeights=NULL;
938    }
939  }
940  if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat);
941  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
942#ifdef PDEBUG
943/* for counting number of pairs [enterL] in Plural */
944/*   extern int zaehler; */
945/*   Print("Total pairs considered:%d\n",zaehler); zaehler=0; */
946#endif PDEBUG
947  return (strat->Shdl);
948}
949#endif
Note: See TracBrowser for help on using the repository browser.