version 1.1, 1999/10/08 02:12:02 |
version 1.4, 2000/03/15 01:31:17 |
|
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/gb.c,v 1.3 2000/02/24 00:27:12 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "extern2.h" |
#include "extern2.h" |
Line 19 extern int UseCriterion1; |
|
Line 20 extern int UseCriterion1; |
|
extern int UseCriterion2B; |
extern int UseCriterion2B; |
extern int Spairs; |
extern int Spairs; |
extern int Criterion2B, Criterion2F, Criterion2M; |
extern int Criterion2B, Criterion2F, Criterion2M; |
|
extern int AutoReduce; |
|
|
|
|
struct gradedPairs *updatePairs(grD,gt,gtGrade,t,grG) |
struct gradedPairs *updatePairs(grD,gt,gtGrade,t,grG) |
Line 279 int forceReduction; |
|
Line 281 int forceReduction; |
|
|
|
if (!(rd ISZERO)) { |
if (!(rd ISZERO)) { |
if (needBack || needSyz) { |
if (needBack || needSyz) { |
syzp = newSyz0(); |
syzp = newSyz0(); |
syzp->cf = syzCf; /* no meaning */ |
syzp->cf = syzCf; /* no meaning */ |
syzp->syz = ppAdd(toSyzPoly(h.a,ig,ii),toSyzPoly(h.b,jg,ji)); |
syzp->syz = ppAdd(toSyzPoly(h.a,ig,ii),toSyzPoly(h.b,jg,ji)); |
syzp->syz = cpMult(toSyzCoeff(syzCf),syzp->syz); |
syzp->syz = cpMult(toSyzCoeff(syzCf),syzp->syz); |
syzp->syz = ppAdd(syzp->syz,syzPoly); |
syzp->syz = ppAdd(syzp->syz,syzPoly); |
} |
} |
|
|
if (ReduceLowerTerms && !(Sugar)) { |
if (ReduceLowerTerms && !(Sugar)) { |
rd = (*reductionCdr)(rd,g,needBack,&syz); |
rd = (*reductionCdr)(rd,g,needBack,&syz); |
if (needBack || needSyz) { |
if (needBack || needSyz) { |
/* syzp->cf = ppMult(syz.cf,syzp->cf); no meaning */ |
/* syzp->cf = ppMult(syz.cf,syzp->cf); no meaning */ |
syzp->syz = ppAdd(syz.syz, |
syzp->syz = ppAdd(syz.syz, |
cpMult(toSyzCoeff(syz.cf),syzp->syz)); |
cpMult(toSyzCoeff(syz.cf),syzp->syz)); |
} |
} |
} |
} |
|
|
if(Sugar && (!forceReduction)){grade=top->grade;}else{grade=-1;}whereInG(g,rd,&grade,&indx,Sugar); |
if(Sugar && (!forceReduction)){grade=top->grade;}else{grade=-1;}whereInG(g,rd,&grade,&indx,Sugar); |
if (KanGBmessage == 2) { |
if (KanGBmessage == 2) { |
printf("(gr,indx)=(%d,%d).\n",grade,indx); |
printf("(gr,indx)=(%d,%d).\n",grade,indx); |
/* |
/* |
printf("sp(%s,%s)-->%s\n",POLYToString(gi,' ',1), |
printf("sp(%s,%s)-->%s\n",POLYToString(gi,' ',1), |
POLYToString(gj,' ',1), |
POLYToString(gj,' ',1), |
POLYToString(rd,' ',1)); |
POLYToString(rd,' ',1)); |
*/ |
*/ |
} |
} |
|
|
d = updatePairs(d,rd,grade,indx,g); |
d = updatePairs(d,rd,grade,indx,g); |
Line 310 int forceReduction; |
|
Line 312 int forceReduction; |
|
if (Sugar) { markRedundant0(g,grade,indx);} |
if (Sugar) { markRedundant0(g,grade,indx);} |
else {markRedundant(g,rd,grade,indx,Sugar);} |
else {markRedundant(g,rd,grade,indx,Sugar);} |
|
|
if (KanGBmessage && (StopDegree < pgrade)) { |
|
printf("Computation of the Groebner basis is suspended bacause of StopDegree < computing grade.\n"); |
|
printf("Note that the result is NOT groebner basis.\n"); |
|
break; |
|
} |
|
if (countDown) { |
if (countDown) { |
if (eliminated(rd) == 1) { |
if (eliminated(rd) == 1) { |
--countDown; |
--countDown; |
printf("x"); fflush(stdout); |
printf("x"); fflush(stdout); |
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"); |
break; |
break; |
} |
} |
} |
} |
} |
} |
if (Debug) { |
if (Debug) { |
outputGradedPairs(d); outputGradedPolySet(g,needSyz); |
outputGradedPairs(d); outputGradedPolySet(g,needSyz); |
} |
} |
}else{ |
}else{ |
if (needSyz) { |
if (needSyz) { |
top->syz = ppAdd(toSyzPoly(h.a,ig,ii),toSyzPoly(h.b,jg,ji)); |
top->syz = ppAdd(toSyzPoly(h.a,ig,ii),toSyzPoly(h.b,jg,ji)); |
top->syz = cpMult(toSyzCoeff(syzCf),top->syz); |
top->syz = cpMult(toSyzCoeff(syzCf),top->syz); |
top->syz = ppAdd(top->syz,syzPoly); |
top->syz = ppAdd(top->syz,syzPoly); |
listP->next = top; top->prev = listP; listP = listP->next; |
listP->next = top; top->prev = listP; listP = listP->next; |
} |
} |
} |
} |
|
if (StopDegree < pgrade) { |
|
fprintf(stderr,"Obtained a partial GB (StopDegree=%d)\n",StopDegree); |
|
if (KanGBmessage) { |
|
printf("Computation of the Groebner basis is suspended bacause of StopDegree < computing grade.\n"); |
|
printf("Note that the result is NOT groebner basis.\n"); |
|
} |
|
break; |
|
} |
} |
} |
|
|
if (KanGBmessage == 2) { |
if (KanGBmessage == 2) { |
Line 357 int forceReduction; |
|
Line 362 int forceReduction; |
|
Spairs = Criterion1 = Criterion2M = Criterion2F = Criterion2B = 0; |
Spairs = Criterion1 = Criterion2M = Criterion2F = Criterion2B = 0; |
} |
} |
|
|
|
if (AutoReduce) { |
|
toReducedBasis(g,needBack,needSyz); |
|
} |
|
|
return(g); |
return(g); |
} |
} |
Line 382 static int sugarGrade(struct pair *inode,struct graded |
|
Line 390 static int sugarGrade(struct pair *inode,struct graded |
|
return( a > b ? a : b); |
return( a > b ? a : b); |
} |
} |
|
|
|
void toReducedBasis(struct gradedPolySet *grP,int needBack, int needSyz) |
|
{ |
|
int changed, grd, i, reduced, grade,indx; |
|
struct syz0 syz; |
|
struct syz0 *syzp; |
|
POLY f; |
|
POLY rd; |
|
struct polySet *set; |
|
|
|
/* KanGBmessage=1; */ |
|
do { |
|
if (KanGBmessage) { |
|
printf("s"); fflush(stdout); |
|
} |
|
changed = 0; |
|
grd = 0; |
|
while (grd < grP->maxGrade) { |
|
set = grP->polys[grd]; |
|
for (i=0; i<set->size; i++) { |
|
if (set->del[i] == 0) { |
|
f = set->g[i]; |
|
if (KanGBmessage) { |
|
/* printf("(%d,%d)",grd,i); */ |
|
fflush(stdout); |
|
} |
|
rd = reductionCdr_except_grd_i(f,grP,needBack,&syz,grd,i,&reduced); |
|
if (KanGBmessage) { |
|
if (reduced) { |
|
printf("."); |
|
}else{ |
|
printf("o"); |
|
} |
|
fflush(stdout); |
|
} |
|
if (reduced) { |
|
changed = 1; |
|
set->del[i] = 1; |
|
if (rd != ZERO) { |
|
if (needSyz) { |
|
syzp = newSyz0(); |
|
syzp->cf = syz.cf; /* no meaning */ |
|
syzp->syz = toSyzPoly(cxx(1,0,0,rd->m->ringp),grd,i); |
|
syzp->syz = cpMult(toSyzCoeff(syz.cf),syzp->syz); |
|
syzp->syz = ppAdd(syzp->syz,syz.syz); |
|
/* rd = c*f + \sum c_{d,i} g_{d,i} |
|
c : syz.cf, \sum c_{d,j} g_{d,j} : syz.syz. |
|
c*grade^grd*index^i + \sum c_{d,j} grade^d*index^j |
|
grP is a set of polynomials. Polynomials are indexed by |
|
grade and index. |
|
*/ |
|
/* printf("%s, ",POLYToString(syzp->cf,' ',1)); |
|
printf("%s\n",POLYToString(syzp->syz,' ',1)); */ |
|
}else{ |
|
syzp = NULL; |
|
} |
|
grade = -1; whereInG(grP,rd,&grade,&indx,Sugar); |
|
/* Do not forget to set grade to -1 */ |
|
/* printf("grade=%d, indx=%d, ",grade,indx); */ |
|
putPolyInG(grP,rd,grade,indx,syzp,0,-1); |
|
} |
|
} |
|
} |
|
} |
|
grd++; |
|
} |
|
} while(changed); |
|
if (KanGBmessage) { |
|
printf("Done(reduced basis)\n"); |
|
} |
|
} |
|
|
|
|