version 1.11, 2000/12/05 06:59:16 |
version 1.17, 2001/09/04 08:48:20 |
|
|
* 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.10 2000/11/07 06:06:39 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.16 2001/05/02 09:03:53 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
|
|
#define ORD_BGRADREV 7 |
#define ORD_BGRADREV 7 |
#define ORD_BLEXREV 8 |
#define ORD_BLEXREV 8 |
#define ORD_ELIM 9 |
#define ORD_ELIM 9 |
|
#define ORD_WEYL_ELIM 10 |
|
#define ORD_HOMO_WW_DRL 11 |
|
|
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}; |
Line 71 void comm_muld_tab(VL,int,struct cdl *,int,struct cdl |
|
Line 73 void comm_muld_tab(VL,int,struct cdl *,int,struct cdl |
|
|
|
void mkwc(int,int,Q *); |
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; |
|
|
if ( !f ) |
if ( !f ) |
return 0; |
return 0; |
else if ( NUM(f) ) |
else if ( NUM(f) ) |
return (NID((Num)f) == N_LM || NID((Num)f) == N_GF2N) ? 1 : 0; |
return (NID((Num)f) == N_LM |
|
|| NID((Num)f) == N_GF2N |
|
|| NID((Num)f) == N_GFPN |
|
|| NID((Num)f) == N_GFS) ? 1 : 0; |
else { |
else { |
for ( dc = DC(f); dc; dc = NEXT(dc) ) |
for ( dc = DC(f); dc; dc = NEXT(dc) ) |
if ( has_fcoef_p(COEF(dc)) ) |
if ( has_fcoef_p(COEF(dc)) ) |
Line 141 struct order_spec *spec; |
|
Line 149 struct order_spec *spec; |
|
cmpdl = cmpdl_blexrev; break; |
cmpdl = cmpdl_blexrev; break; |
case ORD_ELIM: |
case ORD_ELIM: |
cmpdl = cmpdl_elim; break; |
cmpdl = cmpdl_elim; break; |
|
case ORD_WEYL_ELIM: |
|
cmpdl = cmpdl_weyl_elim; break; |
|
case ORD_HOMO_WW_DRL: |
|
cmpdl = cmpdl_homo_ww_drl; break; |
case ORD_LEX: default: |
case ORD_LEX: default: |
cmpdl = cmpdl_lex; break; |
cmpdl = cmpdl_lex; break; |
} |
} |
|
|
DP *pr; |
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,dvl,p,pr) |
|
|
DP p; |
DP p; |
P *pr; |
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; |
|
|
return -1; |
return -1; |
else |
else |
return cmpdl_revgradlex(n,d1,d2); |
return cmpdl_revgradlex(n,d1,d2); |
|
} |
|
|
|
int cmpdl_weyl_elim(n,d1,d2) |
|
int n; |
|
DL d1,d2; |
|
{ |
|
int e1,e2,i; |
|
|
|
for ( i = 1, e1 = 0, e2 = 0; i <= dp_nelim; i++ ) { |
|
e1 += d1->d[n-i]; e2 += d2->d[n-i]; |
|
} |
|
if ( e1 > e2 ) |
|
return 1; |
|
else if ( e1 < e2 ) |
|
return -1; |
|
else if ( d1->td > d2->td ) |
|
return 1; |
|
else if ( d1->td < d2->td ) |
|
return -1; |
|
else return -cmpdl_revlex(n,d1,d2); |
|
} |
|
|
|
/* |
|
a special ordering |
|
1. total order |
|
2. (-w,w) for the first 2*m variables |
|
3. DRL for the first 2*m variables |
|
*/ |
|
|
|
extern int *current_weight_vector; |
|
|
|
int cmpdl_homo_ww_drl(n,d1,d2) |
|
int n; |
|
DL d1,d2; |
|
{ |
|
int e1,e2,m,i; |
|
int *p1,*p2; |
|
|
|
if ( d1->td > d2->td ) |
|
return 1; |
|
else if ( d1->td < d2->td ) |
|
return -1; |
|
|
|
m = n>>1; |
|
for ( i = 0, e1 = e2 = 0; i < m; i++ ) { |
|
e1 += current_weight_vector[i]*(d1->d[m+i] - d1->d[i]); |
|
e2 += current_weight_vector[i]*(d2->d[m+i] - d2->d[i]); |
|
} |
|
if ( e1 > e2 ) |
|
return 1; |
|
else if ( e1 < e2 ) |
|
return -1; |
|
|
|
e1 = d1->td - d1->d[n-1]; |
|
e2 = d2->td - d2->d[n-1]; |
|
if ( e1 > e2 ) |
|
return 1; |
|
else if ( e1 < e2 ) |
|
return -1; |
|
|
|
for ( i= n - 1, p1 = d1->d+n-1, p2 = d2->d+n-1; |
|
i >= 0 && *p1 == *p2; i--, p1--, p2-- ); |
|
return i < 0 ? 0 : (*p1 < *p2 ? 1 : -1); |
} |
} |
|
|
int cmpdl_order_pair(n,d1,d2) |
int cmpdl_order_pair(n,d1,d2) |