=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/replace.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -p -r1.1.1.1 -r1.3 --- OpenXM/src/kan96xx/Kan/replace.c 1999/10/08 02:12:02 1.1.1.1 +++ OpenXM/src/kan96xx/Kan/replace.c 2001/05/04 01:06:25 1.3 @@ -1,3 +1,4 @@ +/* $OpenXM: OpenXM/src/kan96xx/Kan/replace.c,v 1.2 2000/01/16 07:55:41 takayama Exp $ */ #include #include "datatype.h" #include "extern2.h" @@ -5,16 +6,16 @@ static int badLRule(POLY set[],int num); POLY mReplace(mm,lSideX,rSideX,sizex,lSideD,rSideD,sized,commutative) -POLY mm; -int lSideX[]; -POLY rSideX[]; /* Rule: a=lSideX[i], x_a ---> rSideX[i] */ -int sizex; -int lSideD[]; /* Rule: b=lSideD[i], D_b ---> rSideD[i] */ -POLY rSideD[]; -int sized; -int commutative; + POLY mm; + int lSideX[]; + POLY rSideX[]; /* Rule: a=lSideX[i], x_a ---> rSideX[i] */ + int sizex; + int lSideD[]; /* Rule: b=lSideD[i], D_b ---> rSideD[i] */ + POLY rSideD[]; + int sized; + int commutative; { -/* The function should be tuned by using a table. */ + /* The function should be tuned by using a table. */ POLY rp; POLY fac; int i; @@ -32,13 +33,13 @@ int commutative; if (mp->e[i].D != 0) { flag = 1; for (j=0; je[i].D); - else fac = pPower(rSideD[j],mp->e[i].D); - /* if negative, this does not work well!! */ - flag = 0; - break; - } + if (lSideD[j] == i) { + if (commutative) fac = pPower_poly(rSideD[j],mp->e[i].D); + else fac = pPower(rSideD[j],mp->e[i].D); + /* if negative, this does not work well!! */ + flag = 0; + break; + } } if (flag) fac = cdd(1,i,mp->e[i].D,mp->ringp); if (commutative) rp = ppMult_poly(fac,rp); @@ -50,13 +51,13 @@ int commutative; if (mp->e[i].x != 0) { flag = 1; for (j=0; je[i].x); - else fac = pPower(rSideX[j],mp->e[i].x); - /* if negative, this does not work well!! */ - flag = 0; - break; - } + if (lSideX[j] == i) { + if (commutative) fac = pPower_poly(rSideX[j],mp->e[i].x); + else fac = pPower(rSideX[j],mp->e[i].x); + /* if negative, this does not work well!! */ + flag = 0; + break; + } } if (flag) fac = cxx(1,i,mp->e[i].x,mp->ringp); if (commutative) rp = ppMult_poly(fac,rp); @@ -71,10 +72,10 @@ int commutative; lRule[i] ---> rRule[i] */ POLY replace(f,lRule,rRule,num) -POLY f; -POLY lRule[]; /* lRule[i] must be x0 or ... or D{N-1} */ -POLY rRule[]; -int num; + POLY f; + POLY lRule[]; /* lRule[i] must be x0 or ... or D{N-1} */ + POLY rRule[]; + int num; { POLY rSideX[N0]; POLY rSideD[N0]; @@ -86,11 +87,11 @@ int num; int n; /***printf("f=%s\n",POLYToString(f,'*',0)); - for (i=0; i %s\n",POLYToString(lRule[i],'*',0), - POLYToString(rRule[i],'*',0)); - } - printf("\n"); ***/ + for (i=0; i %s\n",POLYToString(lRule[i],'*',0), + POLYToString(rRule[i],'*',0)); + } + printf("\n"); ***/ if (f ISZERO) return(ZERO); sizex = sized = 0; @@ -103,14 +104,14 @@ int num; for (i=0; im->e[i].x == 1) { - lSideX[sizex] = i; - rSideX[sizex] = rRule[j]; - sizex++; - if (sizex >= n) { - warningPoly(" replace(): too many x-rules . "); - sizex--; - } - break; + lSideX[sizex] = i; + rSideX[sizex] = rRule[j]; + sizex++; + if (sizex >= n) { + warningPoly(" replace(): too many x-rules . "); + sizex--; + } + break; } } } @@ -118,14 +119,14 @@ int num; for (i=0; im->e[i].D == 1) { - lSideD[sized] = i; - rSideD[sized] = rRule[j]; - sized++; - if (sized >= n) { - warningPoly(" replacen(): too many D-rules . "); - sized--; - } - break; + lSideD[sized] = i; + rSideD[sized] = rRule[j]; + sized++; + if (sized >= n) { + warningPoly(" replacen(): too many D-rules . "); + sized--; + } + break; } } } @@ -142,10 +143,10 @@ int num; /* For the dirty trick of mpMult_difference */ POLY replace_poly(f,lRule,rRule,num) -POLY f; -POLY lRule[]; /* lRule[i] must be x0 or ... or D{N-1} */ -POLY rRule[]; -int num; + POLY f; + POLY lRule[]; /* lRule[i] must be x0 or ... or D{N-1} */ + POLY rRule[]; + int num; { POLY rSideX[N0]; POLY rSideD[N0]; @@ -157,11 +158,11 @@ int num; int n; /***printf("f=%s\n",POLYToString(f,'*',0)); - for (i=0; i %s\n",POLYToString(lRule[i],'*',0), - POLYToString(rRule[i],'*',0)); - } - printf("\n"); ***/ + for (i=0; i %s\n",POLYToString(lRule[i],'*',0), + POLYToString(rRule[i],'*',0)); + } + printf("\n"); ***/ if (f ISZERO) return(ZERO); sizex = sized = 0; @@ -174,14 +175,14 @@ int num; for (i=0; im->e[i].x == 1) { - lSideX[sizex] = i; - rSideX[sizex] = rRule[j]; - sizex++; - if (sizex >= n) { - warningPoly(" replace(): too many x-rules . "); - sizex--; - } - break; + lSideX[sizex] = i; + rSideX[sizex] = rRule[j]; + sizex++; + if (sizex >= n) { + warningPoly(" replace(): too many x-rules . "); + sizex--; + } + break; } } } @@ -189,14 +190,14 @@ int num; for (i=0; im->e[i].D == 1) { - lSideD[sized] = i; - rSideD[sized] = rRule[j]; - sized++; - if (sized >= n) { - warningPoly(" replacen(): too many D-rules . "); - sized--; - } - break; + lSideD[sized] = i; + rSideD[sized] = rRule[j]; + sized++; + if (sized >= n) { + warningPoly(" replacen(): too many D-rules . "); + sized--; + } + break; } } } @@ -212,14 +213,14 @@ int num; static int badLRule(set,num) -POLY set[]; -int num; + POLY set[]; + int num; { int i; - for (i=0; i