source: git/Singular/kstdfac.cc @ 512a2b

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