version 1.3, 2020/02/03 05:51:52 |
version 1.8, 2021/02/17 22:18:39 |
|
|
* 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/asir2018/builtin/gr.c,v 1.2 2018/09/28 08:20:27 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/builtin/gr.c,v 1.7 2021/01/11 08:37:43 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
|
|
static int *pss; |
static int *pss; |
static int psn,pslen; |
static int psn,pslen; |
static int NVars,CNVars; |
static int NVars; |
|
int CNVars; |
static VL VC; |
static VL VC; |
|
|
int PCoeffs; |
int PCoeffs; |
Line 115 static int Max_mag = 0; |
|
Line 116 static int Max_mag = 0; |
|
static int Max_coef = 0; |
static int Max_coef = 0; |
char *Demand = 0; |
char *Demand = 0; |
static int PtozpRA = 0; |
static int PtozpRA = 0; |
|
int ReversePOT = 0; |
|
|
int doing_f4; |
int doing_f4; |
NODE TraceList; |
NODE TraceList; |
Line 304 void dp_gr_main(LIST f,LIST v,Num homo,int modular,int |
|
Line 306 void dp_gr_main(LIST f,LIST v,Num homo,int modular,int |
|
int i,mindex,m,nochk; |
int i,mindex,m,nochk; |
struct order_spec *ord1; |
struct order_spec *ord1; |
Z q; |
Z q; |
|
Q cont; |
|
P pp; |
VL fv,vv,vc; |
VL fv,vv,vc; |
NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx; |
NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx; |
NODE ind,ind0; |
NODE ind,ind0; |
Line 317 void dp_gr_main(LIST f,LIST v,Num homo,int modular,int |
|
Line 321 void dp_gr_main(LIST f,LIST v,Num homo,int modular,int |
|
if ( ord->id && NVars != ord->nv ) |
if ( ord->id && NVars != ord->nv ) |
error("dp_gr_main : invalid order specification"); |
error("dp_gr_main : invalid order specification"); |
initd(ord); |
initd(ord); |
|
// clear denominators if the ground field is Q |
|
if ( field == 0 ) { |
|
for ( r0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
|
ptozp((P)BDY(t),1,&cont,&pp); |
|
NEXTNODE(r0,r); BDY(r) = (pointer)pp; |
|
} |
|
if ( r0 ) NEXT(r) = 0; |
|
MKLIST(f,r0); |
|
} |
if ( homo ) { |
if ( homo ) { |
homogenize_order(ord,NVars,&ord1); |
homogenize_order(ord,NVars,&ord1); |
for ( fd0 = fi0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
for ( fd0 = fi0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
Line 371 void dp_gr_main(LIST f,LIST v,Num homo,int modular,int |
|
Line 384 void dp_gr_main(LIST f,LIST v,Num homo,int modular,int |
|
} else |
} else |
break; |
break; |
} |
} |
if ( modular ) |
if ( modular ) { |
if ( modular > 1 ) { |
if ( modular > 1 ) { |
*rp = 0; return; |
*rp = 0; return; |
} else |
} else |
m = get_lprime(++mindex); |
m = get_lprime(++mindex); |
|
} |
makesubst(vc,&subst); |
makesubst(vc,&subst); |
psn = length(s); |
psn = length(s); |
for ( i = psn; i < pslen; i++ ) { |
for ( i = psn; i < pslen; i++ ) { |
Line 712 NODE gb_f4(NODE f) |
|
Line 726 NODE gb_f4(NODE f) |
|
rank = generic_gauss_elim(mat,&nm,&dn,&rind,&cind); |
rank = generic_gauss_elim(mat,&nm,&dn,&rind,&cind); |
#endif |
#endif |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
fprintf(asir_out,"done rank = %d\n",rank); |
for ( i = 0; i < rank; i++ ) { |
for ( i = 0; i < rank; i++ ) { |
for ( k = 0; k < nred; k++ ) |
for ( k = 0; k < nred; k++ ) |
if ( !cmpdl(nv,at[rind[i]],ht[k]) ) |
if ( !cmpdl(nv,at[rind[i]],ht[k]) ) |
Line 937 NODE gb_f4_mod(NODE f,int m) |
|
Line 951 NODE gb_f4_mod(NODE f,int m) |
|
init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1); |
init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1); |
|
|
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
fprintf(asir_out,"done rank = %d\n",rank); |
print_eg("Symb",&eg_split_symb); |
print_eg("Symb",&eg_split_symb); |
print_eg("Conv",&eg_split_conv); |
print_eg("Conv",&eg_split_conv); |
print_eg("Elim1",&eg_split_elim1); |
print_eg("Elim1",&eg_split_elim1); |
Line 1125 NODE gb_f4_mod_old(NODE f,int m) |
|
Line 1139 NODE gb_f4_mod_old(NODE f,int m) |
|
init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1); |
init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1); |
|
|
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
fprintf(asir_out,"done rank = %d\n",rank); |
print_eg("Symb",&eg_split_symb); |
print_eg("Symb",&eg_split_symb); |
print_eg("Elim1",&eg_split_elim1); |
print_eg("Elim1",&eg_split_elim1); |
print_eg("Elim2",&eg_split_elim2); |
print_eg("Elim2",&eg_split_elim2); |
Line 1227 void printsubst(NODE s) |
|
Line 1241 void printsubst(NODE s) |
|
fputc('[',asir_out); |
fputc('[',asir_out); |
while ( s ) { |
while ( s ) { |
printv(CO,(V)BDY(s)); s = NEXT(s); |
printv(CO,(V)BDY(s)); s = NEXT(s); |
fprintf(asir_out,"->%d",ZTOS((Q)BDY(s))); |
fprintf(asir_out,"->%ld",ZTOS((Q)BDY(s))); |
if ( NEXT(s) ) { |
if ( NEXT(s) ) { |
fputc(',',asir_out); s = NEXT(s); |
fputc(',',asir_out); s = NEXT(s); |
} else |
} else |
Line 1370 NODE /* of DP */ NODE_sortb_insert( DP newdp, NODE /* |
|
Line 1384 NODE /* of DP */ NODE_sortb_insert( DP newdp, NODE /* |
|
NEXT(newnd) = last; |
NEXT(newnd) = last; |
return newnd; |
return newnd; |
} |
} |
for ( ; p = NEXT(last); last = p ) |
for ( ; (p = NEXT(last)) != 0; last = p ) |
if ( sgn*(*cmpfun)( nv, newdl, BDY((DP) BDY(p))->dl ) > 0 ) break; |
if ( sgn*(*cmpfun)( nv, newdl, BDY((DP) BDY(p))->dl ) > 0 ) break; |
if ( p ) NEXT(NEXT(last) = newnd) = p; |
if ( p ) NEXT(NEXT(last) = newnd) = p; |
else NEXT(last) = newnd; |
else NEXT(last) = newnd; |
Line 1398 NODE /* of index */ NODE_sortbi_insert( int newdpi, NO |
|
Line 1412 NODE /* of index */ NODE_sortbi_insert( int newdpi, NO |
|
NEXT(newnd) = last; |
NEXT(newnd) = last; |
return newnd; |
return newnd; |
} |
} |
for ( ; p = NEXT(last); last = p ) |
for ( ; (p = NEXT(last)) != 0; last = p ) |
if ( sgn*(*cmpfun)( nv, newdl, psh[(long)BDY(p)] ) > 0 ) break; |
if ( sgn*(*cmpfun)( nv, newdl, psh[(long)BDY(p)] ) > 0 ) break; |
if ( p ) NEXT(NEXT(last) = newnd) = p; |
if ( p ) NEXT(NEXT(last) = newnd) = p; |
else NEXT(last) = newnd; |
else NEXT(last) = newnd; |
Line 1696 DP_pairs minp( DP_pairs d, DP_pairs *prest ) |
|
Line 1710 DP_pairs minp( DP_pairs d, DP_pairs *prest ) |
|
} |
} |
for ( lcm = m->lcm, s = m->sugar, ml = 0, l = m; p; p = NEXT(l = p) ) |
for ( lcm = m->lcm, s = m->sugar, ml = 0, l = m; p; p = NEXT(l = p) ) |
if ( NoSugar ? (*cmpfun)( nv, lcm, p->lcm ) >= 0 : |
if ( NoSugar ? (*cmpfun)( nv, lcm, p->lcm ) >= 0 : |
(s > p->sugar || s == p->sugar && (*cmpfun)( nv, lcm, p->lcm ) >= 0) ) |
(s > p->sugar || (s == p->sugar && (*cmpfun)( nv, lcm, p->lcm ) >= 0)) ) |
ml = l, lcm = (m = p)->lcm, s = p->sugar; |
ml = l, lcm = (m = p)->lcm, s = p->sugar; |
if ( !ml ) *prest = NEXT(m); |
if ( !ml ) *prest = NEXT(m); |
else { |
else { |
Line 1960 DP_pairs updpairs( DP_pairs d, NODE /* of index */ g, |
|
Line 1974 DP_pairs updpairs( DP_pairs d, NODE /* of index */ g, |
|
dd = d1; |
dd = d1; |
dl1 = DPPlength(dd); NDP += (dl-dl1); |
dl1 = DPPlength(dd); NDP += (dl-dl1); |
if ( !(nd = d) ) return dd; |
if ( !(nd = d) ) return dd; |
while ( nd = NEXT(d1 = nd) ) ; |
while ( (nd = NEXT(d1 = nd)) != 0 ) ; |
NEXT(d1) = dd; |
NEXT(d1) = dd; |
return d; |
return d; |
} |
} |
Line 2098 DP_pairs criterion_F( DP_pairs d1 ) |
|
Line 2112 DP_pairs criterion_F( DP_pairs d1 ) |
|
|
|
for ( head = last = 0, p = d1; NEXT(p); ) { |
for ( head = last = 0, p = d1; NEXT(p); ) { |
s = (r = w = collect_pairs_of_hdlcm( p, &rest ))->sugar; |
s = (r = w = collect_pairs_of_hdlcm( p, &rest ))->sugar; |
while ( w = NEXT(w) ) |
while ( (w = NEXT(w)) != 0 ) |
if ( !do_weyl && criterion_2( w->dp1, w->dp2 ) ) { |
if ( !do_weyl && criterion_2( w->dp1, w->dp2 ) ) { |
r = w; |
r = w; |
break; |
break; |
Line 2336 void dp_set_flag(Obj name,Obj value) |
|
Line 2350 void dp_set_flag(Obj name,Obj value) |
|
MaxDeg = v; |
MaxDeg = v; |
else if ( !strcmp(n,"NaiveSchreyer") ) |
else if ( !strcmp(n,"NaiveSchreyer") ) |
NaiveSchreyer = v; |
NaiveSchreyer = v; |
|
else if ( !strcmp(n,"ReversePOT") ) |
|
ReversePOT = v; |
} |
} |
|
|
void dp_make_flaglist(LIST *list) |
void dp_make_flaglist(LIST *list) |
Line 2376 void dp_make_flaglist(LIST *list) |
|
Line 2392 void dp_make_flaglist(LIST *list) |
|
STOZ(NoGC,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoGC"); MKNODE(n1,name,n); n = n1; |
STOZ(NoGC,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoGC"); MKNODE(n1,name,n); n = n1; |
STOZ(NoCriB,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoCriB"); MKNODE(n1,name,n); n = n1; |
STOZ(NoCriB,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoCriB"); MKNODE(n1,name,n); n = n1; |
STOZ(NoSugar,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoSugar"); MKNODE(n1,name,n); n = n1; |
STOZ(NoSugar,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoSugar"); MKNODE(n1,name,n); n = n1; |
|
STOZ(ReversePOT,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"ReversePOT"); MKNODE(n1,name,n); n = n1; |
if ( Demand ) |
if ( Demand ) |
MKSTR(path,Demand); |
MKSTR(path,Demand); |
else |
else |