source: git/Singular/kstdfac.cc @ fdc537

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