source: git/Singular/kstdfac.cc @ 09d74fe

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