=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/nd.c,v retrieving revision 1.138 retrieving revision 1.144 diff -u -p -r1.138 -r1.144 --- OpenXM_contrib2/asir2000/engine/nd.c 2006/06/11 11:41:15 1.138 +++ OpenXM_contrib2/asir2000/engine/nd.c 2006/08/26 03:09:55 1.144 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.137 2006/06/11 06:57:54 noro Exp $ */ +/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.143 2006/08/09 02:48:49 noro Exp $ */ #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)); @@ -2359,7 +2376,8 @@ void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe NDV b; int ishomo,nalg; Alg alpha,dp; - P p; + P p,zp; + Q dmy; LIST f1,f2; Obj obj; NumberField nf; @@ -2405,7 +2423,8 @@ void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe nd_setup_parameters(nvar,max); ishomo = 1; for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { - b = (pointer)ptondv(CO,vv,(P)BDY(t)); + ptozp((P)BDY(t),1,&dmy,&zp); + b = (pointer)ptondv(CO,vv,zp); if ( ishomo ) ishomo = ishomo && ndv_ishomo(b); if ( m ) ndv_mod(m,b); @@ -2438,7 +2457,8 @@ void nd_gr_postproc(LIST f,LIST v,int m,struct order_s NDV b; int ishomo,nalg; Alg alpha,dp; - P p; + P p,zp; + Q dmy; LIST f1,f2; Obj obj; NumberField nf; @@ -2478,7 +2498,8 @@ void nd_gr_postproc(LIST f,LIST v,int m,struct order_s nd_setup_parameters(nvar,max); ishomo = 1; for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { - b = (pointer)ptondv(CO,vv,(P)BDY(t)); + ptozp((P)BDY(t),1,&dmy,&zp); + b = (pointer)ptondv(CO,vv,zp); if ( ishomo ) ishomo = ishomo && ndv_ishomo(b); if ( m ) ndv_mod(m,b); @@ -2517,7 +2538,8 @@ void nd_gr_trace(LIST f,LIST v,int trace,int homo,int int m,nocheck,nvar,mindex,e,max; NDV c; NMV a; - P p; + P p,zp; + Q dmy; EPOS oepos; int obpe,oadv,wmax,i,len,cbpe,ishomo,nalg; Alg alpha,dp; @@ -2572,7 +2594,8 @@ void nd_gr_trace(LIST f,LIST v,int trace,int homo,int obpe = nd_bpe; oadv = nmv_adv; oepos = nd_epos; ishomo = 1; for ( in0 = 0, fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { - c = ptondv(CO,vv,(P)BDY(t)); + ptozp((P)BDY(t),1,&dmy,&zp); + c = (pointer)ptondv(CO,vv,zp); if ( ishomo ) ishomo = ishomo && ndv_ishomo(c); if ( c ) {