source: git/Singular/kstdfac.cc @ 3a20c1

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