source: git/Singular/kstdfac.cc @ c4bbf1f

spielwiese
Last change on this file since c4bbf1f was 4b5c87, checked in by Hans Schönemann <hannes@…>, 26 years ago
* hannes: several changes concerning stdfac git-svn-id: file:///usr/local/Singular/svn/trunk@1416 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 20.1 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: kstdfac.cc,v 1.17 1998-04-22 07:49:00 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        if (TEST_OPT_INTSTRATEGY)
498        {
499          if (!TEST_OPT_MINRES||(strat->syzComp==0)||(!strat->homog))
500          {
501            strat->P.p = redtailBba(strat->P.p,strat->sl,strat);
502            if (strat->redTailChange) pCleardenom(strat->P.p);
503          }
504        }
505        else
506        {
507          pNorm(strat->P.p);
508          if (!TEST_OPT_MINRES||(strat->syzComp==0)||(!strat->homog))
509          {
510            strat->P.p = redtailBba(strat->P.p,strat->sl,strat);
511          }
512        }
513        if (strat->redTailChange)
514        {
515          idDelete(&fac);
516          fac=singclap_factorize(strat->P.p,NULL,1);
517#ifndef HAVE_LIBFAC_P
518          if (fac==NULL)
519          {
520            fac=idInit(1,1);
521            fac->m[0]=pCopy(strat->P.p);
522          }
523#endif
524          idDelete(&fac_copy);
525          fac_copy=idInit(IDELEMS(fac),1);
526        }
527        if ((IDELEMS(fac)==1)&&(facdeg==pFDeg(fac->m[0])))
528        {
529          pDelete(&(fac->m[0]));
530          fac->m[0]=strat->P.p;
531        }
532      }
533      if (strat->P.lcm!=NULL) pFree1(strat->P.lcm);
534      int i;
535//      for(i=0;i<IDELEMS(fac);i++)
536//      {
537//        int pos;
538//        if (strat->sl==-1) pos=0;
539//        else pos=posInS(strat->S,strat->sl,fac->m[i]);
540//        if (TEST_OPT_INTSTRATEGY)
541//        {
542//          if (!TEST_OPT_MINRES||(strat->syzComp==0)||(!strat->homog))
543//          {
544//            fac->m[i] = redtailBba(fac->m[i],pos-1,strat);
545//            pCleardenom(fac->m[i]);
546//          }
547//        }
548//        else
549//        {
550//          pNorm(fac->m[i]);
551//          if (!TEST_OPT_MINRES||(strat->syzComp==0)||(!strat->homog))
552//          {
553//            fac->m[i] = redtailBba(fac->m[i],pos-1,strat);
554//          }
555//        }
556//      }
557
558      for(i=IDELEMS(fac)-1;i>=0;i--)
559      {
560        kStrategy n=strat;
561        if (i>=1)
562        {
563          n=kStratCopy(strat);
564          n->next=strat->next;
565          strat->next=n;
566        }
567        memset(&n->P,0,sizeof(n->P));
568
569        n->P.p=fac->m[i];
570        n->initEcart(&n->P);
571
572        /* enter P.p into s and L */
573        int pos;
574        if (n->sl==-1) pos=0;
575        else pos=posInS(n->S,n->sl,n->P.p);
576
577        // we have already reduced all elements from fac....
578        if (TEST_OPT_INTSTRATEGY)
579        {
580          if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
581          {
582            n->P.p = redtailBba(n->P.p,pos-1,n);
583            if (n->redTailChange) pCleardenom(n->P.p);
584          }
585        }
586        else
587        {
588          pNorm(n->P.p);
589          if (!TEST_OPT_MINRES||(n->syzComp==0)||(!n->homog))
590          {
591            n->P.p = redtailBba(n->P.p,pos-1,n);
592          }
593        }
594
595        //if (n->redTailChange)
596        //{
597        //  int pos = n->posInL(n->L,n->Ll,n->P,n);
598        //  enterL(&n->L,&n->Ll,&n->Lmax,n->P,pos);
599        //}
600        //else
601        {
602          if (TEST_OPT_DEBUG)
603          {
604            PrintS("new s:");
605            wrp(n->P.p);
606            PrintLn();
607          }
608          enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
609          n->enterS(n->P,pos,n);
610          if (n->sl>srmax) srmax = n->sl;
611
612          /* enter P.p into T */
613          if ((IDELEMS(fac)>1)||(facdeg!=pFDeg(fac->m[0])))
614          {
615            int pos=n->posInT(n->T,n->tl,n->P);
616            enterTBba(n->P,pos,n);
617          }
618        }
619
620        /* construct D */
621        if (IDELEMS(fac)>1)
622        {
623          if (n->D==NULL)
624          {
625            n->D=idCopy(fac_copy);
626            idSkipZeroes(n->D);
627          }
628          else
629          {
630            idTest(n->D);
631            ideal r=idAdd(n->D,fac_copy);
632            idDelete(&n->D);
633            n->D=r;
634          }
635          if (TEST_OPT_DEBUG)
636          {
637            PrintS("new D:\n");
638            iiWriteMatrix((matrix)n->D,"D",1,0);
639            PrintLn();
640          }
641        }
642
643        fac_copy->m[i]=pCopy(fac->m[i]);
644        fac->m[i]=NULL;
645
646        /* check for empty sets */
647        if (n->D!=NULL)
648        {
649          int j=IDELEMS(n->D)-1;
650          while(j>=0)
651          {
652            if (n->D->m[j]!=NULL)
653            {
654              poly r=kNF(n->Shdl,NULL,n->D->m[j],0,TRUE);
655              if (r==NULL)
656              {
657                if (TEST_OPT_DEBUG)
658                {
659                  PrintS("empty set because:");
660                  wrp(n->D->m[j]);
661                  PrintLn();
662                  messageSets(n);
663                }
664                //if (n->Ll >=0) Print("Ll:%d|",n->Ll);
665                while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
666                //if (n->tl >=0) Print("tl:%d|",n->tl);
667                while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
668                memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
669                n->sl=-1;
670                break;
671              }
672              else
673              {
674                pDelete(&r);
675              }
676            }
677            j--;
678          }
679        }
680
681        /* check for empty sets */
682        {
683          int j=FL->nr;
684          while (j>=0)
685          {
686            if ((n->sl>=0)&&(n->S[0]!=NULL))
687            {
688              ideal r=kNF(n->Shdl,NULL,(ideal)FL->m[j].Data(),0,TRUE);
689              if (idIs0(r))
690              {
691                if (TEST_OPT_DEBUG)
692                {
693                  Print("empty set because:L[%d]\n",j);
694                }
695                while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
696                while (n->tl >= 0) { pDelete(&n->T[n->tl].p); n->tl--; }
697                memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
698                n->sl=-1;
699                idDelete(&r);
700                break;
701              }
702              idDelete(&r);
703            }
704            j--;
705          }
706        }
707      } /* for */
708      for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
709      idDelete(&fac);
710      idDelete(&fac_copy);
711    }
712#ifdef KDEBUG
713    strat->P.lcm=NULL;
714#endif
715    if ((strat->Ll==-1) && (strat->sl>=0))
716    {
717      if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
718    }
719    kTest(strat);
720  }
721  if (TEST_OPT_DEBUG) messageSets(strat);
722  /* complete reduction of the standard basis--------- */
723  /* release temp data-------------------------------- */
724  exitBuchMora(strat);
725  if (TEST_OPT_WEIGHTM)
726  {
727    pFDeg=pFDegOld;
728    pLDeg=pLDegOld;
729    if (ecartWeights)
730    {
731      Free((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
732      ecartWeights=NULL;
733    }
734  }
735  if (TEST_OPT_PROT) messageStat(srmax,lrmax,0,strat);
736  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
737  return (strat->Shdl);
738}
739#endif
740
741lists stdfac(ideal F, ideal Q, tHomog h,intvec ** w,ideal D)
742{
743#ifdef HAVE_FACTORY
744  ideal r;
745  BOOLEAN b=pLexOrder,toReset=FALSE;
746  BOOLEAN delete_w=(w==NULL);
747  kStrategy strat=(kStrategy)Alloc0(sizeof(skStrategy));
748  kStrategy orgstrat=strat;
749  lists L=(lists)Alloc(sizeof(slists)); L->Init(0);
750  sleftv v; memset(&v,0,sizeof(v));
751
752  if (currRing->ch==0) strat->LazyPass=2;
753  else                 strat->LazyPass=20;
754  strat->LazyDegree = 1;
755  strat->ak = idRankFreeModule(F);
756  if ((h==testHomog))
757  {
758    if (strat->ak==0)
759    {
760      h = (tHomog)idHomIdeal(F,Q);
761      w=NULL;
762    }
763    else
764      h = (tHomog)idHomModule(F,Q,w);
765  }
766  if (h==isHomog)
767  {
768    if ((w!=NULL) && (*w!=NULL))
769    {
770      kModW = *w;
771      strat->kModW = *w;
772      pOldFDeg = pFDeg;
773      pFDeg = kModDeg;
774      toReset = TRUE;
775    }
776    pLexOrder = TRUE;
777    strat->LazyPass*=2;
778  }
779  strat->homog=h;
780  spSet(currRing);
781  strat->spSpolyLoop = spGetSpolyLoop(currRing, strat);
782  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
783  initBuchMoraPos(strat);
784  initBba(F,strat);
785  initBuchMora(F, Q,strat);
786  if (D!=NULL)
787  {
788    strat->D=idCopy(D);
789  }
790// Ende der Initalisierung
791  while (strat!=NULL)
792  {
793    if (TEST_OPT_DEBUG)
794      PrintS("====================================\n");
795    if (w!=NULL)
796      r=bbafac(F,Q,*w,strat,L);
797    else
798      r=bbafac(F,Q,NULL,strat,L);
799#ifdef KDEBUG
800    int i;
801    for (i=0; i<IDELEMS(r); i++) pTest(r->m[i]);
802#endif
803    idSkipZeroes(r);
804    // Testausgabe:
805    //if (!idIs0(r))
806    //{
807    //  PrintS("===================================================\n");
808    //  iiWriteMatrix((matrix)r,"S",1,0);
809    //  PrintS("\n===================================================\n");
810    //}
811    //else
812    //{
813    //  PrintS("=========empty============================\n");
814    //}
815    strat=strat->next;
816    if(!idIs0(r))
817    {
818      v.rtyp=IDEAL_CMD;
819      v.data=(void *)r;
820      lists LL=lInsert0(L,&v,0);
821      L=LL;
822    }
823  }
824  /* check for empty sets */
825  {
826    int j=L->nr;
827    while (j>0)
828    {
829      int i=0;
830      while(i<j)
831      {
832        ideal r=kNF((ideal)L->m[j].Data(),NULL,(ideal)L->m[i].Data(),0,TRUE);
833        if (idIs0(r))
834        {
835          if (TEST_OPT_DEBUG)
836          {
837            Print("empty set L[%d] because:L[%d]\n",j,i);
838          }
839          // delete L[j],
840          i=0; j--;
841        }
842        else
843        {
844          i++;
845        }
846        idDelete(&r);
847      }
848      j--;
849    }
850  }
851// Ende: aufraeumen
852  if (toReset)
853  {
854    kModW = NULL;
855    pFDeg = pOldFDeg;
856  }
857  pLexOrder = b;
858  strat=orgstrat;
859  while (strat!=NULL)
860  {
861    orgstrat=strat->next;
862    Free((ADDRESS)strat,sizeof(skStrategy));
863    strat=orgstrat;
864  }
865  if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
866  return L;
867#else
868  return NULL;
869#endif
870}
Note: See TracBrowser for help on using the repository browser.