version 1.15, 2001/03/29 09:49:57 |
version 1.19, 2001/10/09 01:36:11 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.14 2001/02/21 07:10:18 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.18 2001/09/13 03:04:28 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
|
|
int (*cmpdl)()=cmpdl_revgradlex; |
int (*cmpdl)()=cmpdl_revgradlex; |
int (*primitive_cmpdl[3])() = {cmpdl_revgradlex,cmpdl_gradlex,cmpdl_lex}; |
int (*primitive_cmpdl[3])() = {cmpdl_revgradlex,cmpdl_gradlex,cmpdl_lex}; |
|
|
void comm_muld(VL,DP,DP,DP *); |
|
void weyl_muld(VL,DP,DP,DP *); |
|
void weyl_muldm(VL,MP,DP,DP *); |
|
void weyl_mulmm(VL,MP,MP,int,struct cdl *,int); |
|
void comm_muld_tab(VL,int,struct cdl *,int,struct cdl *,int,struct cdl *); |
|
|
|
void mkwc(int,int,Q *); |
|
|
|
int cmpdl_weyl_elim(); |
|
int cmpdl_homo_ww_drl(); |
|
|
|
int do_weyl; |
int do_weyl; |
|
|
int dp_nelim,dp_fcoeffs; |
int dp_nelim,dp_fcoeffs; |
struct order_spec dp_current_spec; |
struct order_spec dp_current_spec; |
int *dp_dl_work; |
int *dp_dl_work; |
|
|
int has_fcoef(DP); |
int has_fcoef(DP f) |
int has_fcoef_p(P); |
|
|
|
int has_fcoef(f) |
|
DP f; |
|
{ |
{ |
MP t; |
MP t; |
|
|
|
|
return t ? 1 : 0; |
return t ? 1 : 0; |
} |
} |
|
|
int has_fcoef_p(f) |
int has_fcoef_p(P f) |
P f; |
|
{ |
{ |
DCP dc; |
DCP dc; |
|
|
|
|
} |
} |
} |
} |
|
|
void initd(spec) |
void initd(struct order_spec *spec) |
struct order_spec *spec; |
|
{ |
{ |
switch ( spec->id ) { |
switch ( spec->id ) { |
case 2: |
case 2: |
Line 161 struct order_spec *spec; |
|
Line 144 struct order_spec *spec; |
|
dp_current_spec = *spec; |
dp_current_spec = *spec; |
} |
} |
|
|
void ptod(vl,dvl,p,pr) |
void ptod(VL vl,VL dvl,P p,DP *pr) |
VL vl,dvl; |
|
P p; |
|
DP *pr; |
|
{ |
{ |
int isconst = 0; |
int isconst = 0; |
int n,i; |
int n,i,j,k; |
VL tvl; |
VL tvl; |
V v; |
V v; |
DL d; |
DL d; |
MP m; |
MP m; |
DCP dc; |
DCP dc; |
|
DCP *w; |
DP r,s,t,u; |
DP r,s,t,u; |
P x,c; |
P x,c; |
|
|
|
|
for ( i = 0, tvl = dvl, v = VR(p); |
for ( i = 0, tvl = dvl, v = VR(p); |
tvl && tvl->v != v; tvl = NEXT(tvl), i++ ); |
tvl && tvl->v != v; tvl = NEXT(tvl), i++ ); |
if ( !tvl ) { |
if ( !tvl ) { |
for ( dc = DC(p), s = 0, MKV(v,x); dc; dc = NEXT(dc) ) { |
for ( dc = DC(p), k = 0; dc; dc = NEXT(dc), k++ ); |
ptod(vl,dvl,COEF(dc),&t); pwrp(vl,x,DEG(dc),&c); |
w = (DCP *)ALLOCA(k*sizeof(DCP)); |
|
for ( dc = DC(p), j = 0; j < k; dc = NEXT(dc), j++ ) |
|
w[j] = dc; |
|
|
|
for ( j = k-1, s = 0, MKV(v,x); j >= 0; j-- ) { |
|
ptod(vl,dvl,COEF(w[j]),&t); pwrp(vl,x,DEG(w[j]),&c); |
muldc(vl,t,c,&r); addd(vl,r,s,&t); s = t; |
muldc(vl,t,c,&r); addd(vl,r,s,&t); s = t; |
} |
} |
*pr = s; |
*pr = s; |
} else { |
} else { |
for ( dc = DC(p), s = 0; dc; dc = NEXT(dc) ) { |
for ( dc = DC(p), k = 0; dc; dc = NEXT(dc), k++ ); |
ptod(vl,dvl,COEF(dc),&t); |
w = (DCP *)ALLOCA(k*sizeof(DCP)); |
NEWDL(d,n); d->td = QTOS(DEG(dc)); d->d[i] = d->td; |
for ( dc = DC(p), j = 0; j < k; dc = NEXT(dc), j++ ) |
|
w[j] = dc; |
|
|
|
for ( j = k-1, s = 0; j >= 0; j-- ) { |
|
ptod(vl,dvl,COEF(w[j]),&t); |
|
NEWDL(d,n); d->td = QTOS(DEG(w[j])); d->d[i] = d->td; |
NEWMP(m); m->dl = d; C(m) = (P)ONE; NEXT(m) = 0; MKDP(n,m,u); u->sugar = d->td; |
NEWMP(m); m->dl = d; C(m) = (P)ONE; NEXT(m) = 0; MKDP(n,m,u); u->sugar = d->td; |
comm_muld(vl,t,u,&r); addd(vl,r,s,&t); s = t; |
comm_muld(vl,t,u,&r); addd(vl,r,s,&t); s = t; |
} |
} |
|
|
} |
} |
} |
} |
} |
} |
|
#if 0 |
if ( !dp_fcoeffs && has_fcoef(*pr) ) |
if ( !dp_fcoeffs && has_fcoef(*pr) ) |
dp_fcoeffs = 1; |
dp_fcoeffs = 1; |
|
#endif |
} |
} |
|
|
void dtop(vl,dvl,p,pr) |
void dtop(VL vl,VL dvl,DP p,P *pr) |
VL vl,dvl; |
|
DP p; |
|
P *pr; |
|
{ |
{ |
int n,i; |
int n,i,j,k; |
DL d; |
DL d; |
MP m; |
MP m; |
|
MP *a; |
P r,s,t,u,w; |
P r,s,t,u,w; |
Q q; |
Q q; |
VL tvl; |
VL tvl; |
|
|
if ( !p ) |
if ( !p ) |
*pr = 0; |
*pr = 0; |
else { |
else { |
for ( n = p->nv, m = BDY(p), s = 0; m; m = NEXT(m) ) { |
for ( k = 0, m = BDY(p); m; m = NEXT(m), k++ ); |
|
a = (MP *)ALLOCA(k*sizeof(MP)); |
|
for ( j = 0, m = BDY(p); j < k; m = NEXT(m), j++ ) |
|
a[j] = m; |
|
|
|
for ( n = p->nv, j = k-1, s = 0; j >= 0; j-- ) { |
|
m = a[j]; |
t = C(m); |
t = C(m); |
if ( NUM(t) && NID((Num)t) == N_M ) { |
if ( NUM(t) && NID((Num)t) == N_M ) { |
mptop(t,&u); t = u; |
mptop(t,&u); t = u; |
|
|
} |
} |
} |
} |
|
|
void nodetod(node,dp) |
void nodetod(NODE node,DP *dp) |
NODE node; |
|
DP *dp; |
|
{ |
{ |
NODE t; |
NODE t; |
int len,i,td; |
int len,i,td; |
|
|
MKDP(len,m,u); u->sugar = td; *dp = u; |
MKDP(len,m,u); u->sugar = td; *dp = u; |
} |
} |
|
|
int sugard(m) |
int sugard(MP m) |
MP m; |
|
{ |
{ |
int s; |
int s; |
|
|
|
|
return s; |
return s; |
} |
} |
|
|
void addd(vl,p1,p2,pr) |
void addd(VL vl,DP p1,DP p2,DP *pr) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
int n; |
int n; |
MP m1,m2,mr,mr0; |
MP m1,m2,mr,mr0; |
|
|
|
|
/* for F4 symbolic reduction */ |
/* for F4 symbolic reduction */ |
|
|
void symb_addd(p1,p2,pr) |
void symb_addd(DP p1,DP p2,DP *pr) |
DP p1,p2,*pr; |
|
{ |
{ |
int n; |
int n; |
MP m1,m2,mr,mr0; |
MP m1,m2,mr,mr0; |
P t; |
|
|
|
if ( !p1 ) |
if ( !p1 ) |
*pr = p2; |
*pr = p2; |
|
|
* return : a merged list |
* return : a merged list |
*/ |
*/ |
|
|
NODE symb_merge(m1,m2,n) |
NODE symb_merge(NODE m1,NODE m2,int n) |
NODE m1,m2; |
|
int n; |
|
{ |
{ |
NODE top,prev,cur,m,t; |
NODE top,prev,cur,m,t; |
|
|
|
|
} |
} |
} |
} |
|
|
void subd(vl,p1,p2,pr) |
DLBUCKET symb_merge_bucket(DLBUCKET m1,DLBUCKET m2,int n) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
|
DLBUCKET top,prev,cur,m,t; |
|
|
|
if ( !m1 ) |
|
return m2; |
|
else if ( !m2 ) |
|
return m1; |
|
else { |
|
if ( m1->td == m2->td ) { |
|
top = m1; |
|
BDY(top) = symb_merge(BDY(top),BDY(m2),n); |
|
m = NEXT(m2); |
|
} else if ( m1->td > m2->td ) { |
|
top = m1; m = m2; |
|
} else { |
|
top = m2; m = m1; |
|
} |
|
prev = top; cur = NEXT(top); |
|
/* prev->td > m->td always holds */ |
|
while ( cur && m ) { |
|
if ( cur->td == m->td ) { |
|
BDY(cur) = symb_merge(BDY(cur),BDY(m),n); |
|
m = NEXT(m); |
|
prev = cur; cur = NEXT(cur); |
|
} else if ( cur->td > m->td ) { |
|
t = NEXT(cur); NEXT(cur) = m; m = t; |
|
prev = cur; cur = NEXT(cur); |
|
} else { |
|
NEXT(prev) = m; m = cur; |
|
prev = NEXT(prev); cur = NEXT(prev); |
|
} |
|
} |
|
if ( !cur ) |
|
NEXT(prev) = m; |
|
return top; |
|
} |
|
} |
|
|
|
void subd(VL vl,DP p1,DP p2,DP *pr) |
|
{ |
DP t; |
DP t; |
|
|
if ( !p2 ) |
if ( !p2 ) |
|
|
} |
} |
} |
} |
|
|
void chsgnd(p,pr) |
void chsgnd(DP p,DP *pr) |
DP p,*pr; |
|
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
|
|
|
|
} |
} |
} |
} |
|
|
void muld(vl,p1,p2,pr) |
void muld(VL vl,DP p1,DP p2,DP *pr) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
if ( ! do_weyl ) |
if ( ! do_weyl ) |
comm_muld(vl,p1,p2,pr); |
comm_muld(vl,p1,p2,pr); |
|
|
weyl_muld(vl,p1,p2,pr); |
weyl_muld(vl,p1,p2,pr); |
} |
} |
|
|
void comm_muld(vl,p1,p2,pr) |
void comm_muld(VL vl,DP p1,DP p2,DP *pr) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
MP m; |
MP m; |
DP s,t,u; |
DP s,t,u; |
|
|
} |
} |
} |
} |
|
|
void muldm(vl,p,m0,pr) |
void muldm(VL vl,DP p,MP m0,DP *pr) |
VL vl; |
|
DP p; |
|
MP m0; |
|
DP *pr; |
|
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
P c; |
P c; |
|
|
} |
} |
} |
} |
|
|
void weyl_muld(vl,p1,p2,pr) |
void weyl_muld(VL vl,DP p1,DP p2,DP *pr) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
MP m; |
MP m; |
DP s,t,u; |
DP s,t,u; |
|
|
|
|
/* monomial * polynomial */ |
/* monomial * polynomial */ |
|
|
void weyl_muldm(vl,m0,p,pr) |
void weyl_muldm(VL vl,MP m0,DP p,DP *pr) |
VL vl; |
|
MP m0; |
|
DP p; |
|
DP *pr; |
|
{ |
{ |
DP r,t,t1; |
DP r,t,t1; |
MP m; |
MP m; |
|
|
/* m0 = x0^d0*x1^d1*... * dx0^e0*dx1^e1*... */ |
/* m0 = x0^d0*x1^d1*... * dx0^e0*dx1^e1*... */ |
/* rtab : array of length (e0+1)*(e1+1)*... */ |
/* rtab : array of length (e0+1)*(e1+1)*... */ |
|
|
void weyl_mulmm(vl,m0,m1,n,rtab,rtablen) |
void weyl_mulmm(VL vl,MP m0,MP m1,int n,struct cdl *rtab,int rtablen) |
VL vl; |
|
MP m0,m1; |
|
int n; |
|
struct cdl *rtab; |
|
int rtablen; |
|
{ |
{ |
MP m,mr,mr0; |
P c,c0,c1; |
DP r,t,t1; |
|
P c,c0,c1,cc; |
|
DL d,d0,d1,dt; |
DL d,d0,d1,dt; |
int i,j,a,b,k,l,n2,s,min,curlen; |
int i,j,a,b,k,l,n2,s,min,curlen; |
struct cdl *p; |
struct cdl *p; |
|
|
] |
] |
*/ |
*/ |
|
|
void comm_muld_tab(vl,nv,t,n,t1,n1,rt) |
void comm_muld_tab(VL vl,int nv,struct cdl *t,int n,struct cdl *t1,int n1,struct cdl *rt) |
VL vl; |
|
int nv; |
|
struct cdl *t; |
|
int n; |
|
struct cdl *t1; |
|
int n1; |
|
struct cdl *rt; |
|
{ |
{ |
int i,j; |
int i,j; |
struct cdl *p; |
struct cdl *p; |
|
|
} |
} |
} |
} |
|
|
void muldc(vl,p,c,pr) |
void muldc(VL vl,DP p,P c,DP *pr) |
VL vl; |
|
DP p; |
|
P c; |
|
DP *pr; |
|
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
|
|
|
|
} |
} |
} |
} |
|
|
void divsdc(vl,p,c,pr) |
void divsdc(VL vl,DP p,P c,DP *pr) |
VL vl; |
|
DP p; |
|
P c; |
|
DP *pr; |
|
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
|
|
|
|
} |
} |
} |
} |
|
|
void adddl(n,d1,d2,dr) |
void adddl(int n,DL d1,DL d2,DL *dr) |
int n; |
|
DL d1,d2; |
|
DL *dr; |
|
{ |
{ |
DL dt; |
DL dt; |
int i; |
int i; |
|
|
|
|
/* d1 += d2 */ |
/* d1 += d2 */ |
|
|
void adddl_destructive(n,d1,d2) |
void adddl_destructive(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
DL dt; |
|
int i; |
int i; |
|
|
d1->td += d2->td; |
d1->td += d2->td; |
|
|
d1->d[i] += d2->d[i]; |
d1->d[i] += d2->d[i]; |
} |
} |
|
|
int compd(vl,p1,p2) |
int compd(VL vl,DP p1,DP p2) |
VL vl; |
|
DP p1,p2; |
|
{ |
{ |
int n,t; |
int n,t; |
MP m1,m2; |
MP m1,m2; |
|
|
} |
} |
} |
} |
|
|
int cmpdl_lex(n,d1,d2) |
int cmpdl_lex(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int i; |
int i; |
|
|
|
|
return i == n ? 0 : (d1->d[i] > d2->d[i] ? 1 : -1); |
return i == n ? 0 : (d1->d[i] > d2->d[i] ? 1 : -1); |
} |
} |
|
|
int cmpdl_revlex(n,d1,d2) |
int cmpdl_revlex(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int i; |
int i; |
|
|
|
|
return i < 0 ? 0 : (d1->d[i] < d2->d[i] ? 1 : -1); |
return i < 0 ? 0 : (d1->d[i] < d2->d[i] ? 1 : -1); |
} |
} |
|
|
int cmpdl_gradlex(n,d1,d2) |
int cmpdl_gradlex(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
if ( d1->td > d2->td ) |
if ( d1->td > d2->td ) |
return 1; |
return 1; |
|
|
return cmpdl_lex(n,d1,d2); |
return cmpdl_lex(n,d1,d2); |
} |
} |
|
|
int cmpdl_revgradlex(n,d1,d2) |
int cmpdl_revgradlex(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
register int i; |
register int i; |
register int *p1,*p2; |
register int *p1,*p2; |
|
|
} |
} |
} |
} |
|
|
int cmpdl_blex(n,d1,d2) |
int cmpdl_blex(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int c; |
int c; |
|
|
|
|
} |
} |
} |
} |
|
|
int cmpdl_bgradlex(n,d1,d2) |
int cmpdl_bgradlex(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,c; |
int e1,e2,c; |
|
|
|
|
} |
} |
} |
} |
|
|
int cmpdl_brevgradlex(n,d1,d2) |
int cmpdl_brevgradlex(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,c; |
int e1,e2,c; |
|
|
|
|
} |
} |
} |
} |
|
|
int cmpdl_brevrev(n,d1,d2) |
int cmpdl_brevrev(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,f1,f2,c,i; |
int e1,e2,f1,f2,c,i; |
|
|
|
|
} |
} |
} |
} |
|
|
int cmpdl_bgradrev(n,d1,d2) |
int cmpdl_bgradrev(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,f1,f2,c,i; |
int e1,e2,f1,f2,c,i; |
|
|
|
|
} |
} |
} |
} |
|
|
int cmpdl_blexrev(n,d1,d2) |
int cmpdl_blexrev(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,f1,f2,c,i; |
int e1,e2,f1,f2,c,i; |
|
|
|
|
} |
} |
} |
} |
|
|
int cmpdl_elim(n,d1,d2) |
int cmpdl_elim(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,i; |
int e1,e2,i; |
|
|
|
|
return cmpdl_revgradlex(n,d1,d2); |
return cmpdl_revgradlex(n,d1,d2); |
} |
} |
|
|
int cmpdl_weyl_elim(n,d1,d2) |
int cmpdl_weyl_elim(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,i; |
int e1,e2,i; |
|
|
|
|
|
|
extern int *current_weight_vector; |
extern int *current_weight_vector; |
|
|
int cmpdl_homo_ww_drl(n,d1,d2) |
int cmpdl_homo_ww_drl(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,m,i; |
int e1,e2,m,i; |
int *p1,*p2; |
int *p1,*p2; |
|
|
return i < 0 ? 0 : (*p1 < *p2 ? 1 : -1); |
return i < 0 ? 0 : (*p1 < *p2 ? 1 : -1); |
} |
} |
|
|
int cmpdl_order_pair(n,d1,d2) |
int cmpdl_order_pair(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int e1,e2,i,j,l; |
int e1,e2,i,j,l; |
int *t1,*t2; |
int *t1,*t2; |
|
|
return 0; |
return 0; |
} |
} |
|
|
int cmpdl_matrix(n,d1,d2) |
int cmpdl_matrix(int n,DL d1,DL d2) |
int n; |
|
DL d1,d2; |
|
{ |
{ |
int *v,*w,*t1,*t2; |
int *v,*w,*t1,*t2; |
int s,i,j,len; |
int s,i,j,len; |