source: git/kernel/gr_kstd2.cc @ 86016d

jengelh-datetimespielwiese
Last change on this file since 86016d was 86016d, checked in by Motsak Oleksandr <motsak@…>, 16 years ago
*motsak: !+!: factors of SCA, debug print for SCA, "kill squares" in std. * : ncRingType, naming, formatting, unified NC setup. git-svn-id: file:///usr/local/Singular/svn/trunk@9792 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 23.6 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: gr_kstd2.cc,v 1.11 2007-01-31 23:51:23 motsak Exp $ */
5/*
6*  ABSTRACT -  Kernel: noncomm. alg. of Buchberger
7*/
8
9#include "mod2.h"
10
11#ifdef HAVE_PLURAL
12
13#define PLURAL_INTERNAL_DECLARATIONS
14
15#include "omalloc.h"
16#include "polys.h"
17#include "ideals.h"
18#include "febase.h"
19#include "kutil.h"
20#include "kstd1.h"
21#include "khstd.h"
22//#include "spolys.h"
23//#include "cntrlc.h"
24#include "weight.h"
25#include "intvec.h"
26#include "structs.h"
27#include "gring.h"
28#include "sca.h"
29
30#if 0
31/*3
32* reduction of p2 with p1
33* do not destroy p1 and p2
34* p1 divides p2 -> for use in NF algorithm
35*/
36poly gnc_ReduceSpolyNew(const poly p1, poly p2/*,poly spNoether*/, const ring r)
37{
38  return(nc_ReduceSPoly(p1,p_Copy(p2,r)/*,spNoether*/,r));
39}
40#endif
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, 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#if 0
214/*2
215*  reduction procedure for the homogeneous case
216*  and the case of a degree-ordering
217*/
218static int nc_redHomog0 (LObject* h,kStrategy strat)
219{
220  if (strat->tl<0)
221  {
222    enterT((*h),strat);
223    return 0;
224  }
225
226  int j = 0;
227  int k = 0;
228
229  if (TEST_OPT_DEBUG)
230  {
231    PrintS("red:");
232    wrp(h->p);
233    PrintS(" ");
234  }
235  loop
236  {
237    if (TEST_OPT_DEBUG) Print("%d",j);
238    if (pDivisibleBy(strat->T[j].p,(*h).p))
239    {
240      if (TEST_OPT_DEBUG)
241      {
242        PrintS("+\nwith ");
243        wrp(strat->S[j]);
244      }
245      /*- compute the s-polynomial -*/
246      (*h).p = nc_ReduceSpoly(strat->T[j].p,(*h).p,strat->kNoether,currRing);
247      if ((*h).p == NULL)
248      {
249        if (TEST_OPT_DEBUG) PrintS(" to 0\n");
250        if (h->lcm!=NULL) pLmFree((*h).lcm);
251        (*h).lcm=NULL;
252        return 0;
253      }
254      else
255      {
256        if (TEST_OPT_INTSTRATEGY)
257        {
258          if (rField_is_Zp_a()) pContent(h->p);
259          else pCleardenom(h->p);// also does a pContent
260        }
261        if (strat->syzComp!=0)
262        {
263          if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
264          {
265/*
266*           (*h).length=pLength0((*h).p);
267*/
268            enterT((*h),strat);
269            return 0;
270          }
271        }
272      }
273      /*- try to reduce the s-polynomial -*/
274      j = 0;
275    }
276    else
277    {
278      if (j >= strat->tl)
279      {
280        if (TEST_OPT_INTSTRATEGY)
281        {
282          if (rField_is_Zp_a()) pContent(h->p);
283          else pCleardenom(h->p);// also does a pContent
284        }
285/*
286*       (*h).length=pLength0((*h).p);
287*/
288        enterT((*h),strat);
289        return 0;
290      }
291      j++;
292    }
293  }
294}
295
296/*2
297*  reduction procedure for the inhomogeneous case
298*  and not a degree-ordering
299*/
300static int nc_redLazy (LObject* h,kStrategy strat)
301{
302  if (strat->tl<0)
303  {
304    enterT((*h),strat);
305    return 0;
306  }
307
308  int at,d,i;
309  int j = 0;
310  int pass = 0;
311  int reddeg = pFDeg((*h).p,currRing);
312
313  if (TEST_OPT_DEBUG)
314  {
315    PrintS("red:");
316    wrp(h->p);
317    PrintS(" ");
318  }
319  loop
320  {
321    if (TEST_OPT_DEBUG) Print("%d",j);
322    if (pDivisibleBy(strat->S[j],(*h).p))
323    {
324      if (TEST_OPT_DEBUG)
325      {
326        PrintS("+\nwith ");
327        wrp(strat->S[j]);
328      }
329      /*- compute the s-polynomial -*/
330      (*h).p = nc_ReduceSpoly(strat->S[j],(*h).p,strat->kNoether,currRing);
331      if ((*h).p == NULL)
332      {
333        if (TEST_OPT_DEBUG) PrintS(" to 0\n");
334        if (h->lcm!=NULL) pLmFree((*h).lcm);
335        (*h).lcm=NULL;
336        return 0;
337      }
338//      else if (strat->syzComp)
339//      {
340//        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
341//        {
342//          if (TEST_OPT_DEBUG) PrintS(" > syzComp\n");
343//          if (TEST_OPT_INTSTRATEGY) pContent(h->p);
344//          enterTBba((*h),strat->tl+1,strat);
345//          return;
346//        }
347//      }
348      else
349      {
350        if (TEST_OPT_DEBUG)
351        {
352          PrintS("to:");
353          wrp((*h).p);
354          PrintLn();
355        }
356        if (TEST_OPT_INTSTRATEGY)
357        {
358          pContent(h->p);
359          //pCleardenom(h->p);// also does a pContent
360        }
361      }
362      /*- try to reduce the s-polynomial -*/
363      pass++;
364      d = pFDeg((*h).p,currRing);
365      if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
366      {
367        at = posInL11(strat->L,strat->Ll,h,strat);
368        if (at <= strat->Ll)
369        {
370          i=strat->sl+1;
371          do
372          {
373            i--;
374            if (i<0)
375            {
376              enterT((*h),strat);
377              return 0;
378            }
379          }
380          while (!pDivisibleBy(strat->S[i],(*h).p));
381          if (TEST_OPT_DEBUG) Print(" ->L[%d]\n",at);
382          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
383          (*h).p = NULL;
384          return 0;
385        }
386      }
387      else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d != reddeg))
388      {
389        Print(".%d",d);mflush();
390        reddeg = d;
391      }
392      j = 0;
393    }
394    else
395    {
396      if (TEST_OPT_DEBUG) PrintS("-");
397      if (j >= strat->sl)
398      {
399        if (TEST_OPT_DEBUG) PrintLn();
400        if (TEST_OPT_INTSTRATEGY)
401        {
402          if (rField_is_Zp_a()) pContent(h->p);
403          else pCleardenom(h->p);// also does a pContent
404        }
405        enterT((*h),strat);
406        return 0;
407      }
408      j++;
409    }
410  }
411}
412
413/*2
414*  reduction procedure for the sugar-strategy (honey)
415* reduces h with elements from T choosing first possible
416* element in T with respect to the given ecart
417*/
418static int nc_redHoney (LObject*  h,kStrategy strat)
419{
420  if (strat->tl<0)
421  {
422    enterT((*h),strat);
423    return 0;
424  }
425
426  poly pi;
427  int i,j,at,reddeg,d,pass,ei;
428
429  pass = j = 0;
430  d = reddeg = pFDeg((*h).p,currRing)+(*h).ecart;
431  if (TEST_OPT_DEBUG)
432  {
433    PrintS("red:");
434    wrp((*h).p);
435  }
436  loop
437  {
438    if (TEST_OPT_DEBUG) Print("%d",j);
439    if (pDivisibleBy(strat->T[j].p,(*h).p))
440    {
441      if (TEST_OPT_DEBUG) PrintS("+");
442      pi = strat->T[j].p;
443      ei = strat->T[j].ecart;
444      /*
445      * the polynomial to reduce with (up to the moment) is;
446      * pi with ecart ei
447      */
448      i = j;
449      loop
450      {
451        /*- takes the first possible with respect to ecart -*/
452        i++;
453        if (i > strat->tl)
454          break;
455        if ((!BTEST1(20)) && (ei <= (*h).ecart))
456          break;
457        if (TEST_OPT_DEBUG) Print("%d",i);
458        if ((strat->T[i].ecart < ei) && pDivisibleBy(strat->T[i].p,(*h).p))
459        {
460          if (TEST_OPT_DEBUG) PrintS("+");
461          /*
462          * the polynomial to reduce with is now;
463          */
464          pi = strat->T[i].p;
465          ei = strat->T[i].ecart;
466        }
467        else if (TEST_OPT_DEBUG) PrintS("-");
468      }
469
470      /*
471      * end of search: have to reduce with pi
472      */
473      if (ei > (*h).ecart)
474      {
475        /*
476        * It is not possible to reduce h with smaller ecart;
477        * if possible h goes to the lazy-set L,i.e
478        * if its position in L would be not the last one
479        */
480        if (strat->Ll >= 0) /* L is not empty */
481        {
482          at = strat->posInL(strat->L,strat->Ll,h,strat);
483          if(at <= strat->Ll)
484          /*- h will not become the next element to reduce -*/
485          {
486            enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
487            if (TEST_OPT_DEBUG) Print(" ecart too big: -> L%d\n",at);
488            (*h).p = NULL;
489            return 0;
490          }
491        }
492      }
493      if (TEST_OPT_DEBUG)
494      {
495        PrintS("\nwith ");
496        wrp(pi);
497      }
498      if (strat->fromT)
499      {
500        strat->fromT=FALSE;
501        (*h).p = gnc_ReduceSpolyNew(pi,(*h).p,strat->kNoether,currRing);
502      }
503      else
504        (*h).p = nc_ReduceSpoly(pi,(*h).p,strat->kNoether,currRing);
505      if (TEST_OPT_DEBUG)
506      {
507        PrintS(" to ");
508        wrp((*h).p);
509        PrintLn();
510      }
511      if ((*h).p == NULL)
512      {
513        if (h->lcm!=NULL) pLmFree((*h).lcm);
514        (*h).lcm=NULL;
515        return 0;
516      }
517      if (TEST_OPT_INTSTRATEGY)
518      {
519        //pContent(h->p);
520        pCleardenom(h->p);// also does a pContent
521      }
522      /* compute the ecart */
523      if (ei <= (*h).ecart)
524        (*h).ecart = d-pFDeg((*h).p,currRing);
525      else
526        (*h).ecart = d-pFDeg((*h).p,currRing)+ei-(*h).ecart;
527//      if (strat->syzComp)
528//      {
529//        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
530//        {
531//          if (TEST_OPT_DEBUG)
532//            PrintS("  >syzComp\n");
533//          if (TEST_OPT_INTSTRATEGY) pContent(h->p);
534//          at=strat->posInT(strat->T,strat->tl,(*h));
535//          enterTBba((*h),at,strat);
536//          return;
537//        }
538//      }
539      /*
540      * try to reduce the s-polynomial h
541      *test first whether h should go to the lazyset L
542      *-if the degree jumps
543      *-if the number of pre-defined reductions jumps
544      */
545      pass++;
546      d = pFDeg((*h).p,currRing)+(*h).ecart;
547      if ((strat->Ll >= 0) && ((d > reddeg) || (pass > strat->LazyPass)))
548      {
549        at = strat->posInL(strat->L,strat->Ll,h,strat);
550        if (at <= strat->Ll)
551        {
552          /*test if h is already standardbasis element*/
553          i=strat->sl+1;
554          do
555          {
556            i--;
557            if (i<0)
558            {
559              enterT((*h),strat);
560              return 0;
561            }
562          } while (!pDivisibleBy(strat->S[i],(*h).p));
563          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
564          if (TEST_OPT_DEBUG)
565            Print(" degree jumped: -> L%d\n",at);
566          (*h).p = NULL;
567          return 0;
568        }
569      }
570      else if (TEST_OPT_PROT && (strat->Ll < 0) && (d > reddeg))
571      {
572        reddeg = d;
573        Print(".%d",d); mflush();
574      }
575      j = 0;
576    }
577    else
578    {
579      if (TEST_OPT_DEBUG) PrintS("-");
580      if (j >= strat->tl)
581      {
582        if (TEST_OPT_DEBUG) PrintLn();
583        if (TEST_OPT_INTSTRATEGY)
584        {
585          //pContent(h->p);
586          pCleardenom(h->p);// also does a pContent
587        }
588        enterT((*h),strat);
589        return 0;
590      }
591      j++;
592    }
593  }
594}
595
596/*2
597*  reduction procedure for tests only
598*  reduces with elements from T and chooses the best possible
599*/
600static int nc_redBest (LObject*  h,kStrategy strat)
601{
602  if (strat->tl<0)
603  {
604    enterT((*h),strat);
605    return 0;
606  }
607
608  int j,jbest,at,reddeg,d,pass;
609  poly     p,ph;
610  pass = j = 0;
611
612  if (strat->honey)
613    reddeg = pFDeg((*h).p,currRing)+(*h).ecart;
614  else
615    reddeg = pFDeg((*h).p,currRing);
616  loop
617  {
618    if (pDivisibleBy(strat->T[j].p,(*h).p))
619    {
620      /* compute the s-polynomial */
621      if (!TEST_OPT_INTSTRATEGY) pNorm((*h).p);
622#ifdef SDRING
623      // spSpolyShortBba will not work in the SRING case
624      if (pSDRING)
625      {
626        p=spSpolyCreate(strat->T[j].p,(*h).p,strat->kNoether);
627        if (p!=NULL) pDelete(&pNext(p));
628      }
629      else
630#endif
631      p = nc_CreateShortSpoly(strat->T[j].p,(*h).p);
632      /* computes only the first monomial of the spoly  */
633      if (p)
634      {
635        jbest = j;
636        /* looking for the best possible reduction */
637        if ((strat->syzComp==0) || (pMinComp(p) <= strat->syzComp))
638        {
639          loop
640          {
641            j++;
642            if (j > strat->tl)
643              break;
644            if (pDivisibleBy(strat->T[j].p,(*h).p))
645            {
646#ifdef SDRING
647              // spSpolyShortBba will not work in the SRING case
648              if (pSDRING)
649              {
650                ph=spSpolyCreate(strat->T[j].p,(*h).p,strat->kNoether);
651                if (ph!=NULL) pDelete(&pNext(ph));
652              }
653              else
654#endif
655              ph = nc_CreateShortSpoly(strat->T[j].p,(*h).p);
656              if (ph==NULL)
657              {
658                pLmFree(p);
659                pDelete(&((*h).p));
660                if (h->lcm!=NULL)
661                {
662                  pLmFree((*h).lcm);
663                  (*h).lcm=NULL;
664                }
665                return 0;
666              }
667              else if (pLmCmp(ph,p) == -1)
668              {
669                pLmFree(p);
670                p = ph;
671                jbest = j;
672              }
673              else
674              {
675                pLmFree(ph);
676              }
677            }
678          }
679        }
680        pLmFree(p);
681        (*h).p = nc_ReduceSpoly(strat->T[jbest].p,(*h).p,strat->kNoether,currRing);
682      }
683      else
684      {
685        if (h->lcm!=NULL)
686        {
687          pLmFree((*h).lcm);
688          (*h).lcm=NULL;
689        }
690        (*h).p = NULL;
691        return 0;
692      }
693      if (strat->honey && pLexOrder)
694        strat->initEcart(h);
695      /* h.length:=l; */
696      /* try to reduce the s-polynomial */
697//      if (strat->syzComp)
698//      {
699//        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
700//        {
701//          if (TEST_OPT_DEBUG)
702//            PrintS(" >syzComp\n");
703//          if (TEST_OPT_INTSTRATEGY) pContent(h->p);
704//          at=strat->posInT(strat->T,strat->tl,(*h));
705//          enterTBba((*h),at,strat);
706//          return;
707//        }
708//      }
709      if (strat->honey || pLexOrder)
710      {
711        pass++;
712        d = pFDeg((*h).p,currRing);
713        if (strat->honey)
714          d += (*h).ecart;
715        if ((strat->Ll >= 0) && ((pass > strat->LazyPass) || (d > reddeg)))
716        {
717          at = strat->posInL(strat->L,strat->Ll,h,strat);
718          if (at <= strat->Ll)
719          {
720            enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
721            (*h).p = NULL;
722            return 0;
723          }
724        }
725        else if (TEST_OPT_PROT && (strat->Ll < 0) && (d != reddeg))
726        {
727          reddeg = d;
728          Print("%d.");
729          mflush();
730        }
731      }
732      j = 0;
733    }
734    else
735    {
736      if (j >= strat->tl)
737      {
738        if (TEST_OPT_INTSTRATEGY)
739        {
740          //pContent(h->p);
741          pCleardenom(h->p);// also does a pContent
742        }
743        enterT((*h),strat);
744        return 0;
745      }
746      j++;
747    }
748  }
749}
750
751#endif
752
753void nc_gr_initBba(ideal F, kStrategy strat)
754{
755  assume(rIsPluralRing(currRing));
756
757  int i;
758  idhdl h;
759 /* setting global variables ------------------- */
760  strat->enterS = enterSBba;
761
762/*
763  if ((BTEST1(20)) && (!strat->honey))
764    strat->red = nc_redBest;
765  else if (strat->honey)
766    strat->red = nc_redHoney;
767  else if (pLexOrder && !strat->homog)
768    strat->red = nc_redLazy;
769  else if (TEST_OPT_INTSTRATEGY && strat->homog)
770    strat->red = nc_redHomog0;
771  else
772    strat->red = nc_redHomog;
773*/
774
775//   if (rIsPluralRing(currRing))
776    strat->red = redGrFirst;
777
778  if (pLexOrder && strat->honey)
779    strat->initEcart = initEcartNormal;
780  else
781    strat->initEcart = initEcartBBA;
782  if (strat->honey)
783    strat->initEcartPair = initEcartPairMora;
784  else
785    strat->initEcartPair = initEcartPairBba;
786  strat->kIdeal = NULL;
787  //if (strat->ak==0) strat->kIdeal->rtyp=IDEAL_CMD;
788  //else              strat->kIdeal->rtyp=MODUL_CMD;
789  //strat->kIdeal->data=(void *)strat->Shdl;
790  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
791  {
792     //interred  machen   Aenderung
793     pFDegOld=pFDeg;
794     pLDegOld=pLDeg;
795  //   h=ggetid("ecart");
796  //   if ((h!=NULL) && (IDTYP(h)==INTVEC_CMD))
797  //   {
798  //     ecartWeights=iv2array(IDINTVEC(h));
799  //   }
800  //   else
801    {
802      ecartWeights=(short *)omAlloc((pVariables+1)*sizeof(short));
803      /*uses automatic computation of the ecartWeights to set them*/
804      kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
805    }
806    pFDeg=totaldegreeWecart;
807    pLDeg=maxdegreeWecart;
808    for(i=1; i<=pVariables; i++)
809      Print(" %d",ecartWeights[i]);
810    PrintLn();
811    mflush();
812  }
813}
814
815ideal gnc_gr_bba(const ideal F, const ideal Q, const intvec *, const intvec *, kStrategy strat)
816{
817  assume(pOrdSgn != -1); // no mora!!! it terminates only for global ordering!!! (?)
818
819  intvec *w=NULL;
820  intvec *hilb=NULL;
821  int   srmax,lrmax;
822  int   olddeg,reduc;
823  int red_result=1;
824  int hilbeledeg=1,hilbcount=0,minimcnt=0;
825
826  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
827  // initHilbCrit(F,Q,&hilb,strat);
828  /* in plural we don't need Hilb yet */
829  nc_gr_initBba(F,strat);
830  initBuchMoraPos(strat);
831  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
832  /*Shdl=*/initBuchMora(F, Q,strat);
833  strat->posInT=posInT110;
834  srmax = strat->sl;
835  reduc = olddeg = lrmax = 0;
836  /* compute------------------------------------------------------- */
837  while (strat->Ll >= 0)
838  {
839    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
840    if (TEST_OPT_DEBUG) messageSets(strat);
841    if (strat->Ll== 0) strat->interpt=TRUE;
842    if (TEST_OPT_DEGBOUND
843    && ((strat->honey
844    && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
845       || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))))
846    {
847      /*
848      *stops computation if
849      * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
850      *a predefined number Kstd1_deg
851      */
852      while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
853      break;
854    }
855    /* picks the last element from the lazyset L */
856    strat->P = strat->L[strat->Ll];
857    strat->Ll--;
858    //kTest(strat);
859    if (pNext(strat->P.p) == strat->tail)
860    {
861      /* deletes the short spoly and computes */
862      pLmFree(strat->P.p);
863      /* the real one */
864      if ((ncRingType(currRing)==nc_lie) && pHasNotCF(strat->P.p1,strat->P.p2)) /* prod crit */
865      {
866        strat->cp++;
867        /* prod.crit itself in nc_CreateSpoly */
868      }
869      strat->P.p = nc_SPoly(strat->P.p1,strat->P.p2/*,strat->kNoether*/,currRing);
870    }
871    if (strat->P.p != NULL)
872    {
873      if (TEST_OPT_PROT)
874      message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
875              &olddeg,&reduc,strat, red_result);
876      /* reduction of the element chosen from L */
877      strat->red(&strat->P,strat);
878    }
879    if (strat->P.p != NULL)
880    {
881          /* statistic */
882          if (TEST_OPT_PROT)
883          {
884            PrintS("s\n");
885          }
886          /* enter P.p into s and L */
887          {
888            strat->P.sev=0;
889            int pos=posInS(strat,strat->sl,strat->P.p, strat->P.ecart);
890            {
891              if (TEST_OPT_INTSTRATEGY)
892              {
893                if ((strat->syzComp==0)||(!strat->homog))
894                {
895                  strat->P.p = redtailBba(strat->P.p,pos-1,strat);
896                }
897                pCleardenom(strat->P.p);
898              }
899              else
900              {
901                pNorm(strat->P.p);
902                if ((strat->syzComp==0)||(!strat->homog))
903                {
904                  strat->P.p = redtailBba(strat->P.p,pos-1,strat);
905                }
906              }
907              // PLURAL debug
908              /* should be used only internally!!! */
909
910              //pWrite(strat->P.p);
911
912              if (TEST_OPT_DEBUG)
913              {
914                PrintS("new s:");
915                wrp(strat->P.p);
916                PrintLn();
917              }
918              // kTest(strat);
919              //
920              enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat);
921              if (strat->sl==-1) pos=0;
922              else pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
923              strat->enterS(strat->P,pos,strat,-1);
924            }
925//            if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
926          }
927          if (strat->P.lcm!=NULL) pLmFree(strat->P.lcm);
928      if (strat->sl>srmax) srmax = strat->sl;
929    }
930#ifdef KDEBUG
931    strat->P.lcm=NULL;
932#endif
933    //kTest(strat);
934  }
935  if (TEST_OPT_DEBUG) messageSets(strat);
936
937  /* complete reduction of the standard basis--------- */
938  if (TEST_OPT_REDSB){
939     completeReduce(strat); // ???
940
941//    ideal I = strat->Shdl;
942//    ideal erg = kInterRed(I,Q);
943//    assume(I!=erg);
944//    id_Delete(&I, currRing);
945//    strat->Shdl = erg;
946  }
947
948  /* release temp data-------------------------------- */
949  exitBuchMora(strat);
950  if (TEST_OPT_WEIGHTM)
951  {
952    pFDeg=pFDegOld;
953    pLDeg=pLDegOld;
954    if (ecartWeights)
955    {
956      omFreeSize((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
957      ecartWeights=NULL;
958    }
959  }
960  if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat);
961  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
962
963
964#ifdef PDEBUG
965/* for counting number of pairs [enterL] in Plural */
966/*   extern int zaehler; */
967/*   Print("Total pairs considered:%d\n",zaehler); zaehler=0; */
968#endif /*PDEBUG*/
969  return (strat->Shdl);
970}
971
972ideal gnc_gr_mora(const ideal, const ideal, const intvec *, const intvec *, kStrategy)
973{
974  PrintS("Sorry, non-commutative mora is not yet implemented!");
975  PrintLn();
976
977  // Not yet!
978  return NULL;
979}
980
981#endif
982
Note: See TracBrowser for help on using the repository browser.