version 1.26, 2020/06/23 01:49:58 |
version 1.27, 2020/06/25 02:53:31 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.25 2020/06/19 22:58:48 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.26 2020/06/23 01:49:58 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 71 static NODE nd_nzlist,nd_check_splist; |
|
Line 71 static NODE nd_nzlist,nd_check_splist; |
|
static int nd_splist; |
static int nd_splist; |
static int *nd_sugarweight; |
static int *nd_sugarweight; |
static int nd_f4red,nd_rank0,nd_last_nonzero; |
static int nd_f4red,nd_rank0,nd_last_nonzero; |
|
static DL *nd_sba_hm; |
|
|
NumberField get_numberfield(); |
NumberField get_numberfield(); |
UINT *nd_det_compute_bound(NDV **dm,int n,int j); |
UINT *nd_det_compute_bound(NDV **dm,int n,int j); |
Line 952 INLINE void ndl_addto(UINT *d1,UINT *d2) |
|
Line 953 INLINE void ndl_addto(UINT *d1,UINT *d2) |
|
#endif |
#endif |
} |
} |
|
|
/* d1 -= d2 */ |
|
INLINE void ndl_subfrom(UINT *d1,UINT *d2) |
|
{ |
|
int i; |
|
|
|
if ( nd_module ) { |
|
if ( MPOS(d1) && MPOS(d2) && (MPOS(d1) != MPOS(d2)) ) |
|
error("ndl_addto : invalid operation"); |
|
} |
|
#if 1 |
|
switch ( nd_wpd ) { |
|
case 2: |
|
TD(d1) -= TD(d2); |
|
d1[1] -= d2[1]; |
|
break; |
|
case 3: |
|
TD(d1) -= TD(d2); |
|
d1[1] -= d2[1]; |
|
d1[2] -= d2[2]; |
|
break; |
|
default: |
|
for ( i = 0; i < nd_wpd; i++ ) d1[i] -= d2[i]; |
|
break; |
|
} |
|
#else |
|
for ( i = 0; i < nd_wpd; i++ ) d1[i] -= d2[i]; |
|
#endif |
|
} |
|
|
|
INLINE void ndl_sub(UINT *d1,UINT *d2,UINT *d) |
INLINE void ndl_sub(UINT *d1,UINT *d2,UINT *d) |
{ |
{ |
int i; |
int i; |
Line 1249 void print_sig(SIG s) |
|
Line 1221 void print_sig(SIG s) |
|
INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
{ |
{ |
RHist r; |
RHist r; |
int i,singular,ret; |
int i,singular,ret,d,k; |
static int wpd,nvar; |
static int wpd,nvar; |
static SIG quo; |
static SIG quo; |
static UINT *tmp; |
static UINT *tmp; |
Line 1259 INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
|
Line 1231 INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
|
wpd = nd_wpd; |
wpd = nd_wpd; |
tmp = (UINT *)MALLOC(wpd*sizeof(UINT)); |
tmp = (UINT *)MALLOC(wpd*sizeof(UINT)); |
} |
} |
|
d = ndl_hash_value(dg); |
|
for ( r = nd_red[d], k = 0; r; r = NEXT(r), k++ ) { |
|
if ( ndl_equal(dg,DL(r)) ) { |
|
return r->index; |
|
} |
|
} |
singular = 0; |
singular = 0; |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
r = nd_psh[i]; |
r = nd_psh[i]; |
if ( ndl_reducible(dg,DL(r)) ) { |
if ( ndl_reducible(dg,DL(r)) ) { |
ndl_copy(dg,tmp); |
ndl_sub(dg,DL(r),tmp); |
ndl_subfrom(tmp,DL(r)); |
|
_ndltodl(tmp,DL(quo)); |
_ndltodl(tmp,DL(quo)); |
_addtodl(nd_nvar,DL(nd_psh[i]->sig),DL(quo)); |
_addtodl(nd_nvar,DL(nd_psh[i]->sig),DL(quo)); |
quo->pos = nd_psh[i]->sig->pos; |
quo->pos = nd_psh[i]->sig->pos; |
Line 1274 INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
|
Line 1251 INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
|
} |
} |
} |
} |
if ( singular ) return -1; |
if ( singular ) return -1; |
else return i; |
else if ( i < nd_psn ) |
|
nd_append_red(dg,i); |
|
return i; |
} |
} |
|
|
ND nd_merge(ND p1,ND p2) |
ND nd_merge(ND p1,ND p2) |
Line 2401 NODE nd_gb(int m,int ishomo,int checkonly,int gensyz,i |
|
Line 2380 NODE nd_gb(int m,int ishomo,int checkonly,int gensyz,i |
|
int diag_count = 0; |
int diag_count = 0; |
P cont; |
P cont; |
LIST list; |
LIST list; |
|
struct oEGT eg1,eg2,eg_update; |
|
|
|
init_eg(&eg_update); |
Nnd_add = 0; |
Nnd_add = 0; |
g = 0; d = 0; |
g = 0; d = 0; |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
|
|
goto again; |
goto again; |
} |
} |
} |
} |
|
get_eg(&eg1); |
d = update_pairs(d,g,nh,0); |
d = update_pairs(d,g,nh,0); |
|
get_eg(&eg2); add_eg(&eg_update,&eg1,&eg2); |
g = update_base(g,nh); |
g = update_base(g,nh); |
FREENDP(l); |
FREENDP(l); |
} else { |
} else { |
|
|
} |
} |
conv_ilist(nd_demand,0,g,indp); |
conv_ilist(nd_demand,0,g,indp); |
if ( !checkonly && DP_Print ) { printf("nd_gb done. Number of nd_add=%d\n",Nnd_add); fflush(stdout); } |
if ( !checkonly && DP_Print ) { printf("nd_gb done. Number of nd_add=%d\n",Nnd_add); fflush(stdout); } |
|
print_eg("update",&eg_update); |
return g; |
return g; |
} |
} |
|
|
Line 2527 NODE insert_sig(NODE l,SIG s) |
|
Line 2511 NODE insert_sig(NODE l,SIG s) |
|
} else |
} else |
prev = p; |
prev = p; |
} |
} |
NEWNODE(r); r->body = (pointer)s; |
NEWNODE(r); r->body = (pointer)s; r->next = 0; |
r->next = root.next; |
for ( p = &root; p->next; p = p->next ); |
return r; |
p->next = r; |
|
// r->next = root.next; |
|
// return r; |
|
return root.next; |
} |
} |
|
|
ND_pairs remove_spair_s(ND_pairs d,SIG sig) |
ND_pairs remove_spair_s(ND_pairs d,SIG sig) |
Line 2572 NODE nd_sba_buch(int m,int ishomo,int **indp) |
|
Line 2559 NODE nd_sba_buch(int m,int ishomo,int **indp) |
|
int Nredundant; |
int Nredundant; |
static int wpd,nvar; |
static int wpd,nvar; |
static DL lcm,quo,mul; |
static DL lcm,quo,mul; |
struct oEGT eg1,eg2,eg_update; |
struct oEGT eg1,eg2,eg_update,eg_remove; |
|
|
|
init_eg(&eg_remove); |
syzlist = 0; |
syzlist = 0; |
Nsyz = 0; |
Nsyz = 0; |
Nnd_add = 0; |
Nnd_add = 0; |
|
|
goto again; |
goto again; |
} else if ( stat == -1 ) { |
} else if ( stat == -1 ) { |
if ( DP_Print ) { printf("S"); fflush(stdout); } |
if ( DP_Print ) { printf("S"); fflush(stdout); } |
|
FREENDP(l); |
} else if ( nf ) { |
} else if ( nf ) { |
if ( DP_Print ) { printf("+"); fflush(stdout); } |
if ( DP_Print ) { printf("+"); fflush(stdout); } |
hc = HCU(nf); |
hc = HCU(nf); |
|
|
FREENDP(l); |
FREENDP(l); |
} else { |
} else { |
// syzygy |
// syzygy |
|
get_eg(&eg1); |
d = remove_spair_s(d,sig); |
d = remove_spair_s(d,sig); |
|
get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2); |
syzlist = insert_sig(syzlist,sig); |
syzlist = insert_sig(syzlist,sig); |
if ( DP_Print ) { printf("."); fflush(stdout); } |
if ( DP_Print ) { printf("."); fflush(stdout); } |
FREENDP(l); |
FREENDP(l); |
|
|
fflush(stdout); |
fflush(stdout); |
print_eg("create",&eg_create); |
print_eg("create",&eg_create); |
print_eg("merge",&eg_merge); |
print_eg("merge",&eg_merge); |
|
print_eg("remove",&eg_remove); |
|
printf("\n"); |
} |
} |
return g; |
return g; |
} |
} |
Line 3148 int comp_sig(SIG s1,SIG s2) |
|
Line 3141 int comp_sig(SIG s1,SIG s2) |
|
if ( nvar != nd_nvar ) { |
if ( nvar != nd_nvar ) { |
nvar = nd_nvar; NEWDL(m1,nvar); NEWDL(m2,nvar); |
nvar = nd_nvar; NEWDL(m1,nvar); NEWDL(m2,nvar); |
} |
} |
_ndltodl(DL(nd_psh[s1->pos]),m1); |
// _ndltodl(DL(nd_psh[s1->pos]),m1); |
_ndltodl(DL(nd_psh[s2->pos]),m2); |
// _ndltodl(DL(nd_psh[s2->pos]),m2); |
|
_copydl(nd_nvar,nd_sba_hm[s1->pos],m1); |
|
_copydl(nd_nvar,nd_sba_hm[s2->pos],m2); |
_addtodl(nd_nvar,s1->dl,m1); |
_addtodl(nd_nvar,s1->dl,m1); |
_addtodl(nd_nvar,s2->dl,m2); |
_addtodl(nd_nvar,s2->dl,m2); |
ret = (*cmpdl)(nd_nvar,m1,m2); |
ret = (*cmpdl)(nd_nvar,m1,m2); |
Line 3183 int _create_spair_s(int i1,int i2,ND_pairs sp,SIG sig1 |
|
Line 3178 int _create_spair_s(int i1,int i2,ND_pairs sp,SIG sig1 |
|
// DL(sig1) <- sp->lcm |
// DL(sig1) <- sp->lcm |
// DL(sig1) -= DL(p1) |
// DL(sig1) -= DL(p1) |
// DL(sig1) += DL(p1->sig) |
// DL(sig1) += DL(p1->sig) |
ndl_copy(sp->lcm,lcm); |
ndl_sub(sp->lcm,DL(p1),lcm); |
ndl_subfrom(lcm,DL(p1)); |
|
_ndltodl(lcm,DL(sig1)); |
_ndltodl(lcm,DL(sig1)); |
_addtodl(nd_nvar,DL(p1->sig),DL(sig1)); |
_addtodl(nd_nvar,DL(p1->sig),DL(sig1)); |
sig1->pos = p1->sig->pos; |
sig1->pos = p1->sig->pos; |
Line 3192 int _create_spair_s(int i1,int i2,ND_pairs sp,SIG sig1 |
|
Line 3186 int _create_spair_s(int i1,int i2,ND_pairs sp,SIG sig1 |
|
// DL(sig2) <- sp->lcm |
// DL(sig2) <- sp->lcm |
// DL(sig2) -= DL(p2) |
// DL(sig2) -= DL(p2) |
// DL(sig2) += DL(p2->sig) |
// DL(sig2) += DL(p2->sig) |
ndl_copy(sp->lcm,lcm); |
ndl_sub(sp->lcm,DL(p2),lcm); |
ndl_subfrom(lcm,DL(p2)); |
|
_ndltodl(lcm,DL(sig2)); |
_ndltodl(lcm,DL(sig2)); |
_addtodl(nd_nvar,DL(p2->sig),DL(sig2)); |
_addtodl(nd_nvar,DL(p2->sig),DL(sig2)); |
sig2->pos = p2->sig->pos; |
sig2->pos = p2->sig->pos; |
Line 3298 ND_pairs nd_newpairs_s( NODE g, int t, NODE syz) |
|
Line 3291 ND_pairs nd_newpairs_s( NODE g, int t, NODE syz) |
|
{ |
{ |
NODE h,s; |
NODE h,s; |
UINT *dl; |
UINT *dl; |
int ts,ret; |
int ts,ret,i; |
ND_pairs r,r0,_sp,sp; |
ND_pairs r,r0,_sp,sp; |
SIG _sig1,_sig2,spsig,tsig; |
SIG _sig1,_sig2,spsig,tsig; |
struct oEGT eg1,eg2,eg3,eg4; |
struct oEGT eg1,eg2,eg3,eg4; |
|
|
dl = DL(nd_psh[t]); |
|
ts = SG(nd_psh[t]) - TD(dl); |
|
NEWND_pairs(_sp); |
NEWND_pairs(_sp); |
NEWSIG(_sig1); NEWSIG(_sig2); |
NEWSIG(_sig1); NEWSIG(_sig2); |
r0 = 0; |
r0 = 0; |
for ( h = g; h; h = NEXT(h) ) { |
for ( i = 0; i < t; i++ ) { |
ret = _create_spair_s((long)BDY(h),t,_sp,_sig1,_sig2); |
ret = _create_spair_s(i,t,_sp,_sig1,_sig2); |
|
// for ( h = g; h; h = NEXT(h) ) { |
|
// ret = _create_spair_s((long)BDY(h),t,_sp,_sig1,_sig2); |
if ( ret ) { |
if ( ret ) { |
spsig = _sp->sig; |
spsig = _sp->sig; |
for ( s = syz; s; s = s->next ) { |
for ( s = syz; s; s = s->next ) { |
Line 3790 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
Line 3783 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
} |
} |
} |
} |
if ( sba ) { |
if ( sba ) { |
|
nd_sba_hm = (DL *)MALLOC(nd_psn*sizeof(DL)); |
// setup signatures |
// setup signatures |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
SIG sig; |
SIG sig; |
|
|
NEWSIG(sig); sig->pos = i; |
NEWSIG(sig); sig->pos = i; |
nd_ps[i]->sig = sig; |
nd_ps[i]->sig = sig; |
if ( nd_demand ) nd_ps_sym[i]->sig = sig; |
if ( nd_demand ) nd_ps_sym[i]->sig = sig; |
nd_psh[i]->sig = sig; |
nd_psh[i]->sig = sig; |
if ( trace ) { |
if ( trace ) { |
nd_ps_trace[i]->sig = sig; |
nd_ps_trace[i]->sig = sig; |
if ( nd_demand ) nd_ps_trace_sym[i]->sig = sig; |
if ( nd_demand ) nd_ps_trace_sym[i]->sig = sig; |
} |
} |
} |
NEWDL(nd_sba_hm[i],nd_nvar); |
|
_ndltodl(DL(nd_psh[i]),nd_sba_hm[i]); |
|
} |
} |
} |
if ( nd_gentrace && nd_tracelist ) NEXT(tn) = 0; |
if ( nd_gentrace && nd_tracelist ) NEXT(tn) = 0; |
return 1; |
return 1; |