=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/nd.c,v retrieving revision 1.138 retrieving revision 1.143 diff -u -p -r1.138 -r1.143 --- OpenXM_contrib2/asir2000/engine/nd.c 2006/06/11 11:41:15 1.138 +++ OpenXM_contrib2/asir2000/engine/nd.c 2006/08/09 02:48:49 1.143 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.137 2006/06/11 06:57:54 noro Exp $ */ +/* $OpenXM$ */ #include "nd.h" @@ -1592,6 +1592,7 @@ NODE nd_gb(int m,int ishomo,int checkonly) NDV nfv; Q q,num,den; union oNDC dn; + int diag_count = 0; g = 0; d = 0; for ( i = 0; i < nd_psn; i++ ) { @@ -1604,6 +1605,7 @@ again: l = nd_minp(d,&d); if ( SG(l) != sugar ) { if ( ishomo ) { + diag_count = 0; stat = do_diagonalize(sugar,m); if ( !stat ) { NEXT(l) = d; d = l; @@ -1639,6 +1641,15 @@ again: } nfv = ndtondv(m,nf); nd_free(nf); nh = ndv_newps(m,nfv,0); + if ( !m && (ishomo && ++diag_count == diag_period) ) { + diag_count = 0; + stat = do_diagonalize(sugar,m); + if ( !stat ) { + NEXT(l) = d; d = l; + d = nd_reconstruct(1,d); + goto again; + } + } d = update_pairs(d,g,nh); g = update_base(g,nh); FREENDP(l); @@ -2208,9 +2219,15 @@ void ndv_setup(int mod,int trace,NODE f,int dont_sort) for ( nd_psn = 0, s = f; s; s = NEXT(s) ) if ( BDY(s) ) nd_psn++; w = (NDV *)ALLOCA(nd_psn*sizeof(NDV)); for ( i = 0, s = f; s; s = NEXT(s) ) if ( BDY(s) ) w[i++] = BDY(s); - if ( !dont_sort ) - qsort(w,nd_psn,sizeof(NDV), - (int (*)(const void *,const void *))ndv_compare); + if ( !dont_sort ) { + /* XXX heuristic */ + if ( !nd_ord->id && (nd_ord->ord.simple<2) ) + qsort(w,nd_psn,sizeof(NDV), + (int (*)(const void *,const void *))ndv_compare_rev); + else + qsort(w,nd_psn,sizeof(NDV), + (int (*)(const void *,const void *))ndv_compare); + } nd_pslen = 2*nd_psn; nd_ps = (NDV *)MALLOC(nd_pslen*sizeof(NDV)); nd_ps_trace = (NDV *)MALLOC(nd_pslen*sizeof(NDV));