version 1.30, 2020/07/03 03:37:59 |
version 1.36, 2020/09/27 04:35:04 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.29 2020/07/02 09:24:17 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.35 2020/08/26 06:40:36 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 18 NM _nm_free_list; |
|
Line 18 NM _nm_free_list; |
|
ND _nd_free_list; |
ND _nd_free_list; |
ND_pairs _ndp_free_list; |
ND_pairs _ndp_free_list; |
NODE nd_hcf; |
NODE nd_hcf; |
int Nsyz; |
int Nsyz,Nsamesig; |
|
|
Obj nd_top_weight; |
Obj nd_top_weight; |
|
|
Line 786 int ndl_module_compare(UINT *d1,UINT *d2) |
|
Line 786 int ndl_module_compare(UINT *d1,UINT *d2) |
|
|
|
extern DMMstack dmm_stack; |
extern DMMstack dmm_stack; |
void _addtodl(int n,DL d1,DL d2); |
void _addtodl(int n,DL d1,DL d2); |
|
void _adddl(int n,DL d1,DL d2,DL d3); |
int _eqdl(int n,DL d1,DL d2); |
int _eqdl(int n,DL d1,DL d2); |
|
|
int ndl_module_schreyer_compare(UINT *m1,UINT *m2) |
int ndl_module_schreyer_compare(UINT *m1,UINT *m2) |
Line 1222 void print_sig(SIG s) |
|
Line 1223 void print_sig(SIG s) |
|
fprintf(asir_out,">>*e%d",s->pos); |
fprintf(asir_out,">>*e%d",s->pos); |
} |
} |
|
|
|
// assuming increasing order wrt signature |
|
|
INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
{ |
{ |
RHist r; |
RHist r; |
Line 1236 INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
|
Line 1239 INLINE int ndl_find_reducer_s(UINT *dg,SIG sig) |
|
tmp = (UINT *)MALLOC(wpd*sizeof(UINT)); |
tmp = (UINT *)MALLOC(wpd*sizeof(UINT)); |
} |
} |
d = ndl_hash_value(dg); |
d = ndl_hash_value(dg); |
|
#if 1 |
for ( r = nd_red[d], k = 0; r; r = NEXT(r), k++ ) { |
for ( r = nd_red[d], k = 0; r; r = NEXT(r), k++ ) { |
if ( ndl_equal(dg,DL(r)) ) { |
if ( ndl_equal(dg,DL(r)) ) { |
return r->index; |
return r->index; |
} |
} |
} |
} |
|
#endif |
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]; |
Line 2476 get_eg(&eg2); add_eg(&eg_update,&eg1,&eg2); |
|
Line 2481 get_eg(&eg2); add_eg(&eg_update,&eg1,&eg2); |
|
} |
} |
if ( DP_Print ) { printf("."); fflush(stdout); } |
if ( DP_Print ) { printf("."); fflush(stdout); } |
FREENDP(l); |
FREENDP(l); |
} |
} |
} |
} |
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; |
if ( DP_Print ) |
|
print_eg("update",&eg_update); |
|
return g; |
} |
} |
|
|
ND_pairs update_pairs_s(ND_pairs d,int t,NODE *syz); |
ND_pairs update_pairs_s(ND_pairs d,int t,NODE *syz); |
Line 2624 NODE nd_sba_buch(int m,int ishomo,int **indp) |
|
Line 2631 NODE nd_sba_buch(int m,int ishomo,int **indp) |
|
NODE *syzlist; |
NODE *syzlist; |
int Nredundant; |
int Nredundant; |
DL lcm,quo,mul; |
DL lcm,quo,mul; |
struct oEGT eg1,eg2,eg_update,eg_remove,eg_large; |
struct oEGT eg1,eg2,eg_update,eg_remove,eg_large,eg_nf,eg_nfzero; |
|
|
init_eg(&eg_remove); |
init_eg(&eg_remove); |
syzlist = (NODE *)MALLOC(nd_psn*sizeof(NODE)); |
syzlist = (NODE *)MALLOC(nd_psn*sizeof(NODE)); |
Line 2646 init_eg(&eg_remove); |
|
Line 2653 init_eg(&eg_remove); |
|
init_eg(&eg_create); |
init_eg(&eg_create); |
init_eg(&eg_merge); |
init_eg(&eg_merge); |
init_eg(&eg_large); |
init_eg(&eg_large); |
|
init_eg(&eg_nf); |
|
init_eg(&eg_nfzero); |
while ( d ) { |
while ( d ) { |
again: |
again: |
if ( DP_Print ) { |
if ( DP_Print ) { |
|
|
d = nd_reconstruct(0,d); |
d = nd_reconstruct(0,d); |
goto again; |
goto again; |
} |
} |
|
get_eg(&eg1); |
#if USE_GEOBUCKET |
#if USE_GEOBUCKET |
stat = m?nd_nf_pbucket_s(m,h,nd_ps,!Top,&nf):nd_nf_s(m,0,h,nd_ps,!Top,&nf); |
stat = m?nd_nf_pbucket_s(m,h,nd_ps,!Top,&nf):nd_nf_s(m,0,h,nd_ps,!Top,&nf); |
#else |
#else |
stat = nd_nf_s(m,0,h,nd_ps,!Top,&nf); |
stat = nd_nf_s(m,0,h,nd_ps,!Top,&nf); |
#endif |
#endif |
|
get_eg(&eg2); |
if ( !stat ) { |
if ( !stat ) { |
NEXT(l) = d; d = l; |
NEXT(l) = d; d = l; |
d = nd_reconstruct(0,d); |
d = nd_reconstruct(0,d); |
|
|
FREENDP(l); |
FREENDP(l); |
} else if ( nf ) { |
} else if ( nf ) { |
if ( DP_Print ) { printf("+"); fflush(stdout); } |
if ( DP_Print ) { printf("+"); fflush(stdout); } |
|
add_eg(&eg_nf,&eg1,&eg2); |
hc = HCU(nf); |
hc = HCU(nf); |
nd_removecont(m,nf); |
nd_removecont(m,nf); |
nfv = ndtondv(m,nf); nd_free(nf); |
nfv = ndtondv(m,nf); nd_free(nf); |
|
|
nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh); |
nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh); |
FREENDP(l); |
FREENDP(l); |
} else { |
} else { |
|
add_eg(&eg_nfzero,&eg1,&eg2); |
// syzygy |
// syzygy |
get_eg(&eg1); |
get_eg(&eg1); |
d = remove_spair_s(d,sig); |
d = remove_spair_s(d,sig); |
Line 2706 get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2); |
|
Line 2719 get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2); |
|
} |
} |
g = conv_ilist_s(nd_demand,0,indp); |
g = conv_ilist_s(nd_demand,0,indp); |
if ( DP_Print ) { |
if ( DP_Print ) { |
printf("\nnd_sba done. nd_add=%d,Nsyz=%d,Nredundant=%d\n",Nnd_add,Nsyz,Nredundant); |
printf("\nnd_sba done. nd_add=%d,Nsyz=%d,Nsamesig=%d,Nredundant=%d\n",Nnd_add,Nsyz,Nsamesig,Nredundant); |
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); |
print_eg("remove",&eg_remove); |
|
print_eg("nf",&eg_nf); |
|
print_eg("nfzero",&eg_nfzero); |
printf("\n"); |
printf("\n"); |
} |
} |
return g; |
return g; |
Line 3200 int comp_sig(SIG s1,SIG s2) |
|
Line 3215 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); |
#if 0 |
// _ndltodl(DL(nd_psh[s2->pos]),m2); |
|
_copydl(nd_nvar,nd_sba_hm[s1->pos],m1); |
_copydl(nd_nvar,nd_sba_hm[s1->pos],m1); |
_copydl(nd_nvar,nd_sba_hm[s2->pos],m2); |
_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); |
|
#else |
|
_adddl(nd_nvar,s1->dl,nd_sba_hm[s1->pos],m1); |
|
_adddl(nd_nvar,s2->dl,nd_sba_hm[s2->pos],m2); |
|
#endif |
ret = (*cmpdl)(nd_nvar,m1,m2); |
ret = (*cmpdl)(nd_nvar,m1,m2); |
if ( ret != 0 ) return ret; |
if ( ret != 0 ) return ret; |
else if ( s1->pos > s2->pos ) return 1; |
else if ( s1->pos > s2->pos ) return 1; |
Line 3295 ND_pairs merge_pairs_s(ND_pairs p1,ND_pairs p2) |
|
Line 3313 ND_pairs merge_pairs_s(ND_pairs p1,ND_pairs p2) |
|
r->next = q2; r = q2; q2 = q2->next; |
r->next = q2; r = q2; q2 = q2->next; |
} else { |
} else { |
ret = DL_COMPARE(q1->lcm,q2->lcm); |
ret = DL_COMPARE(q1->lcm,q2->lcm); |
|
Nsamesig++; |
if ( ret < 0 ) { |
if ( ret < 0 ) { |
r->next = q1; r = q1; q1 = q1->next; |
r->next = q1; r = q1; q1 = q1->next; |
q2 = q2->next; |
q2 = q2->next; |
Line 3679 ND_pairs nd_minsugarp_s( ND_pairs d, ND_pairs *prest ) |
|
Line 3698 ND_pairs nd_minsugarp_s( ND_pairs d, ND_pairs *prest ) |
|
int msugar; |
int msugar; |
ND_pairs t,last; |
ND_pairs t,last; |
|
|
#if 0 |
|
for ( msugar = SG(d), t = d; t; t = NEXT(t) ) |
for ( msugar = SG(d), t = d; t; t = NEXT(t) ) |
if ( SG(t) == msugar ) last = t; |
if ( SG(t) == msugar ) last = t; |
#else |
|
msugar = (d->sig->dl->td)+nd_sba_hm[d->sig->pos]->td; |
|
for ( t = d; t; t = NEXT(t) ) |
|
if ( ((t->sig->dl->td)+nd_sba_hm[t->sig->pos]->td) == msugar ) last = t; |
|
#endif |
|
*prest = last->next; |
*prest = last->next; |
last->next = 0; |
last->next = 0; |
return d; |
return d; |
Line 4260 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 4273 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
nd_module = 0; |
nd_module = 0; |
nd_demand = 0; |
nd_demand = 0; |
parse_nd_option(current_option); |
parse_nd_option(current_option); |
|
Nsamesig = 0; |
if ( DP_Multiple ) |
if ( DP_Multiple ) |
nd_scale = ((double)DP_Multiple)/(double)(Denominator?Denominator:1); |
nd_scale = ((double)DP_Multiple)/(double)(Denominator?Denominator:1); |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&nd_vc); |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&nd_vc); |
Line 4331 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 4344 void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int |
|
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)); |
BDY(r) = ndvtop(m,CO,vv,BDY(t)); |
else BDY(r) = ndvtop(m,CO,vv,BDY(t)); |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
MKLIST(*rp,r0); |
MKLIST(*rp,r0); |
Line 4852 DL ndltodl(int n,UINT *ndl) |
|
Line 4865 DL ndltodl(int n,UINT *ndl) |
|
int i,j,l,s,ord_l; |
int i,j,l,s,ord_l; |
struct order_pair *op; |
struct order_pair *op; |
|
|
NEWDL(dl,n); |
NEWDL_NOINIT(dl,n); |
dl->td = TD(ndl); |
dl->td = TD(ndl); |
d = dl->d; |
d = dl->d; |
if ( nd_blockmask ) { |
if ( nd_blockmask ) { |
Line 10596 int nd_gauss_elim_mod64_s(mp_limb_t **mat,int *sugar,N |
|
Line 10609 int nd_gauss_elim_mod64_s(mp_limb_t **mat,int *sugar,N |
|
UINT *ct; |
UINT *ct; |
ND_pairs pair; |
ND_pairs pair; |
SIG sg; |
SIG sg; |
|
int *used; |
|
|
|
used = (int *)MALLOC(row*sizeof(int)); |
cmat = (UINT **)MALLOC(row*sizeof(UINT *)); |
cmat = (UINT **)MALLOC(row*sizeof(UINT *)); |
for ( i = 0; i < row; i++ ) { |
for ( i = 0; i < row; i++ ) { |
cmat[i] = MALLOC_ATOMIC(col*sizeof(UINT)); |
cmat[i] = MALLOC_ATOMIC(col*sizeof(UINT)); |
bzero(cmat[i],col*sizeof(UINT)); |
bzero(cmat[i],col*sizeof(UINT)); |
} |
} |
|
|
for ( rank = 0, j = 0; j < col; j++ ) { |
for ( j = 0; j < col; j++ ) { |
for ( i = rank; i < row; i++ ) { |
for ( i = 0; i < row; i++ ) { |
a = mat[i][j]; c = cmat[i][j]; |
a = mat[i][j]; c = cmat[i][j]; |
MOD128(a,c,md); |
MOD128(a,c,md); |
mat[i][j] = a; cmat[i][j] = 0; |
mat[i][j] = a; cmat[i][j] = 0; |
} |
} |
imin = -1; |
for ( i = 0; i < row; i++ ) |
for ( i = rank; i < row; i++ ) |
if ( !used[i] && mat[i][j] ) break; |
if ( mat[i][j] && (imin < 0 || comp_sig(sig[imin],sig[i]) > 0) ) imin = i; |
if ( i == row ) { |
if ( imin == -1 ) { |
|
colstat[j] = 0; |
colstat[j] = 0; |
continue; |
continue; |
} else |
} else { |
colstat[j] = 1; |
colstat[j] = 1; |
if ( imin != rank ) { |
used[i] = 1; |
t = mat[imin]; mat[imin] = mat[rank]; mat[rank] = t; |
|
ct = cmat[imin]; cmat[imin] = cmat[rank]; cmat[rank] = ct; |
|
s = sugar[imin]; sugar[imin] = sugar[rank]; sugar[rank] = s; |
|
sg = sig[imin]; sig[imin] = sig[rank]; sig[rank] = sg; |
|
if ( spactive ) { |
|
pair = spactive[imin]; spactive[imin] = spactive[rank]; |
|
spactive[rank] = pair; |
|
} |
|
} |
} |
/* column j is normalized */ |
/* column j is normalized */ |
s = sugar[rank]; |
s = sugar[i]; |
inv = invm((UINT)mat[rank][j],md); |
inv = invm((UINT)mat[i][j],md); |
/* normalize pivot row */ |
/* normalize pivot row */ |
for ( k = j, pk = mat[rank]+j, ck = cmat[rank]+j; k < col; k++, pk++, ck++ ) { |
for ( k = j, pk = mat[i]+j, ck = cmat[i]+j; k < col; k++, pk++, ck++ ) { |
a = *pk; c = *ck; MOD128(a,c,md); *pk = (a*inv)%md; *ck = 0; |
a = *pk; c = *ck; MOD128(a,c,md); *pk = (a*inv)%md; *ck = 0; |
} |
} |
for ( i = rank+1; i < row; i++ ) { |
for ( k = i+1; k < row; k++ ) { |
if ( (a = mat[i][j]) != 0 ) { |
if ( (a = mat[k][j]) != 0 ) { |
sugar[i] = MAX(sugar[i],s); |
sugar[k] = MAX(sugar[k],s); |
red_by_vect64(md,mat[i]+j,cmat[i]+j,mat[rank]+j,(int)(md-a),col-j); |
red_by_vect64(md,mat[k]+j,cmat[k]+j,mat[i]+j,(int)(md-a),col-j); |
Nf4_red++; |
Nf4_red++; |
} |
} |
} |
} |
rank++; |
|
} |
} |
#if 1 |
rank = 0; |
for ( j = col-1, l = rank-1; j >= 0; j-- ) |
for ( i = 0; i < row; i++ ) { |
if ( colstat[j] ) { |
for ( j = 0; j < col; j++ ) |
for ( k = j, pk = mat[l]+j, ck = cmat[l]+j; k < col; k++, pk++, ck++ ) { |
if ( mat[i][j] ) break; |
a = *pk; c = *ck; MOD128(a,c,md); *pk = a; *ck = 0; |
if ( j == col ) sugar[i] = -1; |
} |
else rank++; |
s = sugar[l]; |
} |
for ( i = 0; i < l; i++ ) { |
|
a = mat[i][j]; c = cmat[i][j]; MOD128(a,c,md); mat[i][j] = a; cmat[i][j] = 0; |
|
if ( a && comp_sig(sig[i],sig[l]) > 0 ) { |
|
sugar[i] = MAX(sugar[i],s); |
|
red_by_vect64(md,mat[i]+j,cmat[i]+j,mat[l]+j,(int)(md-a),col-j); |
|
Nf4_red++; |
|
} |
|
} |
|
l--; |
|
} |
|
#endif |
|
for ( i = 0; i < row; i++ ) GCFREE(cmat[i]); |
for ( i = 0; i < row; i++ ) GCFREE(cmat[i]); |
GCFREE(cmat); |
GCFREE(cmat); |
return rank; |
return rank; |
Line 10722 NODE nd_f4_red_mod64_main_s(int m,ND_pairs sp0,int nsp |
|
Line 10716 NODE nd_f4_red_mod64_main_s(int m,ND_pairs sp0,int nsp |
|
colstat = (int *)MALLOC(col*sizeof(int)); |
colstat = (int *)MALLOC(col*sizeof(int)); |
rank = nd_gauss_elim_mod64_s(spmat,spsugar,0,sprow,col,m,colstat,spsig); |
rank = nd_gauss_elim_mod64_s(spmat,spsugar,0,sprow,col,m,colstat,spsig); |
r0 = 0; |
r0 = 0; |
for ( i = 0; i < rank; i++ ) { |
for ( i = 0; i < sprow; i++ ) { |
NEXTNODE(r0,r); |
if ( spsugar[i] >= 0 ) { |
BDY(r) = vect64_to_ndv_s(spmat[i],col,s0vect); |
NEXTNODE(r0,r); |
SG((NDV)BDY(r)) = spsugar[i]; |
BDY(r) = vect64_to_ndv_s(spmat[i],col,s0vect); |
((NDV)BDY(r))->sig = spsig[i]; |
SG((NDV)BDY(r)) = spsugar[i]; |
|
((NDV)BDY(r))->sig = spsig[i]; |
|
} else |
|
syzlistp[spsig[i]->pos] = insert_sig(syzlistp[spsig[i]->pos],spsig[i]); |
GCFREE(spmat[i]); |
GCFREE(spmat[i]); |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
|
|
for ( ; i < sprow; i++ ) { |
|
GCFREE(spmat[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); |
if ( DP_Print ) { |
if ( DP_Print ) { |
Line 10890 int nd_symbolic_preproc_s(PGeoBucket bucket,int trace, |
|
Line 10882 int nd_symbolic_preproc_s(PGeoBucket bucket,int trace, |
|
|
|
NODE nd_sba_f4(int m,int **indp) |
NODE nd_sba_f4(int m,int **indp) |
{ |
{ |
int i,nh,stat,index,f4red; |
int i,nh,stat,index,f4red,f4step; |
NODE r,g,tn0,tn,node; |
int col,rank,len,k,j,a,sugar,nbase,psugar,ms; |
ND_pairs d,l,t,ll0,ll,lh; |
NODE r,g,rp0,nflist; |
LIST l0,l1; |
ND_pairs d,l,t; |
ND spol,red; |
ND h,nf; |
NDV nf,redv; |
NDV nfv; |
NM s0,s; |
union oNDC hc; |
NODE rp0,srp0,nflist; |
UINT *s0vect; |
int nsp,nred,col,rank,len,k,j,a,i1s,i2s; |
|
UINT c; |
UINT c; |
UINT **spmat; |
|
UINT *s0vect,*svect,*p,*v; |
|
int *colstat; |
|
IndArray *imat; |
|
int *rhead; |
|
int spcol,sprow; |
|
int sugar,sugarh; |
|
int nbase; |
|
PGeoBucket bucket; |
PGeoBucket bucket; |
struct oEGT eg0,eg1,eg_f4; |
|
Z i1,i2,sugarq; |
|
NODE *syzlist; |
NODE *syzlist; |
|
SIG sig; |
|
struct oEGT eg0,eg1,eg_f4; |
|
struct oEGT eg2,eg_update,eg_remove,eg_large,eg_nf,eg_nfzero; |
|
|
Nf4_red=0; |
Nf4_red=0; |
d = 0; |
d = 0; |
Line 10921 NODE nd_sba_f4(int m,int **indp) |
|
Line 10905 NODE nd_sba_f4(int m,int **indp) |
|
} |
} |
nd_nbase = nd_psn; |
nd_nbase = nd_psn; |
f4red = 1; |
f4red = 1; |
|
psugar = 0; |
|
f4step = 0; |
while ( d ) { |
while ( d ) { |
l = nd_minsugarp_s(d,&d); |
for ( t = d, ms = SG(d); t; t = NEXT(t) ) |
if ( !l ) continue; |
if ( SG(t) < ms ) ms = SG(t); |
sugar = nd_sugarweight?l->sugar2:SG(l); |
if ( ms == psugar && f4step >= 2 ) { |
if ( MaxDeg > 0 && sugar > MaxDeg ) break; |
again: |
bucket = create_pbucket(); |
l = d; d = d->next; |
stat = nd_sp_f4(m,0,l,bucket); |
if ( small_lcm(l) ) { |
if ( !stat ) { |
if ( DP_Print ) fprintf(asir_out,"M"); |
for ( t = l; NEXT(t); t = NEXT(t) ); |
continue; |
NEXT(t) = d; d = l; |
} |
d = nd_reconstruct(0,d); |
sig = l->sig; |
continue; |
stat = nd_sp(m,0,l,&h); |
} |
if ( !stat ) { |
if ( bucket->m < 0 ) continue; |
NEXT(l) = d; d = l; |
col = nd_symbolic_preproc_s(bucket,0,&s0vect,&rp0); |
d = nd_reconstruct(0,d); |
if ( !col ) { |
goto again; |
for ( t = l; NEXT(t); t = NEXT(t) ); |
} |
NEXT(t) = d; d = l; |
get_eg(&eg1); |
d = nd_reconstruct(0,d); |
#if USE_GEOBUCKET |
continue; |
stat = m?nd_nf_pbucket_s(m,h,nd_ps,!Top,&nf):nd_nf_s(m,0,h,nd_ps,!Top,&nf); |
} |
#else |
if ( DP_Print ) fprintf(asir_out,"sugar=%d,",sugar); |
stat = nd_nf_s(m,0,h,nd_ps,!Top,&nf); |
l = remove_large_lcm(l); |
#endif |
nflist = nd_f4_red_s(m,l,0,s0vect,col,rp0,syzlist); |
get_eg(&eg2); |
/* adding new bases */ |
if ( !stat ) { |
for ( r = nflist; r; r = NEXT(r) ) { |
NEXT(l) = d; d = l; |
ND tmp,tmpred; |
d = nd_reconstruct(0,d); |
SIG sig; |
goto again; |
|
} else if ( stat == -1 ) { |
nf = (NDV)BDY(r); |
if ( DP_Print ) { printf("S"); fflush(stdout); } |
sig = nf->sig; |
FREENDP(l); |
tmp = ndvtond(m,nf); |
} else if ( nf ) { |
stat = nd_nf_s(m,0,tmp,nd_ps,!Top,&tmpred); |
if ( DP_Print ) { printf("+"); fflush(stdout); } |
if ( stat < 0 ) { |
add_eg(&eg_nf,&eg1,&eg2); |
// top reducible |
hc = HCU(nf); |
if ( DP_Print ) { fprintf(asir_out,"S"); fflush(asir_out); } |
nd_removecont(m,nf); |
} else if ( tmpred ) { |
nfv = ndtondv(m,nf); nd_free(nf); |
nf = ndtondv(m,tmpred); |
nh = ndv_newps(m,nfv,0); |
ndv_removecont(m,nf); |
|
nh = ndv_newps(m,nf,0); |
|
d = update_pairs_s(d,nh,syzlist); |
d = update_pairs_s(d,nh,syzlist); |
nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh); |
nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh); |
|
FREENDP(l); |
} else { |
} else { |
|
add_eg(&eg_nfzero,&eg1,&eg2); |
|
// syzygy |
|
get_eg(&eg1); |
|
d = remove_spair_s(d,sig); |
|
get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2); |
syzlist[sig->pos] = insert_sig(syzlist[sig->pos],sig); |
syzlist[sig->pos] = insert_sig(syzlist[sig->pos],sig); |
} |
if ( DP_Print ) { printf("."); fflush(stdout); } |
|
FREENDP(l); |
|
} |
|
} else { |
|
if ( ms != psugar ) f4step = 1; |
|
else f4step++; |
|
again2: |
|
psugar = ms; |
|
l = nd_minsugarp_s(d,&d); |
|
sugar = nd_sugarweight?d->sugar2:SG(d); |
|
bucket = create_pbucket(); |
|
stat = nd_sp_f4(m,0,l,bucket); |
|
if ( !stat ) { |
|
for ( t = l; NEXT(t); t = NEXT(t) ); |
|
NEXT(t) = d; d = l; |
|
d = nd_reconstruct(0,d); |
|
goto again2; |
|
} |
|
if ( bucket->m < 0 ) continue; |
|
col = nd_symbolic_preproc_s(bucket,0,&s0vect,&rp0); |
|
if ( !col ) { |
|
for ( t = l; NEXT(t); t = NEXT(t) ); |
|
NEXT(t) = d; d = l; |
|
d = nd_reconstruct(0,d); |
|
goto again2; |
|
} |
|
if ( DP_Print ) fprintf(asir_out,"\nsugar=%d,",psugar); |
|
nflist = nd_f4_red_s(m,l,0,s0vect,col,rp0,syzlist); |
|
/* adding new bases */ |
|
for ( r = nflist; r; r = NEXT(r) ) { |
|
nfv = (NDV)BDY(r); |
|
ndv_removecont(m,nfv); |
|
nh = ndv_newps(m,nfv,0); |
|
d = update_pairs_s(d,nh,syzlist); |
|
nd_sba_pos[nfv->sig->pos] = append_one(nd_sba_pos[nfv->sig->pos],nh); |
|
} |
|
for ( i = 0; i < nd_nbase; i++ ) |
|
for ( r = syzlist[i]; r; r = NEXT(r) ) |
|
d = remove_spair_s(d,(SIG)BDY(r)); |
|
d = remove_large_lcm(d); |
|
if ( DP_Print ) { |
|
fprintf(asir_out,"f4red=%d,gblen=%d",f4red,nd_psn); fflush(asir_out); |
|
} |
|
f4red++; |
} |
} |
for ( i = 0; i < nd_nbase; i++ ) |
|
for ( r = syzlist[i]; r; r = NEXT(r) ) |
|
d = remove_spair_s(d,(SIG)BDY(r)); |
|
if ( DP_Print ) { |
|
fprintf(asir_out,"f4red=%d,gblen=%d\n",f4red,length(g)); fflush(asir_out); |
|
} |
|
f4red++; |
|
if ( nd_f4red && f4red > nd_f4red ) break; |
|
if ( nd_rank0 && !nflist ) break; |
|
} |
} |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"number of red=%d,",Nf4_red); |
fprintf(asir_out,"\nnumber of red=%d,",Nf4_red); |
} |
} |
g = conv_ilist_s(nd_demand,0,indp); |
g = conv_ilist_s(nd_demand,0,indp); |
return g; |
return g; |