=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/poly4.c,v retrieving revision 1.10 retrieving revision 1.12 diff -u -p -r1.10 -r1.12 --- OpenXM/src/kan96xx/Kan/poly4.c 2003/08/22 11:47:03 1.10 +++ OpenXM/src/kan96xx/Kan/poly4.c 2003/08/24 05:19:42 1.12 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/poly4.c,v 1.9 2003/08/21 12:28:58 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/poly4.c,v 1.11 2003/08/23 02:28:38 takayama Exp $ */ #include #include "datatype.h" #include "stackm.h" @@ -438,17 +438,16 @@ POLY POLYToInitW(f,w) POLY f; int w[]; /* weight vector */ { - POLY node; - struct listPoly nod; POLY h; POLY g; int maxd; int dd; - node = &nod; node->next = POLYNULL; h = node; + h = POLYNULL; + /*printf("1:%s\n",POLYToString(f,'*',1));*/ if (f ISZERO) return(f); maxd = degreeOfInitW(f,w); - g = pCopy(f); /* shallow copy */ + g = f; while (!(f ISZERO)) { dd = degreeOfInitW(f,w); if (dd > maxd) maxd = dd; @@ -457,13 +456,12 @@ POLY POLYToInitW(f,w) while (!(g ISZERO)) { dd = degreeOfInitW(g,w); if (dd == maxd) { - h->next = g; - h = h->next; + h = ppAdd(h,newCell(g->coeffp,g->m)); /* it might be slow. */ } g = g->next; } - h->next = POLYNULL; - return(node->next); + /*printf("2:%s\n",POLYToString(h,'*',1));*/ + return(h); } static int degreeOfInitWS(f,w,s) @@ -475,6 +473,7 @@ static int degreeOfInitWS(f,w,s) if (f ISZERO) { errorPoly("degreeOfInitWS(0,w) "); } + if (s == (int *) NULL) return degreeOfInitW(f,w); n = f->m->ringp->n; dd = 0; for (i=0; im->e[i].D)*w[n+i]; @@ -489,17 +488,16 @@ POLY POLYToInitWS(f,w,s) int w[]; /* weight vector */ int s[]; /* shift vector */ { - POLY node; - struct listPoly nod; POLY h; POLY g; int maxd; int dd; - node = &nod; node->next = POLYNULL; h = node; + h = POLYNULL; + /*printf("1s:%s\n",POLYToString(f,'*',1));*/ if (f ISZERO) return(f); maxd = degreeOfInitWS(f,w,s); - g = pCopy(f); /* shallow copy */ + g = f; while (!(f ISZERO)) { dd = degreeOfInitWS(f,w,s); if (dd > maxd) maxd = dd; @@ -508,13 +506,12 @@ POLY POLYToInitWS(f,w,s) while (!(g ISZERO)) { dd = degreeOfInitWS(g,w,s); if (dd == maxd) { - h->next = g; - h = h->next; + h = ppAdd(h,newCell(g->coeffp,g->m)); /* it might be slow. */ } g = g->next; } - h->next = POLYNULL; - return(node->next); + /*printf("2s:%s\n",POLYToString(h,'*',1));*/ + return(h); } int ordWsAll(f,w,s) @@ -629,7 +626,7 @@ POLY goDeHomogenizeS(POLY f) { cp = f->coeffp; if (cp->tag == POLY_COEFF) { t = goDeHomogenizeS((cp->val).f); - nc = newCell(polyToCoeff(t,f->m->ringp),f->m); + nc = newCell(polyToCoeff(t,f->m->ringp),monomialCopy(f->m)); ans = ppAddv(ans,nc); f = f->next; }else{ @@ -703,9 +700,11 @@ POLY goHomogenize(POLY f,int u[],int v[],int ds[],int message = 1; if (f == POLYNULL) return(POLYNULL); rp = f->m->ringp; + /* if ((rp->degreeShiftSize == 0) && (dssize > 0)) { warningPoly("You are trying to homogenize a polynomial with degree shift. However, the polynomial belongs to the ring without degreeShift option. It may cause a trouble in comparison in free module.\n"); } + */ node = &nod; node->next = POLYNULL; lastf = POLYNULL; @@ -757,7 +756,7 @@ POLY goHomogenize(POLY f,int u[],int v[],int ds[],int h = node->next; /*go-debug printf("m=%d, mp=%d\n",m,mp); */ while (h != POLYNULL) { - /*go-debug printf("Old: h=%d, s=%d\n",h->m->e[0].D,h->m->e[0].x); */ + /*go-debug printf("Old: h=%d, s=%d\n",h->m->e[0].D,h->m->e[0].x); */ if (!onlyS) h->m->e[0].D += m; /* h */ h->m->e[0].x += -mp; /* H, s*/ /*go-debug printf("New: h=%d, s=%d\n",h->m->e[0].D,h->m->e[0].x); */