=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/nd.c,v retrieving revision 1.241 retrieving revision 1.244 diff -u -p -r1.241 -r1.244 --- OpenXM_contrib2/asir2000/engine/nd.c 2017/09/16 08:02:35 1.241 +++ OpenXM_contrib2/asir2000/engine/nd.c 2018/03/05 06:43:09 1.244 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.240 2017/09/15 01:52:51 noro Exp $ */ +/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.243 2018/03/05 01:56:17 noro Exp $ */ #include "nd.h" @@ -3315,7 +3315,7 @@ void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int } homogenize_order(ord,nvar,&ord1); nd_init_ord(ord1); - nd_setup_parameters(nvar+1,wmax); + nd_setup_parameters(nvar+1,nd_nzlist?0:wmax); for ( t = fd0; t; t = NEXT(t) ) ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos,ompos); } @@ -5824,7 +5824,7 @@ int nd_to_vect(int mod,UINT *s0,int n,ND d,UINT *r) return i; } -#if defined(__GNUC__) +#if defined(__GNUC__) && SIZEOF_LONG==8 #define MOD128(a,c,m) ((a)=(((c)!=0||((a)>=(m)))?(((((U128)(c))<<64)+(a))%(m)):(a))) @@ -6239,7 +6239,7 @@ int ndv_reduce_vect(int m,UINT *svect,int col,IndArray return maxrs; } -#if defined(__GNUC__) +#if defined(__GNUC__) && SIZEOF_LONG==8 int ndv_reduce_vect64(int m,U64 *svect,U64 *cvect,int col,IndArray *imat,NM_ind_pair *rp0,int nred) { @@ -6568,7 +6568,7 @@ NDV vect_to_ndv(UINT *vect,int spcol,int col,int *rhea } } -#if defined(__GNUC__) +#if defined(__GNUC__) && SIZEOF_LONG==8 NDV vect64_to_ndv(U64 *vect,int spcol,int col,int *rhead,UINT *s0vect) { int j,k,len; @@ -6804,11 +6804,20 @@ int nd_symbolic_preproc(PGeoBucket bucket,int trace,UI return col; } +void print_ndp(ND_pairs l) +{ + ND_pairs t; + + for ( t = l; t; t = NEXT(t) ) + printf("[%d,%d] ",t->i1,t->i2); + printf("\n"); +} + NODE nd_f4(int m,int checkonly,int **indp) { int i,nh,stat,index,f4red; NODE r,g,tn0,tn,node; - ND_pairs d,l,t,ll0,ll; + ND_pairs d,l,t,ll0,ll,lh; LIST l0,l1; ND spol,red; NDV nf,redv; @@ -6822,7 +6831,7 @@ NODE nd_f4(int m,int checkonly,int **indp) IndArray *imat; int *rhead; int spcol,sprow; - int sugar; + int sugar,sugarh; PGeoBucket bucket; struct oEGT eg0,eg1,eg_f4; Q i1,i2,sugarq; @@ -6831,38 +6840,35 @@ NODE nd_f4(int m,int checkonly,int **indp) #endif g = 0; d = 0; for ( i = 0; i < nd_psn; i++ ) { - if ( !nd_nzlist ) d = update_pairs(d,g,i,0); + d = update_pairs(d,g,i,0); g = update_base(g,i); } nzlist = 0; nzlist_t = nd_nzlist; f4red = 1; nd_last_nonzero = 0; - while ( d || nzlist_t ) { + while ( d ) { get_eg(&eg0); - if ( nd_nzlist ) { + l = nd_minsugarp(d,&d); + sugar = nd_sugarweight?l->sugar2:SG(l); + if ( MaxDeg > 0 && sugar > MaxDeg ) break; + if ( nzlist_t ) { node = BDY((LIST)BDY(nzlist_t)); - sugar = QTOS((Q)ARG0(node)); + sugarh = QTOS((Q)ARG0(node)); tn = BDY((LIST)ARG1(node)); if ( !tn ) { nzlist_t = NEXT(nzlist_t); continue; } /* tn = [[i1,i2],...] */ - l = nd_ipairtospair(tn); - } else { - l = nd_minsugarp(d,&d); - sugar = nd_sugarweight?l->sugar2:SG(l); - if ( MaxDeg > 0 && sugar > MaxDeg ) break; + lh = nd_ipairtospair(tn); } bucket = create_pbucket(); stat = nd_sp_f4(m,0,l,bucket); if ( !stat ) { - if ( !nd_nzlist ) { - for ( t = l; NEXT(t); t = NEXT(t) ); - NEXT(t) = d; d = l; - d = nd_reconstruct(0,d); - } + for ( t = l; NEXT(t); t = NEXT(t) ); + NEXT(t) = d; d = l; + d = nd_reconstruct(0,d); continue; } if ( bucket->m < 0 ) continue; @@ -6877,7 +6883,7 @@ NODE nd_f4(int m,int checkonly,int **indp) if ( DP_Print ) fprintf(asir_out,"sugar=%d,symb=%.3fsec,", sugar,eg_f4.exectime+eg_f4.gctime); - nflist = nd_f4_red(m,l,0,s0vect,col,rp0,nd_gentrace?&ll:0); + nflist = nd_f4_red(m,nd_nzlist?lh:l,0,s0vect,col,rp0,nd_gentrace?&ll:0); if ( checkonly && nflist ) return 0; /* adding new bases */ if ( nflist ) nd_last_nonzero = f4red; @@ -6893,7 +6899,7 @@ NODE nd_f4(int m,int checkonly,int **indp) nf = ndtondv(m,nf1); } nh = ndv_newps(m,nf,0,1); - if ( !nd_nzlist ) d = update_pairs(d,g,nh,0); + d = update_pairs(d,g,nh,0); g = update_base(g,nh); } if ( DP_Print ) { @@ -7232,7 +7238,7 @@ init_eg(&eg_search); rhead[imat[i]->head] = 1; } if ( m > 0 ) -#if defined(__GNUC__) +#if defined(__GNUC__) && SIZEOF_LONG==8 r0 = nd_f4_red_mod64_main(m,sp0,nsp,s0vect,col,rvect,rhead,imat,nred,nz); #else r0 = nd_f4_red_main(m,sp0,nsp,s0vect,col,rvect,rhead,imat,nred,nz); @@ -7341,7 +7347,7 @@ NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s return r0; } -#if defined(__GNUC__) +#if defined(__GNUC__) && SIZEOF_LONG==8 /* for Fp, 2^15=