source: git/Singular/kstd1.cc @ 0e760d0

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