=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/ecart.c,v retrieving revision 1.11 retrieving revision 1.15 diff -u -p -r1.11 -r1.15 --- OpenXM/src/kan96xx/Kan/ecart.c 2003/08/21 02:30:23 1.11 +++ OpenXM/src/kan96xx/Kan/ecart.c 2003/08/26 05:52:43 1.15 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.10 2003/08/20 05:18:35 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.14 2003/08/26 05:06:01 takayama Exp $ */ #include #include "datatype.h" #include "extern2.h" @@ -248,13 +248,17 @@ POLY reduction_ecart(r,gset,needSyz,syzp) struct syz0 *syzp; /* set */ { POLY rn; + if (TraceLift && needSyz) { + warningGradedSet("TraceLift cannot be used to get syzygy. TraceLift is turned off.\n"); + TraceLift = 0; + } if (TraceLift) { if (EcartAutomaticHomogenization) { if (TraceLift_ringmod == NULL) { warningPoly("reduction_ecart: TraceLift_ringmod is not set.\n"); return reduction_ecart1(r,gset,needSyz,syzp); } - rn = reduction_ecart1_mod(r,gset); /* BUG: syzygy is not obtained. */ + rn = reduction_ecart1_mod(r,gset); if (rn == POLYNULL) return rn; else return reduction_ecart1(r,gset,needSyz,syzp); }else{ @@ -293,6 +297,8 @@ static POLY reduction_ecart0(r,gset,needSyz,syzp) POLY cf_o; POLY syz_o; POLY r_0; + int se; + struct coeff *cont; extern struct ring *CurrentRingp; struct ring *rp; @@ -312,6 +318,8 @@ static POLY reduction_ecart0(r,gset,needSyz,syzp) } } + if (DoCancel && (r != POLYNULL)) shouldReduceContent(r,1); + if (DebugReductionEcart&1) printf("--------------------------------------\n"); do { if (DebugReductionRed) printf("r=%s\n",POLYToString(r,'*',1)); @@ -335,6 +343,16 @@ static POLY reduction_ecart0(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)) { + if (shouldReduceContent(r,0)) { + r = reduceContentOfPoly(r,&cont); + shouldReduceContent(r,1); + if (DebugReductionEcart || DebugReductionRed || DebugContentReduction) printf("CONT=%s ",coeffToString(cont)); + } + } + + if (needSyz) { if (ells.first) { if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp)); @@ -364,7 +382,16 @@ static POLY reduction_ecart0(r,gset,needSyz,syzp) } } if (r ISZERO) goto ss; - /*r = ecartDivideSv(r,&se); r = r/s^? Don't do this. */ + + /* r = r/s^? Don't do this?? */ + r = ecartDivideSv(r,&se); + if (needSyz && (se > 0)) { + POLY tt; + tt = cxx(1,0,-se,rp); + cf = mpMult(tt,cf); + syz = cpMult(toSyzCoeff(tt),syz); + } + } }while (ell >= 0); @@ -374,6 +401,13 @@ static POLY reduction_ecart0(r,gset,needSyz,syzp) syzp->syz = syz; /* syz is in the SyzRingp */ } + if (DoCancel && (r != POLYNULL)) { + if (r->m->ringp->p == 0) { + r = reduceContentOfPoly(r,&cont); + if (DebugReductionEcart || DebugReductionRed || DebugContentReduction) printf("cont=%s ",coeffToString(cont)); + } + } + return(r); } @@ -400,6 +434,9 @@ static POLY reduction_ecart1(r,gset,needSyz,syzp) struct ecartPolyArray *gg; POLY pp; int ell; + POLY cf_o; + POLY syz_o; + POLY r_0; int se; struct coeff *cont; @@ -407,6 +444,7 @@ static POLY reduction_ecart1(r,gset,needSyz,syzp) struct ring *rp; extern struct ring *SmallRingp; + r_0 = r; gg = NULL; if (needSyz) { if (r ISZERO) { rp = CurrentRingp; } else { rp = r->m->ringp; } @@ -434,7 +472,11 @@ static POLY reduction_ecart1(r,gset,needSyz,syzp) ell = ells.ell; if (ell > 0) { if (DebugReductionEcart & 2) printf("%"); - gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL); + if (needSyz) { + gg = ecartPutPolyInG(r,gg,cf,syz); + }else{ + gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL); + } } if (ell >= 0) { if (ells.first) { @@ -446,7 +488,7 @@ 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 (DoCancel && (r != POLYNULL)) { if (shouldReduceContent(r,0)) { r = reduceContentOfPoly(r,&cont); shouldReduceContent(r,1); @@ -456,31 +498,62 @@ static POLY reduction_ecart1(r,gset,needSyz,syzp) if (needSyz) { if (ells.first) { + if (ell > 0) cc = ppMult(cc,cxx(1,0,ell,rp)); cf = ppMult(cc,cf); syz = cpMult(toSyzCoeff(cc),syz); syz = ppAddv(syz,toSyzPoly(cg,ells.grade,ells.gseti)); }else{ - fprintf(stderr,"It has not yet implemented.\n"); - exit(10); - /* BUG: not yet */ + if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp)); + cf_o = (gg->cf)[ells.ggi]; + syz_o = (gg->syz)[ells.ggi]; + cf = ppMult(cc,cf); + cf = ppAdd(cf,ppMult(cg,cf_o)); + syz = cpMult(toSyzCoeff(cc),syz); + syz = ppAdd(syz,cpMult(toSyzCoeff(cg),syz_o)); + /* Note. 2003.07.19 */ } } + + if (DebugReductionRed) { + POLY tp; + tp = ecartCheckSyz0(cf,r_0,syz,gset,r); + tp = goDeHomogenizeS(tp); + if (tp != POLYNULL) { + fprintf(stderr,"reduction_ecart1(): sygyzy is broken. Return the Current values.\n"); + fprintf(stderr,"%s\n",POLYToString(tp,'*',1)); + syzp->cf = cf; + syzp->syz = syz; + return r; + } + } + if (r ISZERO) goto ss1; r = ecartDivideSv(r,&se); /* r = r/s^? */ + + if (needSyz && (se > 0)) { /* It may not necessary because of dehomo*/ + POLY tt; + /*printf("!1/H!"); fflush(NULL);*/ /* misc-2003/ecart/t1.sm1 foo4 */ + tt = cxx(1,0,-se,rp); + cf = mpMult(tt,cf); + syz = cpMult(toSyzCoeff(tt),syz); + } + } }while (ell >= 0); ss1: ; if (needSyz) { + /* dehomogenize the syzygy. BUG, this may be inefficient. */ + cf = goDeHomogenizeS(cf); + syz = goDeHomogenizeS(syz); + /*printf("cf=%s\n",POLYToString(cf,'*',1)); + printf("syz=%s\n",POLYToString(syz,'*',1));*/ syzp->cf = cf; /* cf is in the CurrentRingp */ syzp->syz = syz; /* syz is in the SyzRingp */ - /* BUG: dehomogenize the syzygy */ - fprintf(stderr,"It has not yet implemented.\n"); - exit(10); } r = goDeHomogenizeS(r); - if (DoCancel && (r != POLYNULL)) { /* BUG: syzygy should be corrected. */ + if (DoCancel && (r != POLYNULL)) { if (r->m->ringp->p == 0) { r = reduceContentOfPoly(r,&cont); if (DebugReductionEcart || DebugReductionRed || DebugContentReduction) printf("cont=%s ",coeffToString(cont));