source: git/Singular/kstdfac.cc @ ff4e34f

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