=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2018/engine/nd.c,v retrieving revision 1.17 retrieving revision 1.20 diff -u -p -r1.17 -r1.20 --- OpenXM_contrib2/asir2018/engine/nd.c 2019/08/28 23:27:34 1.17 +++ OpenXM_contrib2/asir2018/engine/nd.c 2019/09/15 08:46:12 1.20 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.16 2019/08/21 00:37:47 noro Exp $ */ +/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.19 2019/09/04 05:32:10 noro Exp $ */ #include "nd.h" @@ -8,6 +8,8 @@ struct oEGT eg_search,f4_symb,f4_conv,f4_elim1,f4_elim int diag_period = 6; int weight_check = 1; int (*ndl_compare_function)(UINT *a1,UINT *a2); +/* for schreyer order */ +int (*ndl_base_compare_function)(UINT *a1,UINT *a2); int nd_dcomp; int nd_rref2; NM _nm_free_list; @@ -476,8 +478,11 @@ int ndl_weight(UINT *d) for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) t += (u&nd_mask0); } - if ( nd_module && current_module_weight_vector && MPOS(d) ) - t += current_module_weight_vector[MPOS(d)]; + if ( nd_module && nd_module_rank && MPOS(d) ) + t += nd_module_weight[MPOS(d)-1]; + for ( i = nd_exporigin; i < nd_wpd; i++ ) + if ( d[i] && !t ) + printf("afo\n"); return t; } @@ -492,8 +497,8 @@ int ndl_weight2(UINT *d) u = GET_EXP(d,i); t += nd_sugarweight[i]*u; } - if ( nd_module && current_module_weight_vector && MPOS(d) ) - t += current_module_weight_vector[MPOS(d)]; + if ( nd_module && nd_module_rank && MPOS(d) ) + t += nd_module_weight[MPOS(d)-1]; return t; } @@ -711,19 +716,19 @@ int ndl_module_grlex_compare(UINT *d1,UINT *d2) { int i,c; - if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; +// if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; if ( nd_ispot ) { - if ( nd_pot_nelim && MPOS(d1)>=nd_pot_nelim+1 && MPOS(d2) >= nd_pot_nelim+1 ) { - if ( TD(d1) > TD(d2) ) return 1; - else if ( TD(d1) < TD(d2) ) return -1; - if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; - if ( MPOS(d1) < MPOS(d2) ) return 1; - else if ( MPOS(d1) > MPOS(d2) ) return -1; - return 0; + if ( nd_pot_nelim && MPOS(d1)>=nd_pot_nelim+1 && MPOS(d2) >= nd_pot_nelim+1 ) { + if ( TD(d1) > TD(d2) ) return 1; + else if ( TD(d1) < TD(d2) ) return -1; + if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; + if ( MPOS(d1) < MPOS(d2) ) return 1; + else if ( MPOS(d1) > MPOS(d2) ) return -1; + return 0; + } + if ( MPOS(d1) < MPOS(d2) ) return 1; + else if ( MPOS(d1) > MPOS(d2) ) return -1; } - if ( MPOS(d1) < MPOS(d2) ) return 1; - else if ( MPOS(d1) > MPOS(d2) ) return -1; - } if ( TD(d1) > TD(d2) ) return 1; else if ( TD(d1) < TD(d2) ) return -1; if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; @@ -738,7 +743,7 @@ int ndl_module_glex_compare(UINT *d1,UINT *d2) { int i,c; - if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; +// if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; if ( nd_ispot ) { if ( MPOS(d1) < MPOS(d2) ) return 1; else if ( MPOS(d1) > MPOS(d2) ) return -1; @@ -757,7 +762,7 @@ int ndl_module_lex_compare(UINT *d1,UINT *d2) { int i,c; - if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; +// if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; if ( nd_ispot ) { if ( MPOS(d1) < MPOS(d2) ) return 1; else if ( MPOS(d1) > MPOS(d2) ) return -1; @@ -774,7 +779,7 @@ int ndl_module_block_compare(UINT *d1,UINT *d2) { int i,c; - if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; +// if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; if ( nd_ispot ) { if ( MPOS(d1) < MPOS(d2) ) return 1; else if ( MPOS(d1) > MPOS(d2) ) return -1; @@ -791,7 +796,7 @@ int ndl_module_matrix_compare(UINT *d1,UINT *d2) { int i,c; - if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; +// if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; if ( nd_ispot ) { if ( MPOS(d1) < MPOS(d2) ) return 1; else if ( MPOS(d1) > MPOS(d2) ) return -1; @@ -808,7 +813,7 @@ int ndl_module_composite_compare(UINT *d1,UINT *d2) { int i,c; - if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; +// if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; if ( nd_ispot ) { if ( MPOS(d1) > MPOS(d2) ) return 1; else if ( MPOS(d1) < MPOS(d2) ) return -1; @@ -5514,6 +5519,33 @@ void dpm_sort(DPM p,DPM *rp) *rp = d; } +int dpm_comp(DPM *a,DPM *b) +{ + return compdpm(CO,*a,*b); +} + +NODE dpm_sort_list(NODE l) +{ + int i,len; + NODE t,t1; + DPM *a; + + len = length(l); + a = (DPM *)MALLOC(len*sizeof(DPM)); + for ( t = l, i = 0; i < len; i++, t = NEXT(t) ) a[i] = (DPM)BDY(t); + qsort(a,len,sizeof(DPM),(int (*)(const void *,const void *))dpm_comp); + t = 0; + for ( i = len-1; i >= 0; i-- ) { + MKNODE(t1,(pointer)a[i],t); t = t1; + } + return t; +} + +int nmv_comp(NMV a,NMV b) +{ + return -DL_COMPARE(a->dl,b->dl); +} + NDV dpmtondv(int mod,DPM p) { NDV d; @@ -5538,8 +5570,10 @@ NDV dpmtondv(int mod,DPM p) for ( i = 0; i < len; i++, NMV_ADV(m) ) { dltondl(n,a[i]->dl,DL(m)); MPOS(DL(m)) = a[i]->pos; + TD(DL(m)) = ndl_weight(DL(m)); CZ(m) = (Z)a[i]->c; } + qsort(m0,len,nmv_adv,(int (*)(const void *,const void *))nmv_comp); MKNDV(NV(p),m0,len,d); SG(d) = SG(p); return d; @@ -7841,7 +7875,9 @@ int ndv_ishomo(NDV p) h = TD(DL(m)); NMV_ADV(m); for ( len--; len; len--, NMV_ADV(m) ) - if ( TD(DL(m)) != h ) return 0; + if ( TD(DL(m)) != h ) { + return 0; + } return 1; }