version 1.57, 2003/09/05 05:02:53 |
version 1.60, 2003/09/06 01:33:26 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.56 2003/09/04 08:35:09 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.59 2003/09/05 13:20:14 noro Exp $ */ |
|
|
#include "ca.h" |
#include "ca.h" |
#include "inline.h" |
#include "inline.h" |
Line 121 static int nmv_adv; |
|
Line 121 static int nmv_adv; |
|
static int nd_dcomp; |
static int nd_dcomp; |
|
|
extern int Top,Reverse,dp_nelim,do_weyl; |
extern int Top,Reverse,dp_nelim,do_weyl; |
|
extern int *current_weyl_weight_vector; |
|
|
/* fundamental macros */ |
/* fundamental macros */ |
#define TD(d) (d[0]) |
#define TD(d) (d[0]) |
Line 135 extern int Top,Reverse,dp_nelim,do_weyl; |
|
Line 136 extern int Top,Reverse,dp_nelim,do_weyl; |
|
#define LEN(a) ((a)->len) |
#define LEN(a) ((a)->len) |
#define LCM(a) ((a)->lcm) |
#define LCM(a) ((a)->lcm) |
#define GET_EXP(d,a) (((d)[nd_epos[a].i]>>nd_epos[a].s)&nd_mask0) |
#define GET_EXP(d,a) (((d)[nd_epos[a].i]>>nd_epos[a].s)&nd_mask0) |
|
#define GET_EXP_MASK(d,a,m) ((((d)[nd_epos[a].i]&(m)[nd_epos[a].i])>>nd_epos[a].s)&nd_mask0) |
#define PUT_EXP(r,a,e) ((r)[nd_epos[a].i] |= ((e)<<nd_epos[a].s)) |
#define PUT_EXP(r,a,e) ((r)[nd_epos[a].i] |= ((e)<<nd_epos[a].s)) |
#define XOR_EXP(r,a,e) ((r)[nd_epos[a].i] ^= ((e)<<nd_epos[a].s)) |
#define XOR_EXP(r,a,e) ((r)[nd_epos[a].i] ^= ((e)<<nd_epos[a].s)) |
|
|
Line 556 int ndl_weight(unsigned int *d) |
|
Line 558 int ndl_weight(unsigned int *d) |
|
unsigned int t,u; |
unsigned int t,u; |
int i,j; |
int i,j; |
|
|
for ( t = 0, i = nd_exporigin; i < nd_wpd; i++ ) { |
if ( current_dl_weight_vector ) |
u = d[i]; |
for ( i = 0, t = 0; i < nd_nvar; i++ ) { |
for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) |
u = GET_EXP(d,i); |
t += (u&nd_mask0); |
t += MUL_WEIGHT(u,i); |
} |
} |
|
else |
|
for ( t = 0, i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u = d[i]; |
|
for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) |
|
t += (u&nd_mask0); |
|
} |
return t; |
return t; |
} |
} |
|
|
Line 571 int ndl_weight_mask(unsigned int *d,int index) |
|
Line 579 int ndl_weight_mask(unsigned int *d,int index) |
|
int i,j; |
int i,j; |
|
|
mask = nd_blockmask->mask[index]; |
mask = nd_blockmask->mask[index]; |
for ( t = 0, i = nd_exporigin; i < nd_wpd; i++ ) { |
if ( current_dl_weight_vector ) |
u = d[i]&mask[i]; |
for ( i = 0, t = 0; i < nd_nvar; i++ ) { |
for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) |
u = GET_EXP_MASK(d,i,mask); |
t += (u&nd_mask0); |
t += MUL_WEIGHT(u,i); |
} |
} |
|
else |
|
for ( t = 0, i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u = d[i]&mask[i]; |
|
for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) |
|
t += (u&nd_mask0); |
|
} |
return t; |
return t; |
} |
} |
|
|
Line 621 int ndl_block_compare(unsigned int *d1,unsigned int *d |
|
Line 635 int ndl_block_compare(unsigned int *d1,unsigned int *d |
|
return 0; |
return 0; |
} |
} |
|
|
|
/* TDH -> WW -> TD-> RL */ |
|
|
|
int ndl_ww_lex_compare(unsigned int *d1,unsigned int *d2) |
|
{ |
|
int i,m,e1,e2; |
|
|
|
if ( TD(d1) > TD(d2) ) return 1; |
|
else if ( TD(d1) < TD(d2) ) return -1; |
|
m = nd_nvar>>1; |
|
for ( i = 0, e1 = e2 = 0; i < m; i++ ) { |
|
e1 += current_weyl_weight_vector[i]*(GET_EXP(d1,m+i)-GET_EXP(d1,i)); |
|
e2 += current_weyl_weight_vector[i]*(GET_EXP(d2,m+i)-GET_EXP(d2,i)); |
|
} |
|
if ( e1 > e2 ) return 1; |
|
else if ( e1 < e2 ) return -1; |
|
return ndl_lex_compare(d1,d2); |
|
} |
|
|
INLINE int ndl_equal(unsigned int *d1,unsigned int *d2) |
INLINE int ndl_equal(unsigned int *d1,unsigned int *d2) |
{ |
{ |
int i; |
int i; |
Line 3138 void nd_init_ord(struct order_spec *ord) |
|
Line 3170 void nd_init_ord(struct order_spec *ord) |
|
nd_isrlex = 0; |
nd_isrlex = 0; |
ndl_compare_function = ndl_lex_compare; |
ndl_compare_function = ndl_lex_compare; |
break; |
break; |
|
case 11: |
|
/* XXX */ |
|
nd_dcomp = 0; |
|
nd_isrlex = 1; |
|
ndl_compare_function = ndl_ww_lex_compare; |
|
break; |
default: |
default: |
error("nd_gr : unsupported order"); |
error("nd_gr : unsupported order"); |
} |
} |
Line 3224 EPOS nd_create_epos(struct order_spec *ord) |
|
Line 3262 EPOS nd_create_epos(struct order_spec *ord) |
|
} |
} |
return epos; |
return epos; |
} |
} |
|
|
|
/* external interface */ |
|
|
|
void nd_nf_p(P f,LIST g,LIST v,int m,struct order_spec *ord,P *rp) |
|
{ |
|
NODE t; |
|
ND nd,nf; |
|
VL vv; |
|
DP d,r,dm; |
|
int stat; |
|
|
|
pltovl(v,&vv); |
|
nd_nvar = length(vv); |
|
nd_init_ord(ord); |
|
initd(ord); |
|
for ( t = BDY(g); NEXT(t); t = NEXT(t) ) { |
|
ptod(CO,vv,(P)BDY(t),&d); BDY(t) = (pointer)d; |
|
} |
|
ptod(CO,vv,(P)BDY(t),&d); BDY(t) = (pointer)d; |
|
NEWNODE(NEXT(t)); ptod(CO,vv,f,&d); BDY(NEXT(t)) = d; NEXT(NEXT(t)) = 0; |
|
nd_setup(m,0,BDY(g)); |
|
nd_psn--; |
|
nd_scale=2; |
|
while ( 1 ) { |
|
nd = (pointer)ndvtond(m,nd_ps[nd_psn]); |
|
stat = nd_nf(m,nd,nd_ps,1,&nf); |
|
if ( !stat ) { |
|
nd_psn++; |
|
nd_reconstruct(m,0,0); |
|
nd_psn--; |
|
} else |
|
break; |
|
} |
|
r = (DP)ndtodp(m,nf); |
|
if ( m ) _dtop_mod(CO,vv,r,rp); |
|
else dtop(CO,vv,r,rp); |
|
} |
|
|