source: git/Singular/kstdfac.cc @ 48aa42

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