version 1.14, 2019/03/03 05:21:17 |
version 1.19, 2019/09/04 05:32:10 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.13 2019/01/14 09:17:34 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.18 2019/09/04 01:12:02 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 8 struct oEGT eg_search,f4_symb,f4_conv,f4_elim1,f4_elim |
|
Line 8 struct oEGT eg_search,f4_symb,f4_conv,f4_elim1,f4_elim |
|
int diag_period = 6; |
int diag_period = 6; |
int weight_check = 1; |
int weight_check = 1; |
int (*ndl_compare_function)(UINT *a1,UINT *a2); |
int (*ndl_compare_function)(UINT *a1,UINT *a2); |
|
/* for schreyer order */ |
|
int (*ndl_base_compare_function)(UINT *a1,UINT *a2); |
int nd_dcomp; |
int nd_dcomp; |
int nd_rref2; |
int nd_rref2; |
NM _nm_free_list; |
NM _nm_free_list; |
Line 78 NDV pltondv(VL vl,VL dvl,LIST p); |
|
Line 80 NDV pltondv(VL vl,VL dvl,LIST p); |
|
void pltozpl(LIST l,Q *cont,LIST *pp); |
void pltozpl(LIST l,Q *cont,LIST *pp); |
void ndl_max(UINT *d1,unsigned *d2,UINT *d); |
void ndl_max(UINT *d1,unsigned *d2,UINT *d); |
void nmtodp(int mod,NM m,DP *r); |
void nmtodp(int mod,NM m,DP *r); |
|
void ndltodp(UINT *d,DP *r); |
NODE reverse_node(NODE n); |
NODE reverse_node(NODE n); |
P ndc_div(int mod,union oNDC a,union oNDC b); |
P ndc_div(int mod,union oNDC a,union oNDC b); |
P ndctop(int mod,union oNDC c); |
P ndctop(int mod,union oNDC c); |
Line 87 void parse_nd_option(NODE opt); |
|
Line 90 void parse_nd_option(NODE opt); |
|
void dltondl(int n,DL dl,UINT *r); |
void dltondl(int n,DL dl,UINT *r); |
DP ndvtodp(int mod,NDV p); |
DP ndvtodp(int mod,NDV p); |
DP ndtodp(int mod,ND p); |
DP ndtodp(int mod,ND p); |
|
DPM ndvtodpm(int mod,NDV p); |
|
NDV dpmtondv(int mod,DPM p); |
|
int dpm_getdeg(DPM p,int *rank); |
|
void dpm_ptozp(DPM p,Z *cont,DPM *r); |
|
int compdmm(int nv,DMM a,DMM b); |
|
|
void Pdp_set_weight(NODE,VECT *); |
void Pdp_set_weight(NODE,VECT *); |
void Pox_cmo_rpc(NODE,Obj *); |
void Pox_cmo_rpc(NODE,Obj *); |
Line 707 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
Line 715 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
|
|
if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; |
if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; |
if ( nd_ispot ) { |
if ( nd_ispot ) { |
if ( nd_pot_nelim && MPOS(d1)>=nd_pot_nelim+1 && MPOS(d2) >= nd_pot_nelim+1 ) { |
if ( nd_pot_nelim && MPOS(d1)>=nd_pot_nelim+1 && MPOS(d2) >= nd_pot_nelim+1 ) { |
if ( TD(d1) > TD(d2) ) return 1; |
if ( TD(d1) > TD(d2) ) return 1; |
else if ( TD(d1) < TD(d2) ) return -1; |
else if ( TD(d1) < TD(d2) ) return -1; |
if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; |
if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
return 0; |
return 0; |
|
} |
|
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
} |
} |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
if ( TD(d1) > TD(d2) ) return 1; |
if ( TD(d1) > TD(d2) ) return 1; |
else if ( TD(d1) < TD(d2) ) return -1; |
else if ( TD(d1) < TD(d2) ) return -1; |
if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; |
if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; |
Line 2605 ND_pairs nd_newpairs( NODE g, int t ) |
|
Line 2613 ND_pairs nd_newpairs( NODE g, int t ) |
|
|
|
dl = DL(nd_psh[t]); |
dl = DL(nd_psh[t]); |
ts = SG(nd_psh[t]) - TD(dl); |
ts = SG(nd_psh[t]) - TD(dl); |
if ( nd_module && nd_intersect && (MPOS(dl) > 1) ) return 0; |
if ( nd_module && nd_intersect && (MPOS(dl) > nd_intersect) ) return 0; |
for ( r0 = 0, h = g; h; h = NEXT(h) ) { |
for ( r0 = 0, h = g; h; h = NEXT(h) ) { |
if ( nd_module && (MPOS(DL(nd_psh[(long)BDY(h)])) != MPOS(dl)) ) |
if ( nd_module && (MPOS(DL(nd_psh[(long)BDY(h)])) != MPOS(dl)) ) |
continue; |
continue; |
Line 3224 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3232 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
int *perm; |
int *perm; |
EPOS oepos; |
EPOS oepos; |
int obpe,oadv,ompos,cbpe; |
int obpe,oadv,ompos,cbpe; |
|
VECT hvect; |
|
|
nd_module = 0; |
nd_module = 0; |
if ( !m && Demand ) nd_demand = 1; |
if ( !m && Demand ) nd_demand = 1; |
Line 3267 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3276 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
for ( t = BDY(f), max = 1; t; t = NEXT(t) ) |
for ( t = BDY(f), max = 1; t; t = NEXT(t) ) |
for ( tv = vv; tv; tv = NEXT(tv) ) { |
for ( tv = vv; tv; tv = NEXT(tv) ) { |
if ( nd_module ) { |
if ( nd_module ) { |
s = BDY((LIST)BDY(t)); |
if ( OID(BDY(t)) == O_DPM ) { |
trank = length(s); |
e = dpm_getdeg((DPM)BDY(t),&trank); |
mrank = MAX(mrank,trank); |
max = MAX(e,max); |
for ( ; s; s = NEXT(s) ) { |
mrank = MAX(mrank,trank); |
e = getdeg(tv->v,(P)BDY(s)); |
} else { |
max = MAX(e,max); |
s = BDY((LIST)BDY(t)); |
|
trank = length(s); |
|
mrank = MAX(mrank,trank); |
|
for ( ; s; s = NEXT(s) ) { |
|
e = getdeg(tv->v,(P)BDY(s)); |
|
max = MAX(e,max); |
|
} |
} |
} |
} else { |
} else { |
e = getdeg(tv->v,(P)BDY(t)); |
e = getdeg(tv->v,(P)BDY(t)); |
Line 3284 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3299 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
ishomo = 1; |
ishomo = 1; |
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
if ( nd_module ) { |
if ( nd_module ) { |
if ( !m && !nd_gentrace ) pltozpl((LIST)BDY(t),&dmy,&zpl); |
if ( OID(BDY(t)) == O_DPM ) { |
else zpl = (LIST)BDY(t); |
Z cont; |
|
DPM zdpm; |
|
|
|
if ( !m && !nd_gentrace ) dpm_ptozp((DPM)BDY(t),&cont,&zdpm); |
|
else zdpm = (DPM)BDY(t); |
|
b = (pointer)dpmtondv(m,zdpm); |
|
} else { |
|
if ( !m && !nd_gentrace ) pltozpl((LIST)BDY(t),&dmy,&zpl); |
|
else zpl = (LIST)BDY(t); |
b = (pointer)pltondv(CO,vv,zpl); |
b = (pointer)pltondv(CO,vv,zpl); |
|
} |
} else { |
} else { |
if ( !m && !nd_gentrace ) ptozp((P)BDY(t),1,&dmy,&zp); |
if ( !m && !nd_gentrace ) ptozp((P)BDY(t),1,&dmy,&zp); |
else zp = (P)BDY(t); |
else zp = (P)BDY(t); |
Line 3334 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3358 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
if ( !x ) { |
if ( !x ) { |
*rp = 0; return; |
*rp = 0; return; |
} |
} |
|
if ( nd_gentrace ) { |
|
MKVECT(hvect,nd_psn); |
|
for ( i = 0; i < nd_psn; i++ ) |
|
ndltodp(nd_psh[i]->dl,(DP *)&BDY(hvect)[i]); |
|
} |
if ( !ishomo && homo ) { |
if ( !ishomo && homo ) { |
/* dehomogenization */ |
/* dehomogenization */ |
for ( t = x; t; t = NEXT(t) ) ndv_dehomogenize((NDV)BDY(t),ord); |
for ( t = x; t; t = NEXT(t) ) ndv_dehomogenize((NDV)BDY(t),ord); |
Line 3343 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3372 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
nd_demand = 0; |
nd_demand = 0; |
if ( nd_module && nd_intersect ) { |
if ( nd_module && nd_intersect ) { |
for ( j = nd_psn-1, x = 0; j >= 0; j-- ) |
for ( j = nd_psn-1, x = 0; j >= 0; j-- ) |
if ( MPOS(DL(nd_psh[j])) > 1 ) { |
if ( MPOS(DL(nd_psh[j])) > nd_intersect ) { |
MKNODE(xx,(pointer)((unsigned long)j),x); x = xx; |
MKNODE(xx,(pointer)((unsigned long)j),x); x = xx; |
} |
} |
conv_ilist(nd_demand,0,x,0); |
conv_ilist(nd_demand,0,x,0); |
Line 3367 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3396 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
nd_setup_parameters(nd_nvar,0); |
nd_setup_parameters(nd_nvar,0); |
FINAL: |
FINAL: |
for ( r0 = 0, t = x; t; t = NEXT(t) ) { |
for ( r0 = 0, t = x; t; t = NEXT(t) ) { |
NEXTNODE(r0,r); |
NEXTNODE(r0,r); |
if ( nd_module ) BDY(r) = ndvtopl(m,CO,vv,BDY(t),mrank); |
if ( nd_module ) { |
else if ( retdp ) BDY(r) = ndvtodp(m,BDY(t)); |
if ( retdp ) BDY(r) = ndvtodpm(m,BDY(t)); |
else BDY(r) = ndvtop(m,CO,vv,BDY(t)); |
else BDY(r) = ndvtopl(m,CO,vv,BDY(t),mrank); |
|
} else if ( retdp ) BDY(r) = ndvtodp(m,BDY(t)); |
|
else BDY(r) = ndvtop(m,CO,vv,BDY(t)); |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
if ( !m && nd_nalg ) |
if ( !m && nd_nalg ) |
|
|
if ( f4 ) { |
if ( f4 ) { |
STOZ(16,bpe); |
STOZ(16,bpe); |
STOZ(nd_last_nonzero,last_nonzero); |
STOZ(nd_last_nonzero,last_nonzero); |
tr = mknode(5,*rp,(!ishomo&&homo)?ONE:0,BDY(nzlist),bpe,last_nonzero); MKLIST(*rp,tr); |
tr = mknode(6,*rp,(!ishomo&&homo)?ONE:0,BDY(nzlist),bpe,last_nonzero,hvect); MKLIST(*rp,tr); |
|
|
} else { |
} else { |
tl1 = reverse_node(tl1); tl2 = reverse_node(tl2); |
tl1 = reverse_node(tl1); tl2 = reverse_node(tl2); |
tl3 = reverse_node(tl3); |
tl3 = reverse_node(tl3); |
|
|
MKLIST(l1,tl1); MKLIST(l2,tl2); MKLIST(l3,t); MKLIST(l4,tl3); |
MKLIST(l1,tl1); MKLIST(l2,tl2); MKLIST(l3,t); MKLIST(l4,tl3); |
MKLIST(l5,tl4); |
MKLIST(l5,tl4); |
STOZ(nd_bpe,bpe); |
STOZ(nd_bpe,bpe); |
tr = mknode(8,*rp,(!ishomo&&homo)?ONE:0,l1,l2,l3,l4,l5,bpe); MKLIST(*rp,tr); |
tr = mknode(9,*rp,(!ishomo&&homo)?ONE:0,l1,l2,l3,l4,l5,bpe,hvect); MKLIST(*rp,tr); |
} |
} |
} |
} |
#if 0 |
#if 0 |
Line 3645 void nd_gr_recompute_trace(LIST f,LIST v,int m,struct |
|
Line 3675 void nd_gr_recompute_trace(LIST f,LIST v,int m,struct |
|
if ( DP_Print ) fprintf(asir_out,"\n"); |
if ( DP_Print ) fprintf(asir_out,"\n"); |
} |
} |
|
|
void nd_gr_trace(LIST f,LIST v,int trace,int homo,int f4,struct order_spec *ord,LIST *rp) |
void nd_gr_trace(LIST f,LIST v,int trace,int homo,int retdp,int f4,struct order_spec *ord,LIST *rp) |
{ |
{ |
VL tv,fv,vv,vc,av; |
VL tv,fv,vv,vc,av; |
NODE fd,fd0,in0,in,r,r0,t,s,cand,alist; |
NODE fd,fd0,in0,in,r,r0,t,s,cand,alist; |
Line 3668 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3698 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
int *perm; |
int *perm; |
int j,ret; |
int j,ret; |
Z jq,bpe; |
Z jq,bpe; |
|
VECT hvect; |
|
|
nd_module = 0; |
nd_module = 0; |
nd_lf = 0; |
nd_lf = 0; |
Line 3722 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3753 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
for ( t = BDY(f), max = 1; t; t = NEXT(t) ) |
for ( t = BDY(f), max = 1; t; t = NEXT(t) ) |
for ( tv = vv; tv; tv = NEXT(tv) ) { |
for ( tv = vv; tv; tv = NEXT(tv) ) { |
if ( nd_module ) { |
if ( nd_module ) { |
|
if ( OID(BDY(t)) == O_DPM ) { |
|
e = dpm_getdeg((DPM)BDY(t),&trank); |
|
max = MAX(e,max); |
|
mrank = MAX(mrank,trank); |
|
} else { |
s = BDY((LIST)BDY(t)); |
s = BDY((LIST)BDY(t)); |
trank = length(s); |
trank = length(s); |
mrank = MAX(mrank,trank); |
mrank = MAX(mrank,trank); |
Line 3729 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3765 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
e = getdeg(tv->v,(P)BDY(s)); |
e = getdeg(tv->v,(P)BDY(s)); |
max = MAX(e,max); |
max = MAX(e,max); |
} |
} |
|
} |
} else { |
} else { |
e = getdeg(tv->v,(P)BDY(t)); |
e = getdeg(tv->v,(P)BDY(t)); |
max = MAX(e,max); |
max = MAX(e,max); |
Line 3739 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3776 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
ishomo = 1; |
ishomo = 1; |
for ( in0 = 0, fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
for ( in0 = 0, fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
if ( nd_module ) { |
if ( nd_module ) { |
if ( !nd_gentrace ) pltozpl((LIST)BDY(t),&dmy,&zpl); |
if ( OID(BDY(t)) == O_DPM ) { |
else zpl = (LIST)BDY(t); |
Z cont; |
|
DPM zdpm; |
|
|
|
if ( !nd_gentrace ) dpm_ptozp((DPM)BDY(t),&cont,&zdpm); |
|
else zdpm = (DPM)BDY(t); |
|
c = (pointer)dpmtondv(m,zdpm); |
|
} else { |
|
if ( !nd_gentrace ) pltozpl((LIST)BDY(t),&dmy,&zpl); |
|
else zpl = (LIST)BDY(t); |
c = (pointer)pltondv(CO,vv,zpl); |
c = (pointer)pltondv(CO,vv,zpl); |
|
} |
} else { |
} else { |
if ( !nd_gentrace ) ptozp((P)BDY(t),1,&dmy,&zp); |
if ( !nd_gentrace ) ptozp((P)BDY(t),1,&dmy,&zp); |
else zp = (P)BDY(t); |
else zp = (P)BDY(t); |
c = (pointer)ptondv(CO,vv,zp); |
c = (pointer)ptondv(CO,vv,zp); |
} |
} |
if ( ishomo ) |
if ( ishomo ) |
ishomo = ishomo && ndv_ishomo(c); |
ishomo = ishomo && ndv_ishomo(c); |
Line 3785 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3831 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
else m = get_lprime(++mindex); |
else m = get_lprime(++mindex); |
continue; |
continue; |
} |
} |
|
if ( nd_gentrace ) { |
|
MKVECT(hvect,nd_psn); |
|
for ( i = 0; i < nd_psn; i++ ) |
|
ndltodp(nd_psh[i]->dl,(DP *)&BDY(hvect)[i]); |
|
} |
if ( !ishomo && homo ) { |
if ( !ishomo && homo ) { |
/* dehomogenization */ |
/* dehomogenization */ |
for ( t = cand; t; t = NEXT(t) ) ndv_dehomogenize((NDV)BDY(t),ord); |
for ( t = cand; t; t = NEXT(t) ) ndv_dehomogenize((NDV)BDY(t),ord); |
Line 3837 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3888 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
nd_bpe = cbpe; |
nd_bpe = cbpe; |
nd_setup_parameters(nd_nvar,0); |
nd_setup_parameters(nd_nvar,0); |
for ( r = cand; r; r = NEXT(r) ) { |
for ( r = cand; r; r = NEXT(r) ) { |
if ( nd_module ) BDY(r) = ndvtopl(0,CO,vv,BDY(r),mrank); |
if ( nd_module ) { |
else BDY(r) = (pointer)ndvtop(0,CO,vv,BDY(r)); |
if ( retdp ) BDY(r) = ndvtodpm(0,BDY(r)); |
|
else BDY(r) = ndvtopl(0,CO,vv,BDY(r),mrank); |
|
} else if ( retdp ) BDY(r) = ndvtodp(0,BDY(r)); |
|
else BDY(r) = (pointer)ndvtop(0,CO,vv,BDY(r)); |
} |
} |
if ( nd_nalg ) |
if ( nd_nalg ) |
cand = postprocess_algcoef(av,alist,cand); |
cand = postprocess_algcoef(av,alist,cand); |
Line 3862 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3916 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
MKLIST(l1,tl1); MKLIST(l2,tl2); MKLIST(l3,t); MKLIST(l4,tl3); |
MKLIST(l1,tl1); MKLIST(l2,tl2); MKLIST(l3,t); MKLIST(l4,tl3); |
MKLIST(l5,tl4); |
MKLIST(l5,tl4); |
STOZ(nd_bpe,bpe); |
STOZ(nd_bpe,bpe); |
tr = mknode(8,*rp,(!ishomo&&homo)?ONE:0,l1,l2,l3,l4,l5,bpe); MKLIST(*rp,tr); |
tr = mknode(9,*rp,(!ishomo&&homo)?ONE:0,l1,l2,l3,l4,l5,bpe,hvect); MKLIST(*rp,tr); |
} |
} |
} |
} |
|
|
Line 3926 void nmtodp(int mod,NM m,DP *r) |
|
Line 3980 void nmtodp(int mod,NM m,DP *r) |
|
*r = dp; |
*r = dp; |
} |
} |
|
|
|
void ndltodp(UINT *d,DP *r) |
|
{ |
|
DP dp; |
|
MP mr; |
|
|
|
NEWMP(mr); |
|
mr->dl = ndltodl(nd_nvar,d); |
|
mr->c = (Obj)ONE; |
|
NEXT(mr) = 0; MKDP(nd_nvar,mr,dp); dp->sugar = mr->dl->td; |
|
*r = dp; |
|
} |
|
|
void ndl_print(UINT *dl) |
void ndl_print(UINT *dl) |
{ |
{ |
int n; |
int n; |
Line 5196 NDV ptondv(VL vl,VL dvl,P p) |
|
Line 5262 NDV ptondv(VL vl,VL dvl,P p) |
|
|
|
void pltozpl(LIST l,Q *cont,LIST *pp) |
void pltozpl(LIST l,Q *cont,LIST *pp) |
{ |
{ |
NODE nd,nd1; |
NODE nd,nd1; |
int n; |
int n; |
P *pl; |
P *pl; |
Q *cl; |
Q *cl; |
int i; |
int i; |
P dmy; |
P dmy; |
Z dvr; |
Z dvr,inv; |
LIST r; |
LIST r; |
|
|
nd = BDY(l); n = length(nd); |
nd = BDY(l); n = length(nd); |
pl = (P *)MALLOC(n*sizeof(P)); |
pl = (P *)MALLOC(n*sizeof(P)); |
cl = (Q *)MALLOC(n*sizeof(P)); |
cl = (Q *)MALLOC(n*sizeof(Q)); |
for ( i = 0; i < n; i++, nd = NEXT(nd) ) |
for ( i = 0; i < n; i++, nd = NEXT(nd) ) { |
ptozp((P)BDY(nd),1,&cl[i],&dmy); |
ptozp((P)BDY(nd),1,&cl[i],&dmy); |
qltozl(cl,n,&dvr); |
} |
nd = BDY(l); |
qltozl(cl,n,&dvr); |
for ( i = 0; i < n; i++, nd = NEXT(nd) ) { |
divz(ONE,dvr,&inv); |
divsp(CO,(P)BDY(nd),(P)dvr,&pl[i]); |
nd = BDY(l); |
} |
for ( i = 0; i < n; i++, nd = NEXT(nd) ) |
nd = 0; |
divsp(CO,(P)BDY(nd),(P)dvr,&pl[i]); |
for ( i = n-1; i >= 0; i-- ) { |
nd = 0; |
MKNODE(nd1,pl[i],nd); nd = nd1; |
for ( i = n-1; i >= 0; i-- ) { |
} |
MKNODE(nd1,pl[i],nd); nd = nd1; |
MKLIST(r,nd); |
} |
*pp = r; |
MKLIST(r,nd); |
|
*pp = r; |
} |
} |
|
|
/* (a1,a2,...,an) -> a1*e(1)+...+an*e(n) */ |
/* (a1,a2,...,an) -> a1*e(1)+...+an*e(n) */ |
Line 5409 NDV ndtondv(int mod,ND p) |
|
Line 5476 NDV ndtondv(int mod,ND p) |
|
return d; |
return d; |
} |
} |
|
|
|
static int dmm_comp_nv; |
|
|
|
int dmm_comp(DMM *a,DMM *b) |
|
{ |
|
return -compdmm(dmm_comp_nv,*a,*b); |
|
} |
|
|
|
void dmm_sort_by_ord(DMM *a,int len,int nv) |
|
{ |
|
dmm_comp_nv = nv; |
|
qsort(a,len,sizeof(DMM),(int (*)(const void *,const void *))dmm_comp); |
|
} |
|
|
|
void dpm_sort(DPM p,DPM *rp) |
|
{ |
|
DMM t,t1; |
|
int len,i,n; |
|
DMM *a; |
|
DPM d; |
|
|
|
if ( !p ) *rp = 0; |
|
for ( t = BDY(p), len = 0; t; t = NEXT(t), len++ ); |
|
a = (DMM *)MALLOC(len*sizeof(DMM)); |
|
for ( i = 0, t = BDY(p); i < len; i++, t = NEXT(t) ) a[i] = t; |
|
n = p->nv; |
|
dmm_sort_by_ord(a,len,n); |
|
t = 0; |
|
for ( i = len-1; i >= 0; i-- ) { |
|
NEWDMM(t1); |
|
t1->c = a[i]->c; |
|
t1->dl = a[i]->dl; |
|
t1->pos = a[i]->pos; |
|
t1->next = t; |
|
t = t1; |
|
} |
|
MKDPM(n,t,d); |
|
SG(d) = SG(p); |
|
*rp = d; |
|
} |
|
|
|
int dpm_comp(DPM *a,DPM *b) |
|
{ |
|
return compdpm(CO,*a,*b); |
|
} |
|
|
|
NODE dpm_sort_list(NODE l) |
|
{ |
|
int i,len; |
|
NODE t,t1; |
|
DPM *a; |
|
|
|
len = length(l); |
|
a = (DPM *)MALLOC(len*sizeof(DPM)); |
|
for ( t = l, i = 0; i < len; i++, t = NEXT(t) ) a[i] = (DPM)BDY(t); |
|
qsort(a,len,sizeof(DPM),(int (*)(const void *,const void *))dpm_comp); |
|
t = 0; |
|
for ( i = len-1; i >= 0; i-- ) { |
|
MKNODE(t1,(pointer)a[i],t); t = t1; |
|
} |
|
return t; |
|
} |
|
|
|
NDV dpmtondv(int mod,DPM p) |
|
{ |
|
NDV d; |
|
NMV m,m0; |
|
DMM t; |
|
DMM *a; |
|
int i,len,n; |
|
|
|
if ( !p ) return 0; |
|
for ( t = BDY(p), len = 0; t; t = NEXT(t), len++ ); |
|
a = (DMM *)MALLOC(len*sizeof(DMM)); |
|
for ( i = 0, t = BDY(p); i < len; i++, t = NEXT(t) ) a[i] = t; |
|
n = p->nv; |
|
dmm_sort_by_ord(a,len,n); |
|
if ( mod > 0 || mod == -1 ) |
|
m0 = m = (NMV)MALLOC_ATOMIC_IGNORE_OFF_PAGE(len*nmv_adv); |
|
else |
|
m0 = m = MALLOC(len*nmv_adv); |
|
#if 0 |
|
ndv_alloc += nmv_adv*len; |
|
#endif |
|
for ( i = 0; i < len; i++, NMV_ADV(m) ) { |
|
dltondl(n,a[i]->dl,DL(m)); |
|
MPOS(DL(m)) = a[i]->pos; |
|
CZ(m) = (Z)a[i]->c; |
|
} |
|
MKNDV(NV(p),m0,len,d); |
|
SG(d) = SG(p); |
|
return d; |
|
} |
|
|
ND ndvtond(int mod,NDV p) |
ND ndvtond(int mod,NDV p) |
{ |
{ |
ND d; |
ND d; |
Line 5451 DP ndvtodp(int mod,NDV p) |
|
Line 5611 DP ndvtodp(int mod,NDV p) |
|
return d; |
return d; |
} |
} |
|
|
|
DPM ndvtodpm(int mod,NDV p) |
|
{ |
|
DMM m,m0; |
|
DPM d; |
|
NMV t; |
|
int i,len; |
|
|
|
if ( !p ) return 0; |
|
m0 = 0; |
|
len = p->len; |
|
for ( t = BDY(p), i = 0; i < len; NMV_ADV(t), i++ ) { |
|
NEXTDMM(m0,m); |
|
m->dl = ndltodl(nd_nvar,DL(t)); |
|
m->c = (Obj)ndctop(mod,t->c); |
|
m->pos = MPOS(DL(t)); |
|
} |
|
NEXT(m) = 0; |
|
MKDPM(nd_nvar,m0,d); |
|
SG(d) = SG(p); |
|
return d; |
|
} |
|
|
|
|
DP ndtodp(int mod,ND p) |
DP ndtodp(int mod,ND p) |
{ |
{ |
MP m,m0; |
MP m,m0; |
Line 5538 NODE ndv_reducebase(NODE x,int *perm) |
|
Line 5721 NODE ndv_reducebase(NODE x,int *perm) |
|
|
|
/* XXX incomplete */ |
/* XXX incomplete */ |
|
|
|
extern int dpm_ordtype; |
|
|
void nd_init_ord(struct order_spec *ord) |
void nd_init_ord(struct order_spec *ord) |
{ |
{ |
nd_module = (ord->id >= 256); |
nd_module = (ord->id >= 256); |
Line 5549 void nd_init_ord(struct order_spec *ord) |
|
Line 5734 void nd_init_ord(struct order_spec *ord) |
|
nd_poly_weight = ord->top_weight; |
nd_poly_weight = ord->top_weight; |
nd_module_rank = ord->module_rank; |
nd_module_rank = ord->module_rank; |
nd_module_weight = ord->module_top_weight; |
nd_module_weight = ord->module_top_weight; |
|
dpm_ordtype = ord->ispot; |
} |
} |
nd_matrix = 0; |
nd_matrix = 0; |
nd_matrix_len = 0; |
nd_matrix_len = 0; |
Line 8329 void parse_nd_option(NODE opt) |
|
Line 8515 void parse_nd_option(NODE opt) |
|
nd_newelim = value?1:0; |
nd_newelim = value?1:0; |
else if ( !strcmp(key,"intersect") ) |
else if ( !strcmp(key,"intersect") ) |
nd_intersect = value?1:0; |
nd_intersect = value?1:0; |
|
else if ( !strcmp(key,"syzgen") ) |
|
nd_intersect = ZTOS((Q)value); |
else if ( !strcmp(key,"lf") ) |
else if ( !strcmp(key,"lf") ) |
nd_lf = value?1:0; |
nd_lf = value?1:0; |
else if ( !strcmp(key,"trace") ) { |
else if ( !strcmp(key,"trace") ) { |