=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/red.c,v retrieving revision 1.4 retrieving revision 1.11 diff -u -p -r1.4 -r1.11 --- OpenXM/src/kan96xx/Kan/red.c 2001/05/04 01:06:25 1.4 +++ OpenXM/src/kan96xx/Kan/red.c 2020/10/06 11:33:47 1.11 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/red.c,v 1.3 2000/02/24 00:27:12 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/red.c,v 1.10 2005/06/09 04:09:22 takayama Exp $ */ #include #include "datatype.h" #include "extern2.h" @@ -7,8 +7,15 @@ #define mymax(p,q) (p>q?p:q) int DebugReductionRed = 0; +int DebugContentReduction = 0; extern int Sugar; +struct spValue spZero(void) { + struct spValue r; + r.a = ZERO; + r.b = ZERO; + return r; +} struct spValue sp_gen(f,g) POLY f; POLY g; @@ -151,9 +158,12 @@ POLY reduction1_gen_debug(f,g,needSyz,c,h) getchar(); getchar(); } - if (DebugReductionRed) { + if (DebugReductionRed & 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; if (needSyz) { *c = ppMult(sv.a,*c); @@ -163,8 +173,10 @@ POLY reduction1_gen_debug(f,g,needSyz,c,h) while ((*isReducible)(f,g)) { sv = (*sp)(f,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)); + }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 (!isOrdered(f2) || !isOrdered(f)) { @@ -193,6 +205,7 @@ POLY reduction1_gen_debug(f,g,needSyz,c,h) *h = ppAdd(ppMult(sv.a,*h),sv.b); } } + if (DebugReductionRed & 2) printf("----------- end of reduction_gen_debug\n"); return(f); } @@ -208,13 +221,15 @@ POLY reduction1_gen(f,g,needSyz,c,h) struct ring *rp; struct spValue sv; POLY f2; - + extern int DoCancel; + static int crcount=0; if (needSyz) { if (f ISZERO) { rp = CurrentRingp; } else {rp = f->m->ringp; } *c = cxx(1,0,0,rp); *h = ZERO; } + if ((DoCancel&4) && (f != POLYNULL)) shouldReduceContent(f,1); sv = (*sp)(f,g); f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g)); @@ -229,6 +244,8 @@ POLY reduction1_gen(f,g,needSyz,c,h) *h = ppAdd(ppMult(sv.a,*h),sv.b); } + + while ((*isReducible)(f,g)) { sv = (*sp)(f,g); f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g)); @@ -242,6 +259,20 @@ POLY reduction1_gen(f,g,needSyz,c,h) *c = ppMult(sv.a,*c); *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); } @@ -325,12 +356,18 @@ POLY reduction_gen(f,gset,needSyz,syzp) extern struct ring *CurrentRingp; struct ring *rp; + extern int DoCancel; if (needSyz) { if (f ISZERO) { rp = CurrentRingp; } else { rp = f->m->ringp; } cf = cxx(1,0,0,rp); 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 */ do { @@ -347,6 +384,16 @@ POLY reduction_gen(f,gset,needSyz,syzp) if (f ISZERO) goto ss; if ((*isReducible)(f,set->g[i])) { f = (*reduction1)(f,set->g[i],needSyz,&cc,&cg); + + if (DoCancel && (f != POLYNULL)) { + if (shouldReduceContent(f,0)) { + struct coeff *cont; + f = reduceContentOfPoly(f,&cont); + shouldReduceContent(f,1); + if (DebugContentReduction) printf("CONT=%s ",coeffToString(cont)); + } + } + if (needSyz) { cf = ppMult(cc,cf); syz = cpMult(toSyzCoeff(cc),syz); @@ -365,6 +412,15 @@ POLY reduction_gen(f,gset,needSyz,syzp) syzp->cf = cf; /* cf is in the CurrentRingp */ 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); } @@ -611,6 +667,7 @@ void initSyzRingp() { if (ringName == NULL) errorGradedSet("No more memory."); sprintf(ringName,"syzring%05d",ringSerial); SyzRingp->name = ringName; + SyzRingp->partialEcart = 0; } POLY reductionCdr_except_grd_i(POLY f,struct gradedPolySet *gset, @@ -652,7 +709,7 @@ POLY reductionCdr_except_grd_i(POLY f,struct gradedPol 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) { + if ((fs =(*isCdrReducible)(f,set->g[i])) != ZERO) { f = (*reduction1Cdr)(f,fs,set->g[i],needSyz,&cc,&cg); /* What is cg? */ if (needSyz) {