=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/gr.c,v retrieving revision 1.41 retrieving revision 1.48 diff -u -p -r1.41 -r1.48 --- OpenXM_contrib2/asir2000/builtin/gr.c 2002/01/28 00:54:41 1.41 +++ OpenXM_contrib2/asir2000/builtin/gr.c 2003/06/05 09:40:39 1.48 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.40 2001/11/19 01:40:04 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.47 2003/05/30 06:03:28 noro Exp $ */ #include "ca.h" #include "parse.h" @@ -89,6 +89,7 @@ static VL VC; int PCoeffs; int DP_Print = 0; +int DP_PrintShort = 0; int DP_Multiple = 0; int DP_NFStat = 0; LIST Dist = 0; @@ -101,13 +102,13 @@ static int NoCriB = 0; static int NoGC = 0; static int NoMC = 0; static int NoRA = 0; -static int DP_PrintShort = 0; static int ShowMag = 0; static int Stat = 0; static int Denominator = 1; static int Top = 0; static int Reverse = 0; static int Max_mag = 0; +static int Max_coef = 0; static char *Demand = 0; static int PtozpRA = 0; @@ -338,7 +339,7 @@ void dp_gr_main(LIST f,LIST v,Num homo,int modular,int } print_stat(); if ( ShowMag ) - fprintf(asir_out,"\nMax_mag=%d\n",Max_mag); + fprintf(asir_out,"\nMax_mag=%d, Max_coef=%d\n",Max_mag, Max_coef); } void dp_gr_mod_main(LIST f,LIST v,Num homo,int m,struct order_spec *ord,LIST *rp) @@ -667,7 +668,7 @@ NODE gb_f4_mod(NODE f,int m) bt1 = mknode(2,BDY(sd)->dl,BDY(r)); MKNODE(bt,bt1,blist); blist = bt; symb_merge(s,dt,nv); -/* fprintf(stderr,"%d-",length(s)); */ +/* fprintf(stderr,"%d-",length(s0)); */ nred++; } } @@ -1160,9 +1161,7 @@ void prim_part(DP f,int m,DP *r) else *r = f; } else { - if ( dp_fcoeffs ) - *r = f; - else if ( PCoeffs ) + if ( dp_fcoeffs || PCoeffs ) dp_prim(f,r); else dp_ptozp(f,r); @@ -1537,7 +1536,7 @@ void minsugar(DP_pairs d,DP_pairs *dm,DP_pairs *dr) NODE gb(NODE f,int m,NODE subst) { - int i,nh,prev,mag; + int i,nh,prev,mag,mag0,magt; NODE r,g,gall; DP_pairs d; DP_pairs l; @@ -1551,6 +1550,7 @@ NODE gb(NODE f,int m,NODE subst) static prev_sugar = -1; Max_mag = 0; + Max_coef = 0; prev = 1; doing_f4 = 0; if ( m ) { @@ -1625,8 +1625,12 @@ skip_nf: g = updbase(g,nh); gall = append_one(gall,nh); if ( !dp_fcoeffs && ShowMag ) { - for ( mag = 0, mp = BDY(h); mp; mp = NEXT(mp) ) - mag += p_mag((P)mp->c); + for ( mag = 0, mag0 = 0, mp = BDY(h); mp; mp = NEXT(mp) ) { + magt = p_mag((P)mp->c); + mag0 = MAX(mag0,magt); + mag += magt; + } + Max_coef = MAX(Max_coef,mag0); Max_mag = MAX(Max_mag,mag); } if ( DP_Print ) { @@ -1638,7 +1642,7 @@ skip_nf: l->dp1,l->dp2,length(g),length(gall),DPPlength(d), pss[nh]); if ( ShowMag ) - fprintf(asir_out,",mag=%d",mag); + fprintf(asir_out,",mag=(%d,%d)",mag,mag0); fprintf(asir_out,"\n"); fflush(asir_out); } else if ( DP_PrintShort ) { fprintf(asir_out,"+"); fflush(asir_out); @@ -2061,6 +2065,7 @@ void dp_set_flag(Obj name,Obj value) { char *n; int v; + Q ratio; if ( OID(name) != O_STR ) return; @@ -2071,6 +2076,16 @@ void dp_set_flag(Obj name,Obj value) if ( !strcmp(n,"Dist") ) { Dist = (LIST)value; return; } + if ( !strcmp(n,"Content") ) { + ratio = (Q)value; + if ( ratio ) { + DP_Multiple = BD(NM(ratio))[0]; + Denominator = INT(ratio) ? 1 : BD(DN(ratio))[0]; + } else { + DP_Multiple = 0; + Denominator = 1; + } + } if ( value && OID(value) != O_N ) return; v = QTOS((Q)value); @@ -2114,12 +2129,20 @@ void dp_set_flag(Obj name,Obj value) void dp_make_flaglist(LIST *list) { - Q v; + Q v,nm,dn; STRING name,path; NODE n,n1; +#if 0 STOQ(DP_Multiple,v); MKNODE(n,v,0); MKSTR(name,"DP_Multiple"); MKNODE(n1,name,n); n = n1; STOQ(Denominator,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Denominator"); MKNODE(n1,name,n); n = n1; +#else + if ( DP_Multiple ) { + STOQ(DP_Multiple,nm); STOQ(Denominator,dn); divq(nm,dn,&v); + } else + v = 0; + MKNODE(n,v,0); MKSTR(name,"Content"); MKNODE(n1,name,n); n = n1; +#endif MKNODE(n1,Dist,n); n = n1; MKSTR(name,"Dist"); MKNODE(n1,name,n); n = n1; STOQ(Reverse,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Reverse"); MKNODE(n1,name,n); n = n1; STOQ(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); MKNODE(n1,name,n); n = n1; @@ -2172,7 +2195,11 @@ void dp_load(int index,DP *p) sprintf(path,"%s%c%d",Demand,DELIM,index); if ( !(fp = fopen(path,"rb") ) ) error("dp_load : cannot open a file"); - skipvl(fp); loadobj(fp,(Obj *)p); fclose(fp); + if ( PCoeffs ) + loadvl(fp); + else + skipvl(fp); + loadobj(fp,(Obj *)p); fclose(fp); } } @@ -2185,7 +2212,11 @@ int dp_load_t(int index,DP *p) if ( !(fp = fopen(path,"rb") ) ) return 0; else { - skipvl(fp); loadobj(fp,(Obj *)p); fclose(fp); return 1; + if ( PCoeffs ) + loadvl(fp); + else + skipvl(fp); + loadobj(fp,(Obj *)p); fclose(fp); return 1; } }