source: git/Singular/kstd1.cc @ f003a9

spielwiese
Last change on this file since f003a9 was f003a9, checked in by Olaf Bachmann <obachman@…>, 26 years ago
* polys-impl.cc, polys.cc: No COMP_FAST any more * Makefile.in: Introduced variable PERL, set by configure * kstdfac.cc (kStratCopy): kModW iv is not copied, but just the pointer is set 1998-03-18 Olaf Bachmann <obachman@mathematik.uni-kl.de> * Makefile.in: added Singularb target for bprof * polys-impl.h, polys-comp.h: Cleaned up COMP_FAST and related #defines 1998-03-16 Olaf Bachmann <obachman@mathematik.uni-kl.de> * polys-impl.h: no #define COMP_FAST * configure.in,Makefile.in: check for flex -P; increased version number to 1.1.7 git-svn-id: file:///usr/local/Singular/svn/trunk@1268 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 52.8 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: kstd1.cc,v 1.17 1998-03-23 22:50:58 obachman Exp $ */
5/*
6* ABSTRACT:
7*/
8
9#include "mod2.h"
10#include "tok.h"
11#include "mmemory.h"
12#include "polys.h"
13#include "febase.h"
14#include "kutil.h"
15#include "kstd1.h"
16#include "kstd2.h"
17#include "khstd.h"
18#include "spolys.h"
19#include "stairc.h"
20#include "weight.h"
21#include "cntrlc.h"
22#include "intvec.h"
23#include "ideals.h"
24#include "ipshell.h"
25#include "ipid.h"
26#include "timer.h"
27#include "lists.h"
28#ifdef STDTRACE
29#include "comm.h"
30#endif
31#include "spSpolyLoop.h"
32
33//#include "ipprint.h"
34
35/* the list of all options which give a warning by test */
36BITSET kOptions=Sy_bit(0)|Sy_bit(1)|Sy_bit(3)|Sy_bit(4)|Sy_bit(5)
37                |Sy_bit(8)|Sy_bit(10)|Sy_bit(21)
38                |Sy_bit(OPT_INTSTRATEGY)
39                |Sy_bit(30)|Sy_bit(31);
40
41/* the list of all options which may be used by option and test */
42BITSET validOpts=Sy_bit(0)|Sy_bit(1)|Sy_bit(2)|Sy_bit(3)
43             |Sy_bit(4)|Sy_bit(5)|Sy_bit(6)|Sy_bit(7)
44             |Sy_bit(8)|Sy_bit(9)|Sy_bit(10)
45             |Sy_bit(11)|Sy_bit(12)|Sy_bit(13)|Sy_bit(14)|Sy_bit(15)
46             |Sy_bit(16)|Sy_bit(17)|Sy_bit(18)|Sy_bit(19)|Sy_bit(20)
47             |Sy_bit(21)
48             |Sy_bit(22)
49             /*|Sy_bit(23)*/
50             /*|Sy_bit(24)*/
51             |Sy_bit(OPT_REDTAIL)
52             |Sy_bit(OPT_INTSTRATEGY)|Sy_bit(27)|Sy_bit(28)
53             |Sy_bit(29)
54             |Sy_bit(30)|Sy_bit(31);
55
56//static int (*posInLOld)(LSet L,int Ll, LObject l,kStrategy strat);
57//static int  lastAxis=0;
58//static BOOLEAN update=TRUE;
59//static BOOLEAN posInLOldFlag;
60           /*FALSE, if posInL == posInL10*/
61
62/*0 implementation*/
63
64/*2
65*p is a polynomial in the set s;
66*recompute p and its ecart e with respect to the new noether
67*(cut every monomial of pNext(p) above noether)
68*/
69void deleteHCs (TObject* p,kStrategy strat)
70{
71  poly p1;
72  int o;
73
74  if (strat->kHEdgeFound)
75  {
76    p1 = (*p).p;
77    o = pFDeg(p1);
78    while (pNext(p1) != NULL)
79    {
80      if (pComp0(pNext(p1),strat->kNoether) == -1)
81      {
82        pDelete(&(pNext(p1)));
83        (*p).ecart = pLDeg((*p).p,&((*p).length))-o;
84      }
85      else
86      {
87        pIter(p1);
88      }
89    }
90  }
91}
92
93
94void doRed (LObject* h,poly* with,BOOLEAN intoT,kStrategy strat)
95{
96  poly hp;
97#ifdef KDEBUG
98  pTest((*h).p);
99  pTest(*with);
100#endif
101
102  if (!TEST_OPT_INTSTRATEGY)
103    pNorm(*with);
104  if (intoT)
105  {
106    hp = spSpolyRedNew(*with,(*h).p,strat->kNoether, strat->spSpolyLoop);
107    enterT(*h,strat);
108    (*h).p = hp;
109  }
110  else
111  {
112    (*h).p = spSpolyRed(*with,(*h).p,strat->kNoether, strat->spSpolyLoop);
113  }
114}
115
116/*2
117* reduces h with elements from T choosing first possible
118* element in T with respect to the given ecart
119* requires thar T is sorted by ecart
120*/
121void redEcart19 (LObject* h,kStrategy strat)
122{
123  int i,at,reddeg,d;
124  int j = 0;
125  int pass = 0;
126
127  if (TEST_OPT_CANCELUNIT) cancelunit(h);
128  d = pFDeg((*h).p)+(*h).ecart;
129  reddeg = strat->LazyDegree+d;
130  loop
131  {
132    if (j > strat->tl)
133    {
134#ifdef KDEBUG
135      if (TEST_OPT_DEBUG) PrintLn();
136#endif
137      return;
138    }
139#ifdef KDEBUG
140    if (TEST_OPT_DEBUG) Print("%d",j);
141#endif
142    if (pDivisibleBy1(strat->T[j].p,(*h).p))
143    {
144      //if (strat->interpt) test_int_std(strat->kIdeal);
145#ifdef KDEBUG
146      if (TEST_OPT_DEBUG) PrintS("+");
147#endif
148      /*- compute the s-polynomial -*/
149      if (strat->T[j].ecart > (*h).ecart)
150      {
151        /*
152        * It is not possible to reduce h with smaller ecart;
153        * if possible h goes to the lazy-set L,i.e
154        * if its position in L would be not the last one
155        */
156        strat->fromT = TRUE;
157        if (strat->Ll >= 0) /*- L is not empty -*/
158        {
159          at = strat->posInL(strat->L,strat->Ll,(*h),strat);
160          if (at <= strat->Ll)
161          {
162            /*- h will not become the next element to reduce -*/
163            enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
164#ifdef KDEBUG
165            if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
166#endif
167            (*h).p = NULL;
168            strat->fromT = FALSE;
169            return;
170          }
171        }
172        /*put the polynomial also in the pair set*/
173        if (TEST_OPT_MOREPAIRS)
174        {
175          if (!TEST_OPT_INTSTRATEGY)
176            pNorm((*h).p);
177          enterpairs((*h).p,strat->sl,(*h).ecart,0,strat);
178        }
179      }
180      doRed(h,&strat->T[j].p,strat->fromT,strat);
181      strat->fromT=FALSE;
182      if ((*h).p == NULL)
183      {
184#ifdef KDEBUG
185        if (TEST_OPT_DEBUG) PrintS(" to 0\n");
186#endif
187        if (h->lcm!=NULL) pFree1((*h).lcm);
188        return;
189      }
190      /*computes the ecart*/
191
192      if (strat->honey)
193      {
194        if (strat->T[j].ecart <= (*h).ecart)
195          (*h).ecart = d-pFDeg((*h).p);
196        else
197          (*h).ecart = d-pFDeg((*h).p)+strat->T[j].ecart-(*h).ecart;
198        (*h).length = pLength((*h).p);
199      }
200      else
201        (*h).ecart = pLDeg((*h).p,&((*h).length))-pFDeg((*h).p);
202      if (TEST_OPT_CANCELUNIT) cancelunit(h);
203      if ((strat->syzComp!=0) && !strat->honey)
204      {
205        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
206        {
207#ifdef KDEBUG
208          if (TEST_OPT_DEBUG) PrintS(" > sysComp\n");
209#endif
210          return;
211        }
212      }
213      /*- try to reduce the s-polynomial -*/
214      pass++;
215      d = pFDeg((*h).p)+(*h).ecart;
216      /*
217      *test whether the polynomial should go to the lazyset L
218      *-if the degree jumps
219      *-if the number of pre-defined reductions jumps
220      */
221      if ((strat->Ll >= 0) &&  ((d >= reddeg) || (pass > strat->LazyPass)))
222      {
223        at = strat->posInL(strat->L,strat->Ll,*h,strat);
224        if (at <= strat->Ll)
225        {
226          i=strat->sl+1;
227          do
228          {
229            i--;
230            if (i<0) return;
231          } while (!pDivisibleBy1(strat->S[i],(*h).p));
232          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
233#ifdef KDEBUG
234          if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
235#endif
236          (*h).p = NULL;
237          return;
238        }
239      }
240      else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
241      {
242        reddeg = d+1;
243        Print(".%d",d);mflush();
244      }
245      j = 0;
246#ifdef KDEBUG
247      if TEST_OPT_DEBUG PrintLn();
248#endif
249    }
250    else
251    {
252#ifdef KDEBUG
253      if (TEST_OPT_DEBUG) PrintS("-");
254#endif
255      j++;
256    }
257  }
258}
259
260/*2
261* reduces h with elements from T choosing first possible
262* element in T with respect to the given ecart
263*/
264void redEcart (LObject* h,kStrategy strat)
265{
266  poly pi;
267  int i,at,reddeg,d,ei,li;
268  int j = 0;
269  int pass = 0;
270
271  if (TEST_OPT_CANCELUNIT) cancelunit(h);
272  d = pFDeg((*h).p)+(*h).ecart;
273  reddeg = strat->LazyDegree+d;
274  loop
275  {
276    if (j > strat->tl)
277    {
278#ifdef KDEBUG
279      if (TEST_OPT_DEBUG) PrintLn();
280#endif
281      return;
282    }
283#ifdef KDEBUG
284    if (TEST_OPT_DEBUG) Print("%d",j);
285#endif
286    if (pDivisibleBy1(strat->T[j].p,(*h).p))
287    {
288      //if (strat->interpt) test_int_std(strat->kIdeal);
289#ifdef KDEBUG
290      if (TEST_OPT_DEBUG) PrintS("+");
291#endif
292      /*- compute the s-polynomial -*/
293      pi = strat->T[j].p;
294      ei = strat->T[j].ecart;
295      li = strat->T[j].length;
296      /*
297      * the polynomial to reduce with (up to the moment) is;
298      * pi with ecart ei and length li
299      */
300      i = j;
301      loop
302      {
303      /*- takes the first possible with respect to ecart -*/
304        if (ei <= (*h).ecart) break;
305        i++;
306        if (i > strat->tl) break;
307#ifdef KDEBUG
308        if (TEST_OPT_DEBUG) Print("%d",i);
309#endif
310        if ((((strat->T[i]).ecart < ei)
311          || (((strat->T[i]).ecart == ei)
312          && ((strat->T[i]).length < li)))
313          && pDivisibleBy1((strat->T[i]).p,(*h).p))
314        {
315#ifdef KDEBUG
316          if (TEST_OPT_DEBUG) PrintS("+");
317#endif
318          /*
319           * the polynomial to reduce with is now;
320           */
321          pi = strat->T[i].p;
322          ei = strat->T[i].ecart;
323          li = strat->T[i].length;
324        }
325#ifdef KDEBUG
326        else if (TEST_OPT_DEBUG) PrintS("-");
327#endif
328      }
329      /*
330      * end of search: have to reduce with pi
331      */
332      if (ei > (*h).ecart)
333      {
334        /*
335        * It is not possible to reduce h with smaller ecart;
336        * if possible h goes to the lazy-set L,i.e
337        * if its position in L would be not the last one
338        */
339        strat->fromT = TRUE;
340        if (strat->Ll >= 0) /*- L is not empty -*/
341        {
342          at = strat->posInL(strat->L,strat->Ll,(*h),strat);
343          if (at <= strat->Ll)
344          {
345            /*- h will not become the next element to reduce -*/
346            enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
347#ifdef KDEBUG
348            if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
349#endif
350            (*h).p = NULL;
351            strat->fromT = FALSE;
352            return;
353          }
354        }
355        /*put the polynomial also in the pair set*/
356        if (TEST_OPT_MOREPAIRS)
357        {
358          if (!TEST_OPT_INTSTRATEGY)
359            pNorm((*h).p);
360          enterpairs((*h).p,strat->sl,(*h).ecart,0,strat);
361        }
362      }
363#ifdef KDEBUG
364      if (TEST_OPT_DEBUG)
365      {
366        wrp(h->p);
367        PrintS(" with ");
368        wrp(pi);
369      }
370#endif
371      doRed(h,&pi,strat->fromT,strat);
372      strat->fromT=FALSE;
373#ifdef KDEBUG
374      if (TEST_OPT_DEBUG)
375      {
376        PrintS(" to ");
377        wrp(h->p);
378        PrintLn();
379      }
380#endif
381      if ((*h).p == NULL)
382      {
383        if (h->lcm!=NULL) pFree1((*h).lcm);
384        return;
385      }
386      /*computes the ecart*/
387      if (strat->honey)
388      {
389        if (ei <= (*h).ecart)
390          (*h).ecart = d-pFDeg((*h).p);
391        else
392          (*h).ecart = d-pFDeg((*h).p)+ei-(*h).ecart;
393        pLDeg((*h).p,&((*h).length));
394        //(*h).length = pLength((*h).p);
395      }
396      else
397        (*h).ecart = pLDeg((*h).p,&((*h).length))-pFDeg((*h).p);
398      if (TEST_OPT_CANCELUNIT) cancelunit(h);
399      if (strat->syzComp!=0)
400      {
401        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
402        {
403#ifdef KDEBUG
404          if (TEST_OPT_DEBUG) PrintS(" > sysComp\n");
405#endif
406          return;
407        }
408      }
409      /*- try to reduce the s-polynomial -*/
410      pass++;
411      d = pFDeg((*h).p)+(*h).ecart;
412      /*
413      *test whether the polynomial should go to the lazyset L
414      *-if the degree jumps
415      *-if the number of pre-defined reductions jumps
416      */
417      if ((strat->Ll >= 0)
418      && ((d >= reddeg) || (pass > strat->LazyPass)))
419      {
420        at = strat->posInL(strat->L,strat->Ll,*h,strat);
421        if (at <= strat->Ll)
422        {
423          i=strat->sl+1;
424          do
425          {
426            i--;
427            if (i<0) return;
428          } while (!pDivisibleBy1(strat->S[i],(*h).p));
429          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
430#ifdef KDEBUG
431          if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
432#endif
433          (*h).p = NULL;
434          return;
435        }
436      }
437      else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
438      {
439        Print(".%d",d);mflush();
440        reddeg = d+1;
441      }
442      j = 0;
443    }
444    else
445    {
446#ifdef KDEBUG
447      if (TEST_OPT_DEBUG) PrintS("-");
448#endif
449      j++;
450    }
451  }
452}
453
454/*2
455*reduces h with elements from T choosing  the first possible
456* element in t with respect to the given pDivisibleBy
457*/
458void redFirst (LObject* h,kStrategy strat)
459{
460  int at,reddeg,d,i;
461  int pass = 0;
462  int j = 0;
463
464  if (TEST_OPT_CANCELUNIT) cancelunit(h);
465  d = pFDeg((*h).p)+(*h).ecart;
466  reddeg = strat->LazyDegree+d;
467  loop
468  {
469    if (j > strat->tl)
470    {
471#ifdef KDEBUG
472      if (TEST_OPT_DEBUG) PrintLn();
473#endif
474      return;
475    }
476#ifdef KDEBUG
477    if (TEST_OPT_DEBUG) Print("%d",j);
478#endif
479    if (pDivisibleBy1(strat->T[j].p,(*h).p))
480    {
481      //if (strat->interpt) test_int_std(strat->kIdeal);
482#ifdef KDEBUG
483      if (TEST_OPT_DEBUG) PrintS("+\n");
484#endif
485      /*
486      * the polynomial to reduce with is;
487      * T[j].p
488      */
489      if (!TEST_OPT_INTSTRATEGY)
490        pNorm(strat->T[j].p);
491#ifdef KDEBUG
492      if (TEST_OPT_DEBUG)
493      {
494        wrp(h->p);
495        PrintS(" with ");
496        wrp(strat->T[j].p);
497      }
498#endif
499      (*h).p = spSpolyRed(strat->T[j].p,(*h).p,strat->kNoether,
500                          strat->spSpolyLoop);
501#ifdef KDEBUG
502      if (TEST_OPT_DEBUG)
503      {
504        PrintS(" to ");
505        wrp(h->p);
506      }
507#endif
508      if ((*h).p == NULL)
509      {
510        if (h->lcm!=NULL) pFree1((*h).lcm);
511        return;
512      }
513      if (TEST_OPT_CANCELUNIT) cancelunit(h);
514      /*computes the ecart*/
515      d = pLDeg((*h).p,&((*h).length));
516      (*h).ecart = d-pFDeg((*h).p);
517      if ((strat->syzComp!=0) && !strat->honey)
518      {
519        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
520        {
521#ifdef KDEBUG
522          if (TEST_OPT_DEBUG) PrintS(" > sysComp\n");
523#endif
524          return;
525        }
526      }
527      /*- try to reduce the s-polynomial -*/
528      pass++;
529      /*
530      *test whether the polynomial should go to the lazyset L
531      *-if the degree jumps
532      *-if the number of pre-defined reductions jumps
533      */
534      if ((strat->Ll >= 0)
535      && ((d >= reddeg) || (pass > strat->LazyPass))
536      && !strat->homog)
537      {
538        at = strat->posInL(strat->L,strat->Ll,*h,strat);
539        if (at <= strat->Ll)
540        {
541          i=strat->sl+1;
542          do
543          {
544            i--;
545            if (i<0) return;
546          } while (!pDivisibleBy1(strat->S[i],(*h).p));
547          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
548#ifdef KDEBUG
549          if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
550#endif
551          (*h).p = NULL;
552          return;
553        }
554      }
555      if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
556      {
557        reddeg = d+1;
558        Print(".%d",d);mflush();
559      }
560      j = 0;
561#ifdef KDEBUG
562      if TEST_OPT_DEBUG PrintLn();
563#endif
564    }
565    else
566    {
567#ifdef KDEBUG
568      if (TEST_OPT_DEBUG) PrintS("-");
569#endif
570      j++;
571    }
572  }
573}
574
575/*2
576* reduces h with elements from T choosing the best possible
577* element in t with respect to the ecart and length
578*/
579void redMoraBest (LObject* h,kStrategy strat)
580{
581  poly pi;
582  int reddeg,d,ei,li,i,at;
583  int j = 0;
584  int pass = 0;
585
586  if (TEST_OPT_CANCELUNIT) cancelunit(h);
587  d = pFDeg((*h).p)+(*h).ecart;
588  reddeg = strat->LazyDegree+d;
589  loop
590  {
591    if (j > strat->tl)
592    {
593#ifdef KDEBUG
594      if (TEST_OPT_DEBUG) PrintLn();
595#endif
596      return;
597    }
598#ifdef KDEBUG
599    if (TEST_OPT_DEBUG) Print("%d",j);
600#endif
601    if (pDivisibleBy1(strat->T[j].p,(*h).p))
602    {
603      //if (strat->interpt) test_int_std(strat->kIdeal);
604#ifdef KDEBUG
605      if (TEST_OPT_DEBUG) PrintS("+");
606#endif
607      /*- compute the s-polynomial -*/
608      pi = strat->T[j].p;
609      ei = strat->T[j].ecart;
610      li = strat->T[j].length;
611      /*
612      * the polynomial to reduce with (up to the moment) is;
613      * pi with ecart ei and length li
614      */
615      i = j;
616      loop
617      {
618        /*- takes the best possible with respect to ecart and length -*/
619        i++;
620        if (i > strat->tl) break;
621#ifdef KDEBUG
622        if (TEST_OPT_DEBUG) Print("%d",i);
623#endif
624        if (((strat->T[i].ecart < ei)
625          || ((strat->T[i].ecart == ei)
626        && (strat->T[i].length < li)))
627        && pDivisibleBy1(strat->T[i].p,(*h).p))
628        {
629#ifdef KDEBUG
630          if (TEST_OPT_DEBUG) PrintS("+");
631#endif
632          /*
633          * the polynomial to reduce with is now:
634          */
635          pi = strat->T[i].p;
636          ei = strat->T[i].ecart;
637          li = strat->T[i].length;
638        }
639        else
640        {
641#ifdef KDEBUG
642          if (TEST_OPT_DEBUG) PrintS("-");
643#endif
644        }
645      }
646      /*
647      * end of search: best is pi
648      */
649      if ((ei > (*h).ecart) && (!strat->kHEdgeFound))
650      {
651        /*
652        * It is not possible to reduce h with smaller ecart;
653        * if possible h goes to the lazy-set L,i.e
654        * if its position in L would be not the last one
655        */
656        strat->fromT = TRUE;
657        if (strat->Ll >= 0) /*- L is not empty -*/
658        {
659          at = strat->posInL(strat->L,strat->Ll,(*h),strat);
660          if (at <= strat->Ll)
661          {
662            /*- h will not become the next element to reduce -*/
663            enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
664#ifdef KDEBUG
665            if (TEST_OPT_DEBUG) Print(" ecart too big; -> L%d\n",at);
666#endif
667            (*h).p = NULL;
668            strat->fromT = FALSE;
669            return;
670          }
671        }
672        /*put the polynomial also in the pair set*/
673        if (TEST_OPT_MOREPAIRS)
674        {
675          if (!TEST_OPT_INTSTRATEGY)
676            pNorm((*h).p);
677          enterpairs((*h).p,strat->sl,(*h).ecart,0,strat);
678        }
679      }
680#ifdef KDEBUG
681      if (TEST_OPT_DEBUG)
682      {
683        wrp(h->p);
684        PrintS(" with ");
685        wrp(pi);
686      }
687#endif
688      doRed(h,&pi,strat->fromT,strat);
689      strat->fromT=FALSE;
690#ifdef KDEBUG
691      if (TEST_OPT_DEBUG)
692#endif
693      {
694        PrintS(" to ");
695        wrp(h->p);
696      }
697      if ((*h).p == NULL)
698      {
699        if (h->lcm!=NULL) pFree1((*h).lcm);
700        return;
701      }
702      /*computes the ecart*/
703      if (strat->honey)
704      {
705        if (ei <= (*h).ecart)
706          (*h).ecart = d-pFDeg((*h).p);
707        else
708          (*h).ecart = d-pFDeg((*h).p)+ei-(*h).ecart;
709        (*h).length = pLength((*h).p);
710      }
711      else
712        (*h).ecart = pLDeg((*h).p,&((*h).length))-pFDeg((*h).p);
713      if (TEST_OPT_CANCELUNIT) cancelunit(h);
714      if ((strat->syzComp!=0) && !strat->honey)
715      {
716        if ((strat->syzComp>0) && (pMinComp((*h).p) > strat->syzComp))
717        {
718#ifdef KDEBUG
719          if (TEST_OPT_DEBUG) PrintS(" > sysComp\n");
720#endif
721          return;
722        }
723      }
724      /*- try to reduce the s-polynomial -*/
725      pass++;
726      d = pFDeg((*h).p)+(*h).ecart;
727      /*
728      *test whether the polynomial should go to the lazyset L
729      *-if the degree jumps
730      *-if the number of pre-defined reductions jumps
731      */
732      if ((strat->Ll >= 0)
733      && ((d >= reddeg) || (pass > strat->LazyPass)))
734      {
735        at = strat->posInL(strat->L,strat->Ll,*h,strat);
736        if (at <= strat->Ll)
737        {
738          i=strat->sl+1;
739          do
740          {
741            i--;
742            if (i<0) return;
743          } while (!pDivisibleBy1(strat->S[i],(*h).p));
744          enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
745#ifdef KDEBUG
746          if (TEST_OPT_DEBUG) Print(" degree jumped; ->L%d\n",at);
747#endif
748          (*h).p = NULL;
749          return;
750        }
751      }
752      else if ((TEST_OPT_PROT) && (strat->Ll < 0) && (d >= reddeg))
753      {
754        reddeg = d+1;
755        Print(".%d",d);mflush();
756      }
757      j = 0;
758#ifdef KDEBUG
759      if TEST_OPT_DEBUG PrintLn();
760#endif
761    }
762    else
763    {
764#ifdef KDEBUG
765      if (TEST_OPT_DEBUG) PrintS("-");
766#endif
767      j++;
768    }
769  }
770}
771
772/*2
773* reduces h with elements from T choosing first possible
774* element in T with respect to the given ecart
775* used for computing normal forms outside std
776*/
777static poly redMoraNF (poly h,kStrategy strat)
778{
779  poly pi;
780  LObject H;
781  int o,ei,li;
782  int j = 0;
783  int z = 10;
784
785  H.p = h;
786  o = pFDeg(h);
787  H.ecart = pLDeg(H.p,&H.length)-o;
788  cancelunit(&H);
789  loop
790  {
791    if (j > strat->tl)
792    {
793#ifdef KDEBUG
794      if (TEST_OPT_DEBUG) PrintLn();
795#endif
796      return H.p;
797    }
798#ifdef KDEBUG
799    if (TEST_OPT_DEBUG) Print("%d",j);
800#endif
801    if (pDivisibleBy1(strat->T[j].p,H.p))
802    {
803      //if (strat->interpt) test_int_std(strat->kIdeal);
804#ifdef KDEBUG
805      if (TEST_OPT_DEBUG) PrintS("+");
806#endif
807      /*- remember the found T-poly -*/
808      pi = strat->T[j].p;
809      ei = strat->T[j].ecart;
810      li = strat->T[j].length;
811      /*
812      * the polynomial to reduce with (up to the moment) is;
813      * pi with ecart ei and length li
814      */
815      loop
816      {
817        /*- look for a better one with respect to ecart -*/
818        /*- stop, if the ecart is small enough (<=ecart(H)) -*/
819        j++;
820        if (j > strat->tl) break;
821        if (ei <= H.ecart) break;
822#ifdef KDEBUG
823        if (TEST_OPT_DEBUG) Print("%d",j);
824#endif
825        if (((strat->T[j].ecart < ei)
826          || ((strat->T[j].ecart == ei)
827        && (strat->T[j].length < li)))
828        && pDivisibleBy1(strat->T[j].p,H.p))
829        {
830#ifdef KDEBUG
831          if (TEST_OPT_DEBUG) PrintS("+");
832#endif
833          /*
834          * the polynomial to reduce with is now;
835          */
836          pi = strat->T[j].p;
837          ei = strat->T[j].ecart;
838          li = strat->T[j].length;
839        }
840        else
841        {
842#ifdef KDEBUG
843          if (TEST_OPT_DEBUG) PrintS("-");
844#endif
845        }
846      }
847      /*
848      * end of search: have to reduce with pi
849      */
850      z++;
851      if (z>10)
852      {
853        pNormalize(H.p);
854        z=0;
855      }
856      if ((ei > H.ecart) && (!strat->kHEdgeFound))
857      {
858        /*
859        * It is not possible to reduce h with smaller ecart;
860        * we have to reduce with bad ecart: H has t enter in T
861        */
862        doRed(&H,&pi,TRUE,strat);
863        if (H.p == NULL)
864        {
865#ifdef KDEBUG
866          if (TEST_OPT_DEBUG) PrintS(" to 0\n");
867#endif
868          return NULL;
869        }
870      }
871      else
872      {
873        /*
874        * we reduce with good ecart, h need not to be put to T
875        */
876        doRed(&H,&pi,FALSE,strat);
877        if (H.p == NULL)
878        {
879#ifdef KDEBUG
880          if (TEST_OPT_DEBUG) PrintS(" to 0\n");
881#endif
882          return NULL;
883        }
884      }
885      /*- try to reduce the s-polynomial -*/
886      o = pFDeg(H.p);
887      cancelunit(&H);
888      H.ecart = pLDeg(H.p,&(H.length))-o;
889      j = 0;
890    }
891    else
892    {
893#ifdef KDEBUG
894      if (TEST_OPT_DEBUG) PrintS("-");
895#endif
896      j++;
897    }
898  }
899}
900
901/*2
902*reorders  L with respect to posInL
903*/
904void reorderL(kStrategy strat)
905{
906  int i,j,at;
907  LObject p;
908
909  for (i=1; i<=strat->Ll; i++)
910  {
911    at = strat->posInL(strat->L,i-1,strat->L[i],strat);
912    if (at != i)
913    {
914      p = strat->L[i];
915      for (j=i-1; j>=at; j--) strat->L[j+1] = strat->L[j];
916      strat->L[at] = p;
917    }
918  }
919}
920
921/*2
922*reorders  T with respect to length
923*/
924void reorderT(kStrategy strat)
925{
926  int i,j,at;
927  TObject p;
928
929  for (i=1; i<=strat->tl; i++)
930  {
931    if (strat->T[i-1].length > strat->T[i].length)
932    {
933      p = strat->T[i];
934      at = i-1;
935      loop
936      {
937        at--;
938        if (at < 0) break;
939        if (strat->T[i].length > strat->T[at].length) break;
940      }
941      for (j = i-1; j>at; j--)
942      {
943        strat->T[j+1]=strat->T[j];
944      }
945      strat->T[at+1]=p;
946    }
947  }
948}
949
950/*2
951*looks whether exactly pVariables-1 axis are used
952*returns last != 0 in this case
953*last is the (first) unused axis
954*/
955void missingAxis (int* last,kStrategy strat)
956{
957  int   i = 0;
958  int   k = 0;
959
960  *last = 0;
961  loop
962  {
963    i++;
964    if (i > pVariables) break;
965    if (strat->NotUsedAxis[i])
966    {
967      *last = i;
968      k++;
969    }
970    if (k>1)
971    {
972      *last = 0;
973      break;
974    }
975  }
976}
977
978/*2
979*last is the only non used axis, it looks
980*for a monomial in p being a pure power of this
981*variable and returns TRUE in this case
982*(*length) gives the length between the pure power and the leading term
983*(should be minimal)
984*/
985BOOLEAN hasPurePower (poly p,int last, int *length,kStrategy strat)
986{
987  poly h;
988  int i;
989
990  if (pNext(p) == strat->tail)
991    return FALSE;
992  if (pMinComp(p) == strat->ak)
993  {
994    *length = 0;
995    h = p;
996    while (h != NULL)
997    {
998      i = pIsPurePower(h);
999      if (i==last) return TRUE;
1000      (*length)++;
1001      pIter(h);
1002    }
1003  }
1004  return FALSE;
1005}
1006
1007/*2
1008* looks up the position of polynomial p in L
1009* in the case of looking for the pure powers
1010*/
1011int posInL10 (LSet set, int length, LObject p,kStrategy strat)
1012{
1013  int j,dp,dL;
1014
1015  if (length<0) return 0;
1016  if (hasPurePower(p.p,strat->lastAxis,&dp,strat))
1017  {
1018    int op= pFDeg(p.p)+p.ecart;
1019    for (j=length; j>=0; j--)
1020    {
1021      if (!hasPurePower(set[j].p,strat->lastAxis,&dL,strat))
1022        return j+1;
1023      if (dp < dL)
1024        return j+1;
1025      if ((dp == dL)
1026      && (pFDeg(set[j].p)+set[j].ecart >= op))
1027        return j+1;
1028    }
1029  }
1030  j=length;
1031  loop
1032  {
1033    if (j<0) break;
1034    if (!hasPurePower(set[j].p,strat->lastAxis,&dL,strat)) break;
1035    j--;
1036  }
1037  return strat->posInLOld(set,j,p,strat);
1038}
1039
1040/*2
1041* computes the s-polynomials L[ ].p in L
1042*/
1043void updateL(kStrategy strat)
1044{
1045  LObject p;
1046  int dL;
1047  int j=strat->Ll;
1048  loop
1049  {
1050    if (j<0) break;
1051    if (hasPurePower(strat->L[j].p,strat->lastAxis,&dL,strat))
1052    {
1053      p=strat->L[strat->Ll];
1054      strat->L[strat->Ll]=strat->L[j];
1055      strat->L[j]=p;
1056      break;
1057    }
1058    j--;
1059  }
1060  if (j<0)
1061  {
1062    j=strat->Ll;
1063    loop
1064    {
1065      if (j<0) break;
1066      if (pNext(strat->L[j].p) == strat->tail)
1067      {
1068        pFree1(strat->L[j].p);    /*deletes the short spoly and computes*/
1069        strat->L[j].p=spSpolyCreate(strat->L[j].p1,strat->L[j].p2,strat->kNoether);   /*the real one*/
1070        if (!strat->honey)
1071          strat->initEcart(&strat->L[j]);
1072        else
1073          strat->L[j].length = pLength(strat->L[j].p);
1074        if (hasPurePower(strat->L[j].p,strat->lastAxis,&dL,strat))
1075        {
1076          p=strat->L[strat->Ll];
1077          strat->L[strat->Ll]=strat->L[j];
1078          strat->L[j]=p;
1079          break;
1080        }
1081      }
1082      j--;
1083    }
1084  }
1085}
1086
1087/*2
1088* computes the s-polynomials L[ ].p in L and
1089* cuts elements in L above noether
1090*/
1091void updateLHC(kStrategy strat)
1092{
1093  int i = 0;
1094  while (i <= strat->Ll)
1095  {
1096    if (pNext(strat->L[i].p) == strat->tail)
1097    {
1098       /*- deletes the int spoly and computes -*/
1099      if (pComp0(strat->L[i].p,strat->kNoether) == -1)
1100      {
1101        pFree1(strat->L[i].p);
1102        strat->L[i].p = NULL;
1103      }
1104      else
1105      {
1106        pFree1(strat->L[i].p);
1107        strat->L[i].p = spSpolyCreate(strat->L[i].p1,strat->L[i].p2,strat->kNoether);
1108        strat->L[i].ecart = pLDeg(strat->L[i].p,&strat->L[i].length)-pFDeg(strat->L[i].p);
1109      }
1110    }
1111    else
1112      deleteHC(&strat->L[i].p,&strat->L[i].ecart,&strat->L[i].length,strat);
1113   if (strat->L[i].p == NULL)
1114      deleteInL(strat->L,&strat->Ll,i,strat);
1115    else
1116      i++;
1117  }
1118}
1119
1120/*2
1121* cuts in T above strat->kNoether and tries to cancel a unit
1122*/
1123void updateT(kStrategy strat)
1124{
1125  int i = 0;
1126  LObject p;
1127
1128  while (i <= strat->tl)
1129  {
1130    deleteHCs(&strat->T[i],strat);
1131    /*- tries to cancel a unit: -*/
1132    p.p = strat->T[i].p;
1133    p.ecart = strat->T[i].ecart;
1134    p.length = strat->T[i].length;
1135    cancelunit(&p);
1136    strat->T[i].p = p.p;
1137    strat->T[i].ecart = p.ecart;
1138    strat->T[i].length = p.length;
1139    i++;
1140  }
1141}
1142
1143/*2
1144* arranges red, pos and T if strat->kHEdgeFound (first time)
1145*/
1146void firstUpdate(kStrategy strat)
1147{
1148  if (strat->update)
1149  {
1150    strat->update = (strat->tl == -1);
1151    if (TEST_OPT_WEIGHTM)
1152    {
1153      pFDeg=pFDegOld;
1154      pLDeg=pLDegOld;
1155      if (ecartWeights)
1156      {
1157        Free((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
1158        ecartWeights=NULL;
1159      }
1160    }
1161    if (TEST_OPT_FASTHC)
1162    {
1163      strat->posInL = strat->posInLOld;
1164      strat->lastAxis = 0;
1165    }
1166    if (BTEST1(27))
1167      return;
1168    if (!BTEST1(20))        /*- take the first possible -*/
1169      strat->red = redFirst;
1170    updateT(strat);
1171    strat->posInT = posInT2;
1172    reorderT(strat);
1173  }
1174}
1175
1176/*2
1177*-puts p to the standardbasis s at position at
1178*-reduces the tail of p if TEST_OPT_REDTAIL
1179*-tries to cancel a unit
1180*-HEckeTest
1181*  if TRUE
1182*  - decides about reduction-strategies
1183*  - computes noether
1184*  - stops computation if BTEST1(27)
1185*  - cuts the tails of the polynomials
1186*    in s,t and the elements in L above noether
1187*    and cancels units if possible
1188*  - reorders s,L
1189*/
1190void enterSMora (LObject p,int atS,kStrategy strat)
1191{
1192  int i;
1193
1194#ifdef SDRING
1195  if (pSDRING
1196  && (atS<=strat->sl)
1197  && pComparePolys(p.p,strat->S[atS]))
1198  {
1199    if (TEST_OPT_PROT)
1200      PrintS("m");
1201    p.p=NULL;
1202    return;
1203  }
1204  if (pSDRING
1205  && (atS<strat->sl)
1206  && pComparePolys(p.p,strat->S[atS+1]))
1207  {
1208    if (TEST_OPT_PROT)
1209      PrintS("m");
1210    p.p=NULL;
1211    return;
1212  }
1213  if (pSDRING
1214  && (atS>0)
1215  && pComparePolys(p.p,strat->S[atS-1]))
1216  {
1217    if (TEST_OPT_PROT)
1218      PrintS("m");
1219    p.p=NULL;
1220    return;
1221  }
1222#endif
1223  strat->news = TRUE;
1224  /*- puts p to the standardbasis s at position atS -*/
1225  if (strat->sl == IDELEMS(strat->Shdl)-1)
1226  {
1227    pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
1228    strat->ecartS = (intset) ReAlloc(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int),
1229                                     (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
1230    if (strat->fromQ)
1231    {
1232      strat->fromQ = (intset)ReAlloc(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int),
1233                                    (IDELEMS(strat->Shdl)+setmax)*sizeof(int));
1234    }
1235    IDELEMS(strat->Shdl) += setmax;
1236    strat->Shdl->m=strat->S;
1237  }
1238  for (i=strat->sl+1; i>atS; i--)
1239  {
1240    strat->S[i] = strat->S[i-1];
1241    strat->ecartS[i] = strat->ecartS[i-1];
1242  }
1243  if (strat->fromQ)
1244  {
1245    for (i=strat->sl+1; i>=atS+1; i--)
1246    {
1247      strat->fromQ[i] = strat->fromQ[i-1];
1248    }
1249    strat->fromQ[atS]=0;
1250  }
1251  /*- save result -*/
1252  strat->S[atS] = p.p;
1253  strat->ecartS[atS] = p.ecart;
1254  strat->sl++;
1255#ifdef KDEBUG
1256  if (TEST_OPT_DEBUG)
1257  {
1258    Print("new s%d:",atS);
1259    wrp(p.p);
1260    PrintLn();
1261  }
1262#endif
1263  if ((!strat->kHEdgeFound) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat);
1264  if (strat->kHEdgeFound)
1265  {
1266    if (newHEdge(strat->S,strat->ak,strat))
1267    {
1268      firstUpdate(strat);
1269      if (BTEST1(27))
1270        return;
1271      /*- cuts elements in L above noether and reorders L -*/
1272      updateLHC(strat);
1273      /*- reorders L with respect to posInL -*/
1274      reorderL(strat);
1275    }
1276  }
1277  else if (strat->kNoether!=NULL)
1278    strat->kHEdgeFound = TRUE;
1279  else if (TEST_OPT_FASTHC)
1280  {
1281    if (strat->posInLOldFlag)
1282    {
1283      missingAxis(&strat->lastAxis,strat);
1284      if (strat->lastAxis)
1285      {
1286        strat->posInLOld = strat->posInL;
1287        strat->posInLOldFlag = FALSE;
1288        strat->posInL = posInL10;
1289        updateL(strat);
1290        reorderL(strat);
1291      }
1292    }
1293    else if (strat->lastAxis)
1294      updateL(strat);
1295  }
1296}
1297
1298/*2
1299*-puts p to the standardbasis s at position at
1300*-HEckeTest
1301*  if TRUE
1302*  - computes noether
1303*/
1304void enterSMoraNF (LObject p, int atS,kStrategy strat)
1305{
1306  int i;
1307
1308  /*- puts p to the standardbasis s at position at -*/
1309  if (strat->sl == IDELEMS(strat->Shdl)-1)
1310  {
1311    pEnlargeSet(&strat->S,IDELEMS(strat->Shdl),setmax);
1312    strat->ecartS = (intset) ReAlloc(strat->ecartS,IDELEMS(strat->Shdl)*sizeof(intset),
1313                                     (IDELEMS(strat->Shdl)+setmax)*sizeof(intset));
1314    IDELEMS(strat->Shdl) += setmax;
1315    strat->Shdl->m=strat->S;
1316  }
1317  for (i=strat->sl+1; i>atS; i--)
1318  {
1319    strat->S[i] = strat->S[i-1];
1320    strat->ecartS[i] = strat->ecartS[i-1];
1321  }
1322  strat->S[atS] = p.p;/*- save result -*/
1323  strat->ecartS[atS] = p.ecart;
1324  strat->sl++;
1325  if ((!strat->kHEdgeFound) || (strat->kNoether!=NULL)) HEckeTest(p.p,strat);
1326  if (strat->kHEdgeFound)
1327    newHEdge(strat->S,strat->ak,strat);
1328  else if (strat->kNoether!=NULL)
1329    strat->kHEdgeFound = TRUE;
1330}
1331
1332void initMora(ideal F,kStrategy strat)
1333{
1334  int i,j;
1335  idhdl h;
1336
1337  strat->NotUsedAxis = (BOOLEAN *)Alloc((pVariables+1)*sizeof(BOOLEAN));
1338  for (j=1; j<=pVariables; j++) strat->NotUsedAxis[j] = TRUE;
1339  strat->enterS = enterSMora;
1340  strat->initEcartPair = initEcartPairMora; /*- ecart approximation -*/
1341  strat->posInLOld = strat->posInL;
1342  strat->posInLOldFlag = TRUE;
1343  strat->initEcart = initEcartNormal;
1344  strat->kHEdgeFound = ppNoether != NULL;
1345  if ( strat->kHEdgeFound )
1346     strat->kNoether = pCopy(ppNoether);
1347  if (BTEST1(20))
1348    strat->red = redMoraBest;/*- look for the best in T -*/
1349  else if (strat->kHEdgeFound || strat->homog)
1350    strat->red = redFirst;  /*take the first possible in T*/
1351  else if (BTEST1(19))
1352    strat->red = redEcart19;/*take the first possible in T, rquires T sorted by ecart*/
1353  else
1354    strat->red = redEcart;/*take the first possible in under ecart-restriction*/
1355  if (strat->kHEdgeFound)
1356  {
1357    strat->HCord = pFDeg(ppNoether)+1;
1358    strat->posInT = posInT2;
1359  }
1360  else
1361  {
1362    strat->HCord = 32000;/*- very large -*/
1363  }
1364  /*reads the ecartWeights used for Graebes method from the
1365   *intvec ecart and set ecartWeights
1366   */
1367  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1368  {
1369    //interred  machen   Aenderung
1370    pFDegOld=pFDeg;
1371    pLDegOld=pLDeg;
1372    h=ggetid("ecart");
1373    if ((h!=NULL) && (IDTYP(h)==INTVEC_CMD))
1374    {
1375      ecartWeights=iv2array(IDINTVEC(h));
1376    }
1377    else
1378    {
1379      ecartWeights=(short *)Alloc((pVariables+1)*sizeof(short));
1380      /*uses automatic computation of the ecartWeights to set them*/
1381      kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights);
1382    }
1383    pFDeg=totaldegreeWecart;
1384    pLDeg=maxdegreeWecart;
1385    for(i=1; i<=pVariables; i++)
1386      Print(" %d",ecartWeights[i]);
1387    PrintLn();
1388    mflush();
1389  }
1390}
1391
1392ideal mora (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
1393{
1394  int srmax;
1395  int lrmax = 0;
1396  int olddeg = 0;
1397  int reduc = 0;
1398  int hilbeledeg=1,hilbcount=0;
1399
1400#ifdef SDRING
1401  polyset aug=(polyset)Alloc(setmax*sizeof(poly));
1402  int augmax=setmax, augl=-1;
1403  poly oldLcm;
1404#endif
1405
1406  strat->update = TRUE;
1407  /*- setting global variables ------------------- -*/
1408  initBuchMoraCrit(strat);
1409  initHilbCrit(F,Q,&hilb,strat);
1410  initMora(F,strat);
1411  initBuchMoraPos(strat);
1412  /*Shdl=*/initBuchMora(F,Q,strat);
1413  if (TEST_OPT_FASTHC) missingAxis(&strat->lastAxis,strat);
1414  /*updateS in initBuchMora has Hecketest
1415  * and could have put strat->kHEdgdeFound FALSE*/
1416  if (ppNoether!=NULL)
1417  {
1418    strat->kHEdgeFound = TRUE;
1419  }
1420  if (strat->kHEdgeFound && strat->update)
1421  {
1422    firstUpdate(strat);
1423    updateLHC(strat);
1424    reorderL(strat);
1425  }
1426  if (TEST_OPT_FASTHC && (strat->lastAxis) && strat->posInLOldFlag)
1427  {
1428    strat->posInLOld = strat->posInL;
1429    strat->posInLOldFlag = FALSE;
1430    strat->posInL = posInL10;
1431    updateL(strat);
1432    reorderL(strat);
1433  }
1434  srmax = strat->sl;
1435  /*- compute-------------------------------------------*/
1436  while (strat->Ll >= 0)
1437  {
1438    if (lrmax< strat->Ll) lrmax=strat->Ll; /*stat*/
1439    //test_int_std(strat->kIdeal);
1440#ifdef KDEBUG
1441    if (TEST_OPT_DEBUG) messageSets(strat);
1442#endif
1443    if (TEST_OPT_DEGBOUND
1444    && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p)> Kstd1_deg))
1445    {
1446      /*
1447      * stops computation if
1448      * - 24 (degBound)
1449      *   && upper degree is bigger than Kstd1_deg
1450      */
1451      while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1452      break;
1453    }
1454    strat->P = strat->L[strat->Ll];/*- picks the last element from the lazyset L -*/
1455    if (strat->Ll==0) strat->interpt=TRUE;
1456    strat->Ll--;
1457    if (pNext(strat->P.p) == strat->tail)
1458    {
1459      pFree1(strat->P.p);/*- deletes the short spoly and computes -*/
1460      strat->P.p = spSpolyCreate(strat->P.p1,strat->P.p2,strat->kNoether);/*- the real one -*/
1461      if (!strat->honey)
1462        strat->initEcart(&strat->P);
1463      else
1464        strat->P.length = pLength(strat->P.p);
1465    }
1466#ifdef SDRING
1467    if (strat->P.p != NULL)
1468#endif
1469    {
1470      if (TEST_OPT_PROT) message(strat->P.ecart+pFDeg(strat->P.p),&olddeg,&reduc,strat);
1471      strat->red(&strat->P,strat);/*- reduction of the element choosen from L -*/
1472    }
1473    if (strat->P.p != NULL)
1474    {
1475#ifdef SDRING
1476      aug[0]=strat->P.p;
1477      augl=0;
1478      if (pSDRING)
1479      {
1480        oldLcm=strat->P.lcm;
1481#ifdef SRING
1482        if (pSRING) psAug(pCopy(strat->P.p),pOne(),&aug,&augl,&augmax);
1483#endif
1484#ifdef DRING
1485        if (pDRING) pdAug(pCopy(strat->P.p),&aug,&augl,&augmax);
1486#endif
1487      }
1488      for (augl++;augl != 0;)
1489      {
1490        strat->P.p=aug[--augl];
1491        if (pSDRING)
1492        {
1493          if (oldLcm==NULL) strat->P.lcm=NULL;
1494          else  strat->P.lcm=pCopy1(oldLcm);
1495        }
1496        if ((augl!=0) && (strat->P.p!=NULL)) strat->red(&strat->P,strat);
1497        if (strat->P.p != NULL)
1498        {
1499#endif
1500          if (TEST_OPT_PROT) PrintS("s");/*- statistic -*/
1501          /*- enter P.p into s and b: -*/
1502          if (!TEST_OPT_INTSTRATEGY)
1503          {
1504            pNorm(strat->P.p);
1505          }
1506          strat->P.p = redtail(strat->P.p,strat->sl,strat);
1507          if ((!strat->noTailReduction) && (!strat->honey))
1508          {
1509            strat->initEcart(&strat->P);
1510          }
1511          if (TEST_OPT_INTSTRATEGY)
1512          {
1513            //pContent(strat->P.p);
1514            pCleardenom(strat->P.p);// also does a pContent
1515          }
1516          cancelunit(&strat->P);/*- tries to cancel a unit -*/
1517          enterT(strat->P,strat);
1518          {
1519            int pos;
1520#ifdef SDRING
1521            pos = posInS(strat->S,strat->sl,strat->P.p);
1522            if (pSDRING && (pos<=strat->sl)
1523            && (pComparePolys(strat->P.p,strat->S[pos])))
1524            {
1525              if (TEST_OPT_PROT)
1526                PrintS("d");
1527            }
1528            else
1529#endif
1530            {
1531              enterpairs(strat->P.p,strat->sl,strat->P.ecart,0,strat);
1532              if (strat->sl==-1)
1533              {
1534                pos=0;
1535              }
1536              else
1537              {
1538                pos = posInS(strat->S,strat->sl,strat->P.p);
1539              }
1540              strat->enterS(strat->P,pos,strat);
1541            }
1542            if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
1543          }
1544          if (strat->P.lcm!=NULL) pFree1(strat->P.lcm);
1545#ifdef KDEBUG
1546          strat->P.lcm=NULL;
1547#endif
1548#ifdef SDRING
1549        }
1550      }
1551      /* delete the old pair */
1552      if (pSDRING &&(oldLcm!=NULL)) pFree1(oldLcm);
1553#endif
1554#ifdef KDEBUG
1555      memset(&strat->P,0,sizeof(strat->P));
1556#endif
1557      if (strat->sl>srmax) srmax = strat->sl; /*stat.*/
1558      if (strat->Ll>lrmax) lrmax = strat->Ll;
1559    }
1560    if (strat->kHEdgeFound)
1561    {
1562      if ((BTEST1(27))
1563      || ((TEST_OPT_MULTBOUND) && (scMult0Int((strat->Shdl)) < mu)))
1564      {
1565        /*
1566        * stops computation if strat->kHEdgeFound and
1567        * - 27 (finiteDeterminacyTest)
1568        * or
1569        * - 23
1570        *   (multBound)
1571        *   && multiplicity of the ideal is smaller then a predefined number mu
1572        */
1573        while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
1574      }
1575    }
1576  }
1577  /*- complete reduction of the standard basis------------------------ -*/
1578  if (TEST_OPT_REDSB) completeReduce(strat);
1579  /*- release temp data------------------------------- -*/
1580  exitBuchMora(strat);
1581  /*- polynomials used for HECKE: HC, noether -*/
1582  if (BTEST1(27))
1583  {
1584    if (strat->kHEdge!=NULL)
1585      Kstd1_mu=pFDeg(strat->kHEdge);
1586    else
1587      Kstd1_mu=-1;
1588  }
1589  pDelete(&strat->kHEdge);
1590  strat->update = TRUE; //???
1591  strat->lastAxis = 0; //???
1592  pDelete(&strat->kNoether);
1593  Free((ADDRESS)strat->NotUsedAxis,(pVariables+1)*sizeof(BOOLEAN));
1594#ifdef SDRING
1595  Free((ADDRESS)aug,augmax*sizeof(poly));
1596#endif
1597  if (TEST_OPT_PROT) messageStat(srmax,lrmax,hilbcount,strat);
1598  if (TEST_OPT_WEIGHTM)
1599  {
1600    pFDeg=pFDegOld;
1601    pLDeg=pLDegOld;
1602    if (ecartWeights)
1603    {
1604      Free((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
1605      ecartWeights=NULL;
1606    }
1607  }
1608  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
1609  return (strat->Shdl);
1610}
1611
1612poly kNF1 (ideal F,ideal Q,poly q, kStrategy strat, int lazyReduce)
1613{
1614  poly   p;
1615  int   i;
1616  int   j;
1617  int   o;
1618  LObject   h;
1619  BITSET save_test=test;
1620
1621  if ((idIs0(F))&&(Q==NULL))
1622    return pCopy(q); /*F=0*/
1623  strat->ak = idRankFreeModule(F);
1624  /*- creating temp data structures------------------- -*/
1625  strat->kHEdgeFound = ppNoether != NULL;
1626  strat->kNoether    = pCopy(ppNoether);
1627  test|=Sy_bit(OPT_REDTAIL);
1628  test&=~Sy_bit(OPT_INTSTRATEGY);
1629  if (TEST_OPT_STAIRCASEBOUND
1630  && (0<Kstd1_deg)
1631  && ((!strat->kHEdgeFound)
1632    ||(TEST_OPT_DEGBOUND && (pWTotaldegree(strat->kNoether)<Kstd1_deg))))
1633  {
1634    pDelete(&strat->kNoether);
1635    strat->kNoether=pOne();
1636    pSetExp(strat->kNoether,1, Kstd1_deg+1);
1637    pSetm(strat->kNoether);
1638    strat->kHEdgeFound=TRUE;
1639  }
1640  initBuchMoraCrit(strat);
1641  initBuchMoraPos(strat);
1642  initMora(F,strat);
1643  strat->spSpolyLoop = spGetSpolyLoop(currRing, 
1644                                      MAX(strat->ak,pMaxComp(q)),
1645                                      strat->syzComp, FALSE);
1646  strat->enterS = enterSMoraNF;
1647  /*- set T -*/
1648  strat->tl = -1;
1649  strat->tmax = setmax;
1650  strat->T = initT();
1651  /*- set S -*/
1652  strat->sl = -1;
1653  /*- init local data struct.-------------------------- -*/
1654  /*Shdl=*/initS(F,Q,strat);
1655  if (lazyReduce==0)
1656  {
1657    for (i=strat->sl; i>=0; i--)
1658      pNorm(strat->S[i]);
1659  }
1660  /*- puts the elements of S also to T -*/
1661  for (i=0; i<=strat->sl; i++)
1662  {
1663    h.p = strat->S[i];
1664    h.ecart = strat->ecartS[i];
1665    h.length = pLength(h.p);
1666    enterT(h,strat);
1667  }
1668  /*- compute------------------------------------------- -*/
1669  p = pCopy(q);
1670  deleteHC(&p,&o,&j,strat);
1671  if (p!=NULL) p = redMoraNF(p,strat);
1672  if ((p!=NULL)&&(lazyReduce==0))
1673  {
1674    p = redtail(p,strat->sl,strat);
1675  }
1676  /*- release temp data------------------------------- -*/
1677  cleanT(strat);
1678  Free((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
1679  Free((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
1680  Free((ADDRESS)strat->NotUsedAxis,(pVariables+1)*sizeof(BOOLEAN));
1681  if ((Q!=NULL)&&(strat->fromQ!=NULL))
1682  {
1683    i=((IDELEMS(Q)+IDELEMS(F)+15)/16)*16;
1684    Free((ADDRESS)strat->fromQ,i*sizeof(int));
1685    strat->fromQ=NULL;
1686  }
1687  pDelete(&strat->kHEdge);
1688  pDelete(&strat->kNoether);
1689  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1690  {
1691    pFDeg=pFDegOld;
1692    pLDeg=pLDegOld;
1693    if (ecartWeights)
1694    {
1695      Free((ADDRESS *)&ecartWeights,(pVariables+1)*sizeof(short));
1696      ecartWeights=NULL;
1697    }
1698  }
1699  idDelete(&strat->Shdl);
1700  test=save_test;
1701  return p;
1702}
1703
1704ideal kNF1 (ideal F,ideal Q,ideal q, kStrategy strat, int lazyReduce)
1705{
1706  poly   p;
1707  int   i;
1708  int   j;
1709  int   o;
1710  LObject   h;
1711  ideal res;
1712  BITSET save_test=test;
1713
1714  if (idIs0(q)) return idInit(1,q->rank);
1715  if ((idIs0(F))&&(Q==NULL))
1716    return idCopy(q); /*F=0*/
1717  strat->ak = idRankFreeModule(F);
1718  /*- creating temp data structures------------------- -*/
1719  strat->kHEdgeFound = ppNoether != NULL;
1720  strat->kNoether=pCopy(ppNoether);
1721  test|=Sy_bit(OPT_REDTAIL);
1722  if (TEST_OPT_STAIRCASEBOUND
1723  && (0<Kstd1_deg)
1724  && ((!strat->kHEdgeFound)
1725    ||(TEST_OPT_DEGBOUND && (pWTotaldegree(strat->kNoether)<Kstd1_deg))))
1726  {
1727    pDelete(&strat->kNoether);
1728    strat->kNoether=pOne();
1729    pSetExp(strat->kNoether,1, Kstd1_deg+1);
1730    pSetm(strat->kNoether);
1731    strat->kHEdgeFound=TRUE;
1732  }
1733  initBuchMoraCrit(strat);
1734  initBuchMoraPos(strat);
1735  initMora(F,strat);
1736  strat->enterS = enterSMoraNF;
1737  /*- set T -*/
1738  strat->spSpolyLoop = spGetSpolyLoop(currRing, 
1739                                      MAX(strat->ak,idRankFreeModule(q)),
1740                                      strat->syzComp, FALSE);
1741  strat->tl = -1;
1742  strat->tmax = setmax;
1743  strat->T = initT();
1744  /*- set S -*/
1745  strat->sl = -1;
1746  /*- init local data struct.-------------------------- -*/
1747  /*Shdl=*/initS(F,Q,strat);
1748  if (TEST_OPT_INTSTRATEGY && (lazyReduce==0))
1749  {
1750    for (i=strat->sl; i>=0; i--)
1751      pNorm(strat->S[i]);
1752  }
1753  /*- compute------------------------------------------- -*/
1754  res=idInit(IDELEMS(q),q->rank);
1755  for (i=0; i<IDELEMS(q); i++)
1756  {
1757    if (q->m[i]!=NULL)
1758    {
1759      p = pCopy(q->m[i]);
1760      deleteHC(&p,&o,&j,strat);
1761      if (p!=NULL)
1762      {
1763        /*- puts the elements of S also to T -*/
1764        for (j=0; j<=strat->sl; j++)
1765        {
1766          h.p = strat->S[j];
1767          h.ecart = strat->ecartS[j];
1768          h.length = pLength(h.p);
1769          enterT(h,strat);
1770        }
1771        p = redMoraNF(p,strat);
1772        if ((p!=NULL)&&(lazyReduce==0))
1773        {
1774          p = redtail(p,strat->sl,strat);
1775        }
1776        cleanT(strat);
1777      }
1778      res->m[i]=p;
1779    }
1780    //else
1781    //  res->m[i]=NULL;
1782    if (TEST_OPT_PROT)
1783    {
1784      PrintS("-");mflush();
1785    }
1786  }
1787  /*- release temp data------------------------------- -*/
1788  Free((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
1789  Free((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
1790  if ((Q!=NULL)&&(strat->fromQ!=NULL))
1791  {
1792    i=((IDELEMS(Q)+IDELEMS(F)+15)/16)*16;
1793    Free((ADDRESS)strat->fromQ,i*sizeof(int));
1794    strat->fromQ=NULL;
1795  }
1796  pDelete(&strat->kHEdge);
1797  pDelete(&strat->kNoether);
1798  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
1799  {
1800    pFDeg=pFDegOld;
1801    pLDeg=pLDegOld;
1802    if (ecartWeights)
1803    {
1804      Free((ADDRESS *)&ecartWeights,(pVariables+1)*sizeof(short));
1805      ecartWeights=NULL;
1806    }
1807  }
1808  idDelete(&strat->Shdl);
1809  test=save_test;
1810  return res;
1811}
1812
1813pFDegProc pOldFDeg;
1814intvec * kModW;
1815
1816int kModDeg(poly p)
1817{
1818  int o=pTotaldegree(p);//quasihomogen!!
1819  int i=pGetComp(p);
1820  if (i==0) return o;
1821  return o+(*kModW)[i-1];
1822}
1823ideal std(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
1824          int newIdeal)
1825{
1826  ideal r;
1827  BOOLEAN b=pLexOrder,toReset=FALSE;
1828  BOOLEAN delete_w=(w==NULL);
1829  kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
1830
1831  if(!TEST_OPT_RETURN_SB)
1832    strat->syzComp = syzComp;
1833  if (TEST_OPT_SB_1)
1834    strat->newIdeal = newIdeal;
1835  if (currRing->ch==0) strat->LazyPass=2;
1836  else                 strat->LazyPass=20;
1837  strat->LazyDegree = 1;
1838  if ((h==testHomog)
1839#ifdef DRING
1840  && (!pDRING)
1841#endif
1842  )
1843  {
1844    strat->ak = idRankFreeModule(F);
1845    if (strat->ak == 0)       
1846    {
1847      h = (tHomog)idHomIdeal(F,Q);   
1848      w=NULL;
1849    }
1850    else
1851      h = (tHomog)idHomModule(F,Q,w); 
1852    //Print("test homog:%d\n",h);     
1853    //if ((h==isHomog)&&(w!=NULL)&&(*w!=NULL))
1854    //{
1855    //  (*w)->show();
1856    //  PrintLn();
1857    //  if (F!=NULL) jjPRINT_MA0(idModule2Matrix(idCopy(F)),sNoName);   
1858    //}
1859  }
1860#ifdef DRING
1861  if (pDRING) h=isNotHomog;
1862#endif
1863  if (h==isHomog)
1864  {
1865    if ((w!=NULL) && (*w!=NULL))     
1866    {
1867      kModW = *w;
1868      strat->kModW = *w;
1869      pOldFDeg = pFDeg;
1870      pFDeg = kModDeg;
1871      toReset = TRUE;
1872    }
1873    pLexOrder = TRUE;
1874    if (hilb==NULL) strat->LazyPass*=2;
1875  }
1876  strat->homog=h;
1877  spSet(currRing);
1878  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
1879  if (pOrdSgn==-1)
1880  {
1881    if (w!=NULL)
1882      r=mora(F,Q,*w,hilb,strat);     
1883    else
1884      r=mora(F,Q,NULL,hilb,strat);
1885  }
1886  else
1887  {
1888    #ifdef STDTRACE
1889    lists l;
1890    if (w!=NULL)
1891      l=bbaLink(F,Q,*w,hilb,strat);
1892    else
1893      l=bbaLink(F,Q,NULL,hilb,strat);
1894    r=(ideal)(l->m[0].data);
1895    l->m[0].data=NULL;
1896    l->Clean();
1897    #else
1898    if (w!=NULL)
1899      r=bba(F,Q,*w,hilb,strat);
1900    else
1901      r=bba(F,Q,NULL,hilb,strat);
1902    #endif
1903  }
1904#ifdef KDEBUG
1905  int i;
1906  for (i=0; i<IDELEMS(r); i++) pTest(r->m[i]);
1907#endif
1908  if (toReset)
1909  {
1910    kModW = NULL;
1911    pFDeg = pOldFDeg;
1912  }
1913  pLexOrder = b;
1914//Print("%d reductions canceled \n",strat->cel);
1915  HCord=strat->HCord;
1916  Free((ADDRESS)strat,sizeof(skStrategy));
1917  if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
1918  return r;
1919}
1920
1921//##############################################################
1922//##############################################################
1923//##############################################################
1924//##############################################################
1925//##############################################################
1926
1927#ifdef STDTRACE
1928lists TraceStd(leftv lv,int rw, ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
1929          int newIdeal)
1930{
1931  lists l;
1932  ideal r;
1933  stdLink stdTrace=(stdLink) Alloc0(sizeof(skstdLink));
1934  BOOLEAN b=pLexOrder,toReset=FALSE;
1935  BOOLEAN delete_w=(w==NULL);
1936  kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
1937
1938  if(!TEST_OPT_RETURN_SB)
1939    strat->syzComp = syzComp;
1940  if (TEST_OPT_SB_1)
1941    strat->newIdeal = newIdeal;
1942  strat->LazyPass=32000;
1943  strat->LazyDegree = 10;
1944//   if(stdTrace!=NULL)
1945//     stdTrace->GetPrimes(F,primes);  // Array mit Primzahlen muß geordnet sein !
1946
1947  if ((h==testHomog)
1948#ifdef DRING
1949  && (!pDRING)
1950#endif
1951  )
1952  {
1953    strat->ak = idRankFreeModule(F);
1954    if (strat->ak == 0)
1955    {
1956      h = (tHomog)idHomIdeal(F,Q);
1957      w=NULL;
1958    }
1959    else
1960      h = (tHomog)idHomModule(F,Q,w);
1961  }
1962#ifdef DRING
1963  if (pDRING) h=isNotHomog;
1964#endif
1965  if (h==isHomog)
1966  {
1967    if ((w!=NULL) && (*w!=NULL))
1968    {
1969      kModW = *w;
1970      strat->kModW = *w;
1971      pOldFDeg = pFDeg;
1972      pFDeg = kModDeg;
1973      toReset = TRUE;
1974    }
1975    pLexOrder = TRUE;
1976    if (hilb==NULL) strat->LazyPass*=2;
1977  }
1978  strat->homog=h;
1979  spSet(currRing);
1980  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
1981//   if (pOrdSgn==-1)
1982//   {
1983//     if (w!=NULL)
1984//       r=mora(F,Q,*w,hilb,strat);
1985//     else
1986//       r=mora(F,Q,NULL,hilb,strat);
1987//   }
1988//   else
1989  {
1990    stdTrace->Init(lv,rw);
1991    if(w==NULL)
1992      l=bbaLink(F,Q,NULL,hilb,strat,stdTrace);
1993    else
1994      l=bbaLink(F,Q,*w,hilb,strat,stdTrace);
1995    r=(ideal) (l->m[0].Data());
1996  }
1997#ifdef KDEBUG
1998  int i;
1999  for (i=0; i<IDELEMS(r); i++) pTest(r->m[i]);
2000#endif
2001  if (toReset)
2002  {
2003    kModW = NULL;
2004    pFDeg = pOldFDeg;
2005  }
2006  pLexOrder = b;
2007//Print("%d reductions canceled \n",strat->cel);
2008  HCord=strat->HCord;
2009  Free((ADDRESS)strat,sizeof(skStrategy));
2010  if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
2011  if(stdTrace!=NULL)
2012  {
2013    stdTrace->Kill();
2014    Free(stdTrace, sizeof(skstdLink));
2015  }
2016
2017  return l;
2018}
2019#endif
2020
2021lists min_std(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
2022              int reduced)
2023{
2024  ideal r=NULL;
2025  int Kstd1_OldDeg,i;
2026  BOOLEAN b=pLexOrder,toReset=FALSE;
2027  BOOLEAN delete_w=(w==NULL);
2028  BOOLEAN oldDegBound=TEST_OPT_DEGBOUND;
2029  kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
2030
2031  if(!TEST_OPT_RETURN_SB)
2032     strat->syzComp = syzComp;
2033  if (currRing->ch==0) strat->LazyPass=2;
2034  else                 strat->LazyPass=20;
2035  strat->LazyDegree = 1;
2036  strat->minim=(reduced % 2)+1;
2037  if ((h==testHomog)
2038#ifdef DRING
2039  && (!pDRING)
2040#endif
2041  )
2042  {
2043    strat->ak = idRankFreeModule(F);
2044    if (strat->ak == 0)
2045    {
2046      h = (tHomog)idHomIdeal(F,Q);
2047      w=NULL;
2048    }
2049    else
2050    {
2051      h = (tHomog)idHomModule(F,Q,w);
2052    }
2053  }
2054#ifdef DRING
2055  if (pDRING) h=isNotHomog;
2056#endif
2057  if (h==isHomog)
2058  {
2059    if ((w!=NULL) && (*w!=NULL))
2060    {
2061      kModW = *w;
2062      strat->kModW = *w;
2063      pOldFDeg = pFDeg;
2064      pFDeg = kModDeg;
2065      toReset = TRUE;
2066      if (reduced>1)
2067      {
2068        Kstd1_OldDeg=Kstd1_deg;
2069        Kstd1_deg = -1;
2070        for (i=IDELEMS(F)-1;i>=0;i--)
2071        {
2072          if ((F->m[i]!=NULL) && (pFDeg(F->m[i])>=Kstd1_deg))
2073            Kstd1_deg = pFDeg(F->m[i])+1;
2074        }
2075      }
2076    }
2077    pLexOrder = TRUE;
2078    strat->LazyPass*=2;
2079  }
2080  strat->homog=h;
2081  spSet(currRing);
2082  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
2083  if (pOrdSgn==-1)
2084  {
2085    if (w!=NULL)
2086      r=mora(F,Q,*w,hilb,strat);
2087    else
2088      r=mora(F,Q,NULL,hilb,strat);
2089  }
2090  else
2091  {
2092  #ifdef STDTRACE
2093    lists rl;
2094    if (w!=NULL)
2095      rl=bbaLink(F, Q, *w, hilb, strat, NULL);
2096    else
2097      rl=bbaLink(F, Q, NULL, hilb, strat, NULL);
2098    r=(ideal)(rl->m[0].data);
2099    rl->m[0].data=NULL;
2100    rl->Clean();
2101  #else
2102    if (w!=NULL)
2103      r=bba(F,Q,*w,hilb,strat);
2104    else
2105      r=bba(F,Q,NULL,hilb,strat);
2106  #endif
2107  }
2108#ifdef KDEBUG
2109  {
2110    int i;
2111    for (i=0; i<IDELEMS(r); i++) pTest(r->m[i]);
2112  }
2113#endif
2114  idSkipZeroes(r);
2115  if (toReset)
2116  {
2117    kModW = NULL;
2118    pFDeg = pOldFDeg;
2119  }
2120  pLexOrder = b;
2121  HCord=strat->HCord;
2122  if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
2123  lists l=(lists)Alloc(sizeof(slists));
2124  l->Init(2);
2125  l->m[0].rtyp=IDEAL_CMD;
2126  l->m[0].data=(void *)r;
2127  setFlag(&(l->m[0]),FLAG_STD);
2128  l->m[1].rtyp=IDEAL_CMD;
2129  if (strat->M==NULL)
2130  {
2131    l->m[1].data=(void *)idInit(1,F->rank);
2132    Warn("no minimal generating set computed");
2133  } 
2134  else
2135  {
2136    idSkipZeroes(strat->M);
2137    l->m[1].data=(void *)strat->M;
2138  }
2139  Free((ADDRESS)strat,sizeof(skStrategy));
2140  if (reduced>2)
2141  { 
2142    Kstd1_deg=Kstd1_OldDeg;
2143    if (!oldDegBound)
2144      test &= ~Sy_bit(OPT_DEGBOUND);
2145  }
2146  return l;
2147}
2148
2149poly kNF(ideal F, ideal Q, poly p,int syzComp, int lazyReduce)
2150{
2151  if (p==NULL)
2152     return NULL;
2153  kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
2154  strat->syzComp = syzComp;
2155  spSet(currRing);
2156  if (pOrdSgn==-1)
2157    p=kNF1(F,Q,p,strat,lazyReduce);
2158  else
2159    p=kNF2(F,Q,p,strat,lazyReduce);
2160  Free((ADDRESS)strat,sizeof(skStrategy));
2161  return p;
2162}
2163
2164ideal kNF(ideal F, ideal Q, ideal p,int syzComp,int lazyReduce)
2165{
2166  ideal res;
2167  spSet(currRing);
2168  if (TEST_OPT_PROT)
2169  {
2170    Print("(S:%d)",IDELEMS(p));mflush();
2171  }
2172  kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
2173  strat->syzComp = syzComp;
2174  if (pOrdSgn==-1)
2175    res=kNF1(F,Q,p,strat,lazyReduce);
2176  else
2177    res=kNF2(F,Q,p,strat,lazyReduce);
2178  if (TEST_OPT_PROT)
2179  {
2180    PrintLn();
2181  }
2182  Free((ADDRESS)strat,sizeof(skStrategy));
2183  return res;
2184}
2185
2186/*2
2187*interreduces F
2188*/
2189ideal kInterRed (ideal F, ideal Q)
2190{
2191  int j;
2192  kStrategy strat = (kStrategy)Alloc0(sizeof(skStrategy));
2193
2194//  if (TEST_OPT_PROT)
2195//  {
2196//    writeTime("start InterRed:");
2197//    mflush();
2198//  }
2199  //strat->syzComp     = 0;
2200  strat->kHEdgeFound = ppNoether != NULL;
2201  strat->kNoether=pCopy(ppNoether);
2202  strat->ak = idRankFreeModule(F);
2203  spSet(currRing);
2204  initBuchMoraCrit(strat);
2205  strat->NotUsedAxis = (BOOLEAN *)Alloc((pVariables+1)*sizeof(BOOLEAN));
2206  for (j=1; j<=pVariables; j++) strat->NotUsedAxis[j] = TRUE;
2207  strat->enterS      = enterSBba;
2208  strat->posInT      = posInT0;
2209  strat->initEcart   = initEcartNormal;
2210  strat->sl   = -1;
2211  strat->tl          = -1;
2212  strat->tmax        = setmax;
2213  strat->T           = initT();
2214  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
2215  if (pOrdSgn == -1)   strat->honey = TRUE;
2216  initS(F,Q,strat);
2217  updateS(TRUE,strat);
2218  if (TEST_OPT_REDSB && TEST_OPT_INTSTRATEGY)
2219    completeReduce(strat);
2220  pDelete(&strat->kHEdge);
2221  Free((ADDRESS)strat->T,strat->tmax*sizeof(TObject));
2222  Free((ADDRESS)strat->ecartS,IDELEMS(strat->Shdl)*sizeof(int));
2223  Free((ADDRESS)strat->NotUsedAxis,(pVariables+1)*sizeof(BOOLEAN));
2224  if (strat->fromQ)
2225  {
2226    for (j=0;j<IDELEMS(strat->Shdl);j++)
2227    {
2228      if(strat->fromQ[j]) pDelete(&strat->Shdl->m[j]);
2229    }
2230    Free((ADDRESS)strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
2231    strat->fromQ=NULL;
2232    idSkipZeroes(strat->Shdl);
2233  }
2234//  if (TEST_OPT_PROT)
2235//  {
2236//    writeTime("end Interred:");
2237//    mflush();
2238//  }
2239  ideal shdl=strat->Shdl;
2240  Free((ADDRESS)strat,sizeof(skStrategy));
2241  return shdl;
2242}
Note: See TracBrowser for help on using the repository browser.