source: git/Singular/kstdfac.cc @ 63be42

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