source: git/kernel/gr_kstd2.cc @ f2f460

spielwiese
Last change on this file since f2f460 was f2f460, checked in by Hans Schönemann <hannes@…>, 17 years ago
*hannes: PLURAL TEST git-svn-id: file:///usr/local/Singular/svn/trunk@9684 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 23.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: gr_kstd2.cc,v 1.10 2007-01-11 10:10:37 Singular Exp $ */
5/*
6*  ABSTRACT -  Kernel: noncomm. alg. of Buchberger
7*/
8
9#include "mod2.h"
10
11#ifdef HAVE_PLURAL
12
13
14#include "omalloc.h"
15#include "polys.h"
16#include "ideals.h"
17#include "febase.h"
18#include "kutil.h"
19#include "kstd1.h"
20#include "khstd.h"
21//#include "spolys.h"
22//#include "cntrlc.h"
23#include "weight.h"
24#include "intvec.h"
25#include "structs.h"
26#include "gring.h"
27#include "sca.h"
28
29#if 0
30/*3
31* reduction of p2 with p1
32* do not destroy p1 and p2
33* p1 divides p2 -> for use in NF algorithm
34*/
35poly gnc_ReduceSpolyNew(const poly p1, poly p2/*,poly spNoether*/, const ring r)
36{
37  return(nc_ReduceSPoly(p1,p_Copy(p2,r)/*,spNoether*/,r));
38}
39#endif
40
41/*2
42*reduces h with elements from T choosing  the first possible
43* element in t with respect to the given pDivisibleBy
44*/
45int redGrFirst (LObject* h,kStrategy strat)
46{
47  int at,reddeg,d,i;
48  int pass = 0;
49  int j = 0;
50
51  d = pFDeg((*h).p,currRing)+(*h).ecart;
52  reddeg = strat->LazyDegree+d;
53  loop
54  {
55    if (j > strat->sl)
56    {
57      if (TEST_OPT_DEBUG) PrintLn();
58      return 0;
59    }
60    if (TEST_OPT_DEBUG) Print("%d",j);
61    if (pDivisibleBy(strat->S[j],(*h).p))
62    {
63      if (TEST_OPT_DEBUG) PrintS("+\n");
64      /*
65      * the polynomial to reduce with is;
66      * T[j].p
67      */
68      if (!TEST_OPT_INTSTRATEGY)
69        pNorm(strat->S[j]);
70      if (TEST_OPT_DEBUG)
71      {
72        wrp(h->p);
73        PrintS(" with ");
74        wrp(strat->S[j]);
75      }
76      (*h).p = nc_ReduceSPoly(strat->S[j],(*h).p, currRing);
77      //spSpolyRed(strat->T[j].p,(*h).p,strat->kNoether);
78
79      if (TEST_OPT_DEBUG)
80      {
81        PrintS(" to ");
82        wrp(h->p);
83      }
84      if ((*h).p == NULL)
85      {
86        if (h->lcm!=NULL) p_LmFree((*h).lcm, currRing);
87        return 0;
88      }
89      if (TEST_OPT_INTSTRATEGY)
90      {
91        if (rField_is_Zp_a()) pContent(h->p);
92        else pCleardenom(h->p);// also does a pContent
93      }
94      /*computes the ecart*/
95      d = pLDeg((*h).p,&((*h).length),currRing);
96      (*h).FDeg=pFDeg((*h).p,currRing);
97      (*h).ecart = d-(*h).FDeg; /*pFDeg((*h).p);*/
98      if ((strat->syzComp!=0) && !strat->honey)
99      {
100        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
101        {
102          if (TEST_OPT_DEBUG) PrintS(" > sysComp\n");
103          return 0;
104        }
105      }
106      /*- try to reduce the s-polynomial -*/
107      pass++;
108      /*
109      *test whether the polynomial should go to the lazyset L
110      *-if the degree jumps
111      *-if the number of pre-defined reductions jumps
112      */
113      if ((strat->Ll >= 0)
114      && ((d >= reddeg) || (pass > strat->LazyPass))
115      && !strat->homog)
116      {
117        at = strat->posInL(strat->L,strat->Ll,h,strat);
118        if (at <= strat->Ll)
119        {
120          i=strat->sl+1;
121          do
122          {
123            i--;
124            if (i<0) return 0;
125          } while (!pDivisibleBy(strat->S[i],(*h).p));
126          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
127          if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
128          (*h).p = NULL;
129          return 0;
130        }
131      }
132      if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
133      {
134        reddeg = d+1;
135        Print(".%d",d);mflush();
136      }
137      j = 0;
138      if TEST_OPT_DEBUG PrintLn();
139    }
140    else
141    {
142      if (TEST_OPT_DEBUG) PrintS("-");
143      j++;
144    }
145  }
146}
147
148/*2
149*  reduction procedure for the homogeneous case
150*  and the case of a degree-ordering
151*/
152static int nc_redHomog (LObject* h,kStrategy strat)
153{
154  if (strat->tl<0)
155  {
156    enterT((*h),strat);
157    return 1;
158  }
159
160  int j = 0;
161
162  if (TEST_OPT_DEBUG)
163  {
164    PrintS("red:");
165    wrp(h->p);
166    PrintS(" ");
167  }
168  loop
169  {
170    if (TEST_OPT_DEBUG) Print("%d",j);
171    if (pDivisibleBy(strat->S[j],(*h).p))
172    {
173      if (TEST_OPT_DEBUG)
174      {
175        PrintS("+\nwith ");
176        wrp(strat->S[j]);
177      }
178      /*- compute the s-polynomial -*/
179      (*h).p = nc_ReduceSPoly(strat->S[j],(*h).p/*,strat->kNoether*/,currRing);
180      if ((*h).p == NULL)
181      {
182        if (TEST_OPT_DEBUG) PrintS(" to 0\n");
183        if (h->lcm!=NULL) pLmFree((*h).lcm);
184        (*h).lcm=NULL;
185        return 0;
186      }
187/*
188*      else if (strat->syzComp)
189*      {
190*        if (pMinComp((*h).p) > strat->syzComp)
191*        {
192*          enterT((*h),strat);
193*          return;
194*        }
195*      }
196*/
197      /*- try to reduce the s-polynomial -*/
198      j = 0;
199    }
200    else
201    {
202      if (j >= strat->sl)
203      {
204        enterT((*h),strat);
205        return 1;
206      }
207      j++;
208    }
209  }
210}
211
212#if 0
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 = gnc_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
750#endif
751
752void gr_initBba(ideal F, kStrategy strat)
753{
754  assume(rIsPluralRing(currRing));
755
756  int i;
757  idhdl h;
758 /* setting global variables ------------------- */
759  strat->enterS = enterSBba;
760
761/*
762  if ((BTEST1(20)) && (!strat->honey))
763    strat->red = nc_redBest;
764  else if (strat->honey)
765    strat->red = nc_redHoney;
766  else if (pLexOrder && !strat->homog)
767    strat->red = nc_redLazy;
768  else if (TEST_OPT_INTSTRATEGY && strat->homog)
769    strat->red = nc_redHomog0;
770  else
771    strat->red = nc_redHomog;
772*/
773
774//   if (rIsPluralRing(currRing))
775    strat->red = redGrFirst;
776
777  if (pLexOrder && strat->honey)
778    strat->initEcart = initEcartNormal;
779  else
780    strat->initEcart = initEcartBBA;
781  if (strat->honey)
782    strat->initEcartPair = initEcartPairMora;
783  else
784    strat->initEcartPair = initEcartPairBba;
785  strat->kIdeal = NULL;
786  //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
787  //else              strat->kIdeal->rtyp=MODUL_CMD;
788  //strat->kIdeal->data=(void *)strat->Shdl;
789  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
790  {
791     //interred  machen   Aenderung
792     pFDegOld=pFDeg;
793     pLDegOld=pLDeg;
794  //   h=ggetid("ecart");
795  //   if ((h!=NULL) && (IDTYP(h)==INTVEC_CMD))
796  //   {
797  //     ecartWeights=iv2array(IDINTVEC(h));
798  //   }
799  //   else
800    {
801      ecartWeights=(short *)omAlloc((pVariables+1)*sizeof(short));
802      /*uses automatic computation of the ecartWeights to set them*/
803      kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
804    }
805    pFDeg=totaldegreeWecart;
806    pLDeg=maxdegreeWecart;
807    for(i=1; i<=pVariables; i++)
808      Print(" %d",ecartWeights[i]);
809    PrintLn();
810    mflush();
811  }
812}
813
814ideal gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat)
815{
816  assume(pOrdSgn != -1); // no mora!!! it terminates only for global ordering!!! (?)
817
818  intvec *w=NULL;
819  intvec *hilb=NULL;
820  int   srmax,lrmax;
821  int   olddeg,reduc;
822  int red_result=1;
823  int hilbeledeg=1,hilbcount=0,minimcnt=0;
824
825  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
826  // initHilbCrit(F,Q,&hilb,strat);
827  /* in plural we don't need Hilb yet */
828  gr_initBba(F,strat);
829  initBuchMoraPos(strat);
830  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
831  /*Shdl=*/initBuchMora(F, Q,strat);
832  strat->posInT=posInT110;
833  srmax = strat->sl;
834  reduc = olddeg = lrmax = 0;
835  /* compute------------------------------------------------------- */
836  while (strat->Ll >= 0)
837  {
838    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
839    if (TEST_OPT_DEBUG) messageSets(strat);
840    if (strat->Ll== 0) strat->interpt=TRUE;
841    if (TEST_OPT_DEGBOUND
842    && ((strat->honey
843    && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
844       || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
845    {
846      /*
847      *stops computation if
848      * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
849      *a predefined number Kstd1_deg
850      */
851      while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
852      break;
853    }
854    /* picks the last element from the lazyset L */
855    strat->P = strat->L[strat->Ll];
856    strat->Ll--;
857    //kTest(strat);
858    if (pNext(strat->P.p) == strat->tail)
859    {
860      /* deletes the short spoly and computes */
861      pLmFree(strat->P.p);
862      /* the real one */
863      if ((currRing->nc->type==nc_lie) && pHasNotCF(strat->P.p1,strat->P.p2)) /* prod crit */
864      {
865        strat->cp++;
866        /* prod.crit itself in nc_CreateSpoly */
867      }
868      strat->P.p = nc_SPoly(strat->P.p1,strat->P.p2/*,strat->kNoether*/,currRing);
869    }
870    if (strat->P.p != NULL)
871    {
872      if (TEST_OPT_PROT)
873      message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
874              &olddeg,&reduc,strat, red_result);
875      /* reduction of the element chosen from L */
876      strat->red(&strat->P,strat);
877    }
878    if (strat->P.p != NULL)
879    {
880          /* statistic */
881          if (TEST_OPT_PROT)
882          {
883            PrintS("s\n");
884          }
885          /* enter P.p into s and L */
886          {
887            strat->P.sev=0;
888            int pos=posInS(strat,strat->sl,strat->P.p, strat->P.ecart);
889            {
890              if (TEST_OPT_INTSTRATEGY)
891              {
892                if ((strat->syzComp==0)||(!strat->homog))
893                {
894                  strat->P.p = redtailBba(strat->P.p,pos-1,strat);
895                }
896                pCleardenom(strat->P.p);
897              }
898              else
899              {
900                pNorm(strat->P.p);
901                if ((strat->syzComp==0)||(!strat->homog))
902                {
903                  strat->P.p = redtailBba(strat->P.p,pos-1,strat);
904                }
905              }
906              // PLURAL debug
907              /* should be used only internally!!! */
908
909              //pWrite(strat->P.p);
910
911              if (TEST_OPT_DEBUG)
912              {
913                PrintS("new s:");
914                wrp(strat->P.p);
915                PrintLn();
916              }
917              // kTest(strat);
918              //
919              enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat);
920              if (strat->sl==-1) pos=0;
921              else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
922              strat->enterS(strat->P,pos,strat,-1);
923            }
924            if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
925          }
926          if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
927      if (strat->sl>srmax) srmax = strat->sl;
928    }
929#ifdef KDEBUG
930    strat->P.lcm=NULL;
931#endif
932    //kTest(strat);
933  }
934  if (TEST_OPT_DEBUG) messageSets(strat);
935  /* complete reduction of the standard basis--------- */
936  if (TEST_OPT_REDSB) completeReduce(strat);
937  /* release temp data-------------------------------- */
938  exitBuchMora(strat);
939  if (TEST_OPT_WEIGHTM)
940  {
941    pFDeg=pFDegOld;
942    pLDeg=pLDegOld;
943    if (ecartWeights)
944    {
945      omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
946      ecartWeights=NULL;
947    }
948  }
949  if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat);
950  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
951#ifdef PDEBUG
952/* for counting number of pairs [enterL] in Plural */
953/*   extern int zaehler; */
954/*   Print("Total pairs considered:%d\n",zaehler); zaehler=0; */
955#endif /*PDEBUG*/
956  return (strat->Shdl);
957}
958
959ideal gnc_gr_mora(const ideal, const ideal, const intvec *, const intvec *, kStrategy)
960{
961  PrintS("Sorry, non-commutative mora is not yet implemented!");
962  PrintLn();
963
964  // Not yet!
965  return NULL;
966}
967
968#endif
969
Note: See TracBrowser for help on using the repository browser.