=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/ecart.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -p -r1.9 -r1.10 --- OpenXM/src/kan96xx/Kan/ecart.c 2003/08/20 01:39:17 1.9 +++ OpenXM/src/kan96xx/Kan/ecart.c 2003/08/20 05:18:35 1.10 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.8 2003/08/19 08:02:09 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.9 2003/08/20 01:39:17 takayama Exp $ */ #include #include "datatype.h" #include "extern2.h" @@ -36,6 +36,7 @@ static POLY reduction_ecart1(POLY r,struct gradedPolyS static POLY reduction_ecart1_mod(POLY r,struct gradedPolySet *gset); static POLY ecartCheckSyz0(POLY cf,POLY r_0,POLY syz, struct gradedPolySet *gg,POLY r); +static int shouldReduceContent(POLY f,int ss); extern int DebugReductionRed; extern int TraceLift; @@ -422,6 +423,7 @@ static POLY reduction_ecart1(r,gset,needSyz,syzp) r = goHomogenize11(r,DegreeShifto_vec,DegreeShifto_size,-1,1); /* 1 means homogenize only s */ + if (DoCancel && (r != POLYNULL)) shouldReduceContent(r,1); if (DebugReductionEcart&1) printf("=======================================\n"); do { @@ -443,6 +445,15 @@ static POLY reduction_ecart1(r,gset,needSyz,syzp) } if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */ r = (*reduction1)(r,pp,needSyz,&cc,&cg); + + if (DoCancel && (r != POLYNULL)) { /* BUG: syzygy should be corrected. */ + if (shouldReduceContent(r,0)) { + r = reduceContentOfPoly(r,&cont); + shouldReduceContent(r,1); + if (DebugReductionEcart || DebugReductionRed) printf("CONT=%d ",coeffToString(cont)); + } + } + if (needSyz) { if (ells.first) { cf = ppMult(cc,cf); @@ -470,12 +481,12 @@ static POLY reduction_ecart1(r,gset,needSyz,syzp) r = goDeHomogenizeS(r); if (DoCancel && (r != POLYNULL)) { /* BUG: syzygy should be corrected. */ - if (r->m->ringp->p == 0) { - if (coeffSizeMin(r) >= DoCancel) { - r = reduceContentOfPoly(r,&cont); - if (DebugReductionEcart || DebugReductionRed) printf("cont=%d ",coeffToString(cont)); - } - } + if (r->m->ringp->p == 0) { + if (coeffSizeMin(r) >= DoCancel) { + r = reduceContentOfPoly(r,&cont); + if (DebugReductionEcart || DebugReductionRed) printf("cont=%d ",coeffToString(cont)); + } + } } return(r); @@ -624,4 +635,22 @@ static POLY reduction_ecart1_mod(r,gset) r = goDeHomogenizeS(r); return(r); +} + +static int shouldReduceContent(POLY f,int ss) { + static int prevSize = 1; + int size; + if (f == POLYNULL) return 0; + if (f->m->ringp->p != 0) return 0; + if (f->coeffp->tag != MP_INTEGER) return 0; + size = mpz_size(f->coeffp->val.bigp); + if (ss > 0) { + prevSize = size; + return 0; + } + if (size > 2*prevSize) { + return 1; + }else{ + return 0; + } }