version 1.28, 2020/06/30 01:52:17 |
version 1.29, 2020/07/02 09:24:17 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.27 2020/06/25 02:53:31 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.28 2020/06/30 01:52:17 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 72 static int nd_splist; |
|
Line 72 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; |
static DL *nd_sba_hm; |
|
static NODE *nd_sba_pos; |
|
|
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 1250 INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
|
Line 1251 INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
|
quo->pos = nd_psh[i]->sig->pos; |
quo->pos = nd_psh[i]->sig->pos; |
ret = comp_sig(sig,quo); |
ret = comp_sig(sig,quo); |
if ( ret > 0 ) { singular = 0; break; } |
if ( ret > 0 ) { singular = 0; break; } |
if ( ret == 0 ) { singular = 1; } |
if ( ret == 0 ) { fprintf(asir_out,"s"); fflush(asir_out); singular = 1; } |
} |
} |
} |
} |
if ( singular ) return -1; |
if ( singular ) return -1; |
Line 2483 print_eg("update",&eg_update); |
|
Line 2484 print_eg("update",&eg_update); |
|
return g; |
return g; |
} |
} |
|
|
ND_pairs update_pairs_s(ND_pairs d,NODE g,int t,NODE syz); |
ND_pairs update_pairs_s(ND_pairs d,NODE g,int t,NODE *syz); |
ND_pairs nd_newpairs_s( NODE g, int t ,NODE syz); |
ND_pairs nd_newpairs_s( NODE g, int t ,NODE *syz); |
|
|
int nd_nf_pbucket_s(int mod,ND g,NDV *ps,int full,ND *nf); |
int nd_nf_pbucket_s(int mod,ND g,NDV *ps,int full,ND *nf); |
int nd_nf_s(int mod,ND d,ND g,NDV *ps,int full,ND *nf); |
int nd_nf_s(int mod,ND d,ND g,NDV *ps,int full,ND *nf); |
Line 2543 ND_pairs remove_spair_s(ND_pairs d,SIG sig) |
|
Line 2544 ND_pairs remove_spair_s(ND_pairs d,SIG sig) |
|
return (ND_pairs)root.next; |
return (ND_pairs)root.next; |
} |
} |
|
|
|
int _dl_redble_ext(DL,DL,DL,int); |
|
|
int small_lcm(ND_pairs l) |
int small_lcm(ND_pairs l) |
{ |
{ |
SIG sig; |
SIG sig; |
int i; |
int i; |
|
NODE t; |
static DL lcm,mul,quo; |
static DL lcm,mul,quo; |
static int nvar; |
static int nvar; |
|
|
Line 2555 int small_lcm(ND_pairs l) |
|
Line 2559 int small_lcm(ND_pairs l) |
|
} |
} |
sig = l->sig; |
sig = l->sig; |
_ndltodl(l->lcm,lcm); |
_ndltodl(l->lcm,lcm); |
|
#if 0 |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
if ( sig->pos == nd_psh[i]->sig->pos && |
if ( sig->pos == nd_psh[i]->sig->pos && |
_dl_redble(DL(nd_psh[i]->sig),DL(sig),nd_nvar) ) { |
_dl_redble_ext(DL(nd_psh[i]->sig),DL(sig),quo,nd_nvar) ) { |
_copydl(nd_nvar,DL(sig),quo); |
|
_subfromdl(nd_nvar,DL(nd_psh[i]->sig),quo); |
|
_ndltodl(DL(nd_psh[i]),mul); |
_ndltodl(DL(nd_psh[i]),mul); |
_addtodl(nd_nvar,quo,mul); |
_addtodl(nd_nvar,quo,mul); |
if ( (*cmpdl)(nd_nvar,lcm,mul) > 0 ) |
if ( (*cmpdl)(nd_nvar,lcm,mul) > 0 ) |
Line 2568 int small_lcm(ND_pairs l) |
|
Line 2571 int small_lcm(ND_pairs l) |
|
} |
} |
if ( i < nd_psn ) return 1; |
if ( i < nd_psn ) return 1; |
else return 0; |
else return 0; |
|
#else |
|
for ( t = nd_sba_pos[sig->pos]; t; t = t->next ) { |
|
i = (long)BDY(t); |
|
if ( _dl_redble_ext(DL(nd_psh[i]->sig),DL(sig),quo,nd_nvar) ) { |
|
_ndltodl(DL(nd_psh[i]),mul); |
|
_addtodl(nd_nvar,quo,mul); |
|
if ( (*cmpdl)(nd_nvar,lcm,mul) > 0 ) |
|
break; |
|
} |
|
} |
|
if ( t ) return 1; |
|
else return 0; |
|
#endif |
} |
} |
|
|
ND_pairs remove_large_lcm(ND_pairs d) |
ND_pairs remove_large_lcm(ND_pairs d) |
Line 2592 struct oEGT eg_create,eg_newpairs,eg_merge; |
|
Line 2608 struct oEGT eg_create,eg_newpairs,eg_merge; |
|
|
|
NODE nd_sba_buch(int m,int ishomo,int **indp) |
NODE nd_sba_buch(int m,int ishomo,int **indp) |
{ |
{ |
int i,nh,sugar,stat; |
int i,j,nh,sugar,stat; |
NODE r,g,t; |
NODE r,g,t; |
ND_pairs d; |
ND_pairs d; |
ND_pairs l; |
ND_pairs l; |
Line 2603 NODE nd_sba_buch(int m,int ishomo,int **indp) |
|
Line 2619 NODE nd_sba_buch(int m,int ishomo,int **indp) |
|
P cont; |
P cont; |
LIST list; |
LIST list; |
SIG sig; |
SIG sig; |
NODE syzlist; |
NODE *syzlist; |
int Nredundant; |
int Nredundant; |
DL lcm,quo,mul; |
DL lcm,quo,mul; |
struct oEGT eg1,eg2,eg_update,eg_remove; |
struct oEGT eg1,eg2,eg_update,eg_remove,eg_large; |
|
|
init_eg(&eg_remove); |
init_eg(&eg_remove); |
syzlist = 0; |
syzlist = (NODE *)MALLOC(nd_psn*sizeof(NODE)); |
Nsyz = 0; |
Nsyz = 0; |
Nnd_add = 0; |
Nnd_add = 0; |
Nredundant = 0; |
Nredundant = 0; |
g = 0; d = 0; |
g = 0; d = 0; |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
d = update_pairs_s(d,g,i,0); |
d = update_pairs_s(d,g,i,syzlist); |
g = append_one(g,i); |
g = append_one(g,i); |
} |
} |
|
for ( i = 0; i < nd_psn; i++ ) |
|
for ( j = i+1; j < nd_psn; j++ ) { |
|
NEWSIG(sig); sig->pos = j; |
|
_copydl(nd_nvar,nd_sba_hm[i],sig->dl); |
|
syzlist[sig->pos] = insert_sig(syzlist[sig->pos],sig); |
|
} |
sugar = 0; |
sugar = 0; |
NEWDL(lcm,nd_nvar); NEWDL(quo,nd_nvar); NEWDL(mul,nd_nvar); |
NEWDL(lcm,nd_nvar); NEWDL(quo,nd_nvar); NEWDL(mul,nd_nvar); |
init_eg(&eg_create); |
init_eg(&eg_create); |
init_eg(&eg_merge); |
init_eg(&eg_merge); |
|
init_eg(&eg_large); |
while ( d ) { |
while ( d ) { |
again: |
again: |
if ( DP_Print ) { |
if ( DP_Print ) { |
|
|
|
|
d = update_pairs_s(d,g,nh,syzlist); |
d = update_pairs_s(d,g,nh,syzlist); |
g = append_one(g,nh); |
g = append_one(g,nh); |
|
nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh); |
FREENDP(l); |
FREENDP(l); |
} else { |
} else { |
// syzygy |
// syzygy |
get_eg(&eg1); |
get_eg(&eg1); |
d = remove_spair_s(d,sig); |
d = remove_spair_s(d,sig); |
get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2); |
get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2); |
syzlist = insert_sig(syzlist,sig); |
syzlist[sig->pos] = insert_sig(syzlist[sig->pos],sig); |
if ( DP_Print ) { printf("."); fflush(stdout); } |
if ( DP_Print ) { printf("."); fflush(stdout); } |
FREENDP(l); |
FREENDP(l); |
} |
} |
Line 3111 ND_pairs update_pairs( ND_pairs d, NODE /* of index */ |
|
Line 3135 ND_pairs update_pairs( ND_pairs d, NODE /* of index */ |
|
|
|
ND_pairs merge_pairs_s(ND_pairs d,ND_pairs d1); |
ND_pairs merge_pairs_s(ND_pairs d,ND_pairs d1); |
|
|
ND_pairs update_pairs_s( ND_pairs d, NODE /* of index */ g, int t,NODE syz) |
ND_pairs update_pairs_s( ND_pairs d, NODE /* of index */ g, int t,NODE *syz) |
{ |
{ |
ND_pairs d1; |
ND_pairs d1; |
struct oEGT eg1,eg2,eg3; |
struct oEGT eg1,eg2,eg3; |
Line 3323 ND_pairs insert_pair_s(ND_pairs l,ND_pairs s) |
|
Line 3347 ND_pairs insert_pair_s(ND_pairs l,ND_pairs s) |
|
} |
} |
} |
} |
|
|
ND_pairs nd_newpairs_s( NODE g, int t, NODE syz) |
INLINE int __dl_redble(DL d1,DL d2,int nvar) |
{ |
{ |
|
int i; |
|
|
|
if ( d1->td > d2->td ) |
|
return 0; |
|
for ( i = nvar-1; i >= 0; i-- ) |
|
if ( d1->d[i] > d2->d[i] ) |
|
break; |
|
if ( i >= 0 ) |
|
return 0; |
|
else |
|
return 1; |
|
} |
|
|
|
ND_pairs nd_newpairs_s( NODE g, int t, NODE *syz) |
|
{ |
NODE h,s; |
NODE h,s; |
UINT *dl; |
UINT *dl; |
int ts,ret,i; |
int ts,ret,i; |
ND_pairs r,r0,_sp,sp; |
ND_pairs r,r0,_sp,sp; |
SIG _sig1,_sig2,spsig,tsig; |
SIG spsig,tsig; |
|
static int nvar; |
|
static SIG _sig1,_sig2; |
struct oEGT eg1,eg2,eg3,eg4; |
struct oEGT eg1,eg2,eg3,eg4; |
|
|
NEWND_pairs(_sp); |
NEWND_pairs(_sp); |
NEWSIG(_sig1); NEWSIG(_sig2); |
if ( !_sig1 || nvar != nd_nvar ) { |
|
nvar = nd_nvar; NEWSIG(_sig1); NEWSIG(_sig2); |
|
} |
r0 = 0; |
r0 = 0; |
for ( i = 0; i < t; i++ ) { |
for ( i = 0; i < t; i++ ) { |
ret = _create_spair_s(i,t,_sp,_sig1,_sig2); |
ret = _create_spair_s(i,t,_sp,_sig1,_sig2); |
Line 3341 ND_pairs nd_newpairs_s( NODE g, int t, NODE syz) |
|
Line 3384 ND_pairs nd_newpairs_s( NODE g, int t, NODE syz) |
|
// ret = _create_spair_s((long)BDY(h),t,_sp,_sig1,_sig2); |
// 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[spsig->pos]; s; s = s->next ) { |
tsig = (SIG)s->body; |
tsig = (SIG)s->body; |
if ( tsig->pos == spsig->pos && _dl_redble(DL(tsig),DL(spsig),nd_nvar) ) |
if ( _dl_redble(DL(tsig),DL(spsig),nd_nvar) ) |
break; |
break; |
} |
} |
if ( s == 0 ) { |
if ( s == 0 ) { |
Line 3853 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
Line 3896 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
NEWDL(nd_sba_hm[i],nd_nvar); |
NEWDL(nd_sba_hm[i],nd_nvar); |
_ndltodl(DL(nd_psh[i]),nd_sba_hm[i]); |
_ndltodl(DL(nd_psh[i]),nd_sba_hm[i]); |
} |
} |
|
nd_sba_pos = (NODE *)MALLOC(nd_psn*sizeof(NODE)); |
|
for ( i = 0; i < nd_psn; i++ ) { |
|
j = nd_psh[i]->sig->pos; |
|
nd_sba_pos[j] = append_one(nd_sba_pos[j],i); |
|
} |
} |
} |
if ( nd_gentrace && nd_tracelist ) NEXT(tn) = 0; |
if ( nd_gentrace && nd_tracelist ) NEXT(tn) = 0; |
return 1; |
return 1; |
Line 4210 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 4258 void nd_sba(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; |
|
struct oEGT eg0,eg1,egconv; |
|
|
nd_module = 0; |
nd_module = 0; |
nd_demand = 0; |
nd_demand = 0; |
Line 4281 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 4330 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
x = ndv_reducebase(x,perm); |
x = ndv_reducebase(x,perm); |
x = ndv_reduceall(m,x); |
x = ndv_reduceall(m,x); |
nd_setup_parameters(nd_nvar,0); |
nd_setup_parameters(nd_nvar,0); |
|
get_eg(&eg0); |
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 ( retdp ) BDY(r) = ndvtodp(m,BDY(t)); |
if ( retdp ) BDY(r) = ndvtodp(m,BDY(t)); |
Line 4288 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 4338 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
MKLIST(*rp,r0); |
MKLIST(*rp,r0); |
|
get_eg(&eg1); init_eg(&egconv); add_eg(&egconv,&eg0,&eg1); |
|
print_eg("conv",&egconv); fprintf(asir_out,"\n"); |
} |
} |
|
|
void nd_gr_postproc(LIST f,LIST v,int m,struct order_spec *ord,int do_check,LIST *rp) |
void nd_gr_postproc(LIST f,LIST v,int m,struct order_spec *ord,int do_check,LIST *rp) |
Line 10540 NODE nd_f4_red_mod64_main_s(int m,ND_pairs sp0,int nsp |
|
Line 10592 NODE nd_f4_red_mod64_main_s(int m,ND_pairs sp0,int nsp |
|
for ( a = sprow = 0, sp = sp0; a < nsp; a++, sp = NEXT(sp) ) { |
for ( a = sprow = 0, sp = sp0; a < nsp; a++, sp = NEXT(sp) ) { |
nd_sp(m,0,sp,&spol); |
nd_sp(m,0,sp,&spol); |
if ( !spol ) { |
if ( !spol ) { |
*syzlistp = insert_sig(*syzlistp,sp->sig); |
syzlistp[sp->sig->pos] = insert_sig(syzlistp[sp->sig->pos],sp->sig); |
continue; |
continue; |
} |
} |
svect = (mp_limb_t *)MALLOC(col*sizeof(mp_limb_t)); |
svect = (mp_limb_t *)MALLOC(col*sizeof(mp_limb_t)); |
Line 10553 NODE nd_f4_red_mod64_main_s(int m,ND_pairs sp0,int nsp |
|
Line 10605 NODE nd_f4_red_mod64_main_s(int m,ND_pairs sp0,int nsp |
|
spsig[sprow] = sp->sig; |
spsig[sprow] = sp->sig; |
sprow++; |
sprow++; |
} else { |
} else { |
*syzlistp = insert_sig(*syzlistp,sp->sig); |
syzlistp[sp->sig->pos] = insert_sig(syzlistp[sp->sig->pos],sp->sig); |
} |
} |
nd_free(spol); |
nd_free(spol); |
} |
} |
Line 10580 NODE nd_f4_red_mod64_main_s(int m,ND_pairs sp0,int nsp |
|
Line 10632 NODE nd_f4_red_mod64_main_s(int m,ND_pairs sp0,int nsp |
|
|
|
for ( ; i < sprow; i++ ) { |
for ( ; i < sprow; i++ ) { |
GCFREE(spmat[i]); |
GCFREE(spmat[i]); |
*syzlistp = insert_sig(*syzlistp,spsig[i]); |
syzlistp[spsig[i]->pos] = insert_sig(syzlistp[spsig[i]->pos],spsig[i]); |
} |
} |
get_eg(&eg2); init_eg(&eg_f4_2); add_eg(&eg_f4_2,&eg1,&eg2); add_eg(&f4_elim2,&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); |
Line 10757 NODE nd_sba_f4(int m,int **indp) |
|
Line 10809 NODE nd_sba_f4(int m,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; |
NODE syzlist; |
NODE *syzlist; |
|
|
Nf4_red=0; |
Nf4_red=0; |
g = 0; d = 0; |
g = 0; d = 0; |
syzlist = 0; |
syzlist = (NODE *)MALLOC(nd_psn*sizeof(NODE)); |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
d = update_pairs_s(d,g,i,syzlist); |
d = update_pairs_s(d,g,i,syzlist); |
g = append_one(g,i); |
g = append_one(g,i); |
Line 10790 NODE nd_sba_f4(int m,int **indp) |
|
Line 10842 NODE nd_sba_f4(int m,int **indp) |
|
} |
} |
if ( DP_Print ) fprintf(asir_out,"sugar=%d,",sugar); |
if ( DP_Print ) fprintf(asir_out,"sugar=%d,",sugar); |
l = remove_large_lcm(l); |
l = remove_large_lcm(l); |
nflist = nd_f4_red_s(m,l,0,s0vect,col,rp0,&syzlist); |
nflist = nd_f4_red_s(m,l,0,s0vect,col,rp0,syzlist); |
/* adding new bases */ |
/* adding new bases */ |
for ( r = nflist; r; r = NEXT(r) ) { |
for ( r = nflist; r; r = NEXT(r) ) { |
ND tmp,tmpred; |
ND tmp,tmpred; |
Line 10810 NODE nd_sba_f4(int m,int **indp) |
|
Line 10862 NODE nd_sba_f4(int m,int **indp) |
|
d = update_pairs_s(d,g,nh,syzlist); |
d = update_pairs_s(d,g,nh,syzlist); |
g = append_one(g,nh); |
g = append_one(g,nh); |
} else { |
} else { |
syzlist = insert_sig(syzlist,sig); |
syzlist[sig->pos] = insert_sig(syzlist[sig->pos],sig); |
} |
} |
} |
} |
for ( r = syzlist; r; r = NEXT(r) ) |
// YYY |
d = remove_spair_s(d,(SIG)BDY(r)); |
// for ( r = syzlist; r; r = NEXT(r) ) |
|
// d = remove_spair_s(d,(SIG)BDY(r)); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"f4red=%d,gblen=%d\n",f4red,length(g)); fflush(asir_out); |
fprintf(asir_out,"f4red=%d,gblen=%d\n",f4red,length(g)); fflush(asir_out); |
} |
} |