version 1.2, 2000/01/16 07:55:41 |
version 1.8, 2003/09/12 02:52:50 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/red.c,v 1.7 2003/08/21 04:45:40 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "extern2.h" |
#include "extern2.h" |
|
|
#define mymax(p,q) (p>q?p:q) |
#define mymax(p,q) (p>q?p:q) |
|
|
int DebugReductionRed = 0; |
int DebugReductionRed = 0; |
|
int DebugContentReduction = 0; |
extern int Sugar; |
extern int Sugar; |
|
|
struct spValue sp_gen(f,g) |
struct spValue sp_gen(f,g) |
POLY f; |
POLY f; |
POLY g; |
POLY g; |
/* the results may be rewritten. */ |
/* the results may be rewritten. */ |
{ |
{ |
struct spValue r; |
struct spValue r; |
POLY a; |
POLY a; |
|
|
if (ell-c > 0) { /* q-case */ |
if (ell-c > 0) { /* q-case */ |
amodify = 0; |
amodify = 0; |
for (i=c; i<ell; i++) { |
for (i=c; i<ell; i++) { |
amodify += (tb->e[i].D)*(tg->e[i].x); |
amodify += (tb->e[i].D)*(tg->e[i].x); |
} |
} |
bmodify = 0; |
bmodify = 0; |
for (i=c; i<ell; i++) { |
for (i=c; i<ell; i++) { |
bmodify += (ta->e[i].D)*(tf->e[i].x); |
bmodify += (ta->e[i].D)*(tf->e[i].x); |
} |
} |
if (amodify > bmodify) { |
if (amodify > bmodify) { |
amodify = amodify-bmodify; |
amodify = amodify-bmodify; |
bmodify = 0; |
bmodify = 0; |
}else{ |
}else{ |
bmodify = bmodify - amodify; |
bmodify = bmodify - amodify; |
amodify = 0; |
amodify = 0; |
} |
} |
} |
} |
if (amodify) { |
if (amodify) { |
|
|
|
|
|
|
POLY reduction1_gen_debug(f,g,needSyz,c,h) |
POLY reduction1_gen_debug(f,g,needSyz,c,h) |
POLY f; |
POLY f; |
POLY g; |
POLY g; |
int needSyz; |
int needSyz; |
POLY *c; /* set */ |
POLY *c; /* set */ |
POLY *h; /* set */ |
POLY *h; /* set */ |
/* f must be reducible by g. r = c*f + h*g */ |
/* f must be reducible by g. r = c*f + h*g */ |
{ |
{ |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
struct ring *rp; |
struct ring *rp; |
Line 147 POLY *h; /* set */ |
|
Line 148 POLY *h; /* set */ |
|
printf("error in reduction1."); |
printf("error in reduction1."); |
printf("f=%s --> f2=%s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("f=%s --> f2=%s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("f2 = (%s)*f+(%s)*(%s)\n",POLYToString(sv.a,'*',1), |
printf("f2 = (%s)*f+(%s)*(%s)\n",POLYToString(sv.a,'*',1), |
POLYToString(sv.b,'*',1),POLYToString(g,'*',1)); |
POLYToString(sv.b,'*',1),POLYToString(g,'*',1)); |
getchar(); |
getchar(); |
getchar(); |
getchar(); |
} |
} |
if (DebugReductionRed) { |
if (DebugReductionRed & 1) { |
printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
|
}else if (DebugReductionRed & 2) { |
|
printf("(head) %s --> %s\n",POLYToString(head(f),'*',1),POLYToString(head(f2),'*',1)); |
} |
} |
|
|
f = f2; |
f = f2; |
if (needSyz) { |
if (needSyz) { |
*c = ppMult(sv.a,*c); |
*c = ppMult(sv.a,*c); |
Line 163 POLY *h; /* set */ |
|
Line 167 POLY *h; /* set */ |
|
while ((*isReducible)(f,g)) { |
while ((*isReducible)(f,g)) { |
sv = (*sp)(f,g); |
sv = (*sp)(f,g); |
f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g)); |
f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g)); |
if (DebugReductionRed) { |
if (DebugReductionRed & 1) { |
printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
|
}else if (DebugReductionRed & 2) { |
|
printf("(head) %s --> %s\n",POLYToString(head(f),'*',1),POLYToString(head(f2),'*',1)); |
} |
} |
if (showLength) {printf(" [%d] ",pLength(f)); fflush(stdout);} |
if (showLength) {printf(" [%d] ",pLength(f)); fflush(stdout);} |
if (!isOrdered(f2) || !isOrdered(f)) { |
if (!isOrdered(f2) || !isOrdered(f)) { |
if (!isOrdered(f)) { |
if (!isOrdered(f)) { |
printf("\nf is not ordered polynomial."); |
printf("\nf is not ordered polynomial."); |
}else if (!isOrdered(f)) { |
}else if (!isOrdered(f)) { |
printf("\nf2 is not ordered polynomial."); |
printf("\nf2 is not ordered polynomial."); |
} |
} |
printf("f=%s,\nf2=%s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("f=%s,\nf2=%s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
getchar(); |
getchar(); |
Line 182 POLY *h; /* set */ |
|
Line 188 POLY *h; /* set */ |
|
printf("error in reduction1."); |
printf("error in reduction1."); |
printf("f=%s --> f2=%s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("f=%s --> f2=%s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("f2 = (%s)*f+(%s)*(%s)\n",POLYToString(sv.a,'*',1), |
printf("f2 = (%s)*f+(%s)*(%s)\n",POLYToString(sv.a,'*',1), |
POLYToString(sv.b,'*',1), |
POLYToString(sv.b,'*',1), |
POLYToString(g,'*',1)); |
POLYToString(g,'*',1)); |
getchar(); |
getchar(); |
getchar(); |
getchar(); |
} |
} |
Line 193 POLY *h; /* set */ |
|
Line 199 POLY *h; /* set */ |
|
*h = ppAdd(ppMult(sv.a,*h),sv.b); |
*h = ppAdd(ppMult(sv.a,*h),sv.b); |
} |
} |
} |
} |
|
if (DebugReductionRed & 2) printf("----------- end of reduction_gen_debug\n"); |
return(f); |
return(f); |
} |
} |
|
|
POLY reduction1_gen(f,g,needSyz,c,h) |
POLY reduction1_gen(f,g,needSyz,c,h) |
POLY f; |
POLY f; |
POLY g; |
POLY g; |
int needSyz; |
int needSyz; |
POLY *c; /* set */ |
POLY *c; /* set */ |
POLY *h; /* set */ |
POLY *h; /* set */ |
/* f must be reducible by g. r = c*f + h*g */ |
/* f must be reducible by g. r = c*f + h*g */ |
{ |
{ |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
struct ring *rp; |
struct ring *rp; |
struct spValue sv; |
struct spValue sv; |
POLY f2; |
POLY f2; |
|
extern DoCancel; |
|
static int crcount=0; |
|
|
if (needSyz) { |
if (needSyz) { |
if (f ISZERO) { rp = CurrentRingp; } else {rp = f->m->ringp; } |
if (f ISZERO) { rp = CurrentRingp; } else {rp = f->m->ringp; } |
*c = cxx(1,0,0,rp); |
*c = cxx(1,0,0,rp); |
*h = ZERO; |
*h = ZERO; |
} |
} |
|
if ((DoCancel&4) && (f != POLYNULL)) shouldReduceContent(f,1); |
|
|
sv = (*sp)(f,g); |
sv = (*sp)(f,g); |
f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g)); |
f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g)); |
if (DebugReductionRed) { |
if (DebugReductionRed) { |
printf("c=%s, d=%s, g=%s: f --> c*f + d*g.\n", |
printf("c=%s, d=%s, g=%s: f --> c*f + d*g.\n", |
POLYToString(sv.a,'*',1),POLYToString(sv.b,'*',1),POLYToString(g,'*',1)); |
POLYToString(sv.a,'*',1),POLYToString(sv.b,'*',1),POLYToString(g,'*',1)); |
printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
} |
} |
f = f2; |
f = f2; |
Line 229 POLY *h; /* set */ |
|
Line 238 POLY *h; /* set */ |
|
*h = ppAdd(ppMult(sv.a,*h),sv.b); |
*h = ppAdd(ppMult(sv.a,*h),sv.b); |
} |
} |
|
|
|
|
|
|
while ((*isReducible)(f,g)) { |
while ((*isReducible)(f,g)) { |
sv = (*sp)(f,g); |
sv = (*sp)(f,g); |
f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g)); |
f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g)); |
if (DebugReductionRed) { |
if (DebugReductionRed) { |
printf("! c=%s, d=%s, g=%s: f --> c*f + d*g.\n", |
printf("! c=%s, d=%s, g=%s: f --> c*f + d*g.\n", |
POLYToString(sv.a,'*',1),POLYToString(sv.b,'*',1),POLYToString(g,'*',1)); |
POLYToString(sv.a,'*',1),POLYToString(sv.b,'*',1),POLYToString(g,'*',1)); |
printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1)); |
} |
} |
f = f2; |
f = f2; |
Line 242 POLY *h; /* set */ |
|
Line 253 POLY *h; /* set */ |
|
*c = ppMult(sv.a,*c); |
*c = ppMult(sv.a,*c); |
*h = ppAdd(ppMult(sv.a,*h),sv.b); |
*h = ppAdd(ppMult(sv.a,*h),sv.b); |
} |
} |
|
|
|
if ((DoCancel&4) && (f != POLYNULL)) { |
|
if (shouldReduceContent(f,0)) { |
|
struct coeff *cont; |
|
f = reduceContentOfPoly(f,&cont); |
|
shouldReduceContent(f,1); |
|
if (DebugContentReduction) { |
|
printf("CoNT=%s ",coeffToString(cont)); |
|
if (crcount % 10 == 0) fflush(NULL); |
|
crcount++; |
|
} |
|
} |
|
} |
|
|
} |
} |
return(f); |
return(f); |
} |
} |
|
|
POLY reduction1Cdr_gen(f,fs,g,needSyz,c,h) |
POLY reduction1Cdr_gen(f,fs,g,needSyz,c,h) |
POLY f; |
POLY f; |
POLY fs; |
POLY fs; |
POLY g; |
POLY g; |
int needSyz; |
int needSyz; |
POLY *c; /* set */ |
POLY *c; /* set */ |
POLY *h; /* set */ |
POLY *h; /* set */ |
/* f must be reducible by g. r = c*f + h*g */ |
/* f must be reducible by g. r = c*f + h*g */ |
{ |
{ |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
struct ring *rp; |
struct ring *rp; |
Line 297 POLY *h; /* set */ |
|
Line 322 POLY *h; /* set */ |
|
|
|
/* for debug */ |
/* for debug */ |
int isOrdered(f) |
int isOrdered(f) |
POLY f; |
POLY f; |
{ POLY g; |
{ POLY g; |
if (f ISZERO) return(1); |
if (f ISZERO) return(1); |
g = f->next; |
g = f->next; |
while (g != POLYNULL) { |
while (g != POLYNULL) { |
if ((*mmLarger)(g,f)>=1) return(0); |
if ((*mmLarger)(g,f)>=1) return(0); |
f = g; |
f = g; |
g = f->next; |
g = f->next; |
} |
} |
return(1); |
return(1); |
} |
} |
|
|
|
|
POLY reduction_gen(f,gset,needSyz,syzp) |
POLY reduction_gen(f,gset,needSyz,syzp) |
POLY f; |
POLY f; |
struct gradedPolySet *gset; |
struct gradedPolySet *gset; |
int needSyz; |
int needSyz; |
struct syz0 *syzp; /* set */ |
struct syz0 *syzp; /* set */ |
{ |
{ |
int reduced,reduced1,reduced2; |
int reduced,reduced1,reduced2; |
int grd; |
int grd; |
Line 325 struct syz0 *syzp; /* set */ |
|
Line 350 struct syz0 *syzp; /* set */ |
|
|
|
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
struct ring *rp; |
struct ring *rp; |
|
extern DoCancel; |
|
|
if (needSyz) { |
if (needSyz) { |
if (f ISZERO) { rp = CurrentRingp; } else { rp = f->m->ringp; } |
if (f ISZERO) { rp = CurrentRingp; } else { rp = f->m->ringp; } |
cf = cxx(1,0,0,rp); |
cf = cxx(1,0,0,rp); |
syz = ZERO; |
syz = ZERO; |
} |
} |
|
if (needSyz && DoCancel) { |
|
warningGradedSet("needSyz is not supported when DoCancel is turned on. DoCancel is set to 0.\n"); |
|
DoCancel = 0; |
|
} |
|
if (DoCancel && (f != POLYNULL)) shouldReduceContent(f,1); |
|
|
reduced = 0; /* no */ |
reduced = 0; /* no */ |
do { |
do { |
Line 338 struct syz0 *syzp; /* set */ |
|
Line 369 struct syz0 *syzp; /* set */ |
|
grd = 0; |
grd = 0; |
while (grd < gset->maxGrade) { |
while (grd < gset->maxGrade) { |
if (!Sugar) { |
if (!Sugar) { |
if (grd > (*grade)(f)) break; |
if (grd > (*grade)(f)) break; |
} |
} |
set = gset->polys[grd]; |
set = gset->polys[grd]; |
do { |
do { |
reduced2 = 0; /* no */ |
reduced2 = 0; /* no */ |
for (i=0; i<set->size; i++) { |
for (i=0; i<set->size; i++) { |
if (f ISZERO) goto ss; |
if (f ISZERO) goto ss; |
if ((*isReducible)(f,set->g[i])) { |
if ((*isReducible)(f,set->g[i])) { |
f = (*reduction1)(f,set->g[i],needSyz,&cc,&cg); |
f = (*reduction1)(f,set->g[i],needSyz,&cc,&cg); |
if (needSyz) { |
|
cf = ppMult(cc,cf); |
if (DoCancel && (f != POLYNULL)) { |
syz = cpMult(toSyzCoeff(cc),syz); |
if (shouldReduceContent(f,0)) { |
syz = ppAddv(syz,toSyzPoly(cg,grd,i)); |
struct coeff *cont; |
} |
f = reduceContentOfPoly(f,&cont); |
reduced = reduced1 = reduced2 = 1; /* yes */ |
shouldReduceContent(f,1); |
} |
if (DebugContentReduction) printf("CONT=%s ",coeffToString(cont)); |
} |
} |
|
} |
|
|
|
if (needSyz) { |
|
cf = ppMult(cc,cf); |
|
syz = cpMult(toSyzCoeff(cc),syz); |
|
syz = ppAddv(syz,toSyzPoly(cg,grd,i)); |
|
} |
|
reduced = reduced1 = reduced2 = 1; /* yes */ |
|
} |
|
} |
} while (reduced2 != 0); |
} while (reduced2 != 0); |
grd++; |
grd++; |
} |
} |
}while (reduced1 != 0); |
}while (reduced1 != 0); |
|
|
ss: ; |
ss: ; |
if (needSyz) { |
if (needSyz) { |
syzp->cf = cf; /* cf is in the CurrentRingp */ |
syzp->cf = cf; /* cf is in the CurrentRingp */ |
syzp->syz = syz; /* syz is in the SyzRingp */ |
syzp->syz = syz; /* syz is in the SyzRingp */ |
} |
} |
|
|
|
if (DoCancel && (f != POLYNULL)) { |
|
if (f->m->ringp->p == 0) { |
|
struct coeff *cont; |
|
f = reduceContentOfPoly(f,&cont); |
|
if (DebugContentReduction) printf("cont=%s ",coeffToString(cont)); |
|
} |
|
} |
|
|
return(f); |
return(f); |
} |
} |
|
|
POLY reduction_gen_rev(f,gset,needSyz,syzp) |
POLY reduction_gen_rev(f,gset,needSyz,syzp) |
POLY f; |
POLY f; |
struct gradedPolySet *gset; |
struct gradedPolySet *gset; |
int needSyz; |
int needSyz; |
struct syz0 *syzp; /* set */ |
struct syz0 *syzp; /* set */ |
{ |
{ |
int reduced,reduced1,reduced2; |
int reduced,reduced1,reduced2; |
int grd; |
int grd; |
Line 397 struct syz0 *syzp; /* set */ |
|
Line 447 struct syz0 *syzp; /* set */ |
|
while (grd >= 0) { /* reverse order for reduction */ |
while (grd >= 0) { /* reverse order for reduction */ |
set = gset->polys[grd]; |
set = gset->polys[grd]; |
do { |
do { |
reduced2 = 0; /* no */ |
reduced2 = 0; /* no */ |
for (i=0; i<set->size; i++) { |
for (i=0; i<set->size; i++) { |
if (f ISZERO) goto ss; |
if (f ISZERO) goto ss; |
if ((*isReducible)(f,set->g[i])) { |
if ((*isReducible)(f,set->g[i])) { |
f = (*reduction1)(f,set->g[i],needSyz,&cc,&cg); |
f = (*reduction1)(f,set->g[i],needSyz,&cc,&cg); |
if (needSyz) { |
if (needSyz) { |
cf = ppMult(cc,cf); |
cf = ppMult(cc,cf); |
syz = cpMult(toSyzCoeff(cc),syz); |
syz = cpMult(toSyzCoeff(cc),syz); |
syz = ppAddv(syz,toSyzPoly(cg,grd,i)); |
syz = ppAddv(syz,toSyzPoly(cg,grd,i)); |
} |
} |
reduced = reduced1 = reduced2 = 1; /* yes */ |
reduced = reduced1 = reduced2 = 1; /* yes */ |
} |
} |
} |
} |
} while (reduced2 != 0); |
} while (reduced2 != 0); |
grd--; |
grd--; |
} |
} |
}while (reduced1 != 0); |
}while (reduced1 != 0); |
|
|
ss: ; |
ss: ; |
if (needSyz) { |
if (needSyz) { |
syzp->cf = cf; /* cf is in the CurrentRingp */ |
syzp->cf = cf; /* cf is in the CurrentRingp */ |
syzp->syz = syz; /* syz is in the SyzRingp */ |
syzp->syz = syz; /* syz is in the SyzRingp */ |
Line 424 struct syz0 *syzp; /* set */ |
|
Line 474 struct syz0 *syzp; /* set */ |
|
} |
} |
|
|
POLY reductionCdr_gen(f,gset,needSyz,syzp) |
POLY reductionCdr_gen(f,gset,needSyz,syzp) |
POLY f; |
POLY f; |
struct gradedPolySet *gset; |
struct gradedPolySet *gset; |
int needSyz; |
int needSyz; |
struct syz0 *syzp; /* set */ |
struct syz0 *syzp; /* set */ |
{ |
{ |
int reduced,reduced1,reduced2; |
int reduced,reduced1,reduced2; |
int grd; |
int grd; |
Line 452 struct syz0 *syzp; /* set */ |
|
Line 502 struct syz0 *syzp; /* set */ |
|
grd = 0; |
grd = 0; |
while (grd < gset->maxGrade) { |
while (grd < gset->maxGrade) { |
if (!Sugar) { |
if (!Sugar) { |
if (grd > (*grade)(f)) break; |
if (grd > (*grade)(f)) break; |
} |
} |
set = gset->polys[grd]; |
set = gset->polys[grd]; |
do { |
do { |
reduced2 = 0; /* no */ |
reduced2 = 0; /* no */ |
for (i=0; i<set->size; i++) { |
for (i=0; i<set->size; i++) { |
if (f ISZERO) goto ss; |
if (f ISZERO) goto ss; |
if ((fs =(*isCdrReducible)(f,set->g[i])) != ZERO) { |
if ((fs =(*isCdrReducible)(f,set->g[i])) != ZERO) { |
f = (*reduction1Cdr)(f,fs,set->g[i],needSyz,&cc,&cg); |
f = (*reduction1Cdr)(f,fs,set->g[i],needSyz,&cc,&cg); |
if (needSyz) { |
if (needSyz) { |
cf = ppMult(cc,cf); |
cf = ppMult(cc,cf); |
syz = cpMult(toSyzCoeff(cc),syz); |
syz = cpMult(toSyzCoeff(cc),syz); |
syz = ppAddv(syz,toSyzPoly(cg,grd,i)); |
syz = ppAddv(syz,toSyzPoly(cg,grd,i)); |
} |
} |
reduced = reduced1 = reduced2 = 1; /* yes */ |
reduced = reduced1 = reduced2 = 1; /* yes */ |
} |
} |
} |
} |
} while (reduced2 != 0); |
} while (reduced2 != 0); |
grd++; |
grd++; |
} |
} |
}while (reduced1 != 0); |
}while (reduced1 != 0); |
|
|
ss: ; |
ss: ; |
if (needSyz) { |
if (needSyz) { |
syzp->cf = cf; |
syzp->cf = cf; |
syzp->syz = syz; |
syzp->syz = syz; |
Line 483 struct syz0 *syzp; /* set */ |
|
Line 533 struct syz0 *syzp; /* set */ |
|
} |
} |
|
|
int isReducible_gen(f,g) |
int isReducible_gen(f,g) |
POLY f; |
POLY f; |
POLY g; |
POLY g; |
{ |
{ |
int n,i; |
int n,i; |
MONOMIAL tf; |
MONOMIAL tf; |
|
|
} |
} |
|
|
POLY isCdrReducible_gen(f,g) |
POLY isCdrReducible_gen(f,g) |
POLY f; |
POLY f; |
POLY g; |
POLY g; |
{ |
{ |
while (f != POLYNULL) { |
while (f != POLYNULL) { |
if ((*isReducible)(f,g)) { |
if ((*isReducible)(f,g)) { |
|
|
} |
} |
|
|
POLY lcm_gen(f,g) |
POLY lcm_gen(f,g) |
POLY f; |
POLY f; |
POLY g; |
POLY g; |
{ |
{ |
MONOMIAL tf,tg; |
MONOMIAL tf,tg; |
MONOMIAL lcm; |
MONOMIAL lcm; |
|
|
} |
} |
|
|
int grade_gen(f) |
int grade_gen(f) |
POLY f; |
POLY f; |
{ |
{ |
int r; |
int r; |
int i,n; |
int i,n; |
|
|
|
|
/* constructors */ |
/* constructors */ |
POLY toSyzPoly(cg,grd,index) |
POLY toSyzPoly(cg,grd,index) |
POLY cg; |
POLY cg; |
int grd; |
int grd; |
int index; |
int index; |
/* the result is read only. */ |
/* the result is read only. */ |
{ |
{ |
extern struct ring *SyzRingp; |
extern struct ring *SyzRingp; |
POLY r; |
POLY r; |
|
|
} |
} |
|
|
struct coeff *toSyzCoeff(f) |
struct coeff *toSyzCoeff(f) |
POLY f; |
POLY f; |
{ |
{ |
extern struct ring *SyzRingp; |
extern struct ring *SyzRingp; |
struct coeff *c; |
struct coeff *c; |
Line 613 void initSyzRingp() { |
|
Line 663 void initSyzRingp() { |
|
SyzRingp->name = ringName; |
SyzRingp->name = ringName; |
} |
} |
|
|
|
POLY reductionCdr_except_grd_i(POLY f,struct gradedPolySet *gset, |
|
int needSyz,struct syz0 *syzp, |
|
int skipGrd,int skipi, int *reducedp) |
|
{ |
|
int reduced,reduced1,reduced2; |
|
int grd; |
|
struct polySet *set; |
|
POLY cf,syz; |
|
int i; |
|
POLY cc,cg; |
|
POLY fs; |
|
|
|
extern struct ring *CurrentRingp; |
|
struct ring *rp; |
|
|
|
*reducedp = 0; |
|
if (needSyz) { |
|
if (f ISZERO) { rp = CurrentRingp; } else {rp = f->m->ringp; } |
|
cf = cxx(1,0,0,rp); |
|
syz = ZERO; |
|
} |
|
|
|
reduced = 0; /* no */ |
|
do { |
|
reduced1 = 0; /* no */ |
|
grd = 0; |
|
while (grd < gset->maxGrade) { |
|
/* |
|
if (!Sugar) { |
|
if (grd > (*grade)(f)) break; |
|
} |
|
*/ |
|
set = gset->polys[grd]; |
|
do { |
|
reduced2 = 0; /* no */ |
|
for (i=0; i<set->size; i++) { |
|
if (f ISZERO) goto ss; |
|
if ((!((grd == skipGrd) && (i == skipi))) && (set->del[i]==0)) { |
|
/* Do not use deleted element.*/ |
|
if ((fs =(*isCdrReducible)(f,set->g[i])) != ZERO) { |
|
f = (*reduction1Cdr)(f,fs,set->g[i],needSyz,&cc,&cg); |
|
/* What is cg? */ |
|
if (needSyz) { |
|
cf = ppMult(cc,cf); |
|
syz = cpMult(toSyzCoeff(cc),syz); |
|
syz = ppAddv(syz,toSyzPoly(cg,grd,i)); |
|
} |
|
*reducedp = reduced = reduced1 = reduced2 = 1; /* yes */ |
|
} |
|
} |
|
} |
|
} while (reduced2 != 0); |
|
grd++; |
|
} |
|
}while (reduced1 != 0); |
|
|
|
ss: ; |
|
if (needSyz) { |
|
syzp->cf = cf; |
|
syzp->syz = syz; |
|
} |
|
return(f); |
|
} |