version 1.10, 2003/08/22 11:47:03 |
version 1.11, 2003/08/23 02:28:38 |
|
|
/* $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.10 2003/08/22 11:47:03 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
Line 438 POLY POLYToInitW(f,w) |
|
Line 438 POLY POLYToInitW(f,w) |
|
POLY f; |
POLY f; |
int w[]; /* weight vector */ |
int w[]; /* weight vector */ |
{ |
{ |
POLY node; |
|
struct listPoly nod; |
|
POLY h; |
POLY h; |
POLY g; |
POLY g; |
int maxd; |
int maxd; |
int dd; |
int dd; |
node = &nod; node->next = POLYNULL; h = node; |
h = POLYNULL; |
|
|
|
/*printf("1:%s\n",POLYToString(f,'*',1));*/ |
if (f ISZERO) return(f); |
if (f ISZERO) return(f); |
maxd = degreeOfInitW(f,w); |
maxd = degreeOfInitW(f,w); |
g = pCopy(f); /* shallow copy */ |
g = f; |
while (!(f ISZERO)) { |
while (!(f ISZERO)) { |
dd = degreeOfInitW(f,w); |
dd = degreeOfInitW(f,w); |
if (dd > maxd) maxd = dd; |
if (dd > maxd) maxd = dd; |
Line 457 POLY POLYToInitW(f,w) |
|
Line 456 POLY POLYToInitW(f,w) |
|
while (!(g ISZERO)) { |
while (!(g ISZERO)) { |
dd = degreeOfInitW(g,w); |
dd = degreeOfInitW(g,w); |
if (dd == maxd) { |
if (dd == maxd) { |
h->next = g; |
h = ppAdd(h,newCell(g->coeffp,g->m)); /* it might be slow. */ |
h = h->next; |
|
} |
} |
g = g->next; |
g = g->next; |
} |
} |
h->next = POLYNULL; |
/*printf("2:%s\n",POLYToString(h,'*',1));*/ |
return(node->next); |
return(h); |
} |
} |
|
|
static int degreeOfInitWS(f,w,s) |
static int degreeOfInitWS(f,w,s) |
Line 475 static int degreeOfInitWS(f,w,s) |
|
Line 473 static int degreeOfInitWS(f,w,s) |
|
if (f ISZERO) { |
if (f ISZERO) { |
errorPoly("degreeOfInitWS(0,w) "); |
errorPoly("degreeOfInitWS(0,w) "); |
} |
} |
|
if (s == (int *) NULL) return degreeOfInitW(f,w); |
n = f->m->ringp->n; dd = 0; |
n = f->m->ringp->n; dd = 0; |
for (i=0; i<n-1; i++) { |
for (i=0; i<n-1; i++) { |
dd += (f->m->e[i].D)*w[n+i]; |
dd += (f->m->e[i].D)*w[n+i]; |
Line 489 POLY POLYToInitWS(f,w,s) |
|
Line 488 POLY POLYToInitWS(f,w,s) |
|
int w[]; /* weight vector */ |
int w[]; /* weight vector */ |
int s[]; /* shift vector */ |
int s[]; /* shift vector */ |
{ |
{ |
POLY node; |
|
struct listPoly nod; |
|
POLY h; |
POLY h; |
POLY g; |
POLY g; |
int maxd; |
int maxd; |
int dd; |
int dd; |
node = &nod; node->next = POLYNULL; h = node; |
h = POLYNULL; |
|
|
|
/*printf("1s:%s\n",POLYToString(f,'*',1));*/ |
if (f ISZERO) return(f); |
if (f ISZERO) return(f); |
maxd = degreeOfInitWS(f,w,s); |
maxd = degreeOfInitWS(f,w,s); |
g = pCopy(f); /* shallow copy */ |
g = f; |
while (!(f ISZERO)) { |
while (!(f ISZERO)) { |
dd = degreeOfInitWS(f,w,s); |
dd = degreeOfInitWS(f,w,s); |
if (dd > maxd) maxd = dd; |
if (dd > maxd) maxd = dd; |
Line 508 POLY POLYToInitWS(f,w,s) |
|
Line 506 POLY POLYToInitWS(f,w,s) |
|
while (!(g ISZERO)) { |
while (!(g ISZERO)) { |
dd = degreeOfInitWS(g,w,s); |
dd = degreeOfInitWS(g,w,s); |
if (dd == maxd) { |
if (dd == maxd) { |
h->next = g; |
h = ppAdd(h,newCell(g->coeffp,g->m)); /* it might be slow. */ |
h = h->next; |
|
} |
} |
g = g->next; |
g = g->next; |
} |
} |
h->next = POLYNULL; |
/*printf("2s:%s\n",POLYToString(h,'*',1));*/ |
return(node->next); |
return(h); |
} |
} |
|
|
int ordWsAll(f,w,s) |
int ordWsAll(f,w,s) |
Line 629 POLY goDeHomogenizeS(POLY f) { |
|
Line 626 POLY goDeHomogenizeS(POLY f) { |
|
cp = f->coeffp; |
cp = f->coeffp; |
if (cp->tag == POLY_COEFF) { |
if (cp->tag == POLY_COEFF) { |
t = goDeHomogenizeS((cp->val).f); |
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); |
ans = ppAddv(ans,nc); |
f = f->next; |
f = f->next; |
}else{ |
}else{ |