source: git/Singular/kstdfac.cc @ a28e0e9

spielwiese
Last change on this file since a28e0e9 was a28e0e9, checked in by Hans Schönemann <hannes@…>, 26 years ago
* hannes: additional factorization check after redTail (kstdfac.cc) git-svn-id: file:///usr/local/Singular/svn/trunk@1155 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 19.6 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: kstdfac.cc,v 1.11 1998-02-17 17:53:01 Singular Exp $ */
5/*
6*  ABSTRACT -  Kernel: factorizing alg. of Buchberger
7*/
8
9#include "mod2.h"
10#include "tok.h"
11#include "mmemory.h"
12#include "polys.h"
13#include "ideals.h"
14#include "febase.h"
15#include "kutil.h"
16#include "kstd1.h"
17#include "kstd2.h"
18#include "khstd.h"
19#include "spolys.h"
20#include "cntrlc.h"
21#include "weight.h"
22#include "ipid.h"
23#include "ipshell.h"
24#include "intvec.h"
25#ifdef HAVE_FACTORY
26#include "clapsing.h"
27#endif
28#include "lists.h"
29#include "ideals.h"
30#ifdef COMP_FAST
31#include "spSpolyLoop.h"
32#endif
33#include "timer.h"
34#include "kstdfac.h"
35
36#ifdef HAVE_FACTORY
37/*3
38* copy o->T to n->T, assumes that n->S is already copied
39*/
40static void copyT (kStrategy o,kStrategy n)
41{
42  int i,j;
43  poly  p;
44  TSet t=(TSet)Alloc(o->tmax*sizeof(TObject));
45
46  for (j=0; j<=o->tl; j++)
47  {
48    p = o->T[j].p;
49    i = -1;
50    loop
51    {
52      i++;
53      if (i>o->sl)
54      {
55        t[j].p=pCopy(p);
56        t[j].ecart=o->T[j].ecart;
57        t[j].length=o->T[j].length;
58        break;
59      }
60      if (p == o->S[i])
61      {
62        t[j].p=n->S[i];
63        t[j].ecart=o->T[j].ecart;
64        t[j].length=o->T[j].length;
65        break;
66      }
67    }
68  }
69  n->T=t;
70}
71
72/*3
73* copy o->L to n->L, assumes that n->T,n->tail is already copied
74*/
75static void copyL (kStrategy o,kStrategy n)
76{
77  int i,j;
78  poly  p;
79  LSet l=(LSet)Alloc(o->Lmax*sizeof(LObject));
80
81  for (j=0; j<=o->Ll; j++)
82  {
83    if (o->L[j].p->next!=o->tail)
84      l[j].p=pCopy(o->L[j].p);
85    else
86    {
87      l[j].p=pHead(o->L[j].p);
88      l[j].p->next=n->tail;
89    }
90    if (o->L[j].lcm!=NULL)
91      l[j].lcm=pCopy1(o->L[j].lcm);
92    else
93      l[j].lcm=NULL;
94    l[j].ecart=o->L[j].ecart;
95    l[j].length=o->L[j].length;
96    l[j].p1=NULL;
97    l[j].p2=NULL;
98
99    p = o->L[j].p1;
100    i = -1;
101    loop
102    {
103      if(p==NULL) break;
104      i++;
105      if(i>o->tl)
106      {
107        Print("poly p1 not found in T:");wrp(p);PrintLn();
108        l[j].p1=pCopy(p);
109        break;
110      }
111      if (p == o->T[i].p)
112      {
113        l[j].p1=n->T[i].p;
114        break;
115      }
116    }
117
118    p = o->L[j].p2;
119    i = -1;
120    loop
121    {
122      if(p==NULL) break;
123      i++;
124      if(i>o->tl)
125      {
126        Print("poly p2 not found in T:");wrp(p);PrintLn();
127        l[j].p2=pCopy(p);
128        break;
129      }
130      if (p == o->T[i].p)
131      {
132        l[j].p2=n->T[i].p;
133        break;
134      }
135    }
136  }
137  n->L=l;
138}
139
140kStrategy kStratCopy(kStrategy o)
141{
142  kStrategy s=(kStrategy)Alloc0(sizeof(skStrategy));
143  s->next=NULL;
144  s->red=o->red;
145  s->initEcart=o->initEcart;
146  s->posInT=o->posInT;
147  s->posInL=o->posInL;
148  s->enterS=o->enterS;
149  s->initEcartPair=o->initEcartPair;
150  s->posInLOld=o->posInLOld;
151  s->pOldFDeg=o->pOldFDeg;
152  s->Shdl=idCopy(o->Shdl);
153  s->S=s->Shdl->m;
154  if (o->D!=NULL) s->D=idCopy(o->D);
155  else            s->D=NULL;
156  s->ecartS=(int *)Alloc(IDELEMS(o->Shdl)*sizeof(int));
157  memcpy(s->ecartS,o->ecartS,IDELEMS(o->Shdl)*sizeof(int));
158  if(o->fromQ!=NULL)
159  {
160    s->fromQ=(int *)Alloc(IDELEMS(o->Shdl)*sizeof(int));
161    memcpy(s->fromQ,o->fromQ,IDELEMS(o->Shdl)*sizeof(int));
162  }
163  else
164    s->fromQ=NULL;
165  copyT(o,s);//s->T=...
166  s->tail=pInit();
167  copyL(o,s);//s->L=...
168  s->B=initL();
169  s->kHEdge=pCopy(o->kHEdge);
170  s->kNoether=pCopy(o->kNoether);
171  if (o->NotUsedAxis!=NULL)
172  {
173    s->NotUsedAxis=(BOOLEAN *)Alloc(currRing->N*sizeof(BOOLEAN));
174    memcpy(s->NotUsedAxis,o->NotUsedAxis,currRing->N*sizeof(BOOLEAN));
175  }
176  s->kIdeal=NULL;
177  s->P=s->L[s->Ll+1];
178  s->update=o->update;
179  s->posInLOldFlag=o->posInLOldFlag;
180  if (o->kModW!=NULL)
181    s->kModW=ivCopy(o->kModW);
182  else
183    s->kModW=NULL;
184  s->pairtest=NULL;
185  s->sl=o->sl;
186  s->mu=o->mu;
187  s->tl=o->tl;
188  s->tmax=o->tmax;
189  s->Ll=o->Ll;
190  s->Lmax=o->Lmax;
191  s->Bl=-1;
192  s->Bmax=setmax;
193  s->ak=o->ak;
194  s->syzComp=o->syzComp;
195  s->LazyPass=o->LazyPass;
196  s->LazyDegree=o->LazyDegree;
197  s->HCord=o->HCord;
198  s->lastAxis=o->lastAxis;
199  s->interpt=o->interpt;
200  s->homog=o->homog;
201  s->news=o->news;
202  s->newt=o->newt;
203  s->kHEdgeFound=o->kHEdgeFound;
204  s->honey=o->honey;
205  s->sugarCrit=o->sugarCrit;
206  s->Gebauer=o->Gebauer;
207  s->noTailReduction=o->noTailReduction;
208  s->fromT=o->fromT;
209  s->noetherSet=o->noetherSet;
210#ifdef COMP_FAST
211  s->spSpolyLoop = o->spSpolyLoop;
212#endif 
213  return s;
214}
215
216static void completeReduceFac (kStrategy strat, lists FL)
217{
218  int si;
219
220  strat->noTailReduction = FALSE;
221  if (TEST_OPT_PROT)
222  {
223    PrintLn();
224    if (timerv) writeTime("standard base computed:");
225  }
226  if (TEST_OPT_PROT)
227  {
228    Print("(S:%d)",strat->sl);mflush();
229  }
230  for (si=strat->sl; si>0; si--)
231  {
232    //if (strat->interpt) test_int_std(strat->kIdeal);
233    strat->S[si] = redtailBba(strat->S[si],si-1,strat);
234    if (TEST_OPT_INTSTRATEGY)
235    {
236      pCleardenom(strat->S[si]);
237    }
238    if (TEST_OPT_PROT)
239    {
240      PrintS("-");mflush();
241    }
242    int facdeg=pFDeg(strat->S[si]);
243
244    ideal fac=singclap_factorize(strat->S[si],NULL,1);
245#ifndef HAVE_LIBFAC_P
246    if (fac==NULL)
247    {
248      fac=idInit(1,1);
249      fac->m[0]=pCopy(strat->S[si]);
250    }
251#endif
252
253    if ((IDELEMS(fac)==1)&&(facdeg==pFDeg(fac->m[0])))
254    {
255      idDelete(&fac);
256      continue;
257    }
258    if (TEST_OPT_DEBUG)
259    {
260      wrp(strat->S[si]);
261      Print(" (=S[%d]) -> %d factors\n",si,IDELEMS(fac));
262    }
263    ideal fac_copy=idInit(IDELEMS(fac),1);
264    deleteInS(si,strat);
265    int i;
266    for(i=IDELEMS(fac)-1;i>=0;i--)
267    {
268      kStrategy n=strat;
269      if (i>=1)
270      {
271        n=kStratCopy(strat);
272        n->next=strat->next;
273        strat->next=n;
274      }
275      memset(&n->P,0,sizeof(n->P));
276
277      n->P.p=fac->m[i];
278      n->initEcart(&n->P);
279
280      /* enter P.p into s and L */
281      int pos;
282      if (n->sl==-1) pos=0;
283      else pos=posInS(n->S,n->sl,n->P.p);
284      if (TEST_OPT_INTSTRATEGY)
285      {
286        if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
287        {
288          n->P.p = redtailBba(n->P.p,pos-1,n);
289          pCleardenom(n->P.p);
290        }
291      }
292      else
293      {
294        pNorm(n->P.p);
295        if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
296        {
297          n->P.p = redtailBba(n->P.p,pos-1,n);
298        }
299      }
300      if (TEST_OPT_DEBUG)
301      {
302        PrintS("new s:");
303        wrp(n->P.p);
304        PrintLn();
305      }
306      enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
307      n->enterS(n->P,pos,n);
308
309      /* enter P.p into T */
310      if ((IDELEMS(fac)>1)||(facdeg!=pFDeg(fac->m[0])))
311      {
312        int pos=n->posInT(n->T,n->tl,n->P);
313        enterTBba(n->P,pos,n);
314      }
315
316      /* construct D */
317      if (IDELEMS(fac)>1)
318      {
319        idTest(fac_copy);
320        idTest(n->D);
321        if (n->D==NULL)
322        {
323          n->D=idCopy(fac_copy);
324          idSkipZeroes(n->D);
325        }
326        else
327        {
328          ideal r=idAdd(n->D,fac_copy);
329          idDelete(&n->D);
330          n->D=r;
331        }
332        idTest(n->D);
333        if (TEST_OPT_DEBUG)
334        {
335          PrintS("new D:\n");
336          iiWriteMatrix((matrix)n->D,"D",1,0);
337          PrintLn();
338        }
339        idTest(n->D);
340      }
341
342      idTest(fac_copy);
343
344      fac_copy->m[i]=pCopy(fac->m[i]);
345      fac->m[i]=NULL;
346
347      idTest(fac_copy);
348
349      /* check for empty sets */
350      if (n->D!=NULL)
351      {
352        int j=IDELEMS(n->D)-1;
353        while(j>=0)
354        {
355          if (n->D->m[j]!=NULL)
356          {
357            poly r=kNF(n->Shdl,NULL,n->D->m[j],0,TRUE);
358            if (r==NULL)
359            {
360              if (TEST_OPT_DEBUG)
361              {
362                PrintS("empty set because:");
363                wrp(n->D->m[j]);
364                PrintLn();
365                messageSets(n);
366              }
367              while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
368              while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
369              memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
370              n->sl=-1;
371              if (strat==n) si=-1;
372              break;
373            }
374            else
375            {
376              pDelete(&r);
377            }
378          }
379          j--;
380        }
381      }
382      /* check for empty sets */
383      {
384        int j=FL->nr;
385        while (j>=0)
386        {
387          if ((n->sl>=0)&&(n->S[0]!=NULL))
388          {
389            ideal r=kNF(n->Shdl,NULL,(ideal)FL->m[j].Data(),0,TRUE);
390            if (idIs0(r))
391            {
392              if (TEST_OPT_DEBUG)
393              {
394                Print("empty set because:L[%d]\n",j);
395              }
396              while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
397              while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
398              memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
399              n->sl=-1;
400              if (strat==n) si=-1;
401              idDelete(&r);
402              break;
403            }
404            idDelete(&r);
405          }
406          j--;
407        }
408      }
409    } /* for */
410    for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
411    idDelete(&fac);
412    idDelete(&fac_copy);
413    if ((strat->Ll>=0) && (strat->sl>=0)) break;
414    else si=strat->sl+1;
415  }
416}
417
418ideal bbafac (ideal F, ideal Q,intvec *w,kStrategy strat, lists FL)
419{
420  int   srmax,lrmax;
421  int   olddeg,reduc;
422
423  srmax = strat->sl;
424  reduc = olddeg = lrmax = 0;
425  /* compute------------------------------------------------------- */
426  if ((strat->Ll==-1) && (strat->sl>=0))
427  {
428    if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
429  }
430  while (strat->Ll >= 0)
431  {
432    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
433    if (TEST_OPT_DEBUG) messageSets(strat);
434    //test_int_std(strat->kIdeal);
435    if (strat->Ll== 0) strat->interpt=TRUE;
436    if (TEST_OPT_DEGBOUND
437    && ((strat->honey && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p)>Kstd1_deg))
438       || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p)>Kstd1_deg))))
439    {
440      /*
441      *stops computation if
442      * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
443      *a predefined number Kstd1_deg
444      */
445      while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
446      break;
447    }
448    /* picks the last element from the lazyset L */
449    strat->P = strat->L[strat->Ll];
450    strat->Ll--;
451    kTest(strat);
452    if (pNext(strat->P.p) == strat->tail)
453    {
454      /* deletes the short spoly and computes */
455      pFree1(strat->P.p);
456      /* the real one */
457      strat->P.p = spSpolyCreate(strat->P.p1,strat->P.p2,strat->kNoether);
458    }
459    if (strat->honey)
460    {
461      if (TEST_OPT_PROT) message(strat->P.ecart+pFDeg(strat->P.p),&olddeg,&reduc,strat);
462    }
463    else
464    {
465      if (TEST_OPT_PROT) message(pFDeg(strat->P.p),&olddeg,&reduc,strat);
466    }
467    /* reduction of the element choosen from L */
468    strat->red(&strat->P,strat);
469    if (strat->P.p != NULL)
470    {
471      int facdeg=pFDeg(strat->P.p);
472      /* statistic */
473      if (TEST_OPT_PROT) PrintS("s");
474
475      ideal fac=singclap_factorize(strat->P.p,NULL,1);
476#ifndef HAVE_LIBFAC_P
477      if (fac==NULL)
478      {
479        fac=idInit(1,1);
480        fac->m[0]=pCopy(strat->P.p);
481      }
482#endif
483      ideal fac_copy=idInit(IDELEMS(fac),1);
484
485      if (TEST_OPT_DEBUG)
486      {
487        Print("-> %d factors\n",IDELEMS(fac));
488      }
489      if ((IDELEMS(fac)==1)&&(facdeg==pFDeg(fac->m[0])))
490      {
491        pDelete(&(fac->m[0]));
492        fac->m[0]=strat->P.p;
493      }
494      if (strat->P.lcm!=NULL) pFree1(strat->P.lcm);
495      int i;
496      for(i=0;i<IDELEMS(fac);i++)
497      {
498        int pos;
499        if (strat->sl==-1) pos=0;
500        else pos=posInS(strat->S,strat->sl,fac->m[i]);
501        if (TEST_OPT_INTSTRATEGY)
502        {
503          if (!TEST_OPT_MINRES||(strat->syzComp==0)||(!strat->homog))
504          {
505            fac->m[i] = redtailBba(fac->m[i],pos-1,strat);
506            pCleardenom(fac->m[i]);
507          }
508        }
509        else
510        {
511          pNorm(fac->m[i]);
512          if (!TEST_OPT_MINRES||(strat->syzComp==0)||(!strat->homog))
513          {
514            fac->m[i] = redtailBba(fac->m[i],pos-1,strat);
515          }
516        }
517        facdeg=pFDeg(fac->m[i]);
518        ideal fac2=singclap_factorize(fac->m[i],NULL,1);
519#ifndef HAVE_LIBFAC_P
520        if ((fac2!=NULL)&&(IDELEMS(fac2)>1)&&(facdeg!=pFDeg(fac2->m[0])))
521#else
522        if ((IDELEMS(fac2)>1)&&(facdeg!=pFDeg(fac2->m[0])))
523#endif
524        {
525          if (TEST_OPT_DEBUG)
526          {
527            wrp(fac->m[i]);
528            Print("-> %d factors, again\n",IDELEMS(fac2));
529            //jjPRINT_MA0((matrix)fac2,"");
530          }
531          pDelete(&(fac->m[i]));
532          fac->m[i]=fac2->m[0];
533          pEnlargeSet(&(fac->m),IDELEMS(fac),IDELEMS(fac2)-1);
534          memcpy(fac->m+IDELEMS(fac),&(fac2->m[1]),(IDELEMS(fac2)-1)*sizeof(poly
535));
536          IDELEMS(fac)+=(IDELEMS(fac2)-1);
537         }
538      }
539
540      for(i=IDELEMS(fac)-1;i>=0;i--)
541      {
542        kStrategy n=strat;
543        if (i>=1)
544        {
545          n=kStratCopy(strat);
546          n->next=strat->next;
547          strat->next=n;
548        }
549        memset(&n->P,0,sizeof(n->P));
550
551        n->P.p=fac->m[i];
552        n->initEcart(&n->P);
553
554        /* enter P.p into s and L */
555        int pos;
556        if (n->sl==-1) pos=0;
557        else pos=posInS(n->S,n->sl,n->P.p);
558        // we have already reduced all elements from fac....
559        //if (TEST_OPT_INTSTRATEGY)
560        //{
561        //  if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
562        //  {
563        //    n->P.p = redtailBba(n->P.p,pos-1,n);
564        //    pCleardenom(n->P.p);
565        //  }
566        //}
567        //else
568        //{
569        //  pNorm(n->P.p);
570        //  if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
571        //  {
572        //    n->P.p = redtailBba(n->P.p,pos-1,n);
573        //  }
574        //}
575        if (TEST_OPT_DEBUG)
576        {
577          PrintS("new s:");
578          wrp(n->P.p);
579          PrintLn();
580        }
581        enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
582        n->enterS(n->P,pos,n);
583        if (n->sl>srmax) srmax = n->sl;
584
585        /* enter P.p into T */
586        if ((IDELEMS(fac)>1)||(facdeg!=pFDeg(fac->m[0])))
587        {
588          int pos=n->posInT(n->T,n->tl,n->P);
589          enterTBba(n->P,pos,n);
590        }
591
592        /* construct D */
593        if (IDELEMS(fac)>1)
594        {
595          idTest(fac_copy);
596          idTest(n->D);
597          if (n->D==NULL)
598          {
599            n->D=idCopy(fac_copy);
600            idSkipZeroes(n->D);
601          }
602          else
603          {
604            ideal r=idAdd(n->D,fac_copy);
605            idDelete(&n->D);
606            n->D=r;
607          }
608          idTest(n->D);
609          if (TEST_OPT_DEBUG)
610          {
611            PrintS("new D:\n");
612            iiWriteMatrix((matrix)n->D,"D",1,0);
613            PrintLn();
614          }
615          idTest(n->D);
616        }
617
618        idTest(fac_copy);
619
620        fac_copy->m[i]=pCopy(fac->m[i]);
621        fac->m[i]=NULL;
622
623        idTest(fac_copy);
624
625        /* check for empty sets */
626        if (n->D!=NULL)
627        {
628          int j=IDELEMS(n->D)-1;
629          while(j>=0)
630          {
631            if (n->D->m[j]!=NULL)
632            {
633              poly r=kNF(n->Shdl,NULL,n->D->m[j],0,TRUE);
634              if (r==NULL)
635              {
636                if (TEST_OPT_DEBUG)
637                {
638                  PrintS("empty set because:");
639                  wrp(n->D->m[j]);
640                  PrintLn();
641                  messageSets(n);
642                }
643                while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
644                while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
645                memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
646                n->sl=-1;
647                break;
648              }
649              else
650              {
651                pDelete(&r);
652              }
653            }
654            j--;
655          }
656        }
657        /* check for empty sets */
658        {
659          int j=FL->nr;
660          while (j>=0)
661          {
662            if ((n->sl>=0)&&(n->S[0]!=NULL))
663            {
664              ideal r=kNF(n->Shdl,NULL,(ideal)FL->m[j].Data(),0,TRUE);
665              if (idIs0(r))
666              {
667                if (TEST_OPT_DEBUG)
668                {
669                  Print("empty set because:L[%d]\n",j);
670                }
671                while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
672                while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
673                memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
674                n->sl=-1;
675                idDelete(&r);
676                break;
677              }
678              idDelete(&r);
679            }
680            j--;
681          }
682        }
683      } /* for */
684      for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
685      idDelete(&fac);
686      idDelete(&fac_copy);
687    }
688#ifdef KDEBUG
689    strat->P.lcm=NULL;
690#endif
691    if ((strat->Ll==-1) && (strat->sl>=0))
692    {
693      if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
694    }
695    kTest(strat);
696  }
697  if (TEST_OPT_DEBUG) messageSets(strat);
698  /* complete reduction of the standard basis--------- */
699  /* release temp data-------------------------------- */
700  exitBuchMora(strat);
701  if (TEST_OPT_WEIGHTM)
702  {
703    pFDeg=pFDegOld;
704    pLDeg=pLDegOld;
705    if (ecartWeights)
706    {
707      Free((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
708      ecartWeights=NULL;
709    }
710  }
711  if (TEST_OPT_PROT) messageStat(srmax,lrmax,0,strat);
712  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
713  return (strat->Shdl);
714}
715#endif
716
717lists stdfac(ideal F, ideal Q, tHomog h,intvec ** w,ideal D)
718{
719#ifdef HAVE_FACTORY
720  ideal r;
721  BOOLEAN b=pLexOrder,toReset=FALSE;
722  BOOLEAN delete_w=(w==NULL);
723  kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
724  kStrategy orgstrat=strat;
725  lists L=(lists)Alloc(sizeof(slists)); L->Init(0);
726  sleftv v; memset(&v,0,sizeof(v));
727
728  if (currRing->ch==0) strat->LazyPass=2;
729  else                 strat->LazyPass=20;
730  strat->LazyDegree = 1;
731  if ((h==testHomog))
732  {
733    if (idRankFreeModule(F)==0)
734    {
735      h = (tHomog)idHomIdeal(F,Q);
736      w=NULL;
737    }
738    else
739      h = (tHomog)idHomModule(F,Q,w);
740  }
741  if (h==isHomog)
742  {
743    if ((w!=NULL) && (*w!=NULL))
744    {
745      kModW = *w;
746      pOldFDeg = pFDeg;
747      pFDeg = kModDeg;
748      toReset = TRUE;
749    }
750    pLexOrder = TRUE;
751    strat->LazyPass*=2;
752  }
753  strat->homog=h;
754  spSet(currRing);
755#ifdef COMP_FAST
756  strat->spSpolyLoop = spSetSpolyLoop(currRing, strat->syzComp, strat->ak, strat->homog);
757#endif 
758  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
759  initBuchMoraPos(strat);
760  initBba(F,strat);
761  initBuchMora(F, Q,strat);
762  if (D!=NULL)
763  {
764    strat->D=idCopy(D);
765  }
766// Ende der Initalisierung
767  while (strat!=NULL)
768  {
769    if (TEST_OPT_DEBUG)
770      PrintS("====================================\n");
771    if (w!=NULL)
772      r=bbafac(F,Q,*w,strat,L);
773    else
774      r=bbafac(F,Q,NULL,strat,L);
775#ifdef KDEBUG
776    int i;
777    for (i=0; i<IDELEMS(r); i++) pTest(r->m[i]);
778#endif
779    idSkipZeroes(r);
780    // Testausgabe:
781    //if (!idIs0(r))
782    //{
783    //  PrintS("===================================================\n");
784    //  iiWriteMatrix((matrix)r,"S",1,0);
785    //  PrintS("\n===================================================\n");
786    //}
787    //else
788    //{
789    //  PrintS("=========empty============================\n");
790    //}
791    strat=strat->next;
792    if(!idIs0(r))
793    {
794      v.rtyp=IDEAL_CMD;
795      v.data=(void *)r;
796      lists LL=lInsert0(L,&v,0);
797      L=LL;
798    }
799  }
800  /* check for empty sets */
801  {
802    int j=L->nr;
803    while (j>0)
804    {
805      int i=0;
806      while(i<j)
807      {
808        ideal r=kNF((ideal)L->m[j].Data(),NULL,(ideal)L->m[i].Data(),0,TRUE);
809        if (idIs0(r))
810        {
811          if (TEST_OPT_DEBUG)
812          {
813            Print("empty set L[%d] because:L[%d]\n",j,i);
814          }
815          // delete L[j],
816          i=0; j--;
817        } 
818        else
819        {
820          i++;
821        }
822        idDelete(&r);
823      }
824      j--;
825    }
826  }
827// Ende: aufraeumen
828  if (toReset)
829  {
830    kModW = NULL;
831    pFDeg = pOldFDeg;
832  }
833  pLexOrder = b;
834  strat=orgstrat;
835  while (strat!=NULL)
836  {
837    orgstrat=strat->next;
838    Free((ADDRESS)strat,sizeof(skStrategy));
839    strat=orgstrat;
840  }
841  if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
842  return L;
843#else
844  return NULL;
845#endif
846}
Note: See TracBrowser for help on using the repository browser.