version 1.11, 2018/10/23 04:53:37 |
version 1.22, 2019/11/21 01:54:01 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.10 2018/10/19 23:27:38 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.21 2019/09/19 06:29:48 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
int Nnd_add,Nf4_red; |
int Nnd_add,Nf4_red; |
struct oEGT eg_search; |
struct oEGT eg_search,f4_symb,f4_conv,f4_elim1,f4_elim2; |
|
|
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 general module order */ |
|
int (*ndl_base_compare_function)(UINT *a1,UINT *a2); |
|
int (*dl_base_compare_function)(int nv,DL a,DL b); |
|
int nd_base_ordtype; |
int nd_dcomp; |
int nd_dcomp; |
int nd_rref2; |
int nd_rref2; |
NM _nm_free_list; |
NM _nm_free_list; |
Line 55 static int nd_worb_len; |
|
Line 59 static int nd_worb_len; |
|
static int nd_found,nd_create,nd_notfirst; |
static int nd_found,nd_create,nd_notfirst; |
static int nmv_adv; |
static int nmv_adv; |
static int nd_demand; |
static int nd_demand; |
static int nd_module,nd_ispot,nd_mpos,nd_pot_nelim; |
static int nd_module,nd_module_ordtype,nd_mpos,nd_pot_nelim; |
static int nd_module_rank,nd_poly_weight_len; |
static int nd_module_rank,nd_poly_weight_len; |
static int *nd_poly_weight,*nd_module_weight; |
static int *nd_poly_weight,*nd_module_weight; |
static NODE nd_tracelist; |
static NODE nd_tracelist; |
Line 78 NDV pltondv(VL vl,VL dvl,LIST p); |
|
Line 82 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 92 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 470 int ndl_weight(UINT *d) |
|
Line 480 int ndl_weight(UINT *d) |
|
for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) |
for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) |
t += (u&nd_mask0); |
t += (u&nd_mask0); |
} |
} |
if ( nd_module && current_module_weight_vector && MPOS(d) ) |
if ( nd_module && nd_module_rank && MPOS(d) ) |
t += current_module_weight_vector[MPOS(d)]; |
t += nd_module_weight[MPOS(d)-1]; |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) |
|
if ( d[i] && !t ) |
|
printf("afo\n"); |
return t; |
return t; |
} |
} |
|
|
Line 486 int ndl_weight2(UINT *d) |
|
Line 499 int ndl_weight2(UINT *d) |
|
u = GET_EXP(d,i); |
u = GET_EXP(d,i); |
t += nd_sugarweight[i]*u; |
t += nd_sugarweight[i]*u; |
} |
} |
if ( nd_module && current_module_weight_vector && MPOS(d) ) |
if ( nd_module && nd_module_rank && MPOS(d) ) |
t += current_module_weight_vector[MPOS(d)]; |
t += nd_module_weight[MPOS(d)-1]; |
return t; |
return t; |
} |
} |
|
|
Line 515 void ndl_weight_mask(UINT *d) |
|
Line 528 void ndl_weight_mask(UINT *d) |
|
} |
} |
} |
} |
|
|
|
int ndl_glex_compare(UINT *d1,UINT *d2) |
|
{ |
|
if ( TD(d1) > TD(d2) ) return 1; |
|
else if ( TD(d1) < TD(d2) ) return -1; |
|
else return ndl_lex_compare(d1,d2); |
|
} |
|
|
int ndl_lex_compare(UINT *d1,UINT *d2) |
int ndl_lex_compare(UINT *d1,UINT *d2) |
{ |
{ |
int i; |
int i; |
Line 684 int ndl_ww_lex_compare(UINT *d1,UINT *d2) |
|
Line 704 int ndl_ww_lex_compare(UINT *d1,UINT *d2) |
|
return ndl_lex_compare(d1,d2); |
return ndl_lex_compare(d1,d2); |
} |
} |
|
|
int ndl_module_weight_compare(UINT *d1,UINT *d2) |
// common function for module glex and grlex comparison |
|
int ndl_module_glex_compare(UINT *d1,UINT *d2) |
{ |
{ |
int s,j; |
int c; |
|
|
if ( nd_nvar != nd_poly_weight_len ) |
switch ( nd_module_ordtype ) { |
error("invalid module weight : the length of polynomial weight != the number of variables"); |
case 0: |
s = 0; |
if ( TD(d1) > TD(d2) ) return 1; |
for ( j = 0; j < nd_nvar; j++ ) |
else if ( TD(d1) < TD(d2) ) return -1; |
s += (GET_EXP(d1,j)-GET_EXP(d2,j))*nd_poly_weight[j]; |
else if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; |
if ( MPOS(d1) >= 1 && MPOS(d2) >= 1 ) { |
else if ( MPOS(d1) < MPOS(d2) ) return 1; |
s += nd_module_weight[MPOS(d1)-1]-nd_module_weight[MPOS(d2)-1]; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
} |
else return 0; |
if ( s > 0 ) return 1; |
break; |
else if ( s < 0 ) return -1; |
|
else return 0; |
|
} |
|
|
|
int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
case 1: |
{ |
if ( nd_pot_nelim && MPOS(d1)>=nd_pot_nelim+1 && MPOS(d2) >= nd_pot_nelim+1 ) { |
int i,c; |
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 ( 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; |
|
else if ( TD(d1) > TD(d2) ) return 1; |
|
else if ( TD(d1) < TD(d2) ) return -1; |
|
else return ndl_lex_compare(d1,d2); |
|
break; |
|
|
if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; |
case 2: // weight -> POT |
if ( nd_ispot ) { |
if ( TD(d1) > TD(d2) ) return 1; |
if ( nd_pot_nelim && MPOS(d1)>=nd_pot_nelim+1 && MPOS(d2) >= nd_pot_nelim+1 ) { |
else if ( TD(d1) < TD(d2) ) return -1; |
if ( TD(d1) > TD(d2) ) return 1; |
else if ( MPOS(d1) < MPOS(d2) ) return 1; |
else if ( TD(d1) < TD(d2) ) return -1; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; |
else return ndl_lex_compare(d1,d2); |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
break; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
return 0; |
|
} |
|
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
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 ( !nd_ispot ) { |
|
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
return 0; |
|
} |
|
|
|
int ndl_module_glex_compare(UINT *d1,UINT *d2) |
default: |
{ |
error("ndl_module_glex_compare : invalid module_ordtype"); |
int i,c; |
} |
|
|
if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; |
|
if ( nd_ispot ) { |
|
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
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 ( !nd_ispot ) { |
|
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
return 0; |
|
} |
} |
|
|
int ndl_module_lex_compare(UINT *d1,UINT *d2) |
// common for module comparison |
|
int ndl_module_compare(UINT *d1,UINT *d2) |
{ |
{ |
int i,c; |
int c; |
|
|
if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; |
switch ( nd_module_ordtype ) { |
if ( nd_ispot ) { |
case 0: |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
} |
else if ( MPOS(d1) < MPOS(d2) ) return 1; |
if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c; |
else return 0; |
if ( !nd_ispot ) { |
break; |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
return 0; |
|
} |
|
|
|
int ndl_module_block_compare(UINT *d1,UINT *d2) |
case 1: |
{ |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
int i,c; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
else return (*ndl_base_compare_function)(d1,d2); |
|
break; |
|
|
if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; |
case 2: // weight -> POT |
if ( nd_ispot ) { |
if ( TD(d1) > TD(d2) ) return 1; |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
else if ( TD(d1) < TD(d2) ) return -1; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
else if ( MPOS(d1) < MPOS(d2) ) return 1; |
} |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
if ( (c = ndl_block_compare(d1,d2)) != 0 ) return c; |
else return (*ndl_base_compare_function)(d1,d2); |
if ( !nd_ispot ) { |
break; |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
return 0; |
|
} |
|
|
|
int ndl_module_matrix_compare(UINT *d1,UINT *d2) |
default: |
{ |
error("ndl_module_compare : invalid module_ordtype"); |
int i,c; |
} |
|
|
if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; |
|
if ( nd_ispot ) { |
|
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
if ( (c = ndl_matrix_compare(d1,d2)) != 0 ) return c; |
|
if ( !nd_ispot ) { |
|
if ( MPOS(d1) < MPOS(d2) ) return 1; |
|
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
|
} |
|
return 0; |
|
} |
} |
|
|
int ndl_module_composite_compare(UINT *d1,UINT *d2) |
extern DMMstack dmm_stack; |
|
void _addtodl(int n,DL d1,DL d2); |
|
int _eqdl(int n,DL d1,DL d2); |
|
|
|
int ndl_module_schreyer_compare(UINT *m1,UINT *m2) |
{ |
{ |
int i,c; |
int pos1,pos2,t,j; |
|
DMM *in; |
|
DMMstack s; |
|
static DL d1=0; |
|
static DL d2=0; |
|
static int dlen=0; |
|
|
if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c; |
pos1 = MPOS(m1); pos2 = MPOS(m2); |
if ( nd_ispot ) { |
if ( pos1 == pos2 ) return (*ndl_base_compare_function)(m1,m2); |
if ( MPOS(d1) > MPOS(d2) ) return 1; |
if ( nd_nvar > dlen ) { |
else if ( MPOS(d1) < MPOS(d2) ) return -1; |
NEWDL(d1,nd_nvar); |
|
NEWDL(d2,nd_nvar); |
|
dlen = nd_nvar; |
|
} |
|
d1->td = TD(m1); |
|
for ( j = 0; j < nd_nvar; j++ ) d1->d[j] = GET_EXP(m1,j); |
|
d2->td = TD(m2); |
|
for ( j = 0; j < nd_nvar; j++ ) d2->d[j] = GET_EXP(m2,j); |
|
for ( s = dmm_stack; s; s = NEXT(s) ) { |
|
in = s->in; |
|
_addtodl(nd_nvar,in[pos1]->dl,d1); |
|
_addtodl(nd_nvar,in[pos2]->dl,d2); |
|
if ( in[pos1]->pos == in[pos2]->pos && _eqdl(nd_nvar,d1,d2)) { |
|
if ( pos1 < pos2 ) return 1; |
|
else if ( pos1 > pos2 ) return -1; |
|
else return 0; |
} |
} |
if ( (c = ndl_composite_compare(d1,d2)) != 0 ) return c; |
pos1 = in[pos1]->pos; |
if ( !nd_ispot ) { |
pos2 = in[pos2]->pos; |
if ( MPOS(d1) > MPOS(d2) ) return 1; |
if ( pos1 == pos2 ) return (*dl_base_compare_function)(nd_nvar,d1,d2); |
else if ( MPOS(d1) < MPOS(d2) ) return -1; |
} |
} |
// comparison by the bottom order |
return 0; |
LAST: |
|
switch ( nd_base_ordtype ) { |
|
case 0: |
|
t = (*dl_base_compare_function)(nd_nvar,d1,d2); |
|
if ( t ) return t; |
|
else if ( pos1 < pos2 ) return 1; |
|
else if ( pos1 > pos2 ) return -1; |
|
else return 0; |
|
break; |
|
case 1: |
|
if ( pos1 < pos2 ) return 1; |
|
else if ( pos1 > pos2 ) return -1; |
|
else return (*dl_base_compare_function)(nd_nvar,d1,d2); |
|
break; |
|
case 2: |
|
if ( d1->td > d2->td ) return 1; |
|
else if ( d1->td < d2->td ) return -1; |
|
else if ( pos1 < pos2 ) return 1; |
|
else if ( pos1 > pos2 ) return -1; |
|
else return (*dl_base_compare_function)(nd_nvar,d1,d2); |
|
break; |
|
default: |
|
error("ndl_schreyer_compare : invalid base ordtype"); |
|
} |
} |
} |
|
|
INLINE int ndl_equal(UINT *d1,UINT *d2) |
INLINE int ndl_equal(UINT *d1,UINT *d2) |
Line 1130 INLINE int ndl_hash_value(UINT *d) |
|
Line 1158 INLINE int ndl_hash_value(UINT *d) |
|
|
|
r = 0; |
r = 0; |
for ( i = 0; i < nd_wpd; i++ ) |
for ( i = 0; i < nd_wpd; i++ ) |
r = (r*10007+d[i]); |
r = (r*1511+d[i]); |
r %= REDTAB_LEN; |
r %= REDTAB_LEN; |
return r; |
return r; |
} |
} |
Line 2605 ND_pairs nd_newpairs( NODE g, int t ) |
|
Line 2633 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 3252 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 3296 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 3319 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 3378 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 3392 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 3416 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 3695 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 3718 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 3773 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 3785 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 3796 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 3851 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 3908 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 3936 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 4000 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 4090 void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos |
|
Line 4176 void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos |
|
NMV m,mr0,mr,t; |
NMV m,mr0,mr,t; |
|
|
len = p->len; |
len = p->len; |
for ( m = BDY(p), i = 0, max = 1; i < len; NMV_OADV(m), i++ ) |
for ( m = BDY(p), i = 0, max = 0; i < len; NMV_OADV(m), i++ ) |
max = MAX(max,TD(DL(m))); |
max = MAX(max,TD(DL(m))); |
mr0 = nmv_adv>oadv?(NMV)REALLOC(BDY(p),len*nmv_adv):BDY(p); |
mr0 = nmv_adv>oadv?(NMV)REALLOC(BDY(p),len*nmv_adv):BDY(p); |
m = (NMV)((char *)mr0+(len-1)*oadv); |
m = (NMV)((char *)mr0+(len-1)*oadv); |
Line 4235 void mpz_removecont_array(mpz_t *c,int n) |
|
Line 4321 void mpz_removecont_array(mpz_t *c,int n) |
|
{ |
{ |
mpz_t d0,a,u,u1,gcd; |
mpz_t d0,a,u,u1,gcd; |
int i,j; |
int i,j; |
mpz_t *q,*r; |
static mpz_t *q,*r; |
|
static int c_len = 0; |
|
|
for ( i = 0; i < n; i++ ) |
for ( i = 0; i < n; i++ ) |
if ( mpz_sgn(c[i]) ) break; |
if ( mpz_sgn(c[i]) ) break; |
if ( i == n ) return; |
if ( i == n ) return; |
gcdv_mpz_estimate(d0,c,n); |
gcdv_mpz_estimate(d0,c,n); |
q = (mpz_t *)MALLOC(n*sizeof(mpz_t)); |
if ( n > c_len ) { |
r = (mpz_t *)MALLOC(n*sizeof(mpz_t)); |
q = (mpz_t *)MALLOC(n*sizeof(mpz_t)); |
|
r = (mpz_t *)MALLOC(n*sizeof(mpz_t)); |
|
c_len = n; |
|
} |
for ( i = 0; i < n; i++ ) { |
for ( i = 0; i < n; i++ ) { |
mpz_init(q[i]); mpz_init(r[i]); |
mpz_init(q[i]); mpz_init(r[i]); |
mpz_fdiv_qr(q[i],r[i],c[i],d0); |
mpz_fdiv_qr(q[i],r[i],c[i],d0); |
Line 4414 UINT *nd_compute_bound(ND p) |
|
Line 4504 UINT *nd_compute_bound(ND p) |
|
int nd_get_exporigin(struct order_spec *ord) |
int nd_get_exporigin(struct order_spec *ord) |
{ |
{ |
switch ( ord->id ) { |
switch ( ord->id ) { |
case 0: case 2: case 256: case 258: |
case 0: case 2: case 256: case 258: case 300: |
return 1+nd_module; |
return 1+nd_module; |
case 1: case 257: |
case 1: case 257: |
/* block order */ |
/* block order */ |
Line 5192 NDV ptondv(VL vl,VL dvl,P p) |
|
Line 5282 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 5405 NDV ndtondv(int mod,ND p) |
|
Line 5496 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; |
|
} |
|
|
|
int nmv_comp(NMV a,NMV b) |
|
{ |
|
int t; |
|
t = DL_COMPARE(a->dl,b->dl); |
|
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; |
|
TD(DL(m)) = ndl_weight(DL(m)); |
|
CZ(m) = (Z)a[i]->c; |
|
} |
|
qsort(m0,len,nmv_adv,(int (*)(const void *,const void *))nmv_comp); |
|
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 5447 DP ndvtodp(int mod,NDV p) |
|
Line 5640 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 5534 NODE ndv_reducebase(NODE x,int *perm) |
|
Line 5750 NODE ndv_reducebase(NODE x,int *perm) |
|
|
|
/* XXX incomplete */ |
/* XXX incomplete */ |
|
|
|
extern DMMstack dmm_stack; |
|
int ndl_module_schreyer_compare(UINT *a,UINT *b); |
|
|
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); |
if ( nd_module ) { |
if ( nd_module ) { |
nd_dcomp = -1; |
nd_dcomp = -1; |
nd_ispot = ord->ispot; |
nd_module_ordtype = ord->module_ordtype; |
nd_pot_nelim = ord->pot_nelim; |
nd_pot_nelim = ord->pot_nelim; |
nd_poly_weight_len = ord->nv; |
nd_poly_weight_len = ord->nv; |
nd_poly_weight = ord->top_weight; |
nd_poly_weight = ord->top_weight; |
Line 5603 void nd_init_ord(struct order_spec *ord) |
|
Line 5822 void nd_init_ord(struct order_spec *ord) |
|
case 256: |
case 256: |
switch ( ord->ord.simple ) { |
switch ( ord->ord.simple ) { |
case 0: |
case 0: |
|
nd_dcomp = 0; |
nd_isrlex = 1; |
nd_isrlex = 1; |
ndl_compare_function = ndl_module_grlex_compare; |
ndl_compare_function = ndl_module_glex_compare; |
break; |
break; |
case 1: |
case 1: |
|
nd_dcomp = 0; |
nd_isrlex = 0; |
nd_isrlex = 0; |
ndl_compare_function = ndl_module_glex_compare; |
ndl_compare_function = ndl_module_glex_compare; |
break; |
break; |
case 2: |
case 2: |
|
nd_dcomp = 0; |
nd_isrlex = 0; |
nd_isrlex = 0; |
ndl_compare_function = ndl_module_lex_compare; |
ndl_compare_function = ndl_module_compare; |
|
ndl_base_compare_function = ndl_lex_compare; |
break; |
break; |
default: |
default: |
error("nd_gr : unsupported order"); |
error("nd_init_ord : unsupported order"); |
} |
} |
break; |
break; |
case 257: |
case 257: |
/* block order */ |
/* block order */ |
nd_isrlex = 0; |
nd_isrlex = 0; |
ndl_compare_function = ndl_module_block_compare; |
ndl_compare_function = ndl_module_compare; |
|
ndl_base_compare_function = ndl_block_compare; |
break; |
break; |
case 258: |
case 258: |
/* matrix order */ |
/* matrix order */ |
nd_isrlex = 0; |
nd_isrlex = 0; |
nd_matrix_len = ord->ord.matrix.row; |
nd_matrix_len = ord->ord.matrix.row; |
nd_matrix = ord->ord.matrix.matrix; |
nd_matrix = ord->ord.matrix.matrix; |
ndl_compare_function = ndl_module_matrix_compare; |
ndl_compare_function = ndl_module_compare; |
|
ndl_base_compare_function = ndl_matrix_compare; |
break; |
break; |
case 259: |
case 259: |
/* composite order */ |
/* composite order */ |
nd_isrlex = 0; |
nd_isrlex = 0; |
nd_worb_len = ord->ord.composite.length; |
nd_worb_len = ord->ord.composite.length; |
nd_worb = ord->ord.composite.w_or_b; |
nd_worb = ord->ord.composite.w_or_b; |
ndl_compare_function = ndl_module_composite_compare; |
ndl_compare_function = ndl_module_compare; |
|
ndl_base_compare_function = ndl_composite_compare; |
break; |
break; |
|
case 300: |
|
/* schreyer order */ |
|
if ( ord->base->id != 256 ) |
|
error("nd_init_ord : unsupported base order"); |
|
ndl_compare_function = ndl_module_schreyer_compare; |
|
dmm_stack = ord->dmmstack; |
|
switch ( ord->base->ord.simple ) { |
|
case 0: |
|
nd_isrlex = 1; |
|
ndl_base_compare_function = ndl_glex_compare; |
|
dl_base_compare_function = cmpdl_revgradlex; |
|
break; |
|
case 1: |
|
nd_isrlex = 0; |
|
ndl_base_compare_function = ndl_glex_compare; |
|
dl_base_compare_function = cmpdl_gradlex; |
|
break; |
|
case 2: |
|
nd_isrlex = 0; |
|
ndl_base_compare_function = ndl_lex_compare; |
|
dl_base_compare_function = cmpdl_lex; |
|
break; |
|
default: |
|
error("nd_init_ord : unsupported order"); |
|
} |
|
break; |
} |
} |
nd_ord = ord; |
nd_ord = ord; |
} |
} |
Line 5672 EPOS nd_create_epos(struct order_spec *ord) |
|
Line 5924 EPOS nd_create_epos(struct order_spec *ord) |
|
|
|
epos = (EPOS)MALLOC_ATOMIC(nd_nvar*sizeof(struct oEPOS)); |
epos = (EPOS)MALLOC_ATOMIC(nd_nvar*sizeof(struct oEPOS)); |
switch ( ord->id ) { |
switch ( ord->id ) { |
case 0: case 256: |
case 0: case 256: case 300: |
if ( nd_isrlex ) { |
if ( nd_isrlex ) { |
for ( i = 0; i < nd_nvar; i++ ) { |
for ( i = 0; i < nd_nvar; i++ ) { |
epos[i].i = nd_exporigin + (nd_nvar-1-i)/nd_epw; |
epos[i].i = nd_exporigin + (nd_nvar-1-i)/nd_epw; |
Line 6056 int ndv_reduce_vect_q(Z *svect,int trace,int col,IndAr |
|
Line 6308 int ndv_reduce_vect_q(Z *svect,int trace,int col,IndAr |
|
int ndv_reduce_vect_q(Z *svect0,int trace,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
int ndv_reduce_vect_q(Z *svect0,int trace,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
{ |
{ |
int i,j,k,len,pos,prev; |
int i,j,k,len,pos,prev; |
mpz_t *svect; |
|
mpz_t cs,cr,gcd; |
mpz_t cs,cr,gcd; |
IndArray ivect; |
IndArray ivect; |
unsigned char *ivc; |
unsigned char *ivc; |
Line 6068 int ndv_reduce_vect_q(Z *svect0,int trace,int col,IndA |
|
Line 6319 int ndv_reduce_vect_q(Z *svect0,int trace,int col,IndA |
|
int maxrs; |
int maxrs; |
double hmag; |
double hmag; |
int l; |
int l; |
|
static mpz_t *svect; |
|
static int svect_len=0; |
|
|
maxrs = 0; |
maxrs = 0; |
for ( i = 0; i < col && !svect0[i]; i++ ); |
for ( i = 0; i < col && !svect0[i]; i++ ); |
if ( i == col ) return maxrs; |
if ( i == col ) return maxrs; |
hmag = p_mag((P)svect0[i])*nd_scale; |
hmag = p_mag((P)svect0[i])*nd_scale; |
svect = (mpz_t *)MALLOC(col*sizeof(mpz_t)); |
if ( col > svect_len ) { |
|
svect = (mpz_t *)MALLOC(col*sizeof(mpz_t)); |
|
svect_len = col; |
|
} |
for ( i = 0; i < col; i++ ) { |
for ( i = 0; i < col; i++ ) { |
mpz_init(svect[i]); |
mpz_init(svect[i]); |
if ( svect0[i] ) |
if ( svect0[i] ) |
Line 6679 NODE nd_f4(int m,int checkonly,int **indp) |
|
Line 6935 NODE nd_f4(int m,int checkonly,int **indp) |
|
PGeoBucket bucket; |
PGeoBucket bucket; |
struct oEGT eg0,eg1,eg_f4; |
struct oEGT eg0,eg1,eg_f4; |
Z i1,i2,sugarq; |
Z i1,i2,sugarq; |
|
|
|
init_eg(&f4_symb); init_eg(&f4_conv); init_eg(&f4_conv); init_eg(&f4_elim1); init_eg(&f4_elim2); |
#if 0 |
#if 0 |
ndv_alloc = 0; |
ndv_alloc = 0; |
#endif |
#endif |
Line 6724 NODE nd_f4(int m,int checkonly,int **indp) |
|
Line 6982 NODE nd_f4(int m,int checkonly,int **indp) |
|
d = nd_reconstruct(0,d); |
d = nd_reconstruct(0,d); |
continue; |
continue; |
} |
} |
get_eg(&eg1); init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg1); |
get_eg(&eg1); init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg1); add_eg(&f4_symb,&eg0,&eg1); |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d,symb=%.3fsec,", |
fprintf(asir_out,"sugar=%d,symb=%.3fsec,", |
sugar,eg_f4.exectime); |
sugar,eg_f4.exectime); |
Line 6773 NODE nd_f4(int m,int checkonly,int **indp) |
|
Line 7031 NODE nd_f4(int m,int checkonly,int **indp) |
|
#if 0 |
#if 0 |
fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc); |
fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc); |
#endif |
#endif |
if ( DP_Print ) |
if ( DP_Print ) { |
fprintf(asir_out,"number of red=%d\n",Nf4_red); |
fprintf(asir_out,"number of red=%d,",Nf4_red); |
|
fprintf(asir_out,"symb=%.3fsec,conv=%.3fsec,elim1=%.3fsec,elim2=%.3fsec\n", |
|
f4_symb.exectime,f4_conv.exectime,f4_elim1.exectime,f4_elim2.exectime); |
|
} |
conv_ilist(nd_demand,0,g,indp); |
conv_ilist(nd_demand,0,g,indp); |
return g; |
return g; |
} |
} |
Line 7083 NODE nd_f4_red(int m,ND_pairs sp0,int trace,UINT *s0ve |
|
Line 7344 NODE nd_f4_red(int m,ND_pairs sp0,int trace,UINT *s0ve |
|
rhead[imat[i]->head] = 1; |
rhead[imat[i]->head] = 1; |
start = imat[i]->head; |
start = imat[i]->head; |
} |
} |
get_eg(&eg1); init_eg(&eg_conv); add_eg(&eg_conv,&eg0,&eg1); |
get_eg(&eg1); init_eg(&eg_conv); add_eg(&eg_conv,&eg0,&eg1); add_eg(&f4_conv,&eg0,&eg1); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"conv=%.3fsec,",eg_conv.exectime); |
fprintf(asir_out,"conv=%.3fsec,",eg_conv.exectime); |
fflush(asir_out); |
fflush(asir_out); |
Line 7666 int ndv_ishomo(NDV p) |
|
Line 7927 int ndv_ishomo(NDV p) |
|
h = TD(DL(m)); |
h = TD(DL(m)); |
NMV_ADV(m); |
NMV_ADV(m); |
for ( len--; len; len--, NMV_ADV(m) ) |
for ( len--; len; len--, NMV_ADV(m) ) |
if ( TD(DL(m)) != h ) return 0; |
if ( TD(DL(m)) != h ) { |
|
return 0; |
|
} |
return 1; |
return 1; |
} |
} |
|
|
Line 8316 void parse_nd_option(NODE opt) |
|
Line 8579 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") ) { |
Line 9088 int ndv_reduce_vect64(int m,mp_limb_t *svect,mp_limb_t |
|
Line 9353 int ndv_reduce_vect64(int m,mp_limb_t *svect,mp_limb_t |
|
ivc = ivect->index.c; |
ivc = ivect->index.c; |
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
pos = prev+ivc[j]; c1 = CM(mr); prev = pos; |
pos = prev+ivc[j]; c1 = CM(mr); prev = pos; |
if ( c1 ) { |
c2 = svect[pos]+c1*c; |
c2 = svect[pos]+c1*c; |
if ( c2 < svect[pos] ) cvect[pos]++; |
if ( c2 < svect[pos] ) cvect[pos]++; |
svect[pos] = c2; |
svect[pos] = c2; |
|
} |
|
} |
} |
break; |
break; |
case 2: |
case 2: |
ivs = ivect->index.s; |
ivs = ivect->index.s; |
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
pos = prev+ivs[j]; c1 = CM(mr); prev = pos; |
pos = prev+ivs[j]; c1 = CM(mr); prev = pos; |
if ( c1 ) { |
c2 = svect[pos]+c1*c; |
c2 = svect[pos]+c1*c; |
if ( c2 < svect[pos] ) cvect[pos]++; |
if ( c2 < svect[pos] ) cvect[pos]++; |
svect[pos] = c2; |
svect[pos] = c2; |
|
} |
|
} |
} |
break; |
break; |
case 4: |
case 4: |
ivi = ivect->index.i; |
ivi = ivect->index.i; |
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
pos = prev+ivi[j]; c1 = CM(mr); prev = pos; |
pos = prev+ivi[j]; c1 = CM(mr); prev = pos; |
if ( c1 ) { |
c2 = svect[pos]+c1*c; |
c2 = svect[pos]+c1*c; |
if ( c2 < svect[pos] ) cvect[pos]++; |
if ( c2 < svect[pos] ) cvect[pos]++; |
svect[pos] = c2; |
svect[pos] = c2; |
|
} |
|
} |
} |
break; |
break; |
} |
} |
Line 9170 NODE nd_f4_red_mod64_main(int m,ND_pairs sp0,int nsp,U |
|
Line 9429 NODE nd_f4_red_mod64_main(int m,ND_pairs sp0,int nsp,U |
|
} |
} |
nd_free(spol); |
nd_free(spol); |
} |
} |
get_eg(&eg1); init_eg(&eg_f4_1); add_eg(&eg_f4_1,&eg0,&eg1); |
get_eg(&eg1); init_eg(&eg_f4_1); add_eg(&eg_f4_1,&eg0,&eg1); add_eg(&f4_elim1,&eg0,&eg1); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"elim1=%.3fsec,",eg_f4_1.exectime); |
fprintf(asir_out,"elim1=%.3fsec,",eg_f4_1.exectime); |
fflush(asir_out); |
fflush(asir_out); |
Line 9191 NODE nd_f4_red_mod64_main(int m,ND_pairs sp0,int nsp,U |
|
Line 9450 NODE nd_f4_red_mod64_main(int m,ND_pairs sp0,int nsp,U |
|
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
|
|
for ( ; i < sprow; i++ ) GCFREE(spmat[i]); |
for ( ; i < sprow; i++ ) GCFREE(spmat[i]); |
get_eg(&eg2); init_eg(&eg_f4_2); add_eg(&eg_f4_2,&eg1,&eg2); |
get_eg(&eg2); init_eg(&eg_f4_2); add_eg(&eg_f4_2,&eg1,&eg2); add_eg(&f4_elim2,&eg1,&eg2); |
init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg2); |
init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg2); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"elim2=%.3fsec,",eg_f4_2.exectime); |
fprintf(asir_out,"elim2=%.3fsec,",eg_f4_2.exectime); |