version 1.20, 2002/01/28 00:54:43 |
version 1.23, 2003/05/28 07:32:32 |
|
|
* 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.19 2001/10/09 01:36:11 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.22 2003/01/04 09:06:17 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
|
|
#define ORD_ELIM 9 |
#define ORD_ELIM 9 |
#define ORD_WEYL_ELIM 10 |
#define ORD_WEYL_ELIM 10 |
#define ORD_HOMO_WW_DRL 11 |
#define ORD_HOMO_WW_DRL 11 |
|
#define ORD_DRL_ZIGZAG 12 |
|
#define ORD_HOMO_WW_DRL_ZIGZAG 13 |
|
|
|
int cmpdl_drl_zigzag(), cmpdl_homo_ww_drl_zigzag(); |
|
|
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 int dp_nelim,dp_fcoeffs; |
|
Line 75 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 f) |
int has_sfcoef(DP f) |
{ |
{ |
MP t; |
MP t; |
|
|
if ( !f ) |
if ( !f ) |
return 0; |
return 0; |
for ( t = BDY(f); t; t = NEXT(t) ) |
for ( t = BDY(f); t; t = NEXT(t) ) |
if ( has_fcoef_p(t->c) ) |
if ( has_sfcoef_p(t->c) ) |
break; |
break; |
return t ? 1 : 0; |
return t ? 1 : 0; |
} |
} |
|
|
int has_fcoef_p(P f) |
int has_sfcoef_p(P f) |
{ |
{ |
DCP dc; |
DCP dc; |
|
|
if ( !f ) |
if ( !f ) |
return 0; |
return 0; |
else if ( NUM(f) ) |
else if ( NUM(f) ) |
return (NID((Num)f) == N_LM |
return (NID((Num)f) == N_GFS) ? 1 : 0; |
|| 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_sfcoef_p(COEF(dc)) ) |
return 1; |
return 1; |
return 0; |
return 0; |
} |
} |
Line 136 void initd(struct order_spec *spec) |
|
Line 137 void initd(struct order_spec *spec) |
|
cmpdl = cmpdl_weyl_elim; break; |
cmpdl = cmpdl_weyl_elim; break; |
case ORD_HOMO_WW_DRL: |
case ORD_HOMO_WW_DRL: |
cmpdl = cmpdl_homo_ww_drl; break; |
cmpdl = cmpdl_homo_ww_drl; break; |
|
case ORD_DRL_ZIGZAG: |
|
cmpdl = cmpdl_drl_zigzag; break; |
|
case ORD_HOMO_WW_DRL_ZIGZAG: |
|
cmpdl = cmpdl_homo_ww_drl_zigzag; break; |
case ORD_LEX: default: |
case ORD_LEX: default: |
cmpdl = cmpdl_lex; break; |
cmpdl = cmpdl_lex; break; |
} |
} |
Line 196 void ptod(VL vl,VL dvl,P p,DP *pr) |
|
Line 201 void ptod(VL vl,VL dvl,P p,DP *pr) |
|
} |
} |
} |
} |
#if 0 |
#if 0 |
if ( !dp_fcoeffs && has_fcoef(*pr) ) |
if ( !dp_fcoeffs && has_sfcoef(*pr) ) |
dp_fcoeffs = 1; |
dp_fcoeffs = N_GFS; |
#endif |
#endif |
} |
} |
|
|
Line 416 NODE symb_merge(NODE m1,NODE m2,int n) |
|
Line 421 NODE symb_merge(NODE m1,NODE m2,int n) |
|
} |
} |
} |
} |
|
|
|
void _adddl(int n,DL d1,DL d2,DL d3) |
|
{ |
|
int i; |
|
|
|
d3->td = d1->td+d2->td; |
|
for ( i = 0; i < n; i++ ) |
|
d3->d[i] = d1->d[i]+d2->d[i]; |
|
} |
|
|
|
/* m1 <- m1 U dl*f, destructive */ |
|
|
|
NODE mul_dllist(DL dl,DP f); |
|
|
|
NODE symb_mul_merge(NODE m1,DL dl,DP f,int n) |
|
{ |
|
NODE top,prev,cur,n1; |
|
DP g; |
|
DL t,s; |
|
MP m; |
|
|
|
if ( !m1 ) |
|
return mul_dllist(dl,f); |
|
else if ( !f ) |
|
return m1; |
|
else { |
|
m = BDY(f); |
|
NEWDL_NOINIT(t,n); |
|
_adddl(n,m->dl,dl,t); |
|
top = m1; prev = 0; cur = m1; |
|
while ( m ) { |
|
switch ( (*cmpdl)(n,(DL)BDY(cur),t) ) { |
|
case 0: |
|
prev = cur; cur = NEXT(cur); |
|
if ( !cur ) { |
|
MKDP(n,m,g); |
|
NEXT(prev) = mul_dllist(dl,g); |
|
return; |
|
} |
|
m = NEXT(m); |
|
if ( m ) _adddl(n,m->dl,dl,t); |
|
break; |
|
case 1: |
|
prev = cur; cur = NEXT(cur); |
|
if ( !cur ) { |
|
MKDP(n,m,g); |
|
NEXT(prev) = mul_dllist(dl,g); |
|
return; |
|
} |
|
break; |
|
case -1: |
|
NEWDL_NOINIT(s,n); |
|
s->td = t->td; |
|
bcopy(t->d,s->d,n*sizeof(int)); |
|
NEWNODE(n1); |
|
n1->body = (pointer)s; |
|
NEXT(n1) = cur; |
|
if ( !prev ) { |
|
top = n1; cur = n1; |
|
} else { |
|
NEXT(prev) = n1; prev = n1; |
|
} |
|
m = NEXT(m); |
|
if ( m ) _adddl(n,m->dl,dl,t); |
|
break; |
|
} |
|
} |
|
return top; |
|
} |
|
} |
|
|
DLBUCKET symb_merge_bucket(DLBUCKET m1,DLBUCKET m2,int n) |
DLBUCKET symb_merge_bucket(DLBUCKET m1,DLBUCKET m2,int n) |
{ |
{ |
DLBUCKET top,prev,cur,m,t; |
DLBUCKET top,prev,cur,m,t; |
Line 1079 int cmpdl_homo_ww_drl(int n,DL d1,DL d2) |
|
Line 1154 int cmpdl_homo_ww_drl(int n,DL d1,DL d2) |
|
return -1; |
return -1; |
|
|
m = n>>1; |
m = n>>1; |
for ( i = 0, e1 = e2 = 0; i < m; i++ ) { |
for ( i = 0, e1 = e2 = 0, p1 = d1->d, p2 = d2->d; i < m; i++ ) { |
e1 += current_weyl_weight_vector[i]*(d1->d[m+i] - d1->d[i]); |
e1 += current_weyl_weight_vector[i]*(p1[m+i] - p1[i]); |
e2 += current_weyl_weight_vector[i]*(d2->d[m+i] - d2->d[i]); |
e2 += current_weyl_weight_vector[i]*(p2[m+i] - p2[i]); |
} |
} |
if ( e1 > e2 ) |
if ( e1 > e2 ) |
return 1; |
return 1; |
Line 1098 int cmpdl_homo_ww_drl(int n,DL d1,DL d2) |
|
Line 1173 int cmpdl_homo_ww_drl(int n,DL d1,DL d2) |
|
for ( i= n - 1, p1 = d1->d+n-1, p2 = d2->d+n-1; |
for ( i= n - 1, p1 = d1->d+n-1, p2 = d2->d+n-1; |
i >= 0 && *p1 == *p2; i--, p1--, p2-- ); |
i >= 0 && *p1 == *p2; i--, p1--, p2-- ); |
return i < 0 ? 0 : (*p1 < *p2 ? 1 : -1); |
return i < 0 ? 0 : (*p1 < *p2 ? 1 : -1); |
|
} |
|
|
|
int cmpdl_drl_zigzag(int n,DL d1,DL d2) |
|
{ |
|
int i,t,m; |
|
int *p1,*p2; |
|
|
|
if ( d1->td > d2->td ) |
|
return 1; |
|
else if ( d1->td < d2->td ) |
|
return -1; |
|
else { |
|
m = n>>1; |
|
for ( i= m - 1, p1 = d1->d, p2 = d2->d; i >= 0; i-- ) { |
|
if ( t = p1[m+i] - p2[m+i] ) return t > 0 ? -1 : 1; |
|
if ( t = p1[i] - p2[i] ) return t > 0 ? -1 : 1; |
|
} |
|
return 0; |
|
} |
|
} |
|
|
|
int cmpdl_homo_ww_drl_zigzag(int n,DL d1,DL d2) |
|
{ |
|
int e1,e2,m,i,t; |
|
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, p1 = d1->d, p2 = d2->d; i < m; i++ ) { |
|
e1 += current_weyl_weight_vector[i]*(p1[m+i] - p1[i]); |
|
e2 += current_weyl_weight_vector[i]*(p2[m+i] - p2[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= m - 1, p1 = d1->d, p2 = d2->d; i >= 0; i-- ) { |
|
if ( t = p1[m+i] - p2[m+i] ) return t > 0 ? -1 : 1; |
|
if ( t = p1[i] - p2[i] ) return t > 0 ? -1 : 1; |
|
} |
|
return 0; |
} |
} |
|
|
int cmpdl_order_pair(int n,DL d1,DL d2) |
int cmpdl_order_pair(int n,DL d1,DL d2) |