source: git/Singular/kstdfac.cc @ 5480da

spielwiese
Last change on this file since 5480da was 737b2b4, checked in by Olaf Bachmann <obachman@…>, 26 years ago
1998-03-23 Olaf Bachmann <obachman@mathematik.uni-kl.de> * kstdfac.cc (kStratCopy): kModW iv is not copied, but just the pointer is set git-svn-id: file:///usr/local/Singular/svn/trunk@1256 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.13 1998-03-23 14:07:54 obachman 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    ideal fac_copy=idInit(IDELEMS(fac),1);
261    deleteInS(si,strat);
262    int i;
263    for(i=IDELEMS(fac)-1;i>=0;i--)
264    {
265      kStrategy n=strat;
266      if (i>=1)
267      {
268        n=kStratCopy(strat);
269        n->next=strat->next;
270        strat->next=n;
271      }
272      memset(&n->P,0,sizeof(n->P));
273
274      n->P.p=fac->m[i];
275      n->initEcart(&n->P);
276
277      /* enter P.p into s and L */
278      int pos;
279      if (n->sl==-1) pos=0;
280      else pos=posInS(n->S,n->sl,n->P.p);
281      if (TEST_OPT_INTSTRATEGY)
282      {
283        if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
284        {
285          n->P.p = redtailBba(n->P.p,pos-1,n);
286          pCleardenom(n->P.p);
287        }
288      }
289      else
290      {
291        pNorm(n->P.p);
292        if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
293        {
294          n->P.p = redtailBba(n->P.p,pos-1,n);
295        }
296      }
297      if (TEST_OPT_DEBUG)
298      {
299        PrintS("new s:");
300        wrp(n->P.p);
301        PrintLn();
302      }
303      enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
304      n->enterS(n->P,pos,n);
305
306      /* enter P.p into T */
307      if ((IDELEMS(fac)>1)||(facdeg!=pFDeg(fac->m[0])))
308      {
309        int pos=n->posInT(n->T,n->tl,n->P);
310        enterTBba(n->P,pos,n);
311      }
312
313      /* construct D */
314      if (IDELEMS(fac)>1)
315      {
316        idTest(fac_copy);
317        idTest(n->D);
318        if (n->D==NULL)
319        {
320          n->D=idCopy(fac_copy);
321          idSkipZeroes(n->D);
322        }
323        else
324        {
325          ideal r=idAdd(n->D,fac_copy);
326          idDelete(&n->D);
327          n->D=r;
328        }
329        idTest(n->D);
330        if (TEST_OPT_DEBUG)
331        {
332          PrintS("new D:\n");
333          iiWriteMatrix((matrix)n->D,"D",1,0);
334          PrintLn();
335        }
336        idTest(n->D);
337      }
338
339      idTest(fac_copy);
340
341      fac_copy->m[i]=pCopy(fac->m[i]);
342      fac->m[i]=NULL;
343
344      idTest(fac_copy);
345
346      /* check for empty sets */
347      if (n->D!=NULL)
348      {
349        int j=IDELEMS(n->D)-1;
350        while(j>=0)
351        {
352          if (n->D->m[j]!=NULL)
353          {
354            poly r=kNF(n->Shdl,NULL,n->D->m[j],0,TRUE);
355            if (r==NULL)
356            {
357              if (TEST_OPT_DEBUG)
358              {
359                PrintS("empty set because:");
360                wrp(n->D->m[j]);
361                PrintLn();
362                messageSets(n);
363              }
364              while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
365              while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
366              memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
367              n->sl=-1;
368              if (strat==n) si=-1;
369              break;
370            }
371            else
372            {
373              pDelete(&r);
374            }
375          }
376          j--;
377        }
378      }
379      /* check for empty sets */
380      {
381        int j=FL->nr;
382        while (j>=0)
383        {
384          if ((n->sl>=0)&&(n->S[0]!=NULL))
385          {
386            ideal r=kNF(n->Shdl,NULL,(ideal)FL->m[j].Data(),0,TRUE);
387            if (idIs0(r))
388            {
389              if (TEST_OPT_DEBUG)
390              {
391                Print("empty set because:L[%d]\n",j);
392              }
393              while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
394              while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
395              memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
396              n->sl=-1;
397              if (strat==n) si=-1;
398              idDelete(&r);
399              break;
400            }
401            idDelete(&r);
402          }
403          j--;
404        }
405      }
406    } /* for */
407    for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
408    idDelete(&fac);
409    idDelete(&fac_copy);
410    if ((strat->Ll>=0) && (strat->sl>=0)) break;
411    else si=strat->sl+1;
412  }
413}
414
415ideal bbafac (ideal F, ideal Q,intvec *w,kStrategy strat, lists FL)
416{
417  int   srmax,lrmax;
418  int   olddeg,reduc;
419
420  srmax = strat->sl;
421  reduc = olddeg = lrmax = 0;
422  /* compute------------------------------------------------------- */
423  if ((strat->Ll==-1) && (strat->sl>=0))
424  {
425    if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
426  }
427  while (strat->Ll >= 0)
428  {
429    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
430    if (TEST_OPT_DEBUG) messageSets(strat);
431    //test_int_std(strat->kIdeal);
432    if (strat->Ll== 0) strat->interpt=TRUE;
433    if (TEST_OPT_DEGBOUND
434    && ((strat->honey && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p)>Kstd1_deg))
435       || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p)>Kstd1_deg))))
436    {
437      /*
438      *stops computation if
439      * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
440      *a predefined number Kstd1_deg
441      */
442      while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
443      break;
444    }
445    /* picks the last element from the lazyset L */
446    strat->P = strat->L[strat->Ll];
447    strat->Ll--;
448    kTest(strat);
449    if (pNext(strat->P.p) == strat->tail)
450    {
451      /* deletes the short spoly and computes */
452      pFree1(strat->P.p);
453      /* the real one */
454      strat->P.p = spSpolyCreate(strat->P.p1,strat->P.p2,strat->kNoether);
455    }
456    if (strat->honey)
457    {
458      if (TEST_OPT_PROT) message(strat->P.ecart+pFDeg(strat->P.p),&olddeg,&reduc,strat);
459    }
460    else
461    {
462      if (TEST_OPT_PROT) message(pFDeg(strat->P.p),&olddeg,&reduc,strat);
463    }
464    /* reduction of the element choosen from L */
465    strat->red(&strat->P,strat);
466    if (strat->P.p != NULL)
467    {
468      int facdeg=pFDeg(strat->P.p);
469      /* statistic */
470      if (TEST_OPT_PROT) PrintS("s");
471
472      ideal fac=singclap_factorize(strat->P.p,NULL,1);
473#ifndef HAVE_LIBFAC_P
474      if (fac==NULL)
475      {
476        fac=idInit(1,1);
477        fac->m[0]=pCopy(strat->P.p);
478      }
479#endif
480      ideal fac_copy=idInit(IDELEMS(fac),1);
481
482      if (TEST_OPT_DEBUG)
483      {
484        Print("-> %d factors\n",IDELEMS(fac));
485      }
486      if ((IDELEMS(fac)==1)&&(facdeg==pFDeg(fac->m[0])))
487      {
488        pDelete(&(fac->m[0]));
489        fac->m[0]=strat->P.p;
490      }
491      if (strat->P.lcm!=NULL) pFree1(strat->P.lcm);
492      int i;
493      for(i=0;i<IDELEMS(fac);i++)
494      {
495        int pos;
496        if (strat->sl==-1) pos=0;
497        else pos=posInS(strat->S,strat->sl,fac->m[i]);
498        if (TEST_OPT_INTSTRATEGY)
499        {
500          if (!TEST_OPT_MINRES||(strat->syzComp==0)||(!strat->homog))
501          {
502            fac->m[i] = redtailBba(fac->m[i],pos-1,strat);
503            pCleardenom(fac->m[i]);
504          }
505        }
506        else
507        {
508          pNorm(fac->m[i]);
509          if (!TEST_OPT_MINRES||(strat->syzComp==0)||(!strat->homog))
510          {
511            fac->m[i] = redtailBba(fac->m[i],pos-1,strat);
512          }
513        }
514        facdeg=pFDeg(fac->m[i]);
515        ideal fac2=singclap_factorize(fac->m[i],NULL,1);
516#ifndef HAVE_LIBFAC_P
517        if ((fac2!=NULL)&&(IDELEMS(fac2)>1)&&(facdeg!=pFDeg(fac2->m[0])))
518#else
519        if ((IDELEMS(fac2)>1)&&(facdeg!=pFDeg(fac2->m[0])))
520#endif
521        {
522          if (TEST_OPT_DEBUG)
523          {
524            wrp(fac->m[i]);
525            Print("-> %d factors, again\n",IDELEMS(fac2));
526            //jjPRINT_MA0((matrix)fac2,"");
527          }
528          pDelete(&(fac->m[i]));
529          fac->m[i]=fac2->m[0];
530          pEnlargeSet(&(fac->m),IDELEMS(fac),IDELEMS(fac2)-1);
531          memcpy(fac->m+IDELEMS(fac),&(fac2->m[1]),(IDELEMS(fac2)-1)*sizeof(poly
532));
533          IDELEMS(fac)+=(IDELEMS(fac2)-1);
534         }
535      }
536
537      for(i=IDELEMS(fac)-1;i>=0;i--)
538      {
539        kStrategy n=strat;
540        if (i>=1)
541        {
542          n=kStratCopy(strat);
543          n->next=strat->next;
544          strat->next=n;
545        }
546        memset(&n->P,0,sizeof(n->P));
547
548        n->P.p=fac->m[i];
549        n->initEcart(&n->P);
550
551        /* enter P.p into s and L */
552        int pos;
553        if (n->sl==-1) pos=0;
554        else pos=posInS(n->S,n->sl,n->P.p);
555        // we have already reduced all elements from fac....
556        //if (TEST_OPT_INTSTRATEGY)
557        //{
558        //  if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
559        //  {
560        //    n->P.p = redtailBba(n->P.p,pos-1,n);
561        //    pCleardenom(n->P.p);
562        //  }
563        //}
564        //else
565        //{
566        //  pNorm(n->P.p);
567        //  if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
568        //  {
569        //    n->P.p = redtailBba(n->P.p,pos-1,n);
570        //  }
571        //}
572        if (TEST_OPT_DEBUG)
573        {
574          PrintS("new s:");
575          wrp(n->P.p);
576          PrintLn();
577        }
578        enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
579        n->enterS(n->P,pos,n);
580        if (n->sl>srmax) srmax = n->sl;
581
582        /* enter P.p into T */
583        if ((IDELEMS(fac)>1)||(facdeg!=pFDeg(fac->m[0])))
584        {
585          int pos=n->posInT(n->T,n->tl,n->P);
586          enterTBba(n->P,pos,n);
587        }
588
589        /* construct D */
590        if (IDELEMS(fac)>1)
591        {
592          idTest(fac_copy);
593          idTest(n->D);
594          if (n->D==NULL)
595          {
596            n->D=idCopy(fac_copy);
597            idSkipZeroes(n->D);
598          }
599          else
600          {
601            ideal r=idAdd(n->D,fac_copy);
602            idDelete(&n->D);
603            n->D=r;
604          }
605          idTest(n->D);
606          if (TEST_OPT_DEBUG)
607          {
608            PrintS("new D:\n");
609            iiWriteMatrix((matrix)n->D,"D",1,0);
610            PrintLn();
611          }
612          idTest(n->D);
613        }
614
615        idTest(fac_copy);
616
617        fac_copy->m[i]=pCopy(fac->m[i]);
618        fac->m[i]=NULL;
619
620        idTest(fac_copy);
621
622        /* check for empty sets */
623        if (n->D!=NULL)
624        {
625          int j=IDELEMS(n->D)-1;
626          while(j>=0)
627          {
628            if (n->D->m[j]!=NULL)
629            {
630              poly r=kNF(n->Shdl,NULL,n->D->m[j],0,TRUE);
631              if (r==NULL)
632              {
633                if (TEST_OPT_DEBUG)
634                {
635                  PrintS("empty set because:");
636                  wrp(n->D->m[j]);
637                  PrintLn();
638                  messageSets(n);
639                }
640                while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
641                while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
642                memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
643                n->sl=-1;
644                break;
645              }
646              else
647              {
648                pDelete(&r);
649              }
650            }
651            j--;
652          }
653        }
654        /* check for empty sets */
655        {
656          int j=FL->nr;
657          while (j>=0)
658          {
659            if ((n->sl>=0)&&(n->S[0]!=NULL))
660            {
661              ideal r=kNF(n->Shdl,NULL,(ideal)FL->m[j].Data(),0,TRUE);
662              if (idIs0(r))
663              {
664                if (TEST_OPT_DEBUG)
665                {
666                  Print("empty set because:L[%d]\n",j);
667                }
668                while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
669                while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
670                memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
671                n->sl=-1;
672                idDelete(&r);
673                break;
674              }
675              idDelete(&r);
676            }
677            j--;
678          }
679        }
680      } /* for */
681      for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
682      idDelete(&fac);
683      idDelete(&fac_copy);
684    }
685#ifdef KDEBUG
686    strat->P.lcm=NULL;
687#endif
688    if ((strat->Ll==-1) && (strat->sl>=0))
689    {
690      if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
691    }
692    kTest(strat);
693  }
694  if (TEST_OPT_DEBUG) messageSets(strat);
695  /* complete reduction of the standard basis--------- */
696  /* release temp data-------------------------------- */
697  exitBuchMora(strat);
698  if (TEST_OPT_WEIGHTM)
699  {
700    pFDeg=pFDegOld;
701    pLDeg=pLDegOld;
702    if (ecartWeights)
703    {
704      Free((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
705      ecartWeights=NULL;
706    }
707  }
708  if (TEST_OPT_PROT) messageStat(srmax,lrmax,0,strat);
709  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
710  return (strat->Shdl);
711}
712#endif
713
714lists stdfac(ideal F, ideal Q, tHomog h,intvec ** w,ideal D)
715{
716#ifdef HAVE_FACTORY
717  ideal r;
718  BOOLEAN b=pLexOrder,toReset=FALSE;
719  BOOLEAN delete_w=(w==NULL);
720  kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
721  kStrategy orgstrat=strat;
722  lists L=(lists)Alloc(sizeof(slists)); L->Init(0);
723  sleftv v; memset(&v,0,sizeof(v));
724
725  if (currRing->ch==0) strat->LazyPass=2;
726  else                 strat->LazyPass=20;
727  strat->LazyDegree = 1;
728  if ((h==testHomog))
729  {
730    strat->ak = idRankFreeModule(F);
731    if (strat->ak==0)
732    {
733      h = (tHomog)idHomIdeal(F,Q);
734      w=NULL;
735    }
736    else
737      h = (tHomog)idHomModule(F,Q,w);
738  }
739  if (h==isHomog)
740  {
741    if ((w!=NULL) && (*w!=NULL))
742    {
743      kModW = *w;
744      strat->kModW = *w;
745      pOldFDeg = pFDeg;
746      pFDeg = kModDeg;
747      toReset = TRUE;
748    }
749    pLexOrder = TRUE;
750    strat->LazyPass*=2;
751  }
752  strat->homog=h;
753  spSet(currRing);
754  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
755  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
756  initBuchMoraPos(strat);
757  initBba(F,strat);
758  initBuchMora(F, Q,strat);
759  if (D!=NULL)
760  {
761    strat->D=idCopy(D);
762  }
763// Ende der Initalisierung
764  while (strat!=NULL)
765  {
766    if (TEST_OPT_DEBUG)
767      PrintS("====================================\n");
768    if (w!=NULL)
769      r=bbafac(F,Q,*w,strat,L);
770    else
771      r=bbafac(F,Q,NULL,strat,L);
772#ifdef KDEBUG
773    int i;
774    for (i=0; i<IDELEMS(r); i++) pTest(r->m[i]);
775#endif
776    idSkipZeroes(r);
777    // Testausgabe:
778    //if (!idIs0(r))
779    //{
780    //  PrintS("===================================================\n");
781    //  iiWriteMatrix((matrix)r,"S",1,0);
782    //  PrintS("\n===================================================\n");
783    //}
784    //else
785    //{
786    //  PrintS("=========empty============================\n");
787    //}
788    strat=strat->next;
789    if(!idIs0(r))
790    {
791      v.rtyp=IDEAL_CMD;
792      v.data=(void *)r;
793      lists LL=lInsert0(L,&v,0);
794      L=LL;
795    }
796  }
797  /* check for empty sets */
798  {
799    int j=L->nr;
800    while (j>0)
801    {
802      int i=0;
803      while(i<j)
804      {
805        ideal r=kNF((ideal)L->m[j].Data(),NULL,(ideal)L->m[i].Data(),0,TRUE);
806        if (idIs0(r))
807        {
808          if (TEST_OPT_DEBUG)
809          {
810            Print("empty set L[%d] because:L[%d]\n",j,i);
811          }
812          // delete L[j],
813          i=0; j--;
814        } 
815        else
816        {
817          i++;
818        }
819        idDelete(&r);
820      }
821      j--;
822    }
823  }
824// Ende: aufraeumen
825  if (toReset)
826  {
827    kModW = NULL;
828    pFDeg = pOldFDeg;
829  }
830  pLexOrder = b;
831  strat=orgstrat;
832  while (strat!=NULL)
833  {
834    orgstrat=strat->next;
835    Free((ADDRESS)strat,sizeof(skStrategy));
836    strat=orgstrat;
837  }
838  if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
839  return L;
840#else
841  return NULL;
842#endif
843}
Note: See TracBrowser for help on using the repository browser.