source: git/Singular/kstdfac.cc @ 416465

spielwiese
Last change on this file since 416465 was 416465, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* bug-fixes from work with Thomas git-svn-id: file:///usr/local/Singular/svn/trunk@3826 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 21.2 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: kstdfac.cc,v 1.30 1999-11-15 17:20:15 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 "khstd.h"
18#include "cntrlc.h"
19#include "weight.h"
20#include "ipshell.h"
21#include "intvec.h"
22#ifdef HAVE_FACTORY
23#include "clapsing.h"
24#endif
25#include "lists.h"
26#include "ideals.h"
27#include "timer.h"
28#include "kstdfac.h"
29
30#ifdef HAVE_FACTORY
31/*3
32* copy o->T to n->T, assumes that n->S is already copied
33*/
34static void copyT (kStrategy o,kStrategy n)
35{
36  int i,j;
37  poly  p;
38  TSet t=(TSet)Alloc0(o->tmax*sizeof(TObject));
39
40  for (j=0; j<=o->tl; j++)
41  {
42    p = o->T[j].p;
43    i = -1;
44    loop
45    {
46      i++;
47      if (i>o->sl)
48      {
49        t[j].p=pCopy(p);
50        break;
51      }
52      if (p == o->S[i])
53      {
54        t[j].p=n->S[i];
55        break;
56      }
57    }
58    t[j].ecart=o->T[j].ecart;
59    t[j].length=o->T[j].length;
60    t[j].sev=o->T[j].sev;
61    // t[j].heap=NULL; // done by Alloc0
62  }
63  n->T=t;
64}
65
66/*3
67* copy o->L to n->L, assumes that n->T,n->tail is already copied
68*/
69static void copyL (kStrategy o,kStrategy n)
70{
71  int i,j;
72  poly  p;
73  LSet l=(LSet)Alloc(o->Lmax*sizeof(LObject));
74
75  for (j=0; j<=o->Ll; j++)
76  {
77    // copy .p ----------------------------------------------
78    if (o->L[j].p->next!=o->tail)
79      l[j].p=pCopy(o->L[j].p);
80    else
81    {
82      l[j].p=pHead(o->L[j].p);
83      l[j].p->next=n->tail;
84    }
85    // copy .lcm ----------------------------------------------
86    if (o->L[j].lcm!=NULL)
87      l[j].lcm=pCopy1(o->L[j].lcm);
88    else
89      l[j].lcm=NULL;
90    l[j].ecart=o->L[j].ecart;
91    l[j].length=o->L[j].length;
92    l[j].p1=NULL;
93    l[j].p2=NULL;
94
95    // copy .p1 ----------------------------------------------
96    p = o->L[j].p1;
97    i = -1;
98    loop
99    {
100      if(p==NULL) break;
101      i++;
102      if(i>o->tl)
103      {
104        PrintS("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        PrintS("poly p2 not found in T:");wrp(p);PrintLn();
125        l[j].p2=pCopy(p);
126        break;
127      }
128      if (p == o->T[i].p)
129      {
130        l[j].p2=n->T[i].p;
131        break;
132      }
133    }
134
135    // copy .heap ----------------------------------------------
136    l[j].heap=NULL;
137    // copy .ecart ---------------------------------------------
138    l[j].ecart=o->L[j].ecart;
139    // copy .length --------------------------------------------
140    l[j].length=o->L[j].length;
141    // copy .pLength -------------------------------------------
142    l[j].pLength=o->L[j].pLength;
143    // copy .sev -----------------------------------------------
144    l[j].sev=o->L[j].sev;
145  }
146  n->L=l;
147}
148
149kStrategy kStratCopy(kStrategy o)
150{
151  kStrategy s=(kStrategy)Alloc0SizeOf(skStrategy);
152  s->next=NULL;
153  s->red=o->red;
154  s->initEcart=o->initEcart;
155  s->posInT=o->posInT;
156  s->posInL=o->posInL;
157  s->enterS=o->enterS;
158  s->initEcartPair=o->initEcartPair;
159  s->posInLOld=o->posInLOld;
160  s->pOldFDeg=o->pOldFDeg;
161  s->Shdl=idCopy(o->Shdl);
162  s->S=s->Shdl->m;
163  if (o->D!=NULL) s->D=idCopy(o->D);
164  else            s->D=NULL;
165  s->ecartS=(int *)Alloc(IDELEMS(o->Shdl)*sizeof(int));
166  memcpy(s->ecartS,o->ecartS,IDELEMS(o->Shdl)*sizeof(int));
167  s->sevS=(unsigned long *)Alloc(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 *)Alloc(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 *)Alloc(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  s->update=o->update;
190  s->posInLOldFlag=o->posInLOldFlag;
191  s->kModW = o->kModW;
192//   if (o->kModW!=NULL)
193//     s->kModW=ivCopy(o->kModW);
194//   else
195//     s->kModW=NULL;
196  s->pairtest=NULL;
197  s->sl=o->sl;
198  s->mu=o->mu;
199  s->tl=o->tl;
200  s->tmax=o->tmax;
201  s->Ll=o->Ll;
202  s->Lmax=o->Lmax;
203  s->Bl=-1;
204  s->Bmax=setmax;
205  s->ak=o->ak;
206  s->syzComp=o->syzComp;
207  s->LazyPass=o->LazyPass;
208  s->LazyDegree=o->LazyDegree;
209  s->HCord=o->HCord;
210  s->lastAxis=o->lastAxis;
211  s->interpt=o->interpt;
212  s->homog=o->homog;
213  s->news=o->news;
214  s->newt=o->newt;
215  s->kHEdgeFound=o->kHEdgeFound;
216  s->honey=o->honey;
217  s->sugarCrit=o->sugarCrit;
218  s->Gebauer=o->Gebauer;
219  s->noTailReduction=o->noTailReduction;
220  s->fromT=o->fromT;
221  s->noetherSet=o->noetherSet;
222  return s;
223}
224
225static void completeReduceFac (kStrategy strat, lists FL)
226{
227  int si;
228
229  strat->noTailReduction = FALSE;
230  if (TEST_OPT_PROT)
231  {
232    PrintLn();
233    if (timerv) writeTime("standard base computed:");
234  }
235  if (TEST_OPT_PROT)
236  {
237    Print("(S:%d)",strat->sl);mflush();
238  }
239  for (si=strat->sl; si>0; si--)
240  {
241    //if (strat->interpt) test_int_std(strat->kIdeal);
242    strat->S[si] = redtailBba(strat->S[si],si-1,strat);
243    if (TEST_OPT_INTSTRATEGY)
244    {
245      pCleardenom(strat->S[si]);
246    }
247    if (TEST_OPT_PROT)
248    {
249      PrintS("-");mflush();
250    }
251    int facdeg=pFDeg(strat->S[si]);
252
253    kTest(strat);
254    ideal fac=singclap_factorize(strat->S[si],NULL,1);
255    kTest(strat);
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);
291        n->next=strat->next;
292        strat->next=n;
293      }
294      memset(&n->P,0,sizeof(n->P));
295
296      n->P.p=fac->m[i];
297      n->initEcart(&n->P);
298
299      /* enter P.p into s and L */
300      int pos;
301      if (n->sl==-1) pos=0;
302      else pos=posInS(n->S,n->sl,n->P.p);
303      if (TEST_OPT_INTSTRATEGY)
304      {
305        n->P.p = redtailBba(n->P.p,pos-1,n);
306        pCleardenom(n->P.p);
307      }
308      else
309      {
310        pNorm(n->P.p);
311        n->P.p = redtailBba(n->P.p,pos-1,n);
312      }
313      if (TEST_OPT_DEBUG)
314      {
315        PrintS("new s:");
316        wrp(n->P.p);
317        PrintLn();
318      }
319      enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
320      n->enterS(n->P,pos,n);
321
322      /* enter P.p into T */
323      if ((IDELEMS(fac)>1)||(facdeg!=pFDeg(fac->m[0])))
324      {
325        int pos=n->posInT(n->T,n->tl,n->P);
326        enterTBba(n->P,pos,n);
327      }
328
329      /* construct D */
330      if (IDELEMS(fac)>1)
331      {
332        if (n->D==NULL)
333        {
334          n->D=idCopy(fac_copy);
335          idSkipZeroes(n->D);
336        }
337        else
338        {
339          idTest(n->D);
340          ideal r=idAdd(n->D,fac_copy);
341          idDelete(&n->D);
342          n->D=r;
343        }
344        if (TEST_OPT_DEBUG)
345        {
346          PrintS("new D:\n");
347          iiWriteMatrix((matrix)n->D,"D",1,0);
348          PrintLn();
349        }
350      }
351
352      fac_copy->m[i]=pCopy(fac->m[i]);
353      fac->m[i]=NULL;
354
355      /* check for empty sets */
356      if (n->D!=NULL)
357      {
358        int j=IDELEMS(n->D)-1;
359        while(j>=0)
360        {
361          if (n->D->m[j]!=NULL)
362          {
363            poly r=kNF(n->Shdl,NULL,n->D->m[j],0,TRUE);
364            if (r==NULL)
365            {
366              if (TEST_OPT_DEBUG)
367              {
368                PrintS("empty set because:");
369                wrp(n->D->m[j]);
370                PrintLn();
371                messageSets(n);
372              }
373              while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
374              while (n->tl >= 0)
375              {
376                int i=n->sl;
377                while (i>=0)
378                {
379                  if (n->S[i]==n->T[n->tl].p)
380                  {
381                    n->T[n->tl].p=NULL; n->S[i]=NULL;
382                    break;
383                  }
384                  i--;
385                }
386                pDelete(&n->T[n->tl].p);
387                n->tl--;
388              }
389              memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
390              n->sl=-1;
391              if (strat==n) si=-1;
392              break;
393            }
394            else
395            {
396              pDelete(&r);
397            }
398          }
399          j--;
400        }
401      }
402      /* check for empty sets */
403      {
404        int j=FL->nr;
405        while (j>=0)
406        {
407          if ((n->sl>=0)&&(n->S[0]!=NULL))
408          {
409            ideal r=kNF(n->Shdl,NULL,(ideal)FL->m[j].Data(),0,TRUE);
410            if (idIs0(r))
411            {
412              if (TEST_OPT_DEBUG)
413              {
414                Print("empty set because:L[%d]\n",j);
415              }
416              while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
417              while (n->tl >= 0)
418              {
419                int i=n->sl;
420                while (i>=0)
421                {
422                  if (n->S[i]==n->T[n->tl].p)
423                  {
424                    n->T[n->tl].p=NULL; n->S[i]=NULL;
425                    break;
426                  }
427                  i--;
428                }
429                pDelete(&n->T[n->tl].p);
430                n->tl--;
431              }
432              memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
433              n->sl=-1;
434              if (strat==n) si=-1;
435              idDelete(&r);
436              break;
437            }
438            idDelete(&r);
439          }
440          j--;
441        }
442      }
443    } /* for */
444    for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
445    idDelete(&fac);
446    idDelete(&fac_copy);
447    if ((strat->Ll>=0) && (strat->sl>=0)) break;
448    else si=strat->sl+1;
449  }
450}
451
452ideal bbafac (ideal F, ideal Q,intvec *w,kStrategy strat, lists FL)
453{
454  int   srmax,lrmax;
455  int   olddeg,reduc;
456
457  srmax = strat->sl;
458  reduc = olddeg = lrmax = 0;
459  /* compute------------------------------------------------------- */
460  if ((strat->Ll==-1) && (strat->sl>=0))
461  {
462    if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
463  }
464  while (strat->Ll >= 0)
465  {
466    if (strat->Ll > lrmax) lrmax =strat->Ll;/*stat.*/
467    if (TEST_OPT_DEBUG) messageSets(strat);
468    //test_int_std(strat->kIdeal);
469    if (strat->Ll== 0) strat->interpt=TRUE;
470    if (TEST_OPT_DEGBOUND
471    && ((strat->honey
472        && (strat->L[strat->Ll].ecart+pFDeg(strat->L[strat->Ll].p)>Kstd1_deg))
473      || ((!strat->honey) && (pFDeg(strat->L[strat->Ll].p)>Kstd1_deg))))
474    {
475      /*
476      *stops computation if
477      * 24 IN test and the degree +ecart of L[strat->Ll] is bigger then
478      *a predefined number Kstd1_deg
479      */
480      while (strat->Ll >= 0) deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
481      break;
482    }
483    /* picks the last element from the lazyset L */
484    strat->P = strat->L[strat->Ll];
485    strat->Ll--;
486    kTest(strat);
487    if (pNext(strat->P.p) == strat->tail)
488    {
489      /* deletes the short spoly and computes */
490      pFree1(strat->P.p);
491      /* the real one */
492      strat->P.p = ksOldCreateSpoly(strat->P.p1,
493                                    strat->P.p2,
494                                    strat->kNoether);
495    }
496    if (strat->honey)
497    {
498      if (TEST_OPT_PROT)
499        message(strat->P.ecart+pFDeg(strat->P.p),&olddeg,&reduc,strat);
500    }
501    else
502    {
503      if (TEST_OPT_PROT)
504        message(pFDeg(strat->P.p),&olddeg,&reduc,strat);
505    }
506    /* reduction of the element choosen from L */
507    strat->red(&strat->P,strat);
508    if (strat->P.p != NULL)
509    {
510      int facdeg=pFDeg(strat->P.p);
511      /* statistic */
512      if (TEST_OPT_PROT) PrintS("s");
513
514      ideal fac=singclap_factorize(strat->P.p,NULL,1);
515#ifndef HAVE_LIBFAC_P
516      if (fac==NULL)
517      {
518        fac=idInit(1,1);
519        fac->m[0]=pCopy(strat->P.p);
520      }
521#endif
522      ideal fac_copy=idInit(IDELEMS(fac),1);
523
524      if (TEST_OPT_DEBUG)
525      {
526        Print("-> %d factors\n",IDELEMS(fac));
527      }
528      else if (TEST_OPT_PROT)
529      {
530        int ii=IDELEMS(fac);
531        if (ii>1)
532        {
533          while(ii>0) { PrintS("F"); ii--; }
534        }
535      }
536      if ((IDELEMS(fac)==1)&&(facdeg==pFDeg(fac->m[0])))
537      {
538        if (TEST_OPT_INTSTRATEGY)
539        {
540          strat->P.p = redtailBba(strat->P.p,strat->sl,strat);
541          if (strat->redTailChange) pCleardenom(strat->P.p);
542        }
543        else
544        {
545          pNorm(strat->P.p);
546          strat->P.p = redtailBba(strat->P.p,strat->sl,strat);
547        }
548        if (strat->redTailChange)
549        {
550          idDelete(&fac);
551          fac=singclap_factorize(strat->P.p,NULL,1);
552#ifndef HAVE_LIBFAC_P
553          if (fac==NULL)
554          {
555            fac=idInit(1,1);
556            fac->m[0]=pCopy(strat->P.p);
557          }
558#endif
559          idDelete(&fac_copy);
560          fac_copy=idInit(IDELEMS(fac),1);
561        }
562        if ((IDELEMS(fac)==1)&&(facdeg==pFDeg(fac->m[0])))
563        {
564          pDelete(&(fac->m[0]));
565          fac->m[0]=strat->P.p;
566        }
567      }
568      if (strat->P.lcm!=NULL) pFree1(strat->P.lcm);
569      int i;
570
571      for(i=IDELEMS(fac)-1;i>=0;i--)
572      {
573        kStrategy n=strat;
574        if (i>=1)
575        {
576          n=kStratCopy(strat);
577          n->next=strat->next;
578          strat->next=n;
579        }
580        memset(&n->P,0,sizeof(n->P));
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 (n->redTailChange)
603        //{
604        //  int pos = n->posInL(n->L,n->Ll,n->P,n);
605        //  enterL(&n->L,&n->Ll,&n->Lmax,n->P,pos);
606        //}
607        //else
608        {
609          if (TEST_OPT_DEBUG)
610          {
611            PrintS("new s:");
612            wrp(n->P.p);
613            PrintLn();
614          }
615          enterpairs(n->P.p,n->sl,n->P.ecart,pos,n);
616          n->enterS(n->P,pos,n);
617          if (n->sl>srmax) srmax = n->sl;
618
619          /* enter P.p into T */
620          if ((IDELEMS(fac)>1)||(facdeg!=pFDeg(fac->m[0])))
621          {
622            int pos=n->posInT(n->T,n->tl,n->P);
623            enterTBba(n->P,pos,n);
624          }
625        }
626
627        /* construct D */
628        if (IDELEMS(fac)>1)
629        {
630          if (n->D==NULL)
631          {
632            n->D=idCopy(fac_copy);
633            idSkipZeroes(n->D);
634          }
635          else
636          {
637            idTest(n->D);
638            ideal r=idAdd(n->D,fac_copy);
639            idDelete(&n->D);
640            n->D=r;
641          }
642          if (TEST_OPT_DEBUG)
643          {
644            PrintS("new D:\n");
645            iiWriteMatrix((matrix)n->D,"D",1,0);
646            PrintLn();
647          }
648        }
649
650        fac_copy->m[i]=pCopy(fac->m[i]);
651        fac->m[i]=NULL;
652
653        /* check for empty sets */
654        if (n->D!=NULL)
655        {
656          int j=IDELEMS(n->D)-1;
657          while(j>=0)
658          {
659            if (n->D->m[j]!=NULL)
660            {
661              poly r=kNF(n->Shdl,NULL,n->D->m[j],0,TRUE);
662              if (r==NULL)
663              {
664                if (TEST_OPT_DEBUG)
665                {
666                  PrintS("empty set because:");
667                  wrp(n->D->m[j]);
668                  PrintLn();
669                  messageSets(n);
670                }
671                //if (n->Ll >=0) Print("Ll:%d|",n->Ll);
672                while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
673                //if (n->tl >=0) Print("tl:%d|",n->tl);
674                while (n->tl >= 0)
675                {
676                  int i=n->sl;
677                  while (i>=0)
678                  {
679                    if (n->S[i]==n->T[n->tl].p)
680                    {
681                      n->T[n->tl].p=NULL; n->S[i]=NULL;
682                      break;
683                    }
684                    i--;
685                  }
686                  pDelete(&n->T[n->tl].p);
687                  n->tl--;
688                }
689                memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
690                n->sl=-1;
691                break;
692              }
693              else
694              {
695                pDelete(&r);
696              }
697            }
698            j--;
699          }
700        }
701
702        /* check for empty sets */
703        {
704          int j=FL->nr;
705          while (j>=0)
706          {
707            if ((n->sl>=0)&&(n->S[0]!=NULL))
708            {
709              ideal r=kNF(n->Shdl,NULL,(ideal)FL->m[j].Data(),0,TRUE);
710              if (idIs0(r))
711              {
712                if (TEST_OPT_DEBUG)
713                {
714                  Print("empty set because:L[%d]\n",j);
715                }
716                while (n->Ll >= 0) deleteInL(n->L,&n->Ll,n->Ll,n);
717                while (n->tl >= 0)
718                {
719                  int i=n->sl;
720                  while (i>=0)
721                  {
722                    if (n->S[i]==n->T[n->tl].p)
723                    {
724                      n->T[n->tl].p=NULL; n->S[i]=NULL;
725                      break;
726                    }
727                    i--;
728                  }
729                  pDelete(&n->T[n->tl].p);
730                  n->tl--;
731                }
732                memset(n->Shdl->m,0,IDELEMS(n->Shdl)*sizeof(poly));
733                n->sl=-1;
734                idDelete(&r);
735                break;
736              }
737              idDelete(&r);
738            }
739            j--;
740          }
741        }
742      } /* for */
743    kTest(strat);
744      for(i=0;i<IDELEMS(fac);i++) fac->m[i]=NULL;
745      idDelete(&fac);
746      idDelete(&fac_copy);
747    }
748#ifdef KDEBUG
749    strat->P.lcm=NULL;
750#endif
751    if ((strat->Ll==-1) && (strat->sl>=0))
752    {
753      if (TEST_OPT_REDSB) completeReduceFac(strat,FL);
754    }
755    kTest(strat);
756  }
757  if (TEST_OPT_DEBUG) messageSets(strat);
758  /* complete reduction of the standard basis--------- */
759  /* release temp data-------------------------------- */
760  exitBuchMora(strat);
761  if (TEST_OPT_WEIGHTM)
762  {
763    pFDeg=pFDegOld;
764    pLDeg=pLDegOld;
765    if (ecartWeights)
766    {
767      Free((ADDRESS)ecartWeights,(pVariables+1)*sizeof(short));
768      ecartWeights=NULL;
769    }
770  }
771  if (TEST_OPT_PROT) messageStat(srmax,lrmax,0,strat);
772  if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
773  return (strat->Shdl);
774}
775#endif
776
777lists kStdfac(ideal F, ideal Q, tHomog h,intvec ** w,ideal D)
778{
779#ifdef HAVE_FACTORY
780  ideal r;
781  BOOLEAN b=pLexOrder,toReset=FALSE;
782  BOOLEAN delete_w=(w==NULL);
783  kStrategy strat=(kStrategy)Alloc0SizeOf(skStrategy);
784  kStrategy orgstrat=strat;
785  lists L=(lists)AllocSizeOf(slists); L->Init(0);
786  sleftv v; memset(&v,0,sizeof(v));
787
788  if (rField_has_simple_inverse())
789    strat->LazyPass=20;
790  else
791    strat->LazyPass=2;
792  strat->LazyDegree = 1;
793  strat->ak = idRankFreeModule(F);
794  if ((h==testHomog))
795  {
796    if (strat->ak==0)
797    {
798      h = (tHomog)idHomIdeal(F,Q);
799      w=NULL;
800    }
801    else
802      h = (tHomog)idHomModule(F,Q,w);
803  }
804  if (h==isHomog)
805  {
806    if ((w!=NULL) && (*w!=NULL))
807    {
808      kModW = *w;
809      strat->kModW = *w;
810      pOldFDeg = pFDeg;
811      pFDeg = kModDeg;
812      toReset = TRUE;
813    }
814    pLexOrder = TRUE;
815    strat->LazyPass*=2;
816  }
817  strat->homog=h;
818  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
819  initBuchMoraPos(strat);
820  initBba(F,strat);
821  initBuchMora(F, Q,strat);
822  kinitBbaHeaps(strat);
823  if (D!=NULL)
824  {
825    strat->D=idCopy(D);
826  }
827// Ende der Initalisierung
828  while (strat!=NULL)
829  {
830    if (TEST_OPT_DEBUG)
831      PrintS("====================================\n");
832    if (w!=NULL)
833      r=bbafac(F,Q,*w,strat,L);
834    else
835      r=bbafac(F,Q,NULL,strat,L);
836#ifdef KDEBUG
837    int i;
838    for (i=0; i<IDELEMS(r); i++) pTest(r->m[i]);
839#endif
840    idSkipZeroes(r);
841    // Testausgabe:
842    //if (!idIs0(r))
843    //{
844    //  PrintS("===================================================\n");
845    //  iiWriteMatrix((matrix)r,"S",1,0);
846    //  PrintS("\n===================================================\n");
847    //}
848    //else
849    //{
850    //  PrintS("=========empty============================\n");
851    //}
852    strat=strat->next;
853    if(!idIs0(r))
854    {
855      v.rtyp=IDEAL_CMD;
856      v.data=(void *)r;
857      lists LL=lInsert0(L,&v,0);
858      L=LL;
859    }
860  }
861  /* check for empty sets */
862  {
863    int j=L->nr;
864    while (j>0)
865    {
866      int i=0;
867      while(i<j)
868      {
869        ideal r=kNF((ideal)L->m[j].Data(),NULL,(ideal)L->m[i].Data(),0,TRUE);
870        if (idIs0(r))
871        {
872          if (TEST_OPT_DEBUG)
873          {
874            Print("empty set L[%d] because:L[%d]\n",j,i);
875          }
876          // delete L[j],
877          i=0; j--;
878        }
879        else
880        {
881          i++;
882        }
883        idDelete(&r);
884      }
885      j--;
886    }
887  }
888// Ende: aufraeumen
889  if (toReset)
890  {
891    kModW = NULL;
892    pFDeg = pOldFDeg;
893  }
894  pLexOrder = b;
895  strat=orgstrat;
896  while (strat!=NULL)
897  {
898    orgstrat=strat->next;
899    kFreeStrat(strat);
900    strat=orgstrat;
901  }
902  if ((delete_w)&&(w!=NULL)&&(*w!=NULL)) delete *w;
903  return L;
904#else
905  return NULL;
906#endif
907}
Note: See TracBrowser for help on using the repository browser.