=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/nd.c,v retrieving revision 1.57 retrieving revision 1.59 diff -u -p -r1.57 -r1.59 --- OpenXM_contrib2/asir2000/engine/nd.c 2003/09/05 05:02:53 1.57 +++ OpenXM_contrib2/asir2000/engine/nd.c 2003/09/05 13:20:14 1.59 @@ -1,4 +1,4 @@ -/* $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.58 2003/09/05 07:00:37 noro Exp $ */ #include "ca.h" #include "inline.h" @@ -121,6 +121,7 @@ static int nmv_adv; static int nd_dcomp; extern int Top,Reverse,dp_nelim,do_weyl; +extern int *current_weyl_weight_vector; /* fundamental macros */ #define TD(d) (d[0]) @@ -621,6 +622,24 @@ int ndl_block_compare(unsigned int *d1,unsigned int *d 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) { int i; @@ -3138,6 +3157,12 @@ void nd_init_ord(struct order_spec *ord) nd_isrlex = 0; ndl_compare_function = ndl_lex_compare; break; + case 11: + /* XXX */ + nd_dcomp = 0; + nd_isrlex = 1; + ndl_compare_function = ndl_ww_lex_compare; + break; default: error("nd_gr : unsupported order"); } @@ -3224,3 +3249,41 @@ EPOS nd_create_epos(struct order_spec *ord) } 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); +} +