version 1.38, 2001/11/16 10:35:07 |
version 1.47, 2003/05/30 06:03:28 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.37 2001/10/09 01:36:06 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.46 2003/04/21 02:49:40 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
|
|
int PCoeffs; |
int PCoeffs; |
int DP_Print = 0; |
int DP_Print = 0; |
|
int DP_PrintShort = 0; |
int DP_Multiple = 0; |
int DP_Multiple = 0; |
int DP_NFStat = 0; |
int DP_NFStat = 0; |
LIST Dist = 0; |
LIST Dist = 0; |
Line 101 static int NoCriB = 0; |
|
Line 102 static int NoCriB = 0; |
|
static int NoGC = 0; |
static int NoGC = 0; |
static int NoMC = 0; |
static int NoMC = 0; |
static int NoRA = 0; |
static int NoRA = 0; |
static int DP_PrintShort = 0; |
|
static int ShowMag = 0; |
static int ShowMag = 0; |
static int Stat = 0; |
static int Stat = 0; |
static int Denominator = 1; |
static int Denominator = 1; |
static int Top = 0; |
static int Top = 0; |
static int Reverse = 0; |
static int Reverse = 0; |
static int Max_mag = 0; |
static int Max_mag = 0; |
|
static int Max_coef = 0; |
static char *Demand = 0; |
static char *Demand = 0; |
static int PtozpRA = 0; |
static int PtozpRA = 0; |
|
|
Line 338 void dp_gr_main(LIST f,LIST v,Num homo,int modular,int |
|
Line 339 void dp_gr_main(LIST f,LIST v,Num homo,int modular,int |
|
} |
} |
print_stat(); |
print_stat(); |
if ( ShowMag ) |
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) |
void dp_gr_mod_main(LIST f,LIST v,Num homo,int m,struct order_spec *ord,LIST *rp) |
Line 662 NODE gb_f4_mod(NODE f,int m) |
|
Line 663 NODE gb_f4_mod(NODE f,int m) |
|
dltod(BDY(s),nv,&tdp); |
dltod(BDY(s),nv,&tdp); |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
dt = mul_dllist(BDY(sd)->dl,ps[(int)BDY(r)]); |
dt = mul_dllist(BDY(sd)->dl,ps[(int)BDY(r)]); |
/* fprintf(stderr,"[%d]",length(dt)); */ |
fprintf(stderr,"[%d]",length(dt)); |
/* list of [t,f] */ |
/* list of [t,f] */ |
bt1 = mknode(2,BDY(sd)->dl,BDY(r)); |
bt1 = mknode(2,BDY(sd)->dl,BDY(r)); |
MKNODE(bt,bt1,blist); blist = bt; |
MKNODE(bt,bt1,blist); blist = bt; |
symb_merge(s,dt,nv); |
symb_merge(s,dt,nv); |
/* fprintf(stderr,"%d-",length(s)); */ |
fprintf(stderr,"%d-",length(s0)); |
nred++; |
nred++; |
} |
} |
} |
} |
Line 1160 void prim_part(DP f,int m,DP *r) |
|
Line 1161 void prim_part(DP f,int m,DP *r) |
|
else |
else |
*r = f; |
*r = f; |
} else { |
} else { |
if ( dp_fcoeffs ) |
if ( dp_fcoeffs || PCoeffs ) |
*r = f; |
|
else if ( PCoeffs ) |
|
dp_prim(f,r); |
dp_prim(f,r); |
else |
else |
dp_ptozp(f,r); |
dp_ptozp(f,r); |
Line 1537 void minsugar(DP_pairs d,DP_pairs *dm,DP_pairs *dr) |
|
Line 1536 void minsugar(DP_pairs d,DP_pairs *dm,DP_pairs *dr) |
|
|
|
NODE gb(NODE f,int m,NODE subst) |
NODE gb(NODE f,int m,NODE subst) |
{ |
{ |
int i,nh,prev,mag; |
int i,nh,prev,mag,mag0,magt; |
NODE r,g,gall; |
NODE r,g,gall; |
DP_pairs d; |
DP_pairs d; |
DP_pairs l; |
DP_pairs l; |
Line 1551 NODE gb(NODE f,int m,NODE subst) |
|
Line 1550 NODE gb(NODE f,int m,NODE subst) |
|
static prev_sugar = -1; |
static prev_sugar = -1; |
|
|
Max_mag = 0; |
Max_mag = 0; |
|
Max_coef = 0; |
prev = 1; |
prev = 1; |
doing_f4 = 0; |
doing_f4 = 0; |
if ( m ) { |
if ( m ) { |
|
|
g = updbase(g,nh); |
g = updbase(g,nh); |
gall = append_one(gall,nh); |
gall = append_one(gall,nh); |
if ( !dp_fcoeffs && ShowMag ) { |
if ( !dp_fcoeffs && ShowMag ) { |
for ( mag = 0, mp = BDY(h); mp; mp = NEXT(mp) ) |
for ( mag = 0, mag0 = 0, mp = BDY(h); mp; mp = NEXT(mp) ) { |
mag += p_mag((P)mp->c); |
magt = p_mag((P)mp->c); |
|
mag0 = MAX(mag0,magt); |
|
mag += magt; |
|
} |
|
Max_coef = MAX(Max_coef,mag0); |
Max_mag = MAX(Max_mag,mag); |
Max_mag = MAX(Max_mag,mag); |
} |
} |
if ( DP_Print ) { |
if ( DP_Print ) { |
|
|
l->dp1,l->dp2,length(g),length(gall),DPPlength(d), |
l->dp1,l->dp2,length(g),length(gall),DPPlength(d), |
pss[nh]); |
pss[nh]); |
if ( ShowMag ) |
if ( ShowMag ) |
fprintf(asir_out,",mag=%d",mag); |
fprintf(asir_out,",mag=(%d,%d)",mag,mag0); |
fprintf(asir_out,"\n"); fflush(asir_out); |
fprintf(asir_out,"\n"); fflush(asir_out); |
} else if ( DP_PrintShort ) { |
} else if ( DP_PrintShort ) { |
fprintf(asir_out,"+"); fflush(asir_out); |
fprintf(asir_out,"+"); fflush(asir_out); |
Line 1779 DP_pairs newpairs( NODE /* of index */ g, int t ) |
|
Line 1783 DP_pairs newpairs( NODE /* of index */ g, int t ) |
|
p->lcm = lcm_of_DL(CNVars, dl = psh[dp], tdl, (DL)0 ); |
p->lcm = lcm_of_DL(CNVars, dl = psh[dp], tdl, (DL)0 ); |
#if 0 |
#if 0 |
if ( do_weyl ) |
if ( do_weyl ) |
p->sugar = dl_weight(p->lcm); |
p->sugar = dl_weyl_weight(p->lcm); |
else |
else |
#endif |
#endif |
p->sugar = (ts > (s = pss[dp] - dl->td) ? ts : s) + p->lcm->td; |
p->sugar = (ts > (s = pss[dp] - dl->td) ? ts : s) + p->lcm->td; |
Line 1946 int dl_redble(DL dl1,DL dl2) |
|
Line 1950 int dl_redble(DL dl1,DL dl2) |
|
return 1; |
return 1; |
} |
} |
|
|
int dl_weight(DL dl) |
#if 0 |
|
int dl_weyl_weight(DL dl) |
{ |
{ |
int n,w,i; |
int n,w,i; |
|
|
Line 1955 int dl_weight(DL dl) |
|
Line 1960 int dl_weight(DL dl) |
|
w += (-dl->d[i]+dl->d[n+i]); |
w += (-dl->d[i]+dl->d[n+i]); |
return w; |
return w; |
} |
} |
|
#endif |
|
|
int gbcheck(NODE f) |
int gbcheck(NODE f) |
{ |
{ |
Line 1994 int gbcheck(NODE f) |
|
Line 2000 int gbcheck(NODE f) |
|
return 1; |
return 1; |
} |
} |
|
|
void gbcheck_list(NODE f,LIST *gp,LIST *pp) |
void gbcheck_list(NODE f,int n,VECT *gp,LIST *pp) |
{ |
{ |
int i; |
int i; |
NODE r,g,gall,u,u0,t; |
NODE r,g,gall,u,u0,t; |
|
VECT vect; |
LIST pair; |
LIST pair; |
DP_pairs d,l; |
DP_pairs d,l; |
Q q1,q2; |
Q q1,q2; |
|
|
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
/* we need the following settings */ |
|
NVars = CNVars = n; |
|
setup_arrays(f,0,&r); |
|
for ( gall = g = 0, d = 0; r; r = NEXT(r) ) { |
i = (int)BDY(r); |
i = (int)BDY(r); |
d = updpairs(d,g,i); |
d = updpairs(d,g,i); |
g = updbase(g,i); |
g = updbase(g,i); |
gall = append_one(gall,i); |
gall = append_one(gall,i); |
} |
} |
for ( u0 = 0, t = gall; t; t = NEXT(t) ) { |
NEWVECT(vect); vect->len = psn; vect->body = (pointer)ps; |
NEXTNODE(u0,u); |
*gp = vect; |
BDY(u) = ps[(int)BDY(t)]; |
|
} |
|
if ( u0 ) |
|
NEXT(u) = 0; |
|
MKLIST(*gp,u); |
|
for ( u0 = 0, l = d; l; l = NEXT(l) ) { |
for ( u0 = 0, l = d; l; l = NEXT(l) ) { |
NEXTNODE(u0,u); |
NEXTNODE(u0,u); |
STOQ(l->dp1,q1); |
STOQ(l->dp1,q1); |
Line 2025 void gbcheck_list(NODE f,LIST *gp,LIST *pp) |
|
Line 2031 void gbcheck_list(NODE f,LIST *gp,LIST *pp) |
|
} |
} |
if ( u0 ) |
if ( u0 ) |
NEXT(u) = 0; |
NEXT(u) = 0; |
MKLIST(*pp,u); |
MKLIST(*pp,u0); |
} |
} |
|
|
int membercheck(NODE f,NODE x) |
int membercheck(NODE f,NODE x) |
Line 2059 void dp_set_flag(Obj name,Obj value) |
|
Line 2065 void dp_set_flag(Obj name,Obj value) |
|
{ |
{ |
char *n; |
char *n; |
int v; |
int v; |
|
Q ratio; |
|
|
if ( OID(name) != O_STR ) |
if ( OID(name) != O_STR ) |
return; |
return; |
Line 2069 void dp_set_flag(Obj name,Obj value) |
|
Line 2076 void dp_set_flag(Obj name,Obj value) |
|
if ( !strcmp(n,"Dist") ) { |
if ( !strcmp(n,"Dist") ) { |
Dist = (LIST)value; return; |
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 ) |
if ( value && OID(value) != O_N ) |
return; |
return; |
v = QTOS((Q)value); |
v = QTOS((Q)value); |
Line 2112 void dp_set_flag(Obj name,Obj value) |
|
Line 2129 void dp_set_flag(Obj name,Obj value) |
|
|
|
void dp_make_flaglist(LIST *list) |
void dp_make_flaglist(LIST *list) |
{ |
{ |
Q v; |
Q v,nm,dn; |
STRING name,path; |
STRING name,path; |
NODE n,n1; |
NODE n,n1; |
|
|
|
#if 0 |
STOQ(DP_Multiple,v); MKNODE(n,v,0); MKSTR(name,"DP_Multiple"); MKNODE(n1,name,n); n = n1; |
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; |
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; |
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(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; |
STOQ(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); MKNODE(n1,name,n); n = n1; |
Line 2170 void dp_load(int index,DP *p) |
|
Line 2195 void dp_load(int index,DP *p) |
|
sprintf(path,"%s%c%d",Demand,DELIM,index); |
sprintf(path,"%s%c%d",Demand,DELIM,index); |
if ( !(fp = fopen(path,"rb") ) ) |
if ( !(fp = fopen(path,"rb") ) ) |
error("dp_load : cannot open a file"); |
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); |
} |
} |
} |
} |
|
|
Line 2183 int dp_load_t(int index,DP *p) |
|
Line 2212 int dp_load_t(int index,DP *p) |
|
if ( !(fp = fopen(path,"rb") ) ) |
if ( !(fp = fopen(path,"rb") ) ) |
return 0; |
return 0; |
else { |
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; |
} |
} |
} |
} |
|
|