| version 1.6, 2002/02/10 08:22:56 |
version 1.12, 2005/06/30 08:35:07 |
|
|
| /* $OpenXM: OpenXM/src/kan96xx/Kan/gb.c,v 1.5 2001/05/04 01:06:23 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/gb.c,v 1.11 2005/06/16 08:40:04 takayama Exp $ */ |
| /* untabify on May 4, 2001 */ |
/* untabify on May 4, 2001 */ |
| #include <stdio.h> |
#include <stdio.h> |
| #include "datatype.h" |
#include "datatype.h" |
| Line 23 extern int UseCriterion2B; |
|
| Line 23 extern int UseCriterion2B; |
|
| extern int Spairs; |
extern int Spairs; |
| extern int Criterion2B, Criterion2F, Criterion2M; |
extern int Criterion2B, Criterion2F, Criterion2M; |
| extern int AutoReduce; |
extern int AutoReduce; |
| |
extern int TraceLift; |
| |
extern struct ring *TraceLift_ringmod; |
| static int MaxLength[DMAX]; |
static int MaxLength[DMAX]; |
| static int SpNumber[DMAX]; |
static int SpNumber[DMAX]; |
| |
|
| Line 160 struct gradedPairs *updatePairs(grD,gt,gtGrade,t,grG) |
|
| Line 162 struct gradedPairs *updatePairs(grD,gt,gtGrade,t,grG) |
|
| return(grD); |
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; |
struct arrayOfPOLY *f; |
| int needBack; |
int needBack; |
| int needSyz; |
int needSyz; |
| struct pair **grP; /* if (needSyz), it is set. */ |
struct pair **grP; /* if (needSyz), it is set. */ |
| int countDown; |
int countDown; |
| int forceReduction; |
int forceReduction; |
| |
int reduceOnly; |
| |
int gbCheck; |
| { |
{ |
| int r; |
int r; |
| struct gradedPolySet *g; |
struct gradedPolySet *g; |
| Line 192 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| Line 196 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
| extern char *F_mpMult; |
extern char *F_mpMult; |
| struct ring *rp; |
struct ring *rp; |
| |
int first; |
| int statisticsPL, statisticsCount; |
int statisticsPL, statisticsCount; |
| |
|
| |
if (KanGBmessage) { |
| |
printf("countDown=%d, forceReduction=%d, reduceOnly=%d, gbCheck=%d\n", |
| |
countDown, forceReduction, reduceOnly, gbCheck); |
| |
} |
| if (Statistics) { |
if (Statistics) { |
| for (i=0; i<DMAX; i++) MaxLength[i] = SpNumber[i] = 0; |
for (i=0; i<DMAX; i++) MaxLength[i] = SpNumber[i] = 0; |
| } |
} |
| Line 210 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| Line 219 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| |
|
| Spairs = Criterion1 = Criterion2B = Criterion2F = Criterion2M = 0; |
Spairs = Criterion1 = Criterion2B = Criterion2F = Criterion2M = 0; |
| |
|
| g = newGradedPolySet(INITGRADE); |
g = newGradedPolySet(INITGRADE); g->gb = 1; |
| |
if (reduceOnly) g->gb = 2; /* unknown */ |
| d = newGradedPairs(INITGRADE*2); |
d = newGradedPairs(INITGRADE*2); |
| for (i=0; i<g->lim; i++) { |
for (i=0; i<g->lim; i++) { |
| g->polys[i] = newPolySet(INITSIZE); |
g->polys[i] = newPolySet(INITSIZE); |
| } |
} |
| |
|
| |
first = 1; |
| for (i=0; i<r; i++) { |
for (i=0; i<r; i++) { |
| gt = getArrayOfPOLY(f,i); |
gt = getArrayOfPOLY(f,i); |
| if (gt ISZERO) { rp = CurrentRingp; } else { rp = gt->m->ringp; } |
if (gt ISZERO) { rp = CurrentRingp; } else { rp = gt->m->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); |
grade = -1; whereInG(g,gt,&grade,&indx,Sugar); |
| if (KanGBmessage == 2) { |
if (KanGBmessage == 2) { |
| printf("init=%s, ",POLYToString(head(gt),'*',1)); |
printf("init=%s, ",POLYToString(head(gt),'*',1)); |
| Line 236 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| Line 252 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| g = putPolyInG(g,gt,grade,indx,syzp,1,serial); |
g = putPolyInG(g,gt,grade,indx,syzp,1,serial); |
| } |
} |
| |
|
| markRedundant0(g,grade,indx); |
/* markRedundant0(g,grade,indx); ?*/ |
| |
markGeneratorInG(g,grade,indx); /*?*/ |
| if (Debug) { |
if (Debug) { |
| outputGradedPairs(d); outputGradedPolySet(g,needSyz); |
outputGradedPairs(d); outputGradedPolySet(g,needSyz); |
| } |
} |
| Line 249 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| Line 266 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| while ((top = getPair(d)) != (struct pair *)NULL) { |
while ((top = getPair(d)) != (struct pair *)NULL) { |
| ig = top->ig; ii = top->ii; /* [ig,ii] */ |
ig = top->ig; ii = top->ii; /* [ig,ii] */ |
| jg = top->jg; ji = top->ji; /* [jg,ji] */ |
jg = top->jg; ji = top->ji; /* [jg,ji] */ |
| |
/* |
| |
if (g->polys[ig]->del[ii] || g->polys[jg]->del[ji]) { |
| |
if (KanGBmessage) printf("p"); |
| |
continue; |
| |
} Don't do this. |
| |
*/ |
| gi = g->polys[ig]->g[ii]; |
gi = g->polys[ig]->g[ii]; |
| gj = g->polys[jg]->g[ji]; |
gj = g->polys[jg]->g[ji]; |
| |
|
| Spairs++; |
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)); |
rd = ppAddv(ppMult(h.a,gi),ppMult(h.b,gj)); |
| |
|
| if (Statistics) { |
if (Statistics) { |
| Line 298 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| Line 322 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| } |
} |
| |
|
| if (!(rd ISZERO)) { |
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) { |
if (needBack || needSyz) { |
| syzp = newSyz0(); |
syzp = newSyz0(); |
| syzp->cf = syzCf; /* no meaning */ |
syzp->cf = syzCf; /* no meaning */ |
| Line 337 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| Line 370 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| if (countDown == 0) { |
if (countDown == 0) { |
| printf("\nThe computation of the Groebner basis is suspended because of countDown==0.\n"); |
printf("\nThe computation of the Groebner basis is suspended because of countDown==0.\n"); |
| printf("Note that the result is NOT groebner basis.\n"); |
printf("Note that the result is NOT groebner basis.\n"); |
| |
g->gb = 0; |
| break; |
break; |
| } |
} |
| } |
} |
| Line 358 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| Line 392 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| printf("Computation of the Groebner basis is suspended bacause of StopDegree < computing grade.\n"); |
printf("Computation of the Groebner basis is suspended bacause of StopDegree < computing grade.\n"); |
| printf("Note that the result is NOT groebner basis.\n"); |
printf("Note that the result is NOT groebner basis.\n"); |
| } |
} |
| |
g->gb = 0; |
| break; |
break; |
| } |
} |
| } |
} |
| Line 393 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| Line 428 struct gradedPolySet *groebner_gen(f,needBack,needSyz, |
|
| printf("\n"); |
printf("\n"); |
| } |
} |
| |
|
| if (AutoReduce) { |
if (AutoReduce || reduceOnly) { |
| toReducedBasis(g,needBack,needSyz); |
toReducedBasis(g,needBack,needSyz); |
| } |
} |
| |
|
| Line 490 void toReducedBasis(struct gradedPolySet *grP,int need |
|
| Line 525 void toReducedBasis(struct gradedPolySet *grP,int need |
|
| if (KanGBmessage) { |
if (KanGBmessage) { |
| printf("Done(reduced basis)\n"); |
printf("Done(reduced basis)\n"); |
| } |
} |
| |
grP->reduced = 1; |
| } |
} |
| |
|
| |
|