=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/gb.c,v retrieving revision 1.7 retrieving revision 1.14 diff -u -p -r1.7 -r1.14 --- OpenXM/src/kan96xx/Kan/gb.c 2003/07/30 09:00:52 1.7 +++ OpenXM/src/kan96xx/Kan/gb.c 2020/10/06 11:33:46 1.14 @@ -1,6 +1,7 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/gb.c,v 1.6 2002/02/10 08:22:56 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/gb.c,v 1.13 2005/07/07 02:59:47 takayama Exp $ */ /* untabify on May 4, 2001 */ #include +#include #include "datatype.h" #include "extern2.h" #include "matrix.h" @@ -23,6 +24,8 @@ extern int UseCriterion2B; extern int Spairs; extern int Criterion2B, Criterion2F, Criterion2M; extern int AutoReduce; +extern int TraceLift; +extern struct ring *TraceLift_ringmod; static int MaxLength[DMAX]; static int SpNumber[DMAX]; @@ -160,13 +163,15 @@ struct gradedPairs *updatePairs(grD,gt,gtGrade,t,grG) return(grD); } -struct gradedPolySet *groebner_gen(f,needBack,needSyz,grP,countDown,forceReduction) +struct gradedPolySet *groebner_gen(f,needBack,needSyz,grP,countDown,forceReduction,reduceOnly,gbCheck) struct arrayOfPOLY *f; int needBack; int needSyz; struct pair **grP; /* if (needSyz), it is set. */ int countDown; int forceReduction; + int reduceOnly; + int gbCheck; { int r; struct gradedPolySet *g; @@ -191,9 +196,15 @@ struct gradedPolySet *groebner_gen(f,needBack,needSyz, extern int StopDegree; extern struct ring *CurrentRingp; extern char *F_mpMult; + extern int Homogenize; struct ring *rp; + int first; int statisticsPL, statisticsCount; + if (KanGBmessage) { + printf("Homogenize=%d, countDown=%d, forceReduction=%d, reduceOnly=%d, gbCheck=%d\n", + Homogenize,countDown, forceReduction, reduceOnly, gbCheck); + } if (Statistics) { for (i=0; igb = 1; + if (reduceOnly) g->gb = 2; /* unknown */ d = newGradedPairs(INITGRADE*2); for (i=0; ilim; i++) { g->polys[i] = newPolySet(INITSIZE); } + first = 1; for (i=0; im->ringp; } + if (TraceLift && (!(gt ISZERO)) && first) { + TraceLift_ringmod = newRingOverFp(rp,getPrime(TraceLift)); first = 0; + if (KanGBmessage) printf("Prime number for the trace lift is %d.\n", + TraceLift_ringmod->p); + } grade = -1; whereInG(g,gt,&grade,&indx,Sugar); if (KanGBmessage == 2) { printf("init=%s, ",POLYToString(head(gt),'*',1)); @@ -260,7 +278,8 @@ struct gradedPolySet *groebner_gen(f,needBack,needSyz, gj = g->polys[jg]->g[ji]; Spairs++; - h = (*sp)(gi,gj); + if (reduceOnly && (!needSyz) && (!needBack)) h = spZero(); /* rd = 0 */ + else h = (*sp)(gi,gj); rd = ppAddv(ppMult(h.a,gi),ppMult(h.b,gj)); if (Statistics) { @@ -305,6 +324,15 @@ struct gradedPolySet *groebner_gen(f,needBack,needSyz, } if (!(rd ISZERO)) { + if (gbCheck) { + /* Abort the calculation. */ + g->gb = 0; + if (KanGBmessage) { + printf("gbCheck failed. \n"); + printf("Note that the result is NOT groebner basis.\n"); + } + break; + } if (needBack || needSyz) { syzp = newSyz0(); syzp->cf = syzCf; /* no meaning */ @@ -344,6 +372,7 @@ struct gradedPolySet *groebner_gen(f,needBack,needSyz, if (countDown == 0) { printf("\nThe computation of the Groebner basis is suspended because of countDown==0.\n"); printf("Note that the result is NOT groebner basis.\n"); + g->gb = 0; break; } } @@ -365,6 +394,7 @@ struct gradedPolySet *groebner_gen(f,needBack,needSyz, printf("Computation of the Groebner basis is suspended bacause of StopDegree < computing grade.\n"); printf("Note that the result is NOT groebner basis.\n"); } + g->gb = 0; break; } } @@ -400,7 +430,7 @@ struct gradedPolySet *groebner_gen(f,needBack,needSyz, printf("\n"); } - if (AutoReduce) { + if (AutoReduce || reduceOnly) { toReducedBasis(g,needBack,needSyz); } @@ -497,6 +527,7 @@ void toReducedBasis(struct gradedPolySet *grP,int need if (KanGBmessage) { printf("Done(reduced basis)\n"); } + grP->reduced = 1; }