version 1.235, 2017/02/28 07:06:28 |
version 1.246, 2018/04/20 06:24:56 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.234 2017/02/21 09:20:23 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.245 2018/03/29 01:32:52 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 65 static int *nd_gbblock; |
|
Line 65 static int *nd_gbblock; |
|
static NODE nd_nzlist,nd_check_splist; |
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; |
static int nd_f4red,nd_rank0,nd_last_nonzero; |
|
|
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 98 void Pox_cmo_rpc(NODE,Obj *); |
|
Line 98 void Pox_cmo_rpc(NODE,Obj *); |
|
ND nd_add_lf(ND p1,ND p2); |
ND nd_add_lf(ND p1,ND p2); |
void nd_mul_c_lf(ND p,GZ mul); |
void nd_mul_c_lf(ND p,GZ mul); |
void ndv_mul_c_lf(NDV p,GZ mul); |
void ndv_mul_c_lf(NDV p,GZ mul); |
|
NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, |
|
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz); |
|
NODE nd_f4_red_mod64_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, |
|
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz); |
NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int trace,UINT *s0vect,int col, |
NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int trace,UINT *s0vect,int col, |
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred); |
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred); |
int nd_gauss_elim_lf(mpz_t **mat0,int *sugar,int row,int col,int *colstat); |
int nd_gauss_elim_lf(mpz_t **mat0,int *sugar,int row,int col,int *colstat); |
Line 561 int ndl_matrix_compare(UINT *d1,UINT *d2) |
|
Line 565 int ndl_matrix_compare(UINT *d1,UINT *d2) |
|
{ |
{ |
int i,j,s,row; |
int i,j,s,row; |
int *v; |
int *v; |
Q **mat; |
Q **mat; |
Q *w; |
Q *w; |
Q t,t1,t2; |
Q t,t1,t2; |
|
|
for ( j = 0; j < nd_nvar; j++ ) |
for ( j = 0; j < nd_nvar; j++ ) |
nd_work_vector[j] = GET_EXP(d1,j)-GET_EXP(d2,j); |
nd_work_vector[j] = GET_EXP(d1,j)-GET_EXP(d2,j); |
if ( nd_top_weight ) { |
if ( nd_top_weight ) { |
if ( OID(nd_top_weight) == O_VECT ) { |
if ( OID(nd_top_weight) == O_VECT ) { |
mat = (Q **)&BDY((VECT)nd_top_weight); |
mat = (Q **)&BDY((VECT)nd_top_weight); |
row = 1; |
row = 1; |
} else { |
} else { |
mat = (Q **)BDY((MAT)nd_top_weight); |
mat = (Q **)BDY((MAT)nd_top_weight); |
row = ((MAT)nd_top_weight)->row; |
row = ((MAT)nd_top_weight)->row; |
} |
} |
for ( i = 0; i < row; i++ ) { |
for ( i = 0; i < row; i++ ) { |
w = (Q *)mat[i]; |
w = (Q *)mat[i]; |
for ( j = 0, t = 0; j < nd_nvar; j++ ) { |
for ( j = 0, t = 0; j < nd_nvar; j++ ) { |
STOQ(nd_work_vector[j],t1); |
STOQ(nd_work_vector[j],t1); |
mulq(w[j],t1,&t2); |
mulq(w[j],t1,&t2); |
addq(t,t2,&t1); |
addq(t,t2,&t1); |
t = t1; |
t = t1; |
} |
} |
if ( t ) { |
if ( t ) { |
s = SGN(t); |
s = SGN(t); |
if ( s > 0 ) return 1; |
if ( s > 0 ) return 1; |
else if ( s < 0 ) return -1; |
else if ( s < 0 ) return -1; |
} |
} |
} |
} |
} |
} |
for ( i = 0; i < nd_matrix_len; i++ ) { |
for ( i = 0; i < nd_matrix_len; i++ ) { |
v = nd_matrix[i]; |
v = nd_matrix[i]; |
for ( j = 0, s = 0; j < nd_nvar; j++ ) |
for ( j = 0, s = 0; j < nd_nvar; j++ ) |
Line 597 int ndl_matrix_compare(UINT *d1,UINT *d2) |
|
Line 601 int ndl_matrix_compare(UINT *d1,UINT *d2) |
|
if ( s > 0 ) return 1; |
if ( s > 0 ) return 1; |
else if ( s < 0 ) return -1; |
else if ( s < 0 ) return -1; |
} |
} |
if ( !ndl_equal(d1,d2) ) |
if ( !ndl_equal(d1,d2) ) |
error("afo"); |
error("afo"); |
return 0; |
return 0; |
} |
} |
|
|
Line 652 int ndl_composite_compare(UINT *d1,UINT *d2) |
|
Line 656 int ndl_composite_compare(UINT *d1,UINT *d2) |
|
else if ( nd_work_vector[j] < 0 ) return -1; |
else if ( nd_work_vector[j] < 0 ) return -1; |
break; |
break; |
case 2: |
case 2: |
|
end = start+len; |
for ( j = start; j < end; j++ ) |
for ( j = start; j < end; j++ ) |
if ( nd_work_vector[j] > 0 ) return 1; |
if ( nd_work_vector[j] > 0 ) return 1; |
else if ( nd_work_vector[j] < 0 ) return -1; |
else if ( nd_work_vector[j] < 0 ) return -1; |
Line 704 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
Line 709 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) ) return c; |
if ( c = ndl_lex_compare(d1,d2) ) 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; |
if ( MPOS(d1) < MPOS(d2) ) return 1; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
else if ( MPOS(d1) > MPOS(d2) ) return -1; |
} |
} |
Line 1645 int ndv_check_membership(int m,NODE input,int obpe,int |
|
Line 1650 int ndv_check_membership(int m,NODE input,int obpe,int |
|
ndv_setup(m,0,cand,nd_gentrace?1:0,1); |
ndv_setup(m,0,cand,nd_gentrace?1:0,1); |
n = length(cand); |
n = length(cand); |
|
|
if ( nd_gentrace ) { nd_alltracelist = 0; nd_tracelist = 0; } |
if ( nd_gentrace ) { nd_alltracelist = 0; nd_tracelist = 0; } |
/* membercheck : list is a subset of Id(cand) ? */ |
/* membercheck : list is a subset of Id(cand) ? */ |
for ( t = input, i = 0; t; t = NEXT(t), i++ ) { |
for ( t = input, i = 0; t; t = NEXT(t), i++ ) { |
again: |
again: |
nd_tracelist = 0; |
nd_tracelist = 0; |
if ( nd_bpe > obpe ) |
if ( nd_bpe > obpe ) |
r = ndv_dup_realloc((NDV)BDY(t),obpe,oadv,oepos); |
r = ndv_dup_realloc((NDV)BDY(t),obpe,oadv,oepos); |
else |
else |
r = (NDV)BDY(t); |
r = (NDV)BDY(t); |
if ( m ) ndv_mod(m,r); |
if ( m == -2 ) ndv_mod(m,r); |
d = ndvtond(m,r); |
d = ndvtond(m,r); |
stat = nd_nf(m,0,d,nd_ps,0,0,&nf); |
stat = nd_nf(m,0,d,nd_ps,0,0,&nf); |
if ( !stat ) { |
if ( !stat ) { |
nd_reconstruct(0,0); |
nd_reconstruct(0,0); |
goto again; |
goto again; |
} else if ( nf ) return 0; |
} else if ( nf ) return 0; |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
nd_tracelist = reverse_node(nd_tracelist); |
nd_tracelist = reverse_node(nd_tracelist); |
MKLIST(list,nd_tracelist); |
MKLIST(list,nd_tracelist); |
STOQ(i,q); s = mknode(2,q,list); MKLIST(list,s); |
STOQ(i,q); s = mknode(2,q,list); MKLIST(list,s); |
MKNODE(s,list,nd_alltracelist); |
MKNODE(s,list,nd_alltracelist); |
nd_alltracelist = s; nd_tracelist = 0; |
nd_alltracelist = s; nd_tracelist = 0; |
} |
} |
if ( DP_Print ) { printf("."); fflush(stdout); } |
if ( DP_Print ) { printf("."); fflush(stdout); } |
} |
} |
if ( DP_Print ) { printf("\n"); } |
if ( DP_Print ) { printf("\n"); } |
Line 2034 int do_diagonalize(int sugar,int m) |
|
Line 2039 int do_diagonalize(int sugar,int m) |
|
ndv_free(nfv); |
ndv_free(nfv); |
hc = HCU(nf); nd_removecont(m,nf); |
hc = HCU(nf); nd_removecont(m,nf); |
cont = ndc_div(m,hc,HCU(nf)); |
cont = ndc_div(m,hc,HCU(nf)); |
if ( nd_gentrace ) finalize_tracelist(i,cont); |
if ( nd_gentrace ) finalize_tracelist(i,cont); |
nfv = ndtondv(m,nf); |
nfv = ndtondv(m,nf); |
nd_free(nf); |
nd_free(nf); |
nd_bound[i] = ndv_compute_bound(nfv); |
nd_bound[i] = ndv_compute_bound(nfv); |
Line 2050 int do_diagonalize(int sugar,int m) |
|
Line 2055 int do_diagonalize(int sugar,int m) |
|
|
|
LIST compute_splist() |
LIST compute_splist() |
{ |
{ |
NODE g,tn0,tn,node; |
NODE g,tn0,tn,node; |
LIST l0; |
LIST l0; |
ND_pairs d,t; |
ND_pairs d,t; |
int i; |
int i; |
Q i1,i2; |
Q i1,i2; |
|
|
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(d,g,i,0); |
d = update_pairs(d,g,i,0); |
g = update_base(g,i); |
g = update_base(g,i); |
} |
} |
for ( t = d, tn0 = 0; t; t = NEXT(t) ) { |
for ( t = d, tn0 = 0; t; t = NEXT(t) ) { |
NEXTNODE(tn0,tn); |
NEXTNODE(tn0,tn); |
STOQ(t->i1,i1); STOQ(t->i2,i2); |
STOQ(t->i1,i1); STOQ(t->i2,i2); |
node = mknode(2,i1,i2); MKLIST(l0,node); |
node = mknode(2,i1,i2); MKLIST(l0,node); |
BDY(tn) = l0; |
BDY(tn) = l0; |
} |
} |
if ( tn0 ) NEXT(tn) = 0; MKLIST(l0,tn0); |
if ( tn0 ) NEXT(tn) = 0; MKLIST(l0,tn0); |
return l0; |
return l0; |
} |
} |
|
|
/* return value = 0 => input is not a GB */ |
/* return value = 0 => input is not a GB */ |
|
|
goto again; |
goto again; |
} else if ( nf ) { |
} else if ( nf ) { |
if ( checkonly || gensyz ) return 0; |
if ( checkonly || gensyz ) return 0; |
if ( nd_newelim ) { |
if ( nd_newelim ) { |
if ( nd_module ) { |
if ( nd_module ) { |
if ( MPOS(HDL(nf)) > 1 ) return 0; |
if ( MPOS(HDL(nf)) > 1 ) return 0; |
} else if ( !(HDL(nf)[nd_exporigin] & nd_mask[0]) ) return 0; |
} else if ( !(HDL(nf)[nd_exporigin] & nd_mask[0]) ) return 0; |
} |
} |
if ( DP_Print ) { printf("+"); fflush(stdout); } |
if ( DP_Print ) { printf("+"); fflush(stdout); } |
hc = HCU(nf); |
hc = HCU(nf); |
nd_removecont(m,nf); |
nd_removecont(m,nf); |
|
|
nd_removecont(m,nf); |
nd_removecont(m,nf); |
} |
} |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
cont = ndc_div(m,hc,HCU(nf)); |
cont = ndc_div(m,hc,HCU(nf)); |
if ( m || !UNIQ(cont) ) { |
if ( m || !UNIQ(cont) ) { |
t = mknode(4,NULLP,NULLP,NULLP,cont); |
t = mknode(4,NULLP,NULLP,NULLP,cont); |
MKLIST(list,t); MKNODE(t,list,nd_tracelist); |
MKLIST(list,t); MKNODE(t,list,nd_tracelist); |
nd_tracelist = t; |
nd_tracelist = t; |
} |
} |
} |
} |
nfv = ndtondv(m,nf); nd_free(nf); |
nfv = ndtondv(m,nf); nd_free(nf); |
nh = ndv_newps(m,nfv,0,0); |
nh = ndv_newps(m,nfv,0,0); |
|
|
g = update_base(g,nh); |
g = update_base(g,nh); |
FREENDP(l); |
FREENDP(l); |
} else { |
} else { |
if ( nd_gentrace && gensyz ) { |
if ( nd_gentrace && gensyz ) { |
nd_tracelist = reverse_node(nd_tracelist); |
nd_tracelist = reverse_node(nd_tracelist); |
MKLIST(list,nd_tracelist); |
MKLIST(list,nd_tracelist); |
STOQ(-1,q); t = mknode(2,q,list); MKLIST(list,t); |
STOQ(-1,q); t = mknode(2,q,list); MKLIST(list,t); |
MKNODE(t,list,nd_alltracelist); |
MKNODE(t,list,nd_alltracelist); |
nd_alltracelist = t; nd_tracelist = 0; |
nd_alltracelist = t; nd_tracelist = 0; |
} |
} |
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.\n"); fflush(stdout); } |
if ( !checkonly && DP_Print ) { printf("nd_gb done.\n"); fflush(stdout); } |
return g; |
return g; |
} |
} |
|
|
|
|
int check_splist(int m,NODE splist) |
int check_splist(int m,NODE splist) |
{ |
{ |
NODE t,p; |
NODE t,p; |
ND_pairs d,r,l; |
ND_pairs d,r,l; |
int stat; |
int stat; |
ND h,nf; |
ND h,nf; |
|
|
for ( d = 0, t = splist; t; t = NEXT(t) ) { |
for ( d = 0, t = splist; t; t = NEXT(t) ) { |
p = BDY((LIST)BDY(t)); |
p = BDY((LIST)BDY(t)); |
NEXTND_pairs(d,r); |
NEXTND_pairs(d,r); |
r->i1 = QTOS((Q)ARG0(p)); r->i2 = QTOS((Q)ARG1(p)); |
r->i1 = QTOS((Q)ARG0(p)); r->i2 = QTOS((Q)ARG1(p)); |
ndl_lcm(DL(nd_psh[r->i1]),DL(nd_psh[r->i2]),r->lcm); |
ndl_lcm(DL(nd_psh[r->i1]),DL(nd_psh[r->i2]),r->lcm); |
SG(r) = TD(LCM(r)); /* XXX */ |
SG(r) = TD(LCM(r)); /* XXX */ |
} |
} |
if ( d ) NEXT(r) = 0; |
if ( d ) NEXT(r) = 0; |
|
|
while ( d ) { |
while ( d ) { |
again: |
again: |
|
|
d = nd_reconstruct(0,d); |
d = nd_reconstruct(0,d); |
goto again; |
goto again; |
} else if ( nf ) return 0; |
} else if ( nf ) return 0; |
if ( DP_Print) { printf("."); fflush(stdout); } |
if ( DP_Print) { printf("."); fflush(stdout); } |
} |
} |
if ( DP_Print) { printf("done.\n"); fflush(stdout); } |
if ( DP_Print) { printf("done.\n"); fflush(stdout); } |
return 1; |
return 1; |
} |
} |
|
|
int check_splist_f4(int m,NODE splist) |
int check_splist_f4(int m,NODE splist) |
{ |
{ |
UINT *s0vect; |
UINT *s0vect; |
PGeoBucket bucket; |
PGeoBucket bucket; |
NODE p,rp0,t; |
NODE p,rp0,t; |
ND_pairs d,r,l,ll; |
ND_pairs d,r,l,ll; |
int col,stat; |
int col,stat; |
|
|
for ( d = 0, t = splist; t; t = NEXT(t) ) { |
for ( d = 0, t = splist; t; t = NEXT(t) ) { |
p = BDY((LIST)BDY(t)); |
p = BDY((LIST)BDY(t)); |
NEXTND_pairs(d,r); |
NEXTND_pairs(d,r); |
r->i1 = QTOS((Q)ARG0(p)); r->i2 = QTOS((Q)ARG1(p)); |
r->i1 = QTOS((Q)ARG0(p)); r->i2 = QTOS((Q)ARG1(p)); |
ndl_lcm(DL(nd_psh[r->i1]),DL(nd_psh[r->i2]),r->lcm); |
ndl_lcm(DL(nd_psh[r->i1]),DL(nd_psh[r->i2]),r->lcm); |
SG(r) = TD(LCM(r)); /* XXX */ |
SG(r) = TD(LCM(r)); /* XXX */ |
} |
} |
if ( d ) NEXT(r) = 0; |
if ( d ) NEXT(r) = 0; |
|
|
while ( d ) { |
while ( d ) { |
l = nd_minsugarp(d,&d); |
l = nd_minsugarp(d,&d); |
Line 2298 int do_diagonalize_trace(int sugar,int m) |
|
Line 2303 int do_diagonalize_trace(int sugar,int m) |
|
if ( !stat ) return 0; |
if ( !stat ) return 0; |
ndv_free(nfv); |
ndv_free(nfv); |
hc = HCU(nf); nd_removecont(0,nf); |
hc = HCU(nf); nd_removecont(0,nf); |
cont = ndc_div(0,hc,HCU(nf)); |
cont = ndc_div(0,hc,HCU(nf)); |
if ( nd_gentrace ) finalize_tracelist(i,cont); |
if ( nd_gentrace ) finalize_tracelist(i,cont); |
nfv = ndtondv(0,nf); |
nfv = ndtondv(0,nf); |
nd_free(nf); |
nd_free(nf); |
|
|
nd_removecont(m,nf); nfv = ndtondv(m,nf); nd_free(nf); |
nd_removecont(m,nf); nfv = ndtondv(m,nf); nd_free(nf); |
} |
} |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
cont = ndc_div(0,hnfq,HCU(nfqv)); |
cont = ndc_div(0,hnfq,HCU(nfqv)); |
if ( !UNIQ(cont) ) { |
if ( !UNIQ(cont) ) { |
t = mknode(4,NULLP,NULLP,NULLP,cont); |
t = mknode(4,NULLP,NULLP,NULLP,cont); |
MKLIST(list,t); MKNODE(t,list,nd_tracelist); |
MKLIST(list,t); MKNODE(t,list,nd_tracelist); |
nd_tracelist = t; |
nd_tracelist = t; |
} |
} |
} |
} |
nh = ndv_newps(0,nfv,nfqv,0); |
nh = ndv_newps(0,nfv,nfqv,0); |
if ( ishomo && ++diag_count == diag_period ) { |
if ( ishomo && ++diag_count == diag_period ) { |
|
|
print_eg("le",&eg_le); |
print_eg("le",&eg_le); |
} |
} |
} |
} |
conv_ilist(nd_demand,1,g,indp); |
conv_ilist(nd_demand,1,g,indp); |
if ( DP_Print ) { printf("nd_gb_trace done.\n"); fflush(stdout); } |
if ( DP_Print ) { printf("nd_gb_trace done.\n"); fflush(stdout); } |
return g; |
return g; |
} |
} |
Line 2492 NODE ndv_reduceall(int m,NODE f) |
|
Line 2497 NODE ndv_reduceall(int m,NODE f) |
|
union oNDC dn; |
union oNDC dn; |
Q q,num,den; |
Q q,num,den; |
NODE node; |
NODE node; |
LIST l; |
LIST l; |
Q iq,jq; |
Q iq,jq; |
int *perm; |
int *perm; |
union oNDC hc; |
union oNDC hc; |
P cont,cont1; |
P cont,cont1; |
Line 2501 NODE ndv_reduceall(int m,NODE f) |
|
Line 2506 NODE ndv_reduceall(int m,NODE f) |
|
if ( nd_nora ) return f; |
if ( nd_nora ) return f; |
n = length(f); |
n = length(f); |
ndv_setup(m,0,f,0,1); |
ndv_setup(m,0,f,0,1); |
perm = (int *)MALLOC(n*sizeof(int)); |
perm = (int *)MALLOC(n*sizeof(int)); |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
for ( t = nd_tracelist, i = 0; i < n; i++, t = NEXT(t) ) |
for ( t = nd_tracelist, i = 0; i < n; i++, t = NEXT(t) ) |
perm[i] = QTOS((Q)ARG1(BDY((LIST)BDY(t)))); |
perm[i] = QTOS((Q)ARG1(BDY((LIST)BDY(t)))); |
} |
} |
for ( i = 0; i < n; ) { |
for ( i = 0; i < n; ) { |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
/* Trace = [1,index,1,1] */ |
/* Trace = [1,index,1,1] */ |
Line 2522 NODE ndv_reduceall(int m,NODE f) |
|
Line 2527 NODE ndv_reduceall(int m,NODE f) |
|
ndv_free(nd_ps[i]); |
ndv_free(nd_ps[i]); |
hc = HCU(nf); nd_removecont(m,nf); |
hc = HCU(nf); nd_removecont(m,nf); |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
for ( t = nd_tracelist; t; t = NEXT(t) ) { |
for ( t = nd_tracelist; t; t = NEXT(t) ) { |
jq = ARG1(BDY((LIST)BDY(t))); j = QTOS(jq); |
jq = ARG1(BDY((LIST)BDY(t))); j = QTOS(jq); |
STOQ(perm[j],jq); ARG1(BDY((LIST)BDY(t))) = jq; |
STOQ(perm[j],jq); ARG1(BDY((LIST)BDY(t))) = jq; |
} |
} |
Line 2537 NODE ndv_reduceall(int m,NODE f) |
|
Line 2542 NODE ndv_reduceall(int m,NODE f) |
|
if ( DP_Print ) { printf("\n"); } |
if ( DP_Print ) { printf("\n"); } |
for ( a0 = 0, i = 0; i < n; i++ ) { |
for ( a0 = 0, i = 0; i < n; i++ ) { |
NEXTNODE(a0,a); |
NEXTNODE(a0,a); |
if ( !nd_gentrace ) BDY(a) = (pointer)nd_ps[i]; |
if ( !nd_gentrace ) BDY(a) = (pointer)nd_ps[i]; |
else { |
else { |
for ( j = 0; j < n; j++ ) if ( perm[j] == i ) break; |
for ( j = 0; j < n; j++ ) if ( perm[j] == i ) break; |
BDY(a) = (pointer)nd_ps[j]; |
BDY(a) = (pointer)nd_ps[j]; |
} |
|
} |
} |
|
} |
NEXT(a) = 0; |
NEXT(a) = 0; |
return a0; |
return a0; |
} |
} |
Line 2552 ND_pairs update_pairs( ND_pairs d, NODE /* of index */ |
|
Line 2557 ND_pairs update_pairs( ND_pairs d, NODE /* of index */ |
|
ND_pairs d1,nd,cur,head,prev,remove; |
ND_pairs d1,nd,cur,head,prev,remove; |
|
|
if ( !g ) return d; |
if ( !g ) return d; |
/* for testing */ |
/* for testing */ |
if ( gensyz && nd_gensyz == 2 ) { |
if ( gensyz && nd_gensyz == 2 ) { |
d1 = nd_newpairs(g,t); |
d1 = nd_newpairs(g,t); |
if ( !d ) |
if ( !d ) |
return d1; |
return d1; |
else { |
else { |
nd = d; |
nd = d; |
while ( NEXT(nd) ) nd = NEXT(nd); |
while ( NEXT(nd) ) nd = NEXT(nd); |
NEXT(nd) = d1; |
NEXT(nd) = d1; |
return d; |
return d; |
} |
} |
} |
} |
d = crit_B(d,t); |
d = crit_B(d,t); |
d1 = nd_newpairs(g,t); |
d1 = nd_newpairs(g,t); |
d1 = crit_M(d1); |
d1 = crit_M(d1); |
Line 2603 ND_pairs nd_newpairs( NODE g, int t ) |
|
Line 2608 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) > 1) ) 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; |
if ( nd_gbblock ) { |
if ( nd_gbblock ) { |
t0 = (long)BDY(h); |
t0 = (long)BDY(h); |
for ( i = 0; nd_gbblock[i] >= 0; i += 2 ) { |
for ( i = 0; nd_gbblock[i] >= 0; i += 2 ) { |
min = nd_gbblock[i]; max = nd_gbblock[i+1]; |
min = nd_gbblock[i]; max = nd_gbblock[i+1]; |
if ( t0 >= min && t0 <= max && t >= min && t <= max ) |
if ( t0 >= min && t0 <= max && t >= min && t <= max ) |
break; |
break; |
} |
} |
if ( nd_gbblock[i] >= 0 ) |
if ( nd_gbblock[i] >= 0 ) |
continue; |
continue; |
} |
} |
NEXTND_pairs(r0,r); |
NEXTND_pairs(r0,r); |
r->i1 = (long)BDY(h); |
r->i1 = (long)BDY(h); |
r->i2 = t; |
r->i2 = t; |
Line 2908 ND_pairs nd_minsugarp( ND_pairs d, ND_pairs *prest ) |
|
Line 2913 ND_pairs nd_minsugarp( ND_pairs d, ND_pairs *prest ) |
|
return dm0; |
return dm0; |
} |
} |
|
|
|
int nd_tdeg(NDV c) |
|
{ |
|
int wmax = 0; |
|
int i,len; |
|
NMV a; |
|
|
|
len = LEN(c); |
|
for ( a = BDY(c), i = 0; i < len; i++, NMV_ADV(a) ) |
|
wmax = MAX(TD(DL(a)),wmax); |
|
return wmax; |
|
} |
|
|
int ndv_newps(int m,NDV a,NDV aq,int f4) |
int ndv_newps(int m,NDV a,NDV aq,int f4) |
{ |
{ |
int len; |
int len; |
Line 2933 int ndv_newps(int m,NDV a,NDV aq,int f4) |
|
Line 2950 int ndv_newps(int m,NDV a,NDV aq,int f4) |
|
if ( aq ) { |
if ( aq ) { |
nd_ps_trace[nd_psn] = aq; |
nd_ps_trace[nd_psn] = aq; |
if ( !m ) { |
if ( !m ) { |
if ( !nd_vc ) nd_ps_gz[nd_psn] = ndvtondvgz(aq); |
if ( !nd_vc ) nd_ps_gz[nd_psn] = ndvtondvgz(aq); |
register_hcf(aq); |
register_hcf(aq); |
} else if ( m == -2 ) { |
} else if ( m == -2 ) { |
/* do nothing */ |
/* do nothing */ |
} else |
} else |
error("ndv_newps : invalud modulus"); |
error("ndv_newps : invalud modulus"); |
nd_bound[nd_psn] = ndv_compute_bound(aq); |
nd_bound[nd_psn] = ndv_compute_bound(aq); |
SG(r) = SG(aq); ndl_copy(HDL(aq),DL(r)); |
#if 1 |
|
SG(r) = SG(aq); |
|
#else |
|
SG(r) = nd_tdeg(aq); |
|
#endif |
|
ndl_copy(HDL(aq),DL(r)); |
} else { |
} else { |
if ( !m ) register_hcf(a); |
if ( !m ) register_hcf(a); |
nd_bound[nd_psn] = ndv_compute_bound(a); |
nd_bound[nd_psn] = ndv_compute_bound(a); |
SG(r) = SG(a); ndl_copy(HDL(a),DL(r)); |
#if 1 |
if ( !m && !nd_vc ) nd_ps_gz[nd_psn] = ndvtondvgz(a); |
SG(r) = SG(a); |
|
#else |
|
SG(r) = nd_tdeg(a); |
|
#endif |
|
ndl_copy(HDL(a),DL(r)); |
|
if ( !m && !nd_vc ) nd_ps_gz[nd_psn] = ndvtondvgz(a); |
} |
} |
if ( nd_demand ) { |
if ( nd_demand ) { |
if ( aq ) { |
if ( aq ) { |
Line 3031 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
Line 3058 int ndv_setup(int mod,int trace,NODE f,int dont_sort,i |
|
if ( !dont_removecont) ndv_removecont(-2,a); |
if ( !dont_removecont) ndv_removecont(-2,a); |
am = nd_ps[i] = ndv_dup(trace,w[i].p); |
am = nd_ps[i] = ndv_dup(trace,w[i].p); |
ndv_mod(trace,am); |
ndv_mod(trace,am); |
if ( DL_COMPARE(HDL(am),HDL(a)) ) |
if ( DL_COMPARE(HDL(am),HDL(a)) ) |
return 0; |
return 0; |
ndv_removecont(trace,am); |
ndv_removecont(trace,am); |
} else { |
} else { |
a = nd_ps_trace[i] = ndv_dup(0,w[i].p); |
a = nd_ps_trace[i] = ndv_dup(0,w[i].p); |
if ( !nd_vc ) nd_ps_gz[i] = ndvtondvgz(a); |
if ( !nd_vc ) nd_ps_gz[i] = ndvtondvgz(a); |
if ( !dont_removecont) ndv_removecont(0,a); |
if ( !dont_removecont) ndv_removecont(0,a); |
register_hcf(a); |
register_hcf(a); |
am = nd_ps[i] = ndv_dup(mod,a); |
am = nd_ps[i] = ndv_dup(mod,a); |
ndv_mod(mod,am); |
ndv_mod(mod,am); |
if ( DL_COMPARE(HDL(am),HDL(a)) ) |
if ( DL_COMPARE(HDL(am),HDL(a)) ) |
return 0; |
return 0; |
ndv_removecont(mod,am); |
ndv_removecont(mod,am); |
} |
} |
} else { |
} else { |
a = nd_ps[i] = ndv_dup(mod,w[i].p); |
a = nd_ps[i] = ndv_dup(mod,w[i].p); |
if ( !mod && !nd_vc ) nd_ps_gz[i] = ndvtondvgz(a); |
if ( !mod && !nd_vc ) nd_ps_gz[i] = ndvtondvgz(a); |
if ( mod || !dont_removecont ) ndv_removecont(mod,a); |
if ( mod || !dont_removecont ) ndv_removecont(mod,a); |
if ( !mod ) register_hcf(a); |
if ( !mod ) register_hcf(a); |
} |
} |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
STOQ(i,iq); STOQ(w[i].i,jq); node = mknode(3,iq,jq,ONE); |
STOQ(i,iq); STOQ(w[i].i,jq); node = mknode(3,iq,jq,ONE); |
if ( !dont_removecont ) |
if ( !dont_removecont ) |
ARG2(node) = (pointer)ndc_div(trace?0:mod,hc,HCU(a)); |
ARG2(node) = (pointer)ndc_div(trace?0:mod,hc,HCU(a)); |
MKLIST(l,node); NEXTNODE(nd_tracelist,tn); BDY(tn) = l; |
MKLIST(l,node); NEXTNODE(nd_tracelist,tn); BDY(tn) = l; |
} |
} |
Line 3119 void preprocess_algcoef(VL vv,VL av,struct order_spec |
|
Line 3146 void preprocess_algcoef(VL vv,VL av,struct order_spec |
|
if ( NID(hc) == N_DA ) { |
if ( NID(hc) == N_DA ) { |
invdalg(hc,&inv); |
invdalg(hc,&inv); |
for ( m = BDY(d); m; m = NEXT(m) ) { |
for ( m = BDY(d); m; m = NEXT(m) ) { |
muldalg(inv,(DAlg)m->c,&da); m->c = (P)da; |
muldalg(inv,(DAlg)m->c,&da); m->c = (Obj)da; |
} |
} |
} |
} |
initd(ord); dtop(vv,vv,d,&poly); BDY(f) = (pointer)poly; |
initd(ord); dtop(vv,vv,d,(Obj *)&poly); BDY(f) = (pointer)poly; |
} |
} |
obj_dalgtoalg((Obj)f1,(Obj *)&f); |
obj_dalgtoalg((Obj)f1,(Obj *)&f); |
|
|
Line 3190 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3217 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
int e,max,nvar,i; |
int e,max,nvar,i; |
NDV b; |
NDV b; |
int ishomo,nalg,mrank,trank,wmax,len; |
int ishomo,nalg,mrank,trank,wmax,len; |
NMV a; |
NMV a; |
Alg alpha,dp; |
Alg alpha,dp; |
P p,zp; |
P p,zp; |
Q dmy; |
Q dmy; |
Line 3200 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3227 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
struct order_spec *ord1; |
struct order_spec *ord1; |
NODE tr,tl1,tl2,tl3,tl4,nzlist; |
NODE tr,tl1,tl2,tl3,tl4,nzlist; |
LIST l1,l2,l3,l4,l5; |
LIST l1,l2,l3,l4,l5; |
int j; |
int j; |
Q jq,bpe; |
Q jq,bpe,last_nonzero; |
int *perm; |
int *perm; |
EPOS oepos; |
EPOS oepos; |
int obpe,oadv,ompos,cbpe; |
int obpe,oadv,ompos,cbpe; |
Line 3265 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3292 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 ( !m && !nd_gentrace ) pltozpl((LIST)BDY(t),&dmy,&zpl); |
else zpl = (LIST)BDY(t); |
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); |
b = (pointer)ptondv(CO,vv,zp); |
b = (pointer)ptondv(CO,vv,zp); |
} |
} |
if ( ishomo ) |
if ( ishomo ) |
Line 3280 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3307 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
} |
} |
if ( fd0 ) NEXT(fd) = 0; |
if ( fd0 ) NEXT(fd) = 0; |
|
|
if ( !ishomo && homo ) { |
if ( !ishomo && homo ) { |
for ( t = fd0, wmax = max; t; t = NEXT(t) ) { |
for ( t = fd0, wmax = max; t; t = NEXT(t) ) { |
b = (NDV)BDY(t); len = LEN(b); |
b = (NDV)BDY(t); len = LEN(b); |
for ( a = BDY(b), i = 0; i < len; i++, NMV_ADV(a) ) |
for ( a = BDY(b), i = 0; i < len; i++, NMV_ADV(a) ) |
Line 3288 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3315 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
} |
} |
homogenize_order(ord,nvar,&ord1); |
homogenize_order(ord,nvar,&ord1); |
nd_init_ord(ord1); |
nd_init_ord(ord1); |
nd_setup_parameters(nvar+1,wmax); |
nd_setup_parameters(nvar+1,nd_nzlist?0:wmax); |
for ( t = fd0; t; t = NEXT(t) ) |
for ( t = fd0; t; t = NEXT(t) ) |
ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos,ompos); |
ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos,ompos); |
} |
} |
Line 3297 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3324 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
MKLIST(l1,nd_tracelist); MKNODE(nd_alltracelist,l1,0); |
MKLIST(l1,nd_tracelist); MKNODE(nd_alltracelist,l1,0); |
} |
} |
if ( nd_splist ) { |
if ( nd_splist ) { |
*rp = compute_splist(); |
*rp = compute_splist(); |
return; |
return; |
} |
} |
if ( nd_check_splist ) { |
if ( nd_check_splist ) { |
if ( f4 ) { |
if ( f4 ) { |
if ( check_splist_f4(m,nd_check_splist) ) *rp = (LIST)ONE; |
if ( check_splist_f4(m,nd_check_splist) ) *rp = (LIST)ONE; |
else *rp = 0; |
else *rp = 0; |
Line 3309 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3336 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
if ( check_splist(m,nd_check_splist) ) *rp = (LIST)ONE; |
if ( check_splist(m,nd_check_splist) ) *rp = (LIST)ONE; |
else *rp = 0; |
else *rp = 0; |
} |
} |
return; |
return; |
} |
} |
x = f4?nd_f4(m,0,&perm):nd_gb(m,ishomo || homo,0,0,&perm); |
x = f4?nd_f4(m,0,&perm):nd_gb(m,ishomo || homo,0,0,&perm); |
if ( !x ) { |
if ( !x ) { |
*rp = 0; return; |
*rp = 0; return; |
} |
} |
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); |
nd_init_ord(ord); |
nd_init_ord(ord); |
nd_setup_parameters(nvar,0); |
nd_setup_parameters(nvar,0); |
} |
} |
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])) > 1 ) { |
MKNODE(xx,(pointer)j,x); x = xx; |
MKNODE(xx,(pointer)j,x); x = xx; |
} |
} |
conv_ilist(nd_demand,0,x,0); |
conv_ilist(nd_demand,0,x,0); |
goto FINAL; |
goto FINAL; |
} |
} |
if ( nd_gentrace && f4 ) { nzlist = nd_alltracelist; } |
if ( nd_gentrace && f4 ) { nzlist = nd_alltracelist; } |
x = ndv_reducebase(x,perm); |
x = ndv_reducebase(x,perm); |
if ( nd_gentrace && !f4 ) { tl1 = nd_alltracelist; nd_alltracelist = 0; } |
if ( nd_gentrace && !f4 ) { tl1 = nd_alltracelist; nd_alltracelist = 0; } |
Line 3340 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3367 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
ndv_check_membership(m,fd0,obpe,oadv,oepos,x); |
ndv_check_membership(m,fd0,obpe,oadv,oepos,x); |
tl3 = nd_alltracelist; nd_alltracelist = 0; |
tl3 = nd_alltracelist; nd_alltracelist = 0; |
if ( nd_gensyz ) { |
if ( nd_gensyz ) { |
nd_gb(m,0,1,1,0); |
nd_gb(m,0,1,1,0); |
tl4 = nd_alltracelist; nd_alltracelist = 0; |
tl4 = nd_alltracelist; nd_alltracelist = 0; |
} else tl4 = 0; |
} else tl4 = 0; |
} |
} |
|
|
NEXTNODE(r0,r); |
NEXTNODE(r0,r); |
if ( nd_module ) BDY(r) = ndvtopl(m,CO,vv,BDY(t),mrank); |
if ( nd_module ) BDY(r) = ndvtopl(m,CO,vv,BDY(t),mrank); |
else if ( retdp ) BDY(r) = ndvtodp(m,BDY(t)); |
else if ( retdp ) BDY(r) = ndvtodp(m,BDY(t)); |
else 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; |
if ( !m && nd_nalg ) |
if ( !m && nd_nalg ) |
r0 = postprocess_algcoef(av,alist,r0); |
r0 = postprocess_algcoef(av,alist,r0); |
MKLIST(*rp,r0); |
MKLIST(*rp,r0); |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
if ( f4 ) { |
if ( f4 ) { |
STOQ(16,bpe); |
STOQ(16,bpe); |
tr = mknode(4,*rp,(!ishomo&&homo)?ONE:0,BDY(nzlist),bpe); MKLIST(*rp,tr); |
STOQ(nd_last_nonzero,last_nonzero); |
|
tr = mknode(5,*rp,(!ishomo&&homo)?ONE:0,BDY(nzlist),bpe,last_nonzero); 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); |
Line 3458 void nd_gr_postproc(LIST f,LIST v,int m,struct order_s |
|
Line 3487 void nd_gr_postproc(LIST f,LIST v,int m,struct order_s |
|
} |
} |
} else { |
} else { |
#if 0 |
#if 0 |
/* bug ? */ |
/* bug ? */ |
for ( t = x; t; t = NEXT(t) ) |
for ( t = x; t; t = NEXT(t) ) |
BDY(t) = (pointer)nd_ps[(long)BDY(t)]; |
BDY(t) = (pointer)nd_ps[(long)BDY(t)]; |
#else |
#else |
conv_ilist(0,0,x,&perm); |
conv_ilist(0,0,x,&perm); |
#endif |
#endif |
} |
} |
x = ndv_reducebase(x,perm); |
x = ndv_reducebase(x,perm); |
Line 3482 void nd_gr_recompute_trace(LIST f,LIST v,int m,struct |
|
Line 3511 void nd_gr_recompute_trace(LIST f,LIST v,int m,struct |
|
|
|
NDV recompute_trace(NODE ti,NDV *p,int mod) |
NDV recompute_trace(NODE ti,NDV *p,int mod) |
{ |
{ |
int c,c1,c2,i; |
int c,c1,c2,i; |
NM mul,m,tail; |
NM mul,m,tail; |
ND d,r,rm; |
ND d,r,rm; |
NODE sj; |
NODE sj; |
NDV red; |
NDV red; |
Obj mj; |
Obj mj; |
static int afo=0; |
static int afo=0; |
|
|
afo++; |
afo++; |
mul = (NM)MALLOC(sizeof(struct oNM)+(nd_wpd-1)*sizeof(UINT)); |
mul = (NM)MALLOC(sizeof(struct oNM)+(nd_wpd-1)*sizeof(UINT)); |
CM(mul) = 1; |
CM(mul) = 1; |
tail = 0; |
tail = 0; |
for ( i = 0, d = r = 0; ti; ti = NEXT(ti), i++ ) { |
for ( i = 0, d = r = 0; ti; ti = NEXT(ti), i++ ) { |
sj = BDY((LIST)BDY(ti)); |
sj = BDY((LIST)BDY(ti)); |
if ( ARG0(sj) ) { |
if ( ARG0(sj) ) { |
red = p[QTOS((Q)ARG1(sj))]; |
red = p[QTOS((Q)ARG1(sj))]; |
mj = (Obj)ARG2(sj); |
mj = (Obj)ARG2(sj); |
if ( OID(mj) != O_DP ) ndl_zero(DL(mul)); |
if ( OID(mj) != O_DP ) ndl_zero(DL(mul)); |
else dltondl(nd_nvar,BDY((DP)mj)->dl,DL(mul)); |
else dltondl(nd_nvar,BDY((DP)mj)->dl,DL(mul)); |
rm = ndv_mul_nm(mod,mul,red); |
rm = ndv_mul_nm(mod,mul,red); |
if ( !r ) r = rm; |
if ( !r ) r = rm; |
else { |
else { |
for ( m = BDY(r); m && !ndl_equal(m->dl,BDY(rm)->dl); m = NEXT(m), LEN(r)-- ) { |
for ( m = BDY(r); m && !ndl_equal(m->dl,BDY(rm)->dl); m = NEXT(m), LEN(r)-- ) { |
if ( d ) { |
if ( d ) { |
NEXT(tail) = m; tail = m; LEN(d)++; |
NEXT(tail) = m; tail = m; LEN(d)++; |
} else { |
} else { |
MKND(nd_nvar,m,1,d); tail = BDY(d); |
MKND(nd_nvar,m,1,d); tail = BDY(d); |
} |
} |
} |
} |
if ( !m ) return 0; /* failure */ |
if ( !m ) return 0; /* failure */ |
else { |
else { |
BDY(r) = m; |
BDY(r) = m; |
if ( mod > 0 || mod == -1 ) { |
if ( mod > 0 || mod == -1 ) { |
c1 = invm(HCM(rm),mod); c2 = mod-HCM(r); |
c1 = invm(HCM(rm),mod); c2 = mod-HCM(r); |
DMAR(c1,c2,0,mod,c); |
DMAR(c1,c2,0,mod,c); |
nd_mul_c(mod,rm,c); |
nd_mul_c(mod,rm,c); |
} else { |
} else { |
GZ t,u; |
GZ t,u; |
|
|
Line 3525 NDV recompute_trace(NODE ti,NDV *p,int mod) |
|
Line 3554 NDV recompute_trace(NODE ti,NDV *p,int mod) |
|
divlf(t,HCZ(rm),&u); |
divlf(t,HCZ(rm),&u); |
nd_mul_c_lf(rm,u); |
nd_mul_c_lf(rm,u); |
} |
} |
r = nd_add(mod,r,rm); |
r = nd_add(mod,r,rm); |
} |
} |
} |
} |
} |
} |
} |
} |
if ( tail ) NEXT(tail) = 0; |
if ( tail ) NEXT(tail) = 0; |
d = nd_add(mod,d,r); |
d = nd_add(mod,d,r); |
nd_mul_c(mod,d,invm(HCM(d),mod)); |
nd_mul_c(mod,d,invm(HCM(d),mod)); |
return ndtondv(mod,d); |
return ndtondv(mod,d); |
} |
} |
|
|
void nd_gr_recompute_trace(LIST f,LIST v,int m,struct order_spec *ord,LIST tlist,LIST *rp) |
void nd_gr_recompute_trace(LIST f,LIST v,int m,struct order_spec *ord,LIST tlist,LIST *rp) |
Line 3550 void nd_gr_recompute_trace(LIST f,LIST v,int m,struct |
|
Line 3579 void nd_gr_recompute_trace(LIST f,LIST v,int m,struct |
|
Obj obj; |
Obj obj; |
NumberField nf; |
NumberField nf; |
struct order_spec *ord1; |
struct order_spec *ord1; |
NODE permtrace,intred,ind,perm,trace,ti; |
NODE permtrace,intred,ind,perm,trace,ti; |
int len,n,j; |
int len,n,j; |
NDV *db,*pb; |
NDV *db,*pb; |
|
|
parse_nd_option(current_option); |
parse_nd_option(current_option); |
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 3566 void nd_gr_recompute_trace(LIST f,LIST v,int m,struct |
|
Line 3595 void nd_gr_recompute_trace(LIST f,LIST v,int m,struct |
|
break; |
break; |
} |
} |
nd_init_ord(ord); |
nd_init_ord(ord); |
nd_bpe = QTOS((Q)ARG7(BDY(tlist))); |
nd_bpe = QTOS((Q)ARG7(BDY(tlist))); |
nd_setup_parameters(nvar,0); |
nd_setup_parameters(nvar,0); |
|
|
len = length(BDY(f)); |
len = length(BDY(f)); |
db = (NDV *)MALLOC(len*sizeof(NDV *)); |
db = (NDV *)MALLOC(len*sizeof(NDV *)); |
for ( i = 0, t = BDY(f); t; i++, t = NEXT(t) ) { |
for ( i = 0, t = BDY(f); t; i++, t = NEXT(t) ) { |
ptozp((P)BDY(t),1,&dmy,&zp); |
ptozp((P)BDY(t),1,&dmy,&zp); |
b = ptondv(CO,vv,zp); |
b = ptondv(CO,vv,zp); |
ndv_mod(m,b); |
ndv_mod(m,b); |
ndv_mul_c(m,b,invm(HCM(b),m)); |
ndv_mul_c(m,b,invm(HCM(b),m)); |
db[i] = b; |
db[i] = b; |
} |
} |
|
|
permtrace = BDY((LIST)ARG2(BDY(tlist))); |
permtrace = BDY((LIST)ARG2(BDY(tlist))); |
intred = BDY((LIST)ARG3(BDY(tlist))); |
intred = BDY((LIST)ARG3(BDY(tlist))); |
ind = BDY((LIST)ARG4(BDY(tlist))); |
ind = BDY((LIST)ARG4(BDY(tlist))); |
perm = BDY((LIST)ARG0(permtrace)); |
perm = BDY((LIST)ARG0(permtrace)); |
trace = NEXT(permtrace); |
trace = NEXT(permtrace); |
|
|
for ( i = length(perm)-1, t = trace; t; t = NEXT(t) ) { |
for ( i = length(perm)-1, t = trace; t; t = NEXT(t) ) { |
j = QTOS((Q)ARG0(BDY((LIST)BDY(t)))); |
j = QTOS((Q)ARG0(BDY((LIST)BDY(t)))); |
if ( j > i ) i = j; |
if ( j > i ) i = j; |
} |
} |
n = i+1; |
n = i+1; |
pb = (NDV *)MALLOC(n*sizeof(NDV *)); |
pb = (NDV *)MALLOC(n*sizeof(NDV *)); |
for ( t = perm, i = 0; t; t = NEXT(t), i++ ) { |
for ( t = perm, i = 0; t; t = NEXT(t), i++ ) { |
ti = BDY((LIST)BDY(t)); |
ti = BDY((LIST)BDY(t)); |
pb[QTOS((Q)ARG0(ti))] = db[QTOS((Q)ARG1(ti))]; |
pb[QTOS((Q)ARG0(ti))] = db[QTOS((Q)ARG1(ti))]; |
} |
} |
for ( t = trace; t; t = NEXT(t) ) { |
for ( t = trace; t; t = NEXT(t) ) { |
ti = BDY((LIST)BDY(t)); |
ti = BDY((LIST)BDY(t)); |
pb[QTOS((Q)ARG0(ti))] = recompute_trace(BDY((LIST)ARG1(ti)),pb,m); |
pb[QTOS((Q)ARG0(ti))] = recompute_trace(BDY((LIST)ARG1(ti)),pb,m); |
if ( !pb[QTOS((Q)ARG0(ti))] ) { *rp = 0; return; } |
if ( !pb[QTOS((Q)ARG0(ti))] ) { *rp = 0; return; } |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"."); fflush(asir_out); |
fprintf(asir_out,"."); fflush(asir_out); |
} |
} |
} |
} |
for ( t = intred; t; t = NEXT(t) ) { |
for ( t = intred; t; t = NEXT(t) ) { |
ti = BDY((LIST)BDY(t)); |
ti = BDY((LIST)BDY(t)); |
pb[QTOS((Q)ARG0(ti))] = recompute_trace(BDY((LIST)ARG1(ti)),pb,m); |
pb[QTOS((Q)ARG0(ti))] = recompute_trace(BDY((LIST)ARG1(ti)),pb,m); |
if ( !pb[QTOS((Q)ARG0(ti))] ) { *rp = 0; return; } |
if ( !pb[QTOS((Q)ARG0(ti))] ) { *rp = 0; return; } |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"*"); fflush(asir_out); |
fprintf(asir_out,"*"); fflush(asir_out); |
} |
} |
} |
} |
for ( r0 = 0, t = ind; t; t = NEXT(t) ) { |
for ( r0 = 0, t = ind; t; t = NEXT(t) ) { |
NEXTNODE(r0,r); |
NEXTNODE(r0,r); |
b = pb[QTOS((Q)BDY(t))]; |
b = pb[QTOS((Q)BDY(t))]; |
ndv_mul_c(m,b,invm(HCM(b),m)); |
ndv_mul_c(m,b,invm(HCM(b),m)); |
#if 0 |
#if 0 |
BDY(r) = ndvtop(m,CO,vv,pb[QTOS((Q)BDY(t))]); |
BDY(r) = ndvtop(m,CO,vv,pb[QTOS((Q)BDY(t))]); |
Line 3720 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3749 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 ( !nd_gentrace ) pltozpl((LIST)BDY(t),&dmy,&zpl); |
else zpl = (LIST)BDY(t); |
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 ) |
Line 3751 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3780 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
} |
} |
if ( MaxDeg > 0 ) nocheck = 1; |
if ( MaxDeg > 0 ) nocheck = 1; |
while ( 1 ) { |
while ( 1 ) { |
tl1 = tl2 = tl3 = tl4 = 0; |
tl1 = tl2 = tl3 = tl4 = 0; |
if ( Demand ) |
if ( Demand ) |
nd_demand = 1; |
nd_demand = 1; |
ret = ndv_setup(m,1,fd0,nd_gbblock?1:0,0); |
ret = ndv_setup(m,1,fd0,nd_gbblock?1:0,0); |
Line 3783 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3812 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
break; |
break; |
if ( ret = ndv_check_membership(0,in0,obpe,oadv,oepos,cand) ) { |
if ( ret = ndv_check_membership(0,in0,obpe,oadv,oepos,cand) ) { |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
tl3 = nd_alltracelist; nd_alltracelist = 0; |
tl3 = nd_alltracelist; nd_alltracelist = 0; |
} else tl3 = 0; |
} else tl3 = 0; |
/* gbcheck : cand is a GB of Id(cand) ? */ |
/* gbcheck : cand is a GB of Id(cand) ? */ |
if ( nd_vc || nd_gentrace || nd_gensyz ) |
if ( nd_vc || nd_gentrace || nd_gensyz ) |
ret = nd_gb(0,0,1,nd_gensyz?1:0,0)!=0; |
ret = nd_gb(0,0,1,nd_gensyz?1:0,0)!=0; |
else |
else |
ret = nd_f4(0,1,0)!=0; |
ret = nd_f4(0,1,0)!=0; |
if ( nd_gentrace && nd_gensyz ) { |
if ( nd_gentrace && nd_gensyz ) { |
tl4 = nd_alltracelist; nd_alltracelist = 0; |
tl4 = nd_alltracelist; nd_alltracelist = 0; |
} else tl4 = 0; |
} else tl4 = 0; |
} |
} |
if ( ret ) break; |
if ( ret ) break; |
else if ( trace > 1 ) { |
else if ( trace > 1 ) { |
/* failure */ |
/* failure */ |
*rp = 0; return; |
*rp = 0; return; |
Line 3813 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3842 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
} |
} |
get_eg(&eg1); init_eg(&eg_check); add_eg(&eg_check,&eg0,&eg1); |
get_eg(&eg1); init_eg(&eg_check); add_eg(&eg_check,&eg0,&eg1); |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"check=%fsec\n",eg_check.exectime+eg_check.gctime); |
fprintf(asir_out,"check=%.3fsec,",eg_check.exectime+eg_check.gctime); |
/* dp->p */ |
/* dp->p */ |
nd_bpe = cbpe; |
nd_bpe = cbpe; |
nd_setup_parameters(nd_nvar,0); |
nd_setup_parameters(nd_nvar,0); |
Line 3826 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 3855 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
MKLIST(*rp,cand); |
MKLIST(*rp,cand); |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
tl1 = reverse_node(tl1); tl2 = reverse_node(tl2); |
tl1 = reverse_node(tl1); tl2 = reverse_node(tl2); |
tl3 = reverse_node(tl3); |
tl3 = reverse_node(tl3); |
/* tl2 = [[i,[[*,j,*,*],...]],...] */ |
/* tl2 = [[i,[[*,j,*,*],...]],...] */ |
for ( t = tl2; t; t = NEXT(t) ) { |
for ( t = tl2; t; t = NEXT(t) ) { |
/* s = [i,[*,j,*,*],...] */ |
/* s = [i,[*,j,*,*],...] */ |
s = BDY((LIST)BDY(t)); |
s = BDY((LIST)BDY(t)); |
j = perm[QTOS((Q)ARG0(s))]; STOQ(j,jq); ARG0(s) = (pointer)jq; |
j = perm[QTOS((Q)ARG0(s))]; STOQ(j,jq); ARG0(s) = (pointer)jq; |
for ( s = BDY((LIST)ARG1(s)); s; s = NEXT(s) ) { |
for ( s = BDY((LIST)ARG1(s)); s; s = NEXT(s) ) { |
j = perm[QTOS((Q)ARG1(BDY((LIST)BDY(s))))]; STOQ(j,jq); |
j = perm[QTOS((Q)ARG1(BDY((LIST)BDY(s))))]; STOQ(j,jq); |
ARG1(BDY((LIST)BDY(s))) = (pointer)jq; |
ARG1(BDY((LIST)BDY(s))) = (pointer)jq; |
} |
} |
} |
} |
for ( j = length(cand)-1, t = 0; j >= 0; j-- ) { |
for ( j = length(cand)-1, t = 0; j >= 0; j-- ) { |
STOQ(perm[j],jq); MKNODE(s,jq,t); t = s; |
STOQ(perm[j],jq); MKNODE(s,jq,t); t = s; |
} |
} |
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); |
STOQ(nd_bpe,bpe); |
STOQ(nd_bpe,bpe); |
tr = mknode(8,*rp,(!ishomo&&homo)?ONE:0,l1,l2,l3,l4,l5,bpe); MKLIST(*rp,tr); |
tr = mknode(8,*rp,(!ishomo&&homo)?ONE:0,l1,l2,l3,l4,l5,bpe); MKLIST(*rp,tr); |
} |
} |
} |
} |
Line 3902 void nmtodp(int mod,NM m,DP *r) |
|
Line 3931 void nmtodp(int mod,NM m,DP *r) |
|
|
|
NEWMP(mr); |
NEWMP(mr); |
mr->dl = ndltodl(nd_nvar,DL(m)); |
mr->dl = ndltodl(nd_nvar,DL(m)); |
mr->c = ndctop(mod,m->c); |
mr->c = (Obj)ndctop(mod,m->c); |
NEXT(mr) = 0; MKDP(nd_nvar,mr,dp); dp->sugar = mr->dl->td; |
NEXT(mr) = 0; MKDP(nd_nvar,mr,dp); dp->sugar = mr->dl->td; |
*r = dp; |
*r = dp; |
} |
} |
Line 3927 void ndl_print(UINT *dl) |
|
Line 3956 void ndl_print(UINT *dl) |
|
for ( i = 0; i < n; i++ ) printf(i==n-1?"%d":"%d,",GET_EXP(dl,i)); |
for ( i = 0; i < n; i++ ) printf(i==n-1?"%d":"%d,",GET_EXP(dl,i)); |
} |
} |
printf(">>"); |
printf(">>"); |
if ( MPOS(dl) ) |
if ( nd_module && MPOS(dl) ) |
printf("*e%d",MPOS(dl)); |
printf("*e%d",MPOS(dl)); |
} |
} |
|
|
Line 4368 int nd_get_exporigin(struct order_spec *ord) |
|
Line 4397 int nd_get_exporigin(struct order_spec *ord) |
|
/* module d[0]:weight d[1]:w0,...,d[nd_exporigin-2]:w(n-1) */ |
/* module d[0]:weight d[1]:w0,...,d[nd_exporigin-2]:w(n-1) */ |
return ord->ord.block.length+1+nd_module; |
return ord->ord.block.length+1+nd_module; |
case 3: case 259: |
case 3: case 259: |
|
#if 0 |
error("nd_get_exporigin : composite order is not supported yet."); |
error("nd_get_exporigin : composite order is not supported yet."); |
|
#else |
|
return 1+nd_module; |
|
#endif |
} |
} |
} |
} |
|
|
Line 4393 void nd_setup_parameters(int nvar,int max) { |
|
Line 4426 void nd_setup_parameters(int nvar,int max) { |
|
} |
} |
if ( !do_weyl && weight_check && (current_dl_weight_vector || nd_matrix) ) { |
if ( !do_weyl && weight_check && (current_dl_weight_vector || nd_matrix) ) { |
UINT t; |
UINT t; |
int st; |
int st; |
int *v; |
int *v; |
/* t = max(weights) */ |
/* t = max(weights) */ |
t = 0; |
t = 0; |
if ( current_dl_weight_vector ) |
if ( current_dl_weight_vector ) |
for ( i = 0, t = 0; i < nd_nvar; i++ ) { |
for ( i = 0, t = 0; i < nd_nvar; i++ ) { |
Line 4407 void nd_setup_parameters(int nvar,int max) { |
|
Line 4440 void nd_setup_parameters(int nvar,int max) { |
|
for ( j = 0, v = nd_matrix[i]; j < nd_nvar; j++ ) { |
for ( j = 0, v = nd_matrix[i]; j < nd_nvar; j++ ) { |
if ( (st=v[j]) < 0 ) st = -st; |
if ( (st=v[j]) < 0 ) st = -st; |
if ( t < st ) t = st; |
if ( t < st ) t = st; |
} |
} |
/* i = bitsize of t */ |
/* i = bitsize of t */ |
for ( i = 0; t; t >>=1, i++ ); |
for ( i = 0; t; t >>=1, i++ ); |
/* i += bitsize of nd_nvar */ |
/* i += bitsize of nd_nvar */ |
Line 4739 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
Line 4772 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
c0 = CM(m0); c1 = CM(m1); DMAR(c0,c1,0,mod,c); CM(m) = c; |
c0 = CM(m0); c1 = CM(m1); DMAR(c0,c1,0,mod,c); CM(m) = c; |
} else if ( nd_vc ) |
} else if ( nd_vc ) |
mulp(nd_vc,CP(m0),CP(m1),&CP(m)); |
mulp(nd_vc,CP(m0),CP(m1),&CP(m)); |
else |
else |
mulq(CQ(m0),CQ(m1),&CQ(m)); |
mulq(CQ(m0),CQ(m1),&CQ(m)); |
for ( i = 0; i < nd_wpd; i++ ) d[i] = 0; |
for ( i = 0; i < nd_wpd; i++ ) d[i] = 0; |
homo = n&1 ? 1 : 0; |
homo = n&1 ? 1 : 0; |
Line 4796 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
Line 4829 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
c0 = CM(tab[u]); DMAR(c0,c,0,mod,c1); CM(tab[u]) = c1; |
c0 = CM(tab[u]); DMAR(c0,c,0,mod,c1); CM(tab[u]) = c1; |
} else if ( nd_vc ) |
} else if ( nd_vc ) |
mulp(nd_vc,CP(tab[u]),(P)q,&CP(tab[u])); |
mulp(nd_vc,CP(tab[u]),(P)q,&CP(tab[u])); |
else { |
else { |
mulq(CQ(tab[u]),q,&q1); CQ(tab[u]) = q1; |
mulq(CQ(tab[u]),q,&q1); CQ(tab[u]) = q1; |
} |
} |
} |
} |
Line 4810 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
Line 4843 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
c0 = CM(tab[u]); DMAR(c0,c,0,mod,c1); CM(t) = c1; |
c0 = CM(tab[u]); DMAR(c0,c,0,mod,c1); CM(t) = c1; |
} else if ( nd_vc ) |
} else if ( nd_vc ) |
mulp(nd_vc,CP(tab[u]),(P)q,&CP(t)); |
mulp(nd_vc,CP(tab[u]),(P)q,&CP(t)); |
else |
else |
mulq(CQ(tab[u]),q,&CQ(t)); |
mulq(CQ(tab[u]),q,&CQ(t)); |
*p = t; |
*p = t; |
} |
} |
Line 5035 NDV ndv_dup(int mod,NDV p) |
|
Line 5068 NDV ndv_dup(int mod,NDV p) |
|
|
|
NDV ndvtondvgz(NDV p) |
NDV ndvtondvgz(NDV p) |
{ |
{ |
NDV r; |
NDV r; |
int len,i; |
int len,i; |
NMV t; |
NMV t; |
|
|
r = ndv_dup(0,p); |
r = ndv_dup(0,p); |
len = LEN(p); |
len = LEN(p); |
for ( t = BDY(r), i = 0; i < len; i++, NMV_ADV(t) ) CZ(t) = ztogz(CQ(t)); |
for ( t = BDY(r), i = 0; i < len; i++, NMV_ADV(t) ) CZ(t) = ztogz(CQ(t)); |
return r; |
return r; |
} |
} |
|
|
NDV ndvgztondv(NDV p) |
NDV ndvgztondv(NDV p) |
{ |
{ |
NDV r; |
NDV r; |
int len,i; |
int len,i; |
NMV t; |
NMV t; |
|
|
r = ndv_dup(0,p); |
r = ndv_dup(0,p); |
len = LEN(p); |
len = LEN(p); |
for ( t = BDY(r), i = 0; i < len; i++, NMV_ADV(t) ) CQ(t) = gztoz(CZ(t)); |
for ( t = BDY(r), i = 0; i < len; i++, NMV_ADV(t) ) CQ(t) = gztoz(CZ(t)); |
return r; |
return r; |
} |
} |
|
|
NDV ndv_symbolic(int mod,NDV p) |
NDV ndv_symbolic(int mod,NDV p) |
Line 5094 ND nd_dup(ND p) |
|
Line 5127 ND nd_dup(ND p) |
|
|
|
ND ndtondgz(ND p) |
ND ndtondgz(ND p) |
{ |
{ |
ND r; |
ND r; |
NM t; |
NM t; |
|
|
r = nd_dup(p); |
r = nd_dup(p); |
for ( t = BDY(r); t; t = NEXT(t) ) CZ(t) = ztogz(CQ(t)); |
for ( t = BDY(r); t; t = NEXT(t) ) CZ(t) = ztogz(CQ(t)); |
return r; |
return r; |
} |
} |
|
|
|
|
ND ndgztond(ND p) |
ND ndgztond(ND p) |
{ |
{ |
ND r; |
ND r; |
NM t; |
NM t; |
|
|
r = nd_dup(p); |
r = nd_dup(p); |
for ( t = BDY(r); t; t = NEXT(t) ) CQ(t) = gztoz(CZ(t)); |
for ( t = BDY(r); t; t = NEXT(t) ) CQ(t) = gztoz(CZ(t)); |
return r; |
return r; |
} |
} |
|
|
|
|
Line 5312 P ndvtop(int mod,VL vl,VL dvl,NDV p) |
|
Line 5345 P ndvtop(int mod,VL vl,VL dvl,NDV p) |
|
if ( mod == -1 ) { |
if ( mod == -1 ) { |
e = IFTOF(CM(m)); MKGFS(e,gfs); c = (P)gfs; |
e = IFTOF(CM(m)); MKGFS(e,gfs); c = (P)gfs; |
} else if ( mod == -2 ) { |
} else if ( mod == -2 ) { |
c = gztoz(CZ(m)); |
c = (P)gztoz(CZ(m)); |
} else if ( mod > 0 ) { |
} else if ( mod > 0 ) { |
STOQ(CM(m),q); c = (P)q; |
STOQ(CM(m),q); c = (P)q; |
} else |
} else |
Line 5421 ND ndvtond(int mod,NDV p) |
|
Line 5454 ND ndvtond(int mod,NDV p) |
|
DP ndvtodp(int mod,NDV p) |
DP ndvtodp(int mod,NDV p) |
{ |
{ |
MP m,m0; |
MP m,m0; |
DP d; |
DP d; |
NMV t; |
NMV t; |
int i,len; |
int i,len; |
|
|
Line 5430 DP ndvtodp(int mod,NDV p) |
|
Line 5463 DP ndvtodp(int mod,NDV p) |
|
len = p->len; |
len = p->len; |
for ( t = BDY(p), i = 0; i < len; NMV_ADV(t), i++ ) { |
for ( t = BDY(p), i = 0; i < len; NMV_ADV(t), i++ ) { |
NEXTMP(m0,m); |
NEXTMP(m0,m); |
m->dl = ndltodl(nd_nvar,DL(t)); |
m->dl = ndltodl(nd_nvar,DL(t)); |
m->c = ndctop(mod,t->c); |
m->c = (Obj)ndctop(mod,t->c); |
} |
} |
NEXT(m) = 0; |
NEXT(m) = 0; |
MKDP(nd_nvar,m0,d); |
MKDP(nd_nvar,m0,d); |
SG(d) = SG(p); |
SG(d) = SG(p); |
return d; |
return d; |
} |
} |
Line 5442 DP ndvtodp(int mod,NDV p) |
|
Line 5475 DP ndvtodp(int mod,NDV p) |
|
DP ndtodp(int mod,ND p) |
DP ndtodp(int mod,ND p) |
{ |
{ |
MP m,m0; |
MP m,m0; |
DP d; |
DP d; |
NM t; |
NM t; |
int i,len; |
int i,len; |
|
|
Line 5451 DP ndtodp(int mod,ND p) |
|
Line 5484 DP ndtodp(int mod,ND p) |
|
len = p->len; |
len = p->len; |
for ( t = BDY(p); t; t = NEXT(t) ) { |
for ( t = BDY(p); t; t = NEXT(t) ) { |
NEXTMP(m0,m); |
NEXTMP(m0,m); |
m->dl = ndltodl(nd_nvar,DL(t)); |
m->dl = ndltodl(nd_nvar,DL(t)); |
m->c = ndctop(mod,t->c); |
m->c = (Obj)ndctop(mod,t->c); |
} |
} |
NEXT(m) = 0; |
NEXT(m) = 0; |
MKDP(nd_nvar,m0,d); |
MKDP(nd_nvar,m0,d); |
SG(d) = SG(p); |
SG(d) = SG(p); |
return d; |
return d; |
} |
} |
Line 5537 void nd_init_ord(struct order_spec *ord) |
|
Line 5570 void nd_init_ord(struct order_spec *ord) |
|
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; |
} |
} |
nd_matrix = 0; |
nd_matrix = 0; |
nd_matrix_len = 0; |
nd_matrix_len = 0; |
switch ( ord->id ) { |
switch ( ord->id ) { |
case 0: |
case 0: |
switch ( ord->ord.simple ) { |
switch ( ord->ord.simple ) { |
Line 5734 void nd_nf_p(Obj f,LIST g,LIST v,int m,struct order_sp |
|
Line 5767 void nd_nf_p(Obj f,LIST g,LIST v,int m,struct order_sp |
|
/* max=65536 implies nd_bpe=32 */ |
/* max=65536 implies nd_bpe=32 */ |
max = 65536; |
max = 65536; |
|
|
nd_module = 0; |
nd_module = 0; |
/* nd_module will be set if ord is a module ordering */ |
/* nd_module will be set if ord is a module ordering */ |
nd_init_ord(ord); |
nd_init_ord(ord); |
nd_setup_parameters(nvar,max); |
nd_setup_parameters(nvar,max); |
if ( nd_module && OID(f) != O_LIST ) |
if ( nd_module && OID(f) != O_LIST ) |
error("nd_nf_p : the first argument must be a list"); |
error("nd_nf_p : the first argument must be a list"); |
if ( nd_module ) mrank = length(BDY((LIST)f)); |
if ( nd_module ) mrank = length(BDY((LIST)f)); |
/* conversion to ndv */ |
/* conversion to ndv */ |
for ( in0 = 0, t = BDY(g); t; t = NEXT(t) ) { |
for ( in0 = 0, t = BDY(g); t; t = NEXT(t) ) { |
NEXTNODE(in0,in); |
NEXTNODE(in0,in); |
Line 5791 int nd_to_vect(int mod,UINT *s0,int n,ND d,UINT *r) |
|
Line 5824 int nd_to_vect(int mod,UINT *s0,int n,ND d,UINT *r) |
|
return i; |
return i; |
} |
} |
|
|
|
#if defined(__GNUC__) && SIZEOF_LONG==8 |
|
|
|
#define MOD128(a,c,m) ((a)=(((c)!=0||((a)>=(m)))?(((((U128)(c))<<64)+(a))%(m)):(a))) |
|
|
|
int nd_to_vect64(int mod,UINT *s0,int n,ND d,U64 *r) |
|
{ |
|
NM m; |
|
UINT *t,*s; |
|
int i; |
|
|
|
for ( i = 0; i < n; i++ ) r[i] = 0; |
|
for ( i = 0, s = s0, m = BDY(d); m; m = NEXT(m) ) { |
|
t = DL(m); |
|
for ( ; !ndl_equal(t,s); s += nd_wpd, i++ ); |
|
r[i] = (U64)CM(m); |
|
} |
|
for ( i = 0; !r[i]; i++ ); |
|
return i; |
|
} |
|
#endif |
|
|
int nd_to_vect_q(UINT *s0,int n,ND d,Q *r) |
int nd_to_vect_q(UINT *s0,int n,ND d,Q *r) |
{ |
{ |
NM m; |
NM m; |
Line 5828 unsigned long *nd_to_vect_2(UINT *s0,int n,int *s0hash |
|
Line 5882 unsigned long *nd_to_vect_2(UINT *s0,int n,int *s0hash |
|
NM m; |
NM m; |
unsigned long *v; |
unsigned long *v; |
int i,j,h,size; |
int i,j,h,size; |
UINT *s,*t; |
UINT *s,*t; |
|
|
size = sizeof(unsigned long)*(n+BLEN-1)/BLEN; |
size = sizeof(unsigned long)*(n+BLEN-1)/BLEN; |
v = (unsigned long *)MALLOC_ATOMIC_IGNORE_OFF_PAGE(size); |
v = (unsigned long *)MALLOC_ATOMIC_IGNORE_OFF_PAGE(size); |
bzero(v,size); |
bzero(v,size); |
for ( i = j = 0, s = s0, m = BDY(p); m; j++, m = NEXT(m) ) { |
for ( i = j = 0, s = s0, m = BDY(p); m; j++, m = NEXT(m) ) { |
t = DL(m); |
t = DL(m); |
h = ndl_hash_value(t); |
h = ndl_hash_value(t); |
for ( ; h != s0hash[i] || !ndl_equal(t,s); s += nd_wpd, i++ ); |
for ( ; h != s0hash[i] || !ndl_equal(t,s); s += nd_wpd, i++ ); |
v[i/BLEN] |= 1L <<(i%BLEN); |
v[i/BLEN] |= 1L <<(i%BLEN); |
} |
} |
return v; |
return v; |
} |
} |
Line 5853 int nd_nm_to_vect_2(UINT *s0,int n,int *s0hash,NDV p,N |
|
Line 5907 int nd_nm_to_vect_2(UINT *s0,int n,int *s0hash,NDV p,N |
|
t = (UINT *)MALLOC(nd_wpd*sizeof(UINT)); |
t = (UINT *)MALLOC(nd_wpd*sizeof(UINT)); |
for ( i = j = 0, s = s0, mr = BDY(p); j < len; j++, NMV_ADV(mr) ) { |
for ( i = j = 0, s = s0, mr = BDY(p); j < len; j++, NMV_ADV(mr) ) { |
ndl_add(d,DL(mr),t); |
ndl_add(d,DL(mr),t); |
h = ndl_hash_value(t); |
h = ndl_hash_value(t); |
for ( ; h != s0hash[i] || !ndl_equal(t,s); s += nd_wpd, i++ ); |
for ( ; h != s0hash[i] || !ndl_equal(t,s); s += nd_wpd, i++ ); |
if ( j == 0 ) head = i; |
if ( j == 0 ) head = i; |
v[i/BLEN] |= 1L <<(i%BLEN); |
v[i/BLEN] |= 1L <<(i%BLEN); |
} |
} |
return head; |
return head; |
} |
} |
Line 5910 struct oEGT eg0,eg1; |
|
Line 5964 struct oEGT eg0,eg1; |
|
get_eg(&eg0); |
get_eg(&eg0); |
for ( i = j = 0, s = s0, mr = BDY(p); j < len; j++, NMV_ADV(mr) ) { |
for ( i = j = 0, s = s0, mr = BDY(p); j < len; j++, NMV_ADV(mr) ) { |
ndl_add(d,DL(mr),t); |
ndl_add(d,DL(mr),t); |
h = ndl_hash_value(t); |
h = ndl_hash_value(t); |
for ( ; h != s0hash[i] || !ndl_equal(t,s); s += nd_wpd, i++ ); |
for ( ; h != s0hash[i] || !ndl_equal(t,s); s += nd_wpd, i++ ); |
v[j] = i; |
v[j] = i; |
} |
} |
Line 6048 int ndv_reduce_vect_gz(GZ *gvect,int trace,int col,Ind |
|
Line 6102 int ndv_reduce_vect_gz(GZ *gvect,int trace,int col,Ind |
|
NODE rp; |
NODE rp; |
int maxrs; |
int maxrs; |
double hmag; |
double hmag; |
struct oVECT v; |
struct oVECT v; |
|
|
maxrs = 0; |
maxrs = 0; |
for ( i = 0; i < col && !gvect[i]; i++ ); |
for ( i = 0; i < col && !gvect[i]; i++ ); |
Line 6061 int ndv_reduce_vect_gz(GZ *gvect,int trace,int col,Ind |
|
Line 6115 int ndv_reduce_vect_gz(GZ *gvect,int trace,int col,Ind |
|
maxrs = MAX(maxrs,rp0[i]->sugar); |
maxrs = MAX(maxrs,rp0[i]->sugar); |
redv = nd_ps_gz[rp0[i]->index]; |
redv = nd_ps_gz[rp0[i]->index]; |
len = LEN(redv); mr = BDY(redv); |
len = LEN(redv); mr = BDY(redv); |
gcdgz(gvect[k],CZ(mr),&gcd); |
gcdgz(gvect[k],CZ(mr),&gcd); |
divsgz(gvect[k],gcd,&cs); |
divsgz(gvect[k],gcd,&cs); |
divsgz(CZ(mr),gcd,&cr); |
divsgz(CZ(mr),gcd,&cr); |
chsgngz(cs,&mcs); |
chsgngz(cs,&mcs); |
if ( !UNIGZ(cr) ) { |
if ( !UNIGZ(cr) ) { |
for ( j = 0; j < col; j++ ) { |
for ( j = 0; j < col; j++ ) { |
mulgz(gvect[j],cr,&c1); gvect[j] = c1; |
mulgz(gvect[j],cr,&c1); gvect[j] = c1; |
} |
} |
Line 6097 int ndv_reduce_vect_gz(GZ *gvect,int trace,int col,Ind |
|
Line 6151 int ndv_reduce_vect_gz(GZ *gvect,int trace,int col,Ind |
|
for ( j = k+1; j < col && !gvect[j]; j++ ); |
for ( j = k+1; j < col && !gvect[j]; j++ ); |
if ( j == col ) break; |
if ( j == col ) break; |
if ( hmag && ((double)n_bits_gz(gvect[j]) > hmag) ) { |
if ( hmag && ((double)n_bits_gz(gvect[j]) > hmag) ) { |
v.len = col; v.body = (pointer)gvect; gcdvgz(&v,&gcd); |
v.len = col; v.body = (pointer)gvect; gcdvgz(&v,&gcd); |
#if 1 |
#if 1 |
for ( l = 0; l < col; l++ ) { divsgz(gvect[l],gcd,&t); gvect[l] = t; } |
for ( l = 0; l < col; l++ ) { divsgz(gvect[l],gcd,&t); gvect[l] = t; } |
#endif |
#endif |
hmag = (double)n_bits_gz(gvect[j])*nd_scale; |
hmag = (double)n_bits_gz(gvect[j])*nd_scale; |
} |
} |
} |
} |
} |
} |
for ( j = 0; j < col && !gvect[j]; j++ ); |
for ( j = 0; j < col && !gvect[j]; j++ ); |
if ( j < col ) { |
if ( j < col ) { |
v.len = col; v.body = (pointer)gvect; gcdvgz(&v,&gcd); |
v.len = col; v.body = (pointer)gvect; gcdvgz(&v,&gcd); |
for ( l = 0; l < col; l++ ) { divsgz(gvect[l],gcd,&t); gvect[l] = t; } |
for ( l = 0; l < col; l++ ) { divsgz(gvect[l],gcd,&t); gvect[l] = t; } |
} |
} |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"-"); fflush(asir_out); |
fprintf(asir_out,"-"); fflush(asir_out); |
} |
} |
return maxrs; |
return maxrs; |
} |
} |
|
|
|
|
int ndv_reduce_vect(int m,UINT *svect,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
int ndv_reduce_vect(int m,UINT *svect,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
{ |
{ |
int i,j,k,len,pos,prev; |
int i,j,k,len,pos,prev; |
Line 6144 int ndv_reduce_vect(int m,UINT *svect,int col,IndArray |
|
Line 6197 int ndv_reduce_vect(int m,UINT *svect,int col,IndArray |
|
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 ) { |
if ( c1 ) { |
c2 = svect[pos]; |
c2 = svect[pos]; |
DMA(c1,c,c2,up,lo); |
DMA(c1,c,c2,up,lo); |
if ( up ) { DSAB(m,up,lo,dmy,c3); svect[pos] = c3; |
if ( up ) { DSAB(m,up,lo,dmy,c3); svect[pos] = c3; |
} else svect[pos] = lo; |
} else svect[pos] = lo; |
} |
} |
} |
} |
break; |
break; |
case 2: |
case 2: |
Line 6157 int ndv_reduce_vect(int m,UINT *svect,int col,IndArray |
|
Line 6210 int ndv_reduce_vect(int m,UINT *svect,int col,IndArray |
|
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); |
pos = prev+ivs[j]; c1 = CM(mr); |
prev = pos; |
prev = pos; |
if ( c1 ) { |
if ( c1 ) { |
c2 = svect[pos]; |
c2 = svect[pos]; |
DMA(c1,c,c2,up,lo); |
DMA(c1,c,c2,up,lo); |
if ( up ) { DSAB(m,up,lo,dmy,c3); svect[pos] = c3; |
if ( up ) { DSAB(m,up,lo,dmy,c3); svect[pos] = c3; |
} else svect[pos] = lo; |
} else svect[pos] = lo; |
} |
} |
} |
} |
break; |
break; |
case 4: |
case 4: |
Line 6170 int ndv_reduce_vect(int m,UINT *svect,int col,IndArray |
|
Line 6223 int ndv_reduce_vect(int m,UINT *svect,int col,IndArray |
|
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); |
pos = prev+ivi[j]; c1 = CM(mr); |
prev = pos; |
prev = pos; |
if ( c1 ) { |
if ( c1 ) { |
c2 = svect[pos]; |
c2 = svect[pos]; |
DMA(c1,c,c2,up,lo); |
DMA(c1,c,c2,up,lo); |
if ( up ) { DSAB(m,up,lo,dmy,c3); svect[pos] = c3; |
if ( up ) { DSAB(m,up,lo,dmy,c3); svect[pos] = c3; |
} else svect[pos] = lo; |
} else svect[pos] = lo; |
} |
} |
} |
} |
break; |
break; |
} |
} |
Line 6186 int ndv_reduce_vect(int m,UINT *svect,int col,IndArray |
|
Line 6239 int ndv_reduce_vect(int m,UINT *svect,int col,IndArray |
|
return maxrs; |
return maxrs; |
} |
} |
|
|
|
#if defined(__GNUC__) && SIZEOF_LONG==8 |
|
|
|
int ndv_reduce_vect64(int m,U64 *svect,U64 *cvect,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
|
{ |
|
int i,j,k,len,pos,prev; |
|
U64 a,c,c1,c2; |
|
IndArray ivect; |
|
unsigned char *ivc; |
|
unsigned short *ivs; |
|
unsigned int *ivi; |
|
NDV redv; |
|
NMV mr; |
|
NODE rp; |
|
int maxrs; |
|
|
|
for ( i = 0; i < col; i++ ) cvect[i] = 0; |
|
maxrs = 0; |
|
for ( i = 0; i < nred; i++ ) { |
|
ivect = imat[i]; |
|
k = ivect->head; |
|
a = svect[k]; c = cvect[k]; |
|
MOD128(a,c,m); |
|
svect[k] = a; cvect[k] = 0; |
|
if ( c = svect[k] ) { |
|
maxrs = MAX(maxrs,rp0[i]->sugar); |
|
c = m-c; redv = nd_ps[rp0[i]->index]; |
|
len = LEN(redv); mr = BDY(redv); |
|
svect[k] = 0; prev = k; |
|
switch ( ivect->width ) { |
|
case 1: |
|
ivc = ivect->index.c; |
|
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
|
pos = prev+ivc[j]; c1 = CM(mr); prev = pos; |
|
if ( c1 ) { |
|
c2 = svect[pos]+c1*c; |
|
if ( c2 < svect[pos] ) cvect[pos]++; |
|
svect[pos] = c2; |
|
} |
|
} |
|
break; |
|
case 2: |
|
ivs = ivect->index.s; |
|
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
|
pos = prev+ivs[j]; c1 = CM(mr); prev = pos; |
|
if ( c1 ) { |
|
c2 = svect[pos]+c1*c; |
|
if ( c2 < svect[pos] ) cvect[pos]++; |
|
svect[pos] = c2; |
|
} |
|
} |
|
break; |
|
case 4: |
|
ivi = ivect->index.i; |
|
for ( j = 1, NMV_ADV(mr); j < len; j++, NMV_ADV(mr) ) { |
|
pos = prev+ivi[j]; c1 = CM(mr); prev = pos; |
|
if ( c1 ) { |
|
c2 = svect[pos]+c1*c; |
|
if ( c2 < svect[pos] ) cvect[pos]++; |
|
svect[pos] = c2; |
|
} |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
for ( i = 0; i < col; i++ ) { |
|
a = svect[i]; c = cvect[i]; MOD128(a,c,m); svect[i] = a; |
|
} |
|
return maxrs; |
|
} |
|
#endif |
|
|
int ndv_reduce_vect_sf(int m,UINT *svect,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
int ndv_reduce_vect_sf(int m,UINT *svect,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
{ |
{ |
int i,j,k,len,pos,prev; |
int i,j,k,len,pos,prev; |
Line 6443 NDV vect_to_ndv(UINT *vect,int spcol,int col,int *rhea |
|
Line 6568 NDV vect_to_ndv(UINT *vect,int spcol,int col,int *rhea |
|
} |
} |
} |
} |
|
|
|
#if defined(__GNUC__) && SIZEOF_LONG==8 |
|
NDV vect64_to_ndv(U64 *vect,int spcol,int col,int *rhead,UINT *s0vect) |
|
{ |
|
int j,k,len; |
|
UINT *p; |
|
UINT c; |
|
NDV r; |
|
NMV mr0,mr; |
|
|
|
for ( j = 0, len = 0; j < spcol; j++ ) if ( vect[j] ) len++; |
|
if ( !len ) return 0; |
|
else { |
|
mr0 = (NMV)MALLOC_ATOMIC_IGNORE_OFF_PAGE(nmv_adv*len); |
|
#if 0 |
|
ndv_alloc += nmv_adv*len; |
|
#endif |
|
mr = mr0; |
|
p = s0vect; |
|
for ( j = k = 0; j < col; j++, p += nd_wpd ) |
|
if ( !rhead[j] ) { |
|
if ( c = (UINT)vect[k++] ) { |
|
ndl_copy(p,DL(mr)); CM(mr) = c; NMV_ADV(mr); |
|
} |
|
} |
|
MKNDV(nd_nvar,mr0,len,r); |
|
return r; |
|
} |
|
} |
|
#endif |
|
|
NDV vect_to_ndv_2(unsigned long *vect,int col,UINT *s0vect) |
NDV vect_to_ndv_2(unsigned long *vect,int col,UINT *s0vect) |
{ |
{ |
int j,k,len; |
int j,k,len; |
Line 6457 NDV vect_to_ndv_2(unsigned long *vect,int col,UINT *s0 |
|
Line 6612 NDV vect_to_ndv_2(unsigned long *vect,int col,UINT *s0 |
|
mr = mr0; |
mr = mr0; |
p = s0vect; |
p = s0vect; |
for ( j = 0; j < col; j++, p += nd_wpd ) |
for ( j = 0; j < col; j++, p += nd_wpd ) |
if ( vect[j/BLEN] & (1L<<(j%BLEN)) ) { |
if ( vect[j/BLEN] & (1L<<(j%BLEN)) ) { |
ndl_copy(p,DL(mr)); CM(mr) = 1; NMV_ADV(mr); |
ndl_copy(p,DL(mr)); CM(mr) = 1; NMV_ADV(mr); |
} |
} |
MKNDV(nd_nvar,mr0,len,r); |
MKNDV(nd_nvar,mr0,len,r); |
Line 6614 int nd_symbolic_preproc(PGeoBucket bucket,int trace,UI |
|
Line 6769 int nd_symbolic_preproc(PGeoBucket bucket,int trace,UI |
|
static int afo; |
static int afo; |
|
|
s0 = 0; rp0 = 0; col = 0; |
s0 = 0; rp0 = 0; col = 0; |
if ( nd_demand ) |
if ( nd_demand ) |
ps = trace?nd_ps_trace_sym:nd_ps_sym; |
ps = trace?nd_ps_trace_sym:nd_ps_sym; |
else |
else |
ps = trace?nd_ps_trace:nd_ps; |
ps = trace?nd_ps_trace:nd_ps; |
while ( 1 ) { |
while ( 1 ) { |
head = remove_head_pbucket_symbolic(bucket); |
head = remove_head_pbucket_symbolic(bucket); |
if ( !head ) break; |
if ( !head ) break; |
Line 6649 int nd_symbolic_preproc(PGeoBucket bucket,int trace,UI |
|
Line 6804 int nd_symbolic_preproc(PGeoBucket bucket,int trace,UI |
|
return col; |
return col; |
} |
} |
|
|
|
void print_ndp(ND_pairs l) |
|
{ |
|
ND_pairs t; |
|
|
|
for ( t = l; t; t = NEXT(t) ) |
|
printf("[%d,%d] ",t->i1,t->i2); |
|
printf("\n"); |
|
} |
|
|
NODE nd_f4(int m,int checkonly,int **indp) |
NODE nd_f4(int m,int checkonly,int **indp) |
{ |
{ |
int i,nh,stat,index,f4red; |
int i,nh,stat,index,f4red; |
NODE r,g,tn0,tn,node; |
NODE r,g,tn0,tn,node; |
ND_pairs d,l,t,ll0,ll; |
ND_pairs d,l,t,ll0,ll,lh; |
LIST l0,l1; |
LIST l0,l1; |
ND spol,red; |
ND spol,red; |
NDV nf,redv; |
NDV nf,redv; |
NM s0,s; |
NM s0,s; |
Line 6667 NODE nd_f4(int m,int checkonly,int **indp) |
|
Line 6831 NODE nd_f4(int m,int checkonly,int **indp) |
|
IndArray *imat; |
IndArray *imat; |
int *rhead; |
int *rhead; |
int spcol,sprow; |
int spcol,sprow; |
int sugar; |
int sugar,sugarh; |
PGeoBucket bucket; |
PGeoBucket bucket; |
struct oEGT eg0,eg1,eg_f4; |
struct oEGT eg0,eg1,eg_f4; |
Q i1,i2,sugarq; |
Q i1,i2,sugarq; |
Line 6676 NODE nd_f4(int m,int checkonly,int **indp) |
|
Line 6840 NODE nd_f4(int m,int checkonly,int **indp) |
|
#endif |
#endif |
g = 0; d = 0; |
g = 0; d = 0; |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
if ( !nd_nzlist ) d = update_pairs(d,g,i,0); |
d = update_pairs(d,g,i,0); |
g = update_base(g,i); |
g = update_base(g,i); |
} |
} |
nzlist = 0; |
nzlist = 0; |
nzlist_t = nd_nzlist; |
nzlist_t = nd_nzlist; |
f4red = 0; |
f4red = 1; |
while ( d || nzlist_t ) { |
nd_last_nonzero = 0; |
|
while ( d ) { |
get_eg(&eg0); |
get_eg(&eg0); |
if ( nd_nzlist ) { |
l = nd_minsugarp(d,&d); |
|
sugar = nd_sugarweight?l->sugar2:SG(l); |
|
if ( MaxDeg > 0 && sugar > MaxDeg ) break; |
|
if ( nzlist_t ) { |
node = BDY((LIST)BDY(nzlist_t)); |
node = BDY((LIST)BDY(nzlist_t)); |
sugar = (int)ARG0(node); |
sugarh = QTOS((Q)ARG0(node)); |
tn = BDY((LIST)ARG1(node)); |
tn = BDY((LIST)ARG1(node)); |
if ( !tn ) { |
if ( !tn ) { |
nzlist_t = NEXT(nzlist_t); |
nzlist_t = NEXT(nzlist_t); |
continue; |
continue; |
} |
} |
/* tn = [[i1,i2],...] */ |
/* tn = [[i1,i2],...] */ |
l = nd_ipairtospair(tn); |
lh = nd_ipairtospair(tn); |
} else { |
|
l = nd_minsugarp(d,&d); |
|
sugar = nd_sugarweight?l->sugar2:SG(l); |
|
if ( MaxDeg > 0 && sugar > MaxDeg ) break; |
|
} |
} |
bucket = create_pbucket(); |
bucket = create_pbucket(); |
stat = nd_sp_f4(m,0,l,bucket); |
stat = nd_sp_f4(m,0,l,bucket); |
if ( !stat ) { |
if ( !stat ) { |
if ( !nd_nzlist ) { |
for ( t = l; NEXT(t); t = NEXT(t) ); |
for ( t = l; NEXT(t); t = NEXT(t) ); |
NEXT(t) = d; d = l; |
NEXT(t) = d; d = l; |
d = nd_reconstruct(0,d); |
d = nd_reconstruct(0,d); |
|
} |
|
continue; |
continue; |
} |
} |
if ( bucket->m < 0 ) continue; |
if ( bucket->m < 0 ) continue; |
Line 6719 NODE nd_f4(int m,int checkonly,int **indp) |
|
Line 6881 NODE nd_f4(int m,int checkonly,int **indp) |
|
} |
} |
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); |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d,symb=%fsec,", |
fprintf(asir_out,"sugar=%d,symb=%.3fsec,", |
sugar,eg_f4.exectime+eg_f4.gctime); |
sugar,eg_f4.exectime+eg_f4.gctime); |
nflist = nd_f4_red(m,l,0,s0vect,col,rp0,nd_gentrace?&ll:0); |
nflist = nd_f4_red(m,nd_nzlist?lh:l,0,s0vect,col,rp0,nd_gentrace?&ll:0); |
if ( checkonly && nflist ) return 0; |
if ( checkonly && nflist ) return 0; |
/* adding new bases */ |
/* adding new bases */ |
|
if ( nflist ) nd_last_nonzero = f4red; |
for ( r = nflist; r; r = NEXT(r) ) { |
for ( r = nflist; r; r = NEXT(r) ) { |
nf = (NDV)BDY(r); |
nf = (NDV)BDY(r); |
ndv_removecont(m,nf); |
ndv_removecont(m,nf); |
Line 6736 NODE nd_f4(int m,int checkonly,int **indp) |
|
Line 6899 NODE nd_f4(int m,int checkonly,int **indp) |
|
nf = ndtondv(m,nf1); |
nf = ndtondv(m,nf1); |
} |
} |
nh = ndv_newps(m,nf,0,1); |
nh = ndv_newps(m,nf,0,1); |
if ( !nd_nzlist ) d = update_pairs(d,g,nh,0); |
d = update_pairs(d,g,nh,0); |
g = update_base(g,nh); |
g = update_base(g,nh); |
} |
} |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"f4red=%d,gblen=%d,",f4red,length(g)); fflush(asir_out); |
fprintf(asir_out,"f4red=%d,gblen=%d\n",f4red,length(g)); fflush(asir_out); |
} |
} |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
for ( t = ll, tn0 = 0; t; t = NEXT(t) ) { |
for ( t = ll, tn0 = 0; t; t = NEXT(t) ) { |
NEXTNODE(tn0,tn); |
NEXTNODE(tn0,tn); |
STOQ(t->i1,i1); STOQ(t->i2,i2); |
STOQ(t->i1,i1); STOQ(t->i2,i2); |
node = mknode(2,i1,i2); MKLIST(l0,node); |
node = mknode(2,i1,i2); MKLIST(l0,node); |
BDY(tn) = l0; |
BDY(tn) = l0; |
} |
} |
if ( tn0 ) NEXT(tn) = 0; MKLIST(l0,tn0); |
if ( tn0 ) NEXT(tn) = 0; MKLIST(l0,tn0); |
STOQ(sugar,sugarq); node = mknode(2,sugarq,l0); MKLIST(l1,node); |
STOQ(sugar,sugarq); node = mknode(2,sugarq,l0); MKLIST(l1,node); |
MKNODE(node,l1,nzlist); nzlist = node; |
MKNODE(node,l1,nzlist); nzlist = node; |
} |
} |
if ( nd_nzlist ) nzlist_t = NEXT(nzlist_t); |
if ( nd_nzlist ) nzlist_t = NEXT(nzlist_t); |
f4red++; |
f4red++; |
if ( nd_f4red && f4red >= nd_f4red ) break; |
if ( nd_f4red && f4red > nd_f4red ) break; |
if ( nd_rank0 && !nflist ) break; |
if ( nd_rank0 && !nflist ) break; |
} |
} |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
MKLIST(l0,reverse_node(nzlist)); |
MKLIST(l0,reverse_node(nzlist)); |
MKNODE(nd_alltracelist,l0,0); |
MKNODE(nd_alltracelist,l0,0); |
} |
} |
#if 0 |
#if 0 |
fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc); |
fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc); |
#endif |
#endif |
conv_ilist(nd_demand,0,g,indp); |
conv_ilist(nd_demand,0,g,indp); |
return g; |
return g; |
} |
} |
|
|
Line 6818 NODE nd_f4_trace(int m,int **indp) |
|
Line 6981 NODE nd_f4_trace(int m,int **indp) |
|
} |
} |
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); |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d,symb=%fsec,", |
fprintf(asir_out,"sugar=%d,symb=%.3fsec,", |
sugar,eg_f4.exectime+eg_f4.gctime); |
sugar,eg_f4.exectime+eg_f4.gctime); |
nflist = nd_f4_red(m,l,0,s0vect,col,rp0,&l0); |
nflist = nd_f4_red(m,l,0,s0vect,col,rp0,&l0); |
if ( !l0 ) continue; |
if ( !l0 ) continue; |
Line 6866 NODE nd_f4_trace(int m,int **indp) |
|
Line 7029 NODE nd_f4_trace(int m,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 |
conv_ilist(nd_demand,1,g,indp); |
conv_ilist(nd_demand,1,g,indp); |
return g; |
return g; |
} |
} |
|
|
Line 6885 int rref(matrix mat,int *sugar) |
|
Line 7048 int rref(matrix mat,int *sugar) |
|
pivot = (int *)MALLOC_ATOMIC(row*sizeof(int)); |
pivot = (int *)MALLOC_ATOMIC(row*sizeof(int)); |
i = 0; |
i = 0; |
for ( j = 0; j < col; j++ ) { |
for ( j = 0; j < col; j++ ) { |
wj = j/BLEN; bj = 1L<<(j%BLEN); |
wj = j/BLEN; bj = 1L<<(j%BLEN); |
for ( k = i; k < row; k++ ) |
for ( k = i; k < row; k++ ) |
if ( a[k][wj] & bj ) break; |
if ( a[k][wj] & bj ) break; |
if ( k == row ) continue; |
if ( k == row ) continue; |
pivot[i] = j; |
pivot[i] = j; |
if ( k != i ) { |
if ( k != i ) { |
t = a[i]; a[i] = a[k]; a[k] = t; |
t = a[i]; a[i] = a[k]; a[k] = t; |
s = sugar[i]; sugar[i] = sugar[k]; sugar[k] = s; |
s = sugar[i]; sugar[i] = sugar[k]; sugar[k] = s; |
} |
} |
ai = a[i]; |
ai = a[i]; |
for ( k = i+1; k < row; k++ ) { |
for ( k = i+1; k < row; k++ ) { |
ak = a[k]; |
ak = a[k]; |
if ( ak[wj] & bj ) { |
if ( ak[wj] & bj ) { |
for ( l = wj; l < wcol; l++ ) |
for ( l = wj; l < wcol; l++ ) |
ak[l] ^= ai[l]; |
ak[l] ^= ai[l]; |
sugar[k] = MAX(sugar[k],sugar[i]); |
sugar[k] = MAX(sugar[k],sugar[i]); |
} |
} |
} |
|
i++; |
|
} |
} |
|
i++; |
|
} |
for ( k = i-1; k >= 0; k-- ) { |
for ( k = i-1; k >= 0; k-- ) { |
j = pivot[k]; wj = j/BLEN; bj = 1L<<(j%BLEN); |
j = pivot[k]; wj = j/BLEN; bj = 1L<<(j%BLEN); |
ak = a[k]; |
ak = a[k]; |
for ( s = 0; s < k; s++ ) { |
for ( s = 0; s < k; s++ ) { |
as = a[s]; |
as = a[s]; |
if ( as[wj] & bj ) { |
if ( as[wj] & bj ) { |
for ( l = wj; l < wcol; l++ ) |
for ( l = wj; l < wcol; l++ ) |
as[l] ^= ak[l]; |
as[l] ^= ak[l]; |
sugar[s] = MAX(sugar[s],sugar[k]); |
sugar[s] = MAX(sugar[s],sugar[k]); |
} |
} |
} |
|
} |
} |
|
} |
return i; |
return i; |
} |
} |
|
|
Line 6929 void print_matrix(matrix mat) |
|
Line 7092 void print_matrix(matrix mat) |
|
col = mat->col; |
col = mat->col; |
printf("%d x %d\n",row,col); |
printf("%d x %d\n",row,col); |
for ( i = 0; i < row; i++ ) { |
for ( i = 0; i < row; i++ ) { |
ai = mat->a[i]; |
ai = mat->a[i]; |
for ( j = 0; j < col; j++ ) { |
for ( j = 0; j < col; j++ ) { |
if ( ai[j/BLEN] & (1L<<(j%BLEN)) ) putchar('1'); |
if ( ai[j/BLEN] & (1L<<(j%BLEN)) ) putchar('1'); |
else putchar('0'); |
else putchar('0'); |
} |
|
putchar('\n'); |
|
} |
} |
|
putchar('\n'); |
|
} |
} |
} |
|
|
NDV vect_to_ndv_2(unsigned long *vect,int col,UINT *s0vect); |
NDV vect_to_ndv_2(unsigned long *vect,int col,UINT *s0vect); |
Line 6961 void red_by_vect_2(matrix mat,int *sugar,unsigned long |
|
Line 7124 void red_by_vect_2(matrix mat,int *sugar,unsigned long |
|
bj = 1L<<rhead%BLEN; |
bj = 1L<<rhead%BLEN; |
a = mat->a; |
a = mat->a; |
for ( i = 0; i < row; i++ ) { |
for ( i = 0; i < row; i++ ) { |
ai = a[i]; |
ai = a[i]; |
if ( ai[wj]&bj ) { |
if ( ai[wj]&bj ) { |
for ( j = 0; j < len; j++ ) |
for ( j = 0; j < len; j++ ) |
ai[pos[j]] ^= v[pos[j]]; |
ai[pos[j]] ^= v[pos[j]]; |
sugar[i] = MAX(sugar[i],rsugar); |
sugar[i] = MAX(sugar[i],rsugar); |
} |
|
} |
} |
|
} |
} |
} |
|
|
NODE nd_f4_red_2(ND_pairs sp0,UINT *s0vect,int col,NODE rp0,ND_pairs *nz) |
NODE nd_f4_red_2(ND_pairs sp0,UINT *s0vect,int col,NODE rp0,ND_pairs *nz) |
Line 6975 NODE nd_f4_red_2(ND_pairs sp0,UINT *s0vect,int col,NOD |
|
Line 7138 NODE nd_f4_red_2(ND_pairs sp0,UINT *s0vect,int col,NOD |
|
int nsp,nred,i,i0,k,rank,row; |
int nsp,nred,i,i0,k,rank,row; |
NODE r0,rp; |
NODE r0,rp; |
ND_pairs sp; |
ND_pairs sp; |
ND spol; |
ND spol; |
NM_ind_pair rt; |
NM_ind_pair rt; |
int *s0hash; |
int *s0hash; |
UINT *s; |
UINT *s; |
int *pivot,*sugar,*head; |
int *pivot,*sugar,*head; |
matrix mat; |
matrix mat; |
NM m; |
NM m; |
NODE r; |
NODE r; |
struct oEGT eg0,eg1,eg2,eg_elim1,eg_elim2; |
struct oEGT eg0,eg1,eg2,eg_elim1,eg_elim2; |
int rhead,rsugar,size; |
int rhead,rsugar,size; |
unsigned long *v; |
unsigned long *v; |
|
|
get_eg(&eg0); |
get_eg(&eg0); |
Line 6996 init_eg(&eg_search); |
|
Line 7159 init_eg(&eg_search); |
|
for ( i = 0, s = s0vect; i < col; i++, s += nd_wpd ) |
for ( i = 0, s = s0vect; i < col; i++, s += nd_wpd ) |
s0hash[i] = ndl_hash_value(s); |
s0hash[i] = ndl_hash_value(s); |
|
|
sugar = (int *)MALLOC(nsp*sizeof(int)); |
sugar = (int *)MALLOC(nsp*sizeof(int)); |
for ( i = 0, sp = sp0; sp; sp = NEXT(sp) ) { |
for ( i = 0, sp = sp0; sp; sp = NEXT(sp) ) { |
nd_sp(2,0,sp,&spol); |
nd_sp(2,0,sp,&spol); |
if ( spol ) { |
if ( spol ) { |
mat->a[i] = nd_to_vect_2(s0vect,col,s0hash,spol); |
mat->a[i] = nd_to_vect_2(s0vect,col,s0hash,spol); |
sugar[i] = SG(spol); |
sugar[i] = SG(spol); |
i++; |
i++; |
} |
} |
} |
} |
mat->row = i; |
mat->row = i; |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"%dx%d,",mat->row,mat->col); fflush(asir_out); |
fprintf(asir_out,"%dx%d,",mat->row,mat->col); fflush(asir_out); |
} |
} |
size = ((col+BLEN-1)/BLEN)*sizeof(unsigned long); |
size = ((col+BLEN-1)/BLEN)*sizeof(unsigned long); |
v = CALLOC((col+BLEN-1)/BLEN,sizeof(unsigned long)); |
v = CALLOC((col+BLEN-1)/BLEN,sizeof(unsigned long)); |
for ( rp = rp0, i = 0; rp; rp = NEXT(rp), i++ ) { |
for ( rp = rp0, i = 0; rp; rp = NEXT(rp), i++ ) { |
rt = (NM_ind_pair)BDY(rp); |
rt = (NM_ind_pair)BDY(rp); |
bzero(v,size); |
bzero(v,size); |
rhead = nd_nm_to_vect_2(s0vect,col,s0hash,nd_ps[rt->index],rt->mul,v); |
rhead = nd_nm_to_vect_2(s0vect,col,s0hash,nd_ps[rt->index],rt->mul,v); |
rsugar = SG(nd_ps[rt->index])+TD(DL(rt->mul)); |
rsugar = SG(nd_ps[rt->index])+TD(DL(rt->mul)); |
red_by_vect_2(mat,sugar,v,rhead,rsugar); |
red_by_vect_2(mat,sugar,v,rhead,rsugar); |
} |
} |
|
|
get_eg(&eg1); |
get_eg(&eg1); |
init_eg(&eg_elim1); add_eg(&eg_elim1,&eg0,&eg1); |
init_eg(&eg_elim1); add_eg(&eg_elim1,&eg0,&eg1); |
rank = rref(mat,sugar); |
rank = rref(mat,sugar); |
|
|
for ( i = 0, r0 = 0; i < rank; i++ ) { |
for ( i = 0, r0 = 0; i < rank; i++ ) { |
NEXTNODE(r0,r); |
NEXTNODE(r0,r); |
BDY(r) = (pointer)vect_to_ndv_2(mat->a[i],col,s0vect); |
BDY(r) = (pointer)vect_to_ndv_2(mat->a[i],col,s0vect); |
SG((NDV)BDY(r)) = sugar[i]; |
SG((NDV)BDY(r)) = sugar[i]; |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
get_eg(&eg2); |
get_eg(&eg2); |
init_eg(&eg_elim2); add_eg(&eg_elim2,&eg1,&eg2); |
init_eg(&eg_elim2); add_eg(&eg_elim2,&eg1,&eg2); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"elim1=%fsec,elim2=%fsec\n", |
fprintf(asir_out,"elim1=%.3fsec,elim2=%.3fsec,", |
eg_elim1.exectime+eg_elim1.gctime,eg_elim2.exectime+eg_elim2.gctime); |
eg_elim1.exectime+eg_elim1.gctime,eg_elim2.exectime+eg_elim2.gctime); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
return r0; |
return r0; |
} |
} |
|
|
Line 7052 NODE nd_f4_red(int m,ND_pairs sp0,int trace,UINT *s0ve |
|
Line 7215 NODE nd_f4_red(int m,ND_pairs sp0,int trace,UINT *s0ve |
|
int *s0hash; |
int *s0hash; |
|
|
if ( m == 2 && nd_rref2 ) |
if ( m == 2 && nd_rref2 ) |
return nd_f4_red_2(sp0,s0vect,col,rp0,nz); |
return nd_f4_red_2(sp0,s0vect,col,rp0,nz); |
|
|
init_eg(&eg_search); |
init_eg(&eg_search); |
for ( sp = sp0, nsp = 0; sp; sp = NEXT(sp), nsp++ ); |
for ( sp = sp0, nsp = 0; sp; sp = NEXT(sp), nsp++ ); |
Line 7063 init_eg(&eg_search); |
|
Line 7226 init_eg(&eg_search); |
|
|
|
/* construction of index arrays */ |
/* construction of index arrays */ |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(stderr,"%dx%d,",nsp+nred,col); |
fprintf(asir_out,"%dx%d,",nsp+nred,col); |
} |
} |
rvect = (NM_ind_pair *)MALLOC(nred*sizeof(NM_ind_pair)); |
rvect = (NM_ind_pair *)MALLOC(nred*sizeof(NM_ind_pair)); |
s0hash = (int *)MALLOC(col*sizeof(int)); |
s0hash = (int *)MALLOC(col*sizeof(int)); |
Line 7074 init_eg(&eg_search); |
|
Line 7237 init_eg(&eg_search); |
|
imat[i] = nm_ind_pair_to_vect_compress(trace,s0vect,col,s0hash,rvect[i]); |
imat[i] = nm_ind_pair_to_vect_compress(trace,s0vect,col,s0hash,rvect[i]); |
rhead[imat[i]->head] = 1; |
rhead[imat[i]->head] = 1; |
} |
} |
if ( m > 0 || m == -1 ) |
if ( m > 0 ) |
|
#if defined(__GNUC__) && SIZEOF_LONG==8 |
|
r0 = nd_f4_red_mod64_main(m,sp0,nsp,s0vect,col,rvect,rhead,imat,nred,nz); |
|
#else |
r0 = nd_f4_red_main(m,sp0,nsp,s0vect,col,rvect,rhead,imat,nred,nz); |
r0 = nd_f4_red_main(m,sp0,nsp,s0vect,col,rvect,rhead,imat,nred,nz); |
|
#endif |
|
else if ( m == -1 ) |
|
r0 = nd_f4_red_sf_main(m,sp0,nsp,s0vect,col,rvect,rhead,imat,nred,nz); |
else if ( m == -2 ) |
else if ( m == -2 ) |
r0 = nd_f4_red_lf_main(m,sp0,nsp,trace,s0vect,col,rvect,rhead,imat,nred); |
r0 = nd_f4_red_lf_main(m,sp0,nsp,trace,s0vect,col,rvect,rhead,imat,nred); |
else |
else |
|
#if defined(VISUAL) |
|
r0 = nd_f4_red_q_main(sp0,nsp,trace,s0vect,col,rvect,rhead,imat,nred); |
|
#else |
r0 = nd_f4_red_gz_main(sp0,nsp,trace,s0vect,col,rvect,rhead,imat,nred); |
r0 = nd_f4_red_gz_main(sp0,nsp,trace,s0vect,col,rvect,rhead,imat,nred); |
|
#endif |
|
#if 0 |
if ( DP_Print ) print_eg("search",&eg_search); |
if ( DP_Print ) print_eg("search",&eg_search); |
|
#endif |
return r0; |
return r0; |
} |
} |
|
|
/* for small finite fields */ |
/* for Fp, 2<=p<2^16 */ |
|
|
NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, |
NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, |
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz) |
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz) |
{ |
{ |
Line 7130 NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s |
|
Line 7306 NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s |
|
} |
} |
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); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"elim1=%fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
fprintf(asir_out,"elim1=%.3fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
/* free index arrays */ |
/* free index arrays */ |
Line 7155 NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s |
|
Line 7331 NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s |
|
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); |
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=%fsec\n",eg_f4_2.exectime+eg_f4_2.gctime); |
fprintf(asir_out,"elim2=%.3fsec,",eg_f4_2.exectime+eg_f4_2.gctime); |
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
nsp,nred,sprow,spcol,rank); |
nsp,nred,sprow,spcol,rank); |
fprintf(asir_out,"%fsec\n",eg_f4.exectime+eg_f4.gctime); |
fprintf(asir_out,"%.3fsec,",eg_f4.exectime+eg_f4.gctime); |
} |
} |
if ( nz ) { |
if ( nz ) { |
for ( i = 0; i < rank-1; i++ ) NEXT(spactive[i]) = spactive[i+1]; |
for ( i = 0; i < rank-1; i++ ) NEXT(spactive[i]) = spactive[i+1]; |
Line 7171 NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s |
|
Line 7347 NODE nd_f4_red_main(int m,ND_pairs sp0,int nsp,UINT *s |
|
return r0; |
return r0; |
} |
} |
|
|
|
#if defined(__GNUC__) && SIZEOF_LONG==8 |
|
/* for Fp, 2^15=<p<2^29 */ |
|
|
|
NODE nd_f4_red_mod64_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, |
|
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz) |
|
{ |
|
int spcol,sprow,a; |
|
int i,j,k,l,rank; |
|
NODE r0,r; |
|
ND_pairs sp; |
|
ND spol; |
|
U64 **spmat; |
|
U64 *svect,*cvect; |
|
U64 *v; |
|
int *colstat; |
|
struct oEGT eg0,eg1,eg2,eg_f4,eg_f4_1,eg_f4_2; |
|
int maxrs; |
|
int *spsugar; |
|
ND_pairs *spactive; |
|
|
|
spcol = col-nred; |
|
get_eg(&eg0); |
|
/* elimination (1st step) */ |
|
spmat = (U64 **)MALLOC(nsp*sizeof(U64 *)); |
|
svect = (U64 *)MALLOC(col*sizeof(U64)); |
|
cvect = (U64 *)MALLOC(col*sizeof(U64)); |
|
spsugar = (int *)MALLOC(nsp*sizeof(int)); |
|
spactive = !nz?0:(ND_pairs *)MALLOC(nsp*sizeof(ND_pairs)); |
|
for ( a = sprow = 0, sp = sp0; a < nsp; a++, sp = NEXT(sp) ) { |
|
nd_sp(m,0,sp,&spol); |
|
if ( !spol ) continue; |
|
nd_to_vect64(m,s0vect,col,spol,svect); |
|
maxrs = ndv_reduce_vect64(m,svect,cvect,col,imat,rvect,nred); |
|
for ( i = 0; i < col; i++ ) if ( svect[i] ) break; |
|
if ( i < col ) { |
|
spmat[sprow] = v = (U64 *)MALLOC_ATOMIC(spcol*sizeof(U64)); |
|
for ( j = k = 0; j < col; j++ ) |
|
if ( !rhead[j] ) v[k++] = (UINT)svect[j]; |
|
spsugar[sprow] = MAX(maxrs,SG(spol)); |
|
if ( nz ) |
|
spactive[sprow] = sp; |
|
sprow++; |
|
} |
|
nd_free(spol); |
|
} |
|
get_eg(&eg1); init_eg(&eg_f4_1); add_eg(&eg_f4_1,&eg0,&eg1); |
|
if ( DP_Print ) { |
|
fprintf(asir_out,"elim1=%.3fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
|
fflush(asir_out); |
|
} |
|
/* free index arrays */ |
|
for ( i = 0; i < nred; i++ ) GCFREE(imat[i]->index.c); |
|
|
|
/* elimination (2nd step) */ |
|
colstat = (int *)MALLOC(spcol*sizeof(int)); |
|
rank = nd_gauss_elim_mod64(spmat,spsugar,spactive,sprow,spcol,m,colstat); |
|
r0 = 0; |
|
for ( i = 0; i < rank; i++ ) { |
|
NEXTNODE(r0,r); BDY(r) = |
|
(pointer)vect64_to_ndv(spmat[i],spcol,col,rhead,s0vect); |
|
SG((NDV)BDY(r)) = spsugar[i]; |
|
GCFREE(spmat[i]); |
|
} |
|
if ( r0 ) NEXT(r) = 0; |
|
|
|
for ( ; i < sprow; i++ ) GCFREE(spmat[i]); |
|
get_eg(&eg2); init_eg(&eg_f4_2); add_eg(&eg_f4_2,&eg1,&eg2); |
|
init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg2); |
|
if ( DP_Print ) { |
|
fprintf(asir_out,"elim2=%.3fsec,",eg_f4_2.exectime+eg_f4_2.gctime); |
|
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
|
nsp,nred,sprow,spcol,rank); |
|
fprintf(asir_out,"%.3fsec,",eg_f4.exectime+eg_f4.gctime); |
|
} |
|
if ( nz ) { |
|
for ( i = 0; i < rank-1; i++ ) NEXT(spactive[i]) = spactive[i+1]; |
|
if ( rank > 0 ) { |
|
NEXT(spactive[rank-1]) = 0; |
|
*nz = spactive[0]; |
|
} else |
|
*nz = 0; |
|
} |
|
return r0; |
|
} |
|
#endif |
|
|
|
/* for small finite fields */ |
|
|
|
NODE nd_f4_red_sf_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, |
|
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred,ND_pairs *nz) |
|
{ |
|
int spcol,sprow,a; |
|
int i,j,k,l,rank; |
|
NODE r0,r; |
|
ND_pairs sp; |
|
ND spol; |
|
int **spmat; |
|
UINT *svect,*v; |
|
int *colstat; |
|
struct oEGT eg0,eg1,eg2,eg_f4,eg_f4_1,eg_f4_2; |
|
int maxrs; |
|
int *spsugar; |
|
ND_pairs *spactive; |
|
|
|
spcol = col-nred; |
|
get_eg(&eg0); |
|
/* elimination (1st step) */ |
|
spmat = (int **)MALLOC(nsp*sizeof(UINT *)); |
|
svect = (UINT *)MALLOC(col*sizeof(UINT)); |
|
spsugar = (int *)MALLOC(nsp*sizeof(int)); |
|
spactive = !nz?0:(ND_pairs *)MALLOC(nsp*sizeof(ND_pairs)); |
|
for ( a = sprow = 0, sp = sp0; a < nsp; a++, sp = NEXT(sp) ) { |
|
nd_sp(m,0,sp,&spol); |
|
if ( !spol ) continue; |
|
nd_to_vect(m,s0vect,col,spol,svect); |
|
maxrs = ndv_reduce_vect_sf(m,svect,col,imat,rvect,nred); |
|
for ( i = 0; i < col; i++ ) if ( svect[i] ) break; |
|
if ( i < col ) { |
|
spmat[sprow] = v = (UINT *)MALLOC_ATOMIC(spcol*sizeof(UINT)); |
|
for ( j = k = 0; j < col; j++ ) |
|
if ( !rhead[j] ) v[k++] = svect[j]; |
|
spsugar[sprow] = MAX(maxrs,SG(spol)); |
|
if ( nz ) |
|
spactive[sprow] = sp; |
|
sprow++; |
|
} |
|
nd_free(spol); |
|
} |
|
get_eg(&eg1); init_eg(&eg_f4_1); add_eg(&eg_f4_1,&eg0,&eg1); |
|
if ( DP_Print ) { |
|
fprintf(asir_out,"elim1=%.3fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
|
fflush(asir_out); |
|
} |
|
/* free index arrays */ |
|
for ( i = 0; i < nred; i++ ) GCFREE(imat[i]->index.c); |
|
|
|
/* elimination (2nd step) */ |
|
colstat = (int *)MALLOC(spcol*sizeof(int)); |
|
rank = nd_gauss_elim_sf(spmat,spsugar,sprow,spcol,m,colstat); |
|
r0 = 0; |
|
for ( i = 0; i < rank; i++ ) { |
|
NEXTNODE(r0,r); BDY(r) = |
|
(pointer)vect_to_ndv(spmat[i],spcol,col,rhead,s0vect); |
|
SG((NDV)BDY(r)) = spsugar[i]; |
|
GCFREE(spmat[i]); |
|
} |
|
if ( r0 ) NEXT(r) = 0; |
|
|
|
for ( ; i < sprow; i++ ) GCFREE(spmat[i]); |
|
get_eg(&eg2); init_eg(&eg_f4_2); add_eg(&eg_f4_2,&eg1,&eg2); |
|
init_eg(&eg_f4); add_eg(&eg_f4,&eg0,&eg2); |
|
if ( DP_Print ) { |
|
fprintf(asir_out,"elim2=%.3fsec,",eg_f4_2.exectime+eg_f4_2.gctime); |
|
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
|
nsp,nred,sprow,spcol,rank); |
|
fprintf(asir_out,"%.3fsec,",eg_f4.exectime+eg_f4.gctime); |
|
} |
|
if ( nz ) { |
|
for ( i = 0; i < rank-1; i++ ) NEXT(spactive[i]) = spactive[i+1]; |
|
if ( rank > 0 ) { |
|
NEXT(spactive[rank-1]) = 0; |
|
*nz = spactive[0]; |
|
} else |
|
*nz = 0; |
|
} |
|
return r0; |
|
} |
|
|
NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int trace,UINT *s0vect,int col, |
NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int trace,UINT *s0vect,int col, |
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred) |
NM_ind_pair *rvect,int *rhead,IndArray *imat,int nred) |
{ |
{ |
Line 7210 NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int |
|
Line 7554 NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int |
|
} |
} |
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); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"elim1=%fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
fprintf(asir_out,"elim1=%.3fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
/* free index arrays */ |
/* free index arrays */ |
Line 7229 NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int |
|
Line 7573 NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int |
|
SG((NDV)w[i]) = spsugar[i]; |
SG((NDV)w[i]) = spsugar[i]; |
#endif |
#endif |
/* GCFREE(spmat[i]); */ |
/* GCFREE(spmat[i]); */ |
|
|
} |
} |
#if 0 |
#if 0 |
qsort(w,rank,sizeof(NDV), |
qsort(w,rank,sizeof(NDV), |
Line 7245 NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int |
|
Line 7589 NODE nd_f4_red_lf_main(int m,ND_pairs sp0,int nsp,int |
|
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); |
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=%fsec\n",eg_f4_2.exectime+eg_f4_2.gctime); |
fprintf(asir_out,"elim2=%.3fsec,",eg_f4_2.exectime+eg_f4_2.gctime); |
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
nsp,nred,sprow,spcol,rank); |
nsp,nred,sprow,spcol,rank); |
fprintf(asir_out,"%fsec\n",eg_f4.exectime+eg_f4.gctime); |
fprintf(asir_out,"%.3fsec,",eg_f4.exectime+eg_f4.gctime); |
} |
} |
return r0; |
return r0; |
} |
} |
Line 7293 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
Line 7637 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
} |
} |
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); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"elim1=%fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
fprintf(asir_out,"elim1=%.3fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
/* free index arrays */ |
/* free index arrays */ |
Line 7327 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
Line 7671 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
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); |
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=%fsec\n",eg_f4_2.exectime+eg_f4_2.gctime); |
fprintf(asir_out,"elim2=%.3fsec,",eg_f4_2.exectime+eg_f4_2.gctime); |
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
nsp,nred,sprow,spcol,rank); |
nsp,nred,sprow,spcol,rank); |
fprintf(asir_out,"%fsec\n",eg_f4.exectime+eg_f4.gctime); |
fprintf(asir_out,"%.3fsec,",eg_f4.exectime+eg_f4.gctime); |
} |
} |
return r0; |
return r0; |
} |
} |
Line 7360 NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace, |
|
Line 7704 NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace, |
|
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(0,trace,sp,&spol); |
nd_sp(0,trace,sp,&spol); |
if ( !spol ) continue; |
if ( !spol ) continue; |
spol = ndtondgz(spol); |
spol = ndtondgz(spol); |
nd_to_vect_q(s0vect,col,spol,(Q *)svect); |
nd_to_vect_q(s0vect,col,spol,(Q *)svect); |
maxrs = ndv_reduce_vect_gz(svect,trace,col,imat,rvect,nred); |
maxrs = ndv_reduce_vect_gz(svect,trace,col,imat,rvect,nred); |
for ( i = 0; i < col; i++ ) if ( svect[i] ) break; |
for ( i = 0; i < col; i++ ) if ( svect[i] ) break; |
Line 7375 NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace, |
|
Line 7719 NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace, |
|
} |
} |
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); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"elim1=%fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
fprintf(asir_out,"elim1=%.3fsec,",eg_f4_1.exectime+eg_f4_1.gctime); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
/* free index arrays */ |
/* free index arrays */ |
Line 7388 NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace, |
|
Line 7732 NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace, |
|
for ( i = 0; i < rank; i++ ) { |
for ( i = 0; i < rank; i++ ) { |
#if 0 |
#if 0 |
w[rank-i-1] = (pointer)vect_to_ndv_gz(spmat[i],spcol,col,rhead,s0vect); |
w[rank-i-1] = (pointer)vect_to_ndv_gz(spmat[i],spcol,col,rhead,s0vect); |
w[rank-i-1] = ndvgztondv(w[rank-i-1]); |
w[rank-i-1] = ndvgztondv(w[rank-i-1]); |
SG((NDV)w[rank-i-1]) = spsugar[i]; |
SG((NDV)w[rank-i-1]) = spsugar[i]; |
#else |
#else |
w[i] = (pointer)vect_to_ndv_gz(spmat[i],spcol,col,rhead,s0vect); |
w[i] = (pointer)vect_to_ndv_gz(spmat[i],spcol,col,rhead,s0vect); |
w[i] = ndvgztondv(w[i]); |
w[i] = ndvgztondv(w[i]); |
SG((NDV)w[i]) = spsugar[i]; |
SG((NDV)w[i]) = spsugar[i]; |
#endif |
#endif |
/* GCFREE(spmat[i]); */ |
/* GCFREE(spmat[i]); */ |
|
|
} |
} |
#if 0 |
#if 0 |
qsort(w,rank,sizeof(NDV), |
qsort(w,rank,sizeof(NDV), |
Line 7412 NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace, |
|
Line 7756 NODE nd_f4_red_gz_main(ND_pairs sp0,int nsp,int trace, |
|
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); |
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=%fsec\n",eg_f4_2.exectime+eg_f4_2.gctime); |
fprintf(asir_out,"elim2=%.3fsec,",eg_f4_2.exectime+eg_f4_2.gctime); |
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
fprintf(asir_out,"nsp=%d,nred=%d,spmat=(%d,%d),rank=%d ", |
nsp,nred,sprow,spcol,rank); |
nsp,nred,sprow,spcol,rank); |
fprintf(asir_out,"%fsec\n",eg_f4.exectime+eg_f4.gctime); |
fprintf(asir_out,"%.3fsec,",eg_f4.exectime+eg_f4.gctime); |
} |
} |
return r0; |
return r0; |
} |
} |
Line 7665 int nd_gauss_elim_mod(int **mat0,int *sugar,ND_pairs * |
|
Line 8009 int nd_gauss_elim_mod(int **mat0,int *sugar,ND_pairs * |
|
return rank; |
return rank; |
} |
} |
|
|
|
#if defined(__GNUC__) && SIZEOF_LONG==8 |
|
|
|
int nd_gauss_elim_mod64(U64 **mat,int *sugar,ND_pairs *spactive,int row,int col,int md,int *colstat) |
|
{ |
|
int i,j,k,l,rank,s; |
|
U64 inv; |
|
U64 a; |
|
UINT c; |
|
U64 *t,*pivot,*pk; |
|
UINT *ck; |
|
UINT **cmat; |
|
UINT *ct; |
|
ND_pairs pair; |
|
|
|
cmat = (UINT **)MALLOC(row*sizeof(UINT *)); |
|
for ( i = 0; i < row; i++ ) { |
|
cmat[i] = MALLOC_ATOMIC(col*sizeof(UINT)); |
|
bzero(cmat[i],col*sizeof(UINT)); |
|
} |
|
|
|
for ( rank = 0, j = 0; j < col; j++ ) { |
|
for ( i = rank; i < row; i++ ) { |
|
a = mat[i][j]; c = cmat[i][j]; |
|
MOD128(a,c,md); |
|
mat[i][j] = a; cmat[i][j] = 0; |
|
} |
|
for ( i = rank; i < row; i++ ) |
|
if ( mat[i][j] ) |
|
break; |
|
if ( i == row ) { |
|
colstat[j] = 0; |
|
continue; |
|
} else |
|
colstat[j] = 1; |
|
if ( i != rank ) { |
|
t = mat[i]; mat[i] = mat[rank]; mat[rank] = t; |
|
ct = cmat[i]; cmat[i] = cmat[rank]; cmat[rank] = ct; |
|
s = sugar[i]; sugar[i] = sugar[rank]; sugar[rank] = s; |
|
if ( spactive ) { |
|
pair = spactive[i]; spactive[i] = spactive[rank]; |
|
spactive[rank] = pair; |
|
} |
|
} |
|
/* column j is normalized */ |
|
s = sugar[rank]; |
|
inv = invm((UINT)mat[rank][j],md); |
|
/* normalize pivot row */ |
|
for ( k = j, pk = mat[rank]+j, ck = cmat[rank]+j; k < col; k++, pk++, ck++ ) { |
|
a = *pk; c = *ck; MOD128(a,c,md); *pk = (a*inv)%md; *ck = 0; |
|
} |
|
for ( i = rank+1; i < row; i++ ) { |
|
if ( a = mat[i][j] ) { |
|
sugar[i] = MAX(sugar[i],s); |
|
red_by_vect64(md,mat[i]+j,cmat[i]+j,mat[rank]+j,(int)(md-a),col-j); |
|
} |
|
} |
|
rank++; |
|
} |
|
for ( j = col-1, l = rank-1; j >= 0; j-- ) |
|
if ( colstat[j] ) { |
|
for ( k = j, pk = mat[l]+j, ck = cmat[l]+j; k < col; k++, pk++, ck++ ) { |
|
a = *pk; c = *ck; MOD128(a,c,md); *pk = a; *ck = 0; |
|
} |
|
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 ) { |
|
sugar[i] = MAX(sugar[i],s); |
|
red_by_vect64(md,mat[i]+j,cmat[i]+j,mat[l]+j,(int)(md-a),col-j); |
|
} |
|
} |
|
l--; |
|
} |
|
for ( i = 0; i < row; i++ ) GCFREE(cmat[i]); |
|
GCFREE(cmat); |
|
return rank; |
|
} |
|
#endif |
|
|
int nd_gauss_elim_sf(int **mat0,int *sugar,int row,int col,int md,int *colstat) |
int nd_gauss_elim_sf(int **mat0,int *sugar,int row,int col,int md,int *colstat) |
{ |
{ |
int i,j,k,l,inv,a,rank,s; |
int i,j,k,l,inv,a,rank,s; |
Line 7781 void nd_save_mod(ND p,int index) |
|
Line 8204 void nd_save_mod(ND p,int index) |
|
sprintf(name,"%s/%d",Demand,index); |
sprintf(name,"%s/%d",Demand,index); |
s = fopen(name,"w"); |
s = fopen(name,"w"); |
if ( !p ) { |
if ( !p ) { |
len = 0; |
len = 0; |
write_int(s,&len); |
write_int(s,&len); |
fclose(s); |
fclose(s); |
return; |
return; |
} |
} |
nv = NV(p); |
nv = NV(p); |
sugar = SG(p); |
sugar = SG(p); |
len = LEN(p); |
len = LEN(p); |
write_int(s,&nv); write_int(s,&sugar); write_int(s,&len); |
write_int(s,&nv); write_int(s,&sugar); write_int(s,&len); |
for ( m = BDY(p); m; m = NEXT(m) ) { |
for ( m = BDY(p); m; m = NEXT(m) ) { |
c = CM(m); write_int(s,&c); |
c = CM(m); write_int(s,&c); |
write_intarray(s,DL(m),nd_wpd); |
write_intarray(s,DL(m),nd_wpd); |
} |
} |
fclose(s); |
fclose(s); |
} |
} |
|
|
Line 7846 ND nd_load_mod(int index) |
|
Line 8269 ND nd_load_mod(int index) |
|
FILE *s; |
FILE *s; |
char name[BUFSIZ]; |
char name[BUFSIZ]; |
int nv,sugar,len,i,c; |
int nv,sugar,len,i,c; |
ND d; |
ND d; |
NM m0,m; |
NM m0,m; |
|
|
sprintf(name,"%s/%d",Demand,index); |
sprintf(name,"%s/%d",Demand,index); |
s = fopen(name,"r"); |
s = fopen(name,"r"); |
/* if the file does not exist, it means p[index]=0 */ |
/* if the file does not exist, it means p[index]=0 */ |
if ( !s ) return 0; |
if ( !s ) return 0; |
|
|
read_int(s,&nv); |
read_int(s,&nv); |
if ( !nv ) { fclose(s); return 0; } |
if ( !nv ) { fclose(s); return 0; } |
|
|
read_int(s,&sugar); |
read_int(s,&sugar); |
read_int(s,&len); |
read_int(s,&len); |
for ( m0 = 0, i = 0; i < len; i++ ) { |
for ( m0 = 0, i = 0; i < len; i++ ) { |
NEXTNM(m0,m); |
NEXTNM(m0,m); |
read_int(s,&c); CM(m) = c; |
read_int(s,&c); CM(m) = c; |
read_intarray(s,DL(m),nd_wpd); |
read_intarray(s,DL(m),nd_wpd); |
} |
} |
NEXT(m) = 0; |
NEXT(m) = 0; |
MKND(nv,m0,len,d); |
MKND(nv,m0,len,d); |
SG(d) = sugar; |
SG(d) = sugar; |
fclose(s); |
fclose(s); |
return d; |
return d; |
} |
} |
|
|
Line 7954 void nd_det(int mod,MAT f,P *rp) |
|
Line 8377 void nd_det(int mod,MAT f,P *rp) |
|
chsgnq(ONE,&mone); |
chsgnq(ONE,&mone); |
for ( j = 0, sgn = 1; j < n; j++ ) { |
for ( j = 0, sgn = 1; j < n; j++ ) { |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(stderr,".",j); |
fprintf(asir_out,".",j); |
} |
} |
for ( i = j; i < n && !dm[i][j]; i++ ); |
for ( i = j; i < n && !dm[i][j]; i++ ); |
if ( i == n ) { |
if ( i == n ) { |
*rp = 0; |
*rp = 0; |
Line 7984 void nd_det(int mod,MAT f,P *rp) |
|
Line 8407 void nd_det(int mod,MAT f,P *rp) |
|
nd_det_reconstruct(dm,n,j,d); |
nd_det_reconstruct(dm,n,j,d); |
|
|
for ( i = j+1, mj = dm[j], mjj = mj[j]; i < n; i++ ) { |
for ( i = j+1, mj = dm[j], mjj = mj[j]; i < n; i++ ) { |
/* if ( DP_Print ) fprintf(stderr," i=%d\n ",i); */ |
/* if ( DP_Print ) fprintf(asir_out," i=%d\n ",i); */ |
mi = dm[i]; mij = mi[j]; |
mi = dm[i]; mij = mi[j]; |
if ( mod ) |
if ( mod ) |
ndv_mul_c(mod,mij,mod-1); |
ndv_mul_c(mod,mij,mod-1); |
else |
else |
ndv_mul_c_q(mij,mone); |
ndv_mul_c_q(mij,mone); |
for ( k = j+1; k < n; k++ ) { |
for ( k = j+1; k < n; k++ ) { |
/* if ( DP_Print ) fprintf(stderr,"k=%d ",k); */ |
/* if ( DP_Print ) fprintf(asir_out,"k=%d ",k); */ |
bucket = create_pbucket(); |
bucket = create_pbucket(); |
if ( mi[k] ) { |
if ( mi[k] ) { |
nmv = BDY(mjj); len = LEN(mjj); |
nmv = BDY(mjj); len = LEN(mjj); |
Line 8010 void nd_det(int mod,MAT f,P *rp) |
|
Line 8433 void nd_det(int mod,MAT f,P *rp) |
|
u = nd_quo(mod,bucket,d); |
u = nd_quo(mod,bucket,d); |
mi[k] = ndtondv(mod,u); |
mi[k] = ndtondv(mod,u); |
} |
} |
/* if ( DP_Print ) fprintf(stderr,"\n",k); */ |
/* if ( DP_Print ) fprintf(asir_out,"\n",k); */ |
} |
} |
d = mjj; |
d = mjj; |
} |
} |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(stderr,"\n",k); |
fprintf(asir_out,"\n",k); |
} |
} |
if ( sgn < 0 ) |
if ( sgn < 0 ) |
if ( mod ) |
if ( mod ) |
Line 8191 int nd_monic(int mod,ND *p) |
|
Line 8614 int nd_monic(int mod,ND *p) |
|
is_lc = 1; |
is_lc = 1; |
while ( 1 ) { |
while ( 1 ) { |
NEWMP(mp0); mp = mp0; |
NEWMP(mp0); mp = mp0; |
mp->c = (P)CQ(m); |
mp->c = (Obj)CQ(m); |
mp->dl = nd_separate_d(DL(m),DL(ma)); |
mp->dl = nd_separate_d(DL(m),DL(ma)); |
NEWNM(mb); |
NEWNM(mb); |
for ( m = NEXT(m); m; m = NEXT(m) ) { |
for ( m = NEXT(m); m; m = NEXT(m) ) { |
alg = nd_separate_d(DL(m),DL(mb)); |
alg = nd_separate_d(DL(m),DL(mb)); |
if ( !ndl_equal(DL(ma),DL(mb)) ) |
if ( !ndl_equal(DL(ma),DL(mb)) ) |
break; |
break; |
NEXTMP(mp0,mp); mp->c = (P)CQ(m); mp->dl = alg; |
NEXTMP(mp0,mp); mp->c = (Obj)CQ(m); mp->dl = alg; |
} |
} |
NEXT(mp) = 0; |
NEXT(mp) = 0; |
MKDP(nd_nalg,mp0,nm); |
MKDP(nd_nalg,mp0,nm); |
Line 8303 P ndctop(int mod,union oNDC c) |
|
Line 8726 P ndctop(int mod,union oNDC c) |
|
|
|
void finalize_tracelist(int i,P cont) |
void finalize_tracelist(int i,P cont) |
{ |
{ |
LIST l; |
LIST l; |
NODE node; |
NODE node; |
Q iq; |
Q iq; |
|
|
if ( !UNIQ(cont) ) { |
if ( !UNIQ(cont) ) { |
node = mknode(4,NULLP,NULLP,NULLP,cont); |
node = mknode(4,NULLP,NULLP,NULLP,cont); |
MKLIST(l,node); MKNODE(node,l,nd_tracelist); |
MKLIST(l,node); MKNODE(node,l,nd_tracelist); |
nd_tracelist = node; |
nd_tracelist = node; |
} |
} |
STOQ(i,iq); |
STOQ(i,iq); |
nd_tracelist = reverse_node(nd_tracelist); |
nd_tracelist = reverse_node(nd_tracelist); |
MKLIST(l,nd_tracelist); |
MKLIST(l,nd_tracelist); |
Line 8323 void finalize_tracelist(int i,P cont) |
|
Line 8746 void finalize_tracelist(int i,P cont) |
|
void conv_ilist(int demand,int trace,NODE g,int **indp) |
void conv_ilist(int demand,int trace,NODE g,int **indp) |
{ |
{ |
int n,i,j; |
int n,i,j; |
int *ind; |
int *ind; |
NODE t; |
NODE t; |
|
|
n = length(g); |
n = length(g); |
ind = (int *)MALLOC(n*sizeof(int)); |
ind = (int *)MALLOC(n*sizeof(int)); |
for ( i = 0, t = g; i < n; i++, t = NEXT(t) ) { |
for ( i = 0, t = g; i < n; i++, t = NEXT(t) ) { |
j = (long)BDY(t); ind[i] = j; |
j = (long)BDY(t); ind[i] = j; |
BDY(t) = (pointer)(demand?ndv_load(j):(trace?nd_ps_trace[j]:nd_ps[j])); |
BDY(t) = (pointer)(demand?ndv_load(j):(trace?nd_ps_trace[j]:nd_ps[j])); |
} |
} |
if ( indp ) *indp = ind; |
if ( indp ) *indp = ind; |
} |
} |
|
|
void parse_nd_option(NODE opt) |
void parse_nd_option(NODE opt) |
{ |
{ |
NODE t,p,u; |
NODE t,p,u; |
int i,s,n; |
int i,s,n; |
char *key; |
char *key; |
Obj value; |
Obj value; |
|
|
nd_gentrace = 0; nd_gensyz = 0; nd_nora = 0; nd_gbblock = 0; |
nd_gentrace = 0; nd_gensyz = 0; nd_nora = 0; nd_gbblock = 0; |
nd_newelim = 0; nd_intersect = 0; nd_nzlist = 0; |
nd_newelim = 0; nd_intersect = 0; nd_nzlist = 0; |
nd_splist = 0; nd_check_splist = 0; |
nd_splist = 0; nd_check_splist = 0; |
nd_sugarweight = 0; |
nd_sugarweight = 0; |
nd_f4red =0; |
nd_f4red =0; |
nd_rank0 = 0; |
nd_rank0 = 0; |
Line 8360 void parse_nd_option(NODE opt) |
|
Line 8783 void parse_nd_option(NODE opt) |
|
nd_nora = value?1:0; |
nd_nora = value?1:0; |
else if ( !strcmp(key,"gbblock") ) { |
else if ( !strcmp(key,"gbblock") ) { |
if ( value && OID(value) == O_LIST ) { |
if ( value && OID(value) == O_LIST ) { |
u = BDY((LIST)value); |
u = BDY((LIST)value); |
nd_gbblock = MALLOC((2*length(u)+1)*sizeof(int)); |
nd_gbblock = MALLOC((2*length(u)+1)*sizeof(int)); |
for ( i = 0; u; u = NEXT(u) ) { |
for ( i = 0; u; u = NEXT(u) ) { |
p = BDY((LIST)BDY(u)); |
p = BDY((LIST)BDY(u)); |
s = nd_gbblock[i++] = QTOS((Q)BDY(p)); |
s = nd_gbblock[i++] = QTOS((Q)BDY(p)); |
nd_gbblock[i++] = s+QTOS((Q)BDY(NEXT(p)))-1; |
nd_gbblock[i++] = s+QTOS((Q)BDY(NEXT(p)))-1; |
} |
} |
nd_gbblock[i] = -1; |
nd_gbblock[i] = -1; |
} else |
} else |
nd_gbblock = 0; |
nd_gbblock = 0; |
} else if ( !strcmp(key,"newelim") ) |
} else if ( !strcmp(key,"newelim") ) |
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,"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") ) { |
u = BDY((LIST)value); |
if ( value ) { |
nd_nzlist = BDY((LIST)ARG2(u)); |
u = BDY((LIST)value); |
nd_bpe = QTOS((Q)ARG3(u)); |
nd_nzlist = BDY((LIST)ARG2(u)); |
} else if ( !strcmp(key,"f4red") ) { |
nd_bpe = QTOS((Q)ARG3(u)); |
nd_f4red = QTOS((Q)value); |
} |
} else if ( !strcmp(key,"rank0") ) { |
} else if ( !strcmp(key,"f4red") ) { |
|
nd_f4red = QTOS((Q)value); |
|
} else if ( !strcmp(key,"rank0") ) { |
nd_rank0 = value?1:0; |
nd_rank0 = value?1:0; |
} else if ( !strcmp(key,"splist") ) { |
} else if ( !strcmp(key,"splist") ) { |
nd_splist = value?1:0; |
nd_splist = value?1:0; |
} else if ( !strcmp(key,"check_splist") ) { |
} else if ( !strcmp(key,"check_splist") ) { |
nd_check_splist = BDY((LIST)value); |
nd_check_splist = BDY((LIST)value); |
} else if ( !strcmp(key,"sugarweight") ) { |
} else if ( !strcmp(key,"sugarweight") ) { |
u = BDY((LIST)value); |
u = BDY((LIST)value); |
n = length(u); |
n = length(u); |
nd_sugarweight = MALLOC(n*sizeof(int)); |
nd_sugarweight = MALLOC(n*sizeof(int)); |
for ( i = 0; i < n; i++, u = NEXT(u) ) |
for ( i = 0; i < n; i++, u = NEXT(u) ) |
nd_sugarweight[i] = QTOS((Q)BDY(u)); |
nd_sugarweight[i] = QTOS((Q)BDY(u)); |
} |
|
} |
} |
|
} |
} |
} |
|
|
ND mdptond(DP d); |
ND mdptond(DP d); |
Line 8412 ND mdptond(DP d) |
|
Line 8837 ND mdptond(DP d) |
|
ND r; |
ND r; |
|
|
if ( OID(d) == 1 ) |
if ( OID(d) == 1 ) |
r = ptond(CO,CO,(P)d); |
r = ptond(CO,CO,(P)d); |
else { |
else { |
NEWNM(m); |
NEWNM(m); |
dltondl(NV(d),BDY(d)->dl,DL(m)); |
dltondl(NV(d),BDY(d)->dl,DL(m)); |
Line 8436 ND nd_mul_nm(int mod,NM m0,ND p) |
|
Line 8861 ND nd_mul_nm(int mod,NM m0,ND p) |
|
mr0 = 0; |
mr0 = 0; |
for ( tm = BDY(p); tm; tm = NEXT(tm) ) { |
for ( tm = BDY(p); tm; tm = NEXT(tm) ) { |
NEXTNM(mr0,mr); |
NEXTNM(mr0,mr); |
c = CM(tm); DMAR(c0,c,0,mod,c1); CM(mr) = c1; |
c = CM(tm); DMAR(c0,c,0,mod,c1); CM(mr) = c1; |
ndl_add(d0,DL(tm),DL(mr)); |
ndl_add(d0,DL(tm),DL(mr)); |
} |
} |
NEXT(mr) = 0; |
NEXT(mr) = 0; |
MKND(NV(p),mr0,LEN(p),r); |
MKND(NV(p),mr0,LEN(p),r); |
Line 8455 ND *btog(NODE ti,ND **p,int nb,int mod) |
|
Line 8880 ND *btog(NODE ti,ND **p,int nb,int mod) |
|
|
|
r = (PGeoBucket *)MALLOC(nb*sizeof(PGeoBucket)); |
r = (PGeoBucket *)MALLOC(nb*sizeof(PGeoBucket)); |
for ( i = 0; i < nb; i++ ) |
for ( i = 0; i < nb; i++ ) |
r[i] = create_pbucket(); |
r[i] = create_pbucket(); |
for ( t = ti; t; t = NEXT(t) ) { |
for ( t = ti; t; t = NEXT(t) ) { |
s = BDY((LIST)BDY(t)); |
s = BDY((LIST)BDY(t)); |
if ( ARG0(s) ) { |
if ( ARG0(s) ) { |
m = mdptond((DP)ARG2(s)); |
m = mdptond((DP)ARG2(s)); |
ptomp(mod,(P)HCQ(m),&c); |
ptomp(mod,(P)HCQ(m),&c); |
if ( ci = ((MQ)c)->cont ) { |
if ( ci = ((MQ)c)->cont ) { |
HCM(m) = ci; |
HCM(m) = ci; |
pi = p[QTOS((Q)ARG1(s))]; |
pi = p[QTOS((Q)ARG1(s))]; |
for ( i = 0; i < nb; i++ ) { |
for ( i = 0; i < nb; i++ ) { |
tp = nd_mul_nm(mod,BDY(m),pi[i]); |
tp = nd_mul_nm(mod,BDY(m),pi[i]); |
add_pbucket(mod,r[i],tp); |
add_pbucket(mod,r[i],tp); |
} |
} |
} |
} |
ci = 1; |
ci = 1; |
} else { |
} else { |
ptomp(mod,(P)ARG3(s),&c); ci = ((MQ)c)->cont; |
ptomp(mod,(P)ARG3(s),&c); ci = ((MQ)c)->cont; |
ci = invm(ci,mod); |
ci = invm(ci,mod); |
} |
|
} |
} |
|
} |
rd = (ND *)MALLOC(nb*sizeof(ND)); |
rd = (ND *)MALLOC(nb*sizeof(ND)); |
for ( i = 0; i < nb; i++ ) |
for ( i = 0; i < nb; i++ ) |
rd[i] = normalize_pbucket(mod,r[i]); |
rd[i] = normalize_pbucket(mod,r[i]); |
if ( ci != 1 ) |
if ( ci != 1 ) |
for ( i = 0; i < nb; i++ ) nd_mul_c(mod,rd[i],ci); |
for ( i = 0; i < nb; i++ ) nd_mul_c(mod,rd[i],ci); |
return rd; |
return rd; |
Line 8494 ND btog_one(NODE ti,ND *p,int nb,int mod) |
|
Line 8919 ND btog_one(NODE ti,ND *p,int nb,int mod) |
|
|
|
r = create_pbucket(); |
r = create_pbucket(); |
for ( t = ti; t; t = NEXT(t) ) { |
for ( t = ti; t; t = NEXT(t) ) { |
s = BDY((LIST)BDY(t)); |
s = BDY((LIST)BDY(t)); |
if ( ARG0(s) ) { |
if ( ARG0(s) ) { |
m = mdptond((DP)ARG2(s)); |
m = mdptond((DP)ARG2(s)); |
ptomp(mod,(P)HCQ(m),&c); |
ptomp(mod,(P)HCQ(m),&c); |
if ( ci = ((MQ)c)->cont ) { |
if ( ci = ((MQ)c)->cont ) { |
HCM(m) = ci; |
HCM(m) = ci; |
pi = p[j=QTOS((Q)ARG1(s))]; |
pi = p[j=QTOS((Q)ARG1(s))]; |
if ( !pi ) { |
if ( !pi ) { |
pi = nd_load_mod(j); |
pi = nd_load_mod(j); |
tp = nd_mul_nm(mod,BDY(m),pi); |
tp = nd_mul_nm(mod,BDY(m),pi); |
nd_free(pi); |
nd_free(pi); |
add_pbucket(mod,r,tp); |
add_pbucket(mod,r,tp); |
} else { |
|
tp = nd_mul_nm(mod,BDY(m),pi); |
|
add_pbucket(mod,r,tp); |
|
} |
|
} |
|
ci = 1; |
|
} else { |
} else { |
ptomp(mod,(P)ARG3(s),&c); ci = ((MQ)c)->cont; |
tp = nd_mul_nm(mod,BDY(m),pi); |
ci = invm(ci,mod); |
add_pbucket(mod,r,tp); |
} |
} |
|
} |
|
ci = 1; |
|
} else { |
|
ptomp(mod,(P)ARG3(s),&c); ci = ((MQ)c)->cont; |
|
ci = invm(ci,mod); |
} |
} |
|
} |
rd = normalize_pbucket(mod,r); |
rd = normalize_pbucket(mod,r); |
free_pbucket(r); |
free_pbucket(r); |
if ( ci != 1 ) nd_mul_c(mod,rd,ci); |
if ( ci != 1 ) nd_mul_c(mod,rd,ci); |
Line 8557 MAT nd_btog(LIST f,LIST v,int mod,struct order_spec *o |
|
Line 8982 MAT nd_btog(LIST f,LIST v,int mod,struct order_spec *o |
|
ind = BDY((LIST)ARG4(BDY(tlist))); |
ind = BDY((LIST)ARG4(BDY(tlist))); |
perm = BDY((LIST)BDY(permtrace)); trace =NEXT(permtrace); |
perm = BDY((LIST)BDY(permtrace)); trace =NEXT(permtrace); |
for ( i = length(perm)-1, t = trace; t; t = NEXT(t) ) { |
for ( i = length(perm)-1, t = trace; t; t = NEXT(t) ) { |
j = QTOS((Q)BDY(BDY((LIST)BDY(t)))); |
j = QTOS((Q)BDY(BDY((LIST)BDY(t)))); |
if ( j > i ) i = j; |
if ( j > i ) i = j; |
} |
} |
n = i+1; |
n = i+1; |
nb = length(BDY(f)); |
nb = length(BDY(f)); |
p = (ND **)MALLOC(n*sizeof(ND *)); |
p = (ND **)MALLOC(n*sizeof(ND *)); |
for ( t = perm, i = 0; t; t = NEXT(t), i++ ) { |
for ( t = perm, i = 0; t; t = NEXT(t), i++ ) { |
pi = BDY((LIST)BDY(t)); |
pi = BDY((LIST)BDY(t)); |
pi0 = QTOS((Q)ARG0(pi)); pi1 = QTOS((Q)ARG1(pi)); |
pi0 = QTOS((Q)ARG0(pi)); pi1 = QTOS((Q)ARG1(pi)); |
p[pi0] = c = (ND *)MALLOC(nb*sizeof(ND)); |
p[pi0] = c = (ND *)MALLOC(nb*sizeof(ND)); |
ptomp(mod,(P)ARG2(pi),&inv); |
ptomp(mod,(P)ARG2(pi),&inv); |
((MQ)inv)->cont = invm(((MQ)inv)->cont,mod); |
((MQ)inv)->cont = invm(((MQ)inv)->cont,mod); |
u = ptond(CO,vv,(P)ONE); |
u = ptond(CO,vv,(P)ONE); |
HCM(u) = ((MQ)inv)->cont; |
HCM(u) = ((MQ)inv)->cont; |
c[pi1] = u; |
c[pi1] = u; |
} |
} |
for ( t = trace,i=0; t; t = NEXT(t), i++ ) { |
for ( t = trace,i=0; t; t = NEXT(t), i++ ) { |
printf("%d ",i); fflush(stdout); |
printf("%d ",i); fflush(stdout); |
ti = BDY((LIST)BDY(t)); |
ti = BDY((LIST)BDY(t)); |
p[j=QTOS((Q)ARG0(ti))] = btog(BDY((LIST)ARG1(ti)),p,nb,mod); |
p[j=QTOS((Q)ARG0(ti))] = btog(BDY((LIST)ARG1(ti)),p,nb,mod); |
} |
} |
for ( t = intred, i=0; t; t = NEXT(t), i++ ) { |
for ( t = intred, i=0; t; t = NEXT(t), i++ ) { |
printf("%d ",i); fflush(stdout); |
printf("%d ",i); fflush(stdout); |
ti = BDY((LIST)BDY(t)); |
ti = BDY((LIST)BDY(t)); |
p[j=QTOS((Q)ARG0(ti))] = btog(BDY((LIST)ARG1(ti)),p,nb,mod); |
p[j=QTOS((Q)ARG0(ti))] = btog(BDY((LIST)ARG1(ti)),p,nb,mod); |
} |
} |
Line 8587 MAT nd_btog(LIST f,LIST v,int mod,struct order_spec *o |
|
Line 9012 MAT nd_btog(LIST f,LIST v,int mod,struct order_spec *o |
|
MKMAT(mat,nb,m); |
MKMAT(mat,nb,m); |
for ( j = 0, t = ind; j < m; j++, t = NEXT(t) ) |
for ( j = 0, t = ind; j < m; j++, t = NEXT(t) ) |
for ( i = 0, c = p[QTOS((Q)BDY(t))]; i < nb; i++ ) |
for ( i = 0, c = p[QTOS((Q)BDY(t))]; i < nb; i++ ) |
BDY(mat)[i][j] = ndtodp(mod,c[i]); |
BDY(mat)[i][j] = ndtodp(mod,c[i]); |
return mat; |
return mat; |
} |
} |
|
|
Line 8626 VECT nd_btog_one(LIST f,LIST v,int mod,struct order_sp |
|
Line 9051 VECT nd_btog_one(LIST f,LIST v,int mod,struct order_sp |
|
ind = BDY((LIST)ARG4(BDY(tlist))); |
ind = BDY((LIST)ARG4(BDY(tlist))); |
perm = BDY((LIST)BDY(permtrace)); trace =NEXT(permtrace); |
perm = BDY((LIST)BDY(permtrace)); trace =NEXT(permtrace); |
for ( i = length(perm)-1, t = trace; t; t = NEXT(t) ) { |
for ( i = length(perm)-1, t = trace; t; t = NEXT(t) ) { |
j = QTOS((Q)BDY(BDY((LIST)BDY(t)))); |
j = QTOS((Q)BDY(BDY((LIST)BDY(t)))); |
if ( j > i ) i = j; |
if ( j > i ) i = j; |
} |
} |
n = i+1; |
n = i+1; |
nb = length(BDY(f)); |
nb = length(BDY(f)); |
p = (ND *)MALLOC(n*sizeof(ND *)); |
p = (ND *)MALLOC(n*sizeof(ND *)); |
for ( t = perm, i = 0; t; t = NEXT(t), i++ ) { |
for ( t = perm, i = 0; t; t = NEXT(t), i++ ) { |
pi = BDY((LIST)BDY(t)); |
pi = BDY((LIST)BDY(t)); |
pi0 = QTOS((Q)ARG0(pi)); pi1 = QTOS((Q)ARG1(pi)); |
pi0 = QTOS((Q)ARG0(pi)); pi1 = QTOS((Q)ARG1(pi)); |
if ( pi1 == pos ) { |
if ( pi1 == pos ) { |
ptomp(mod,(P)ARG2(pi),&inv); |
ptomp(mod,(P)ARG2(pi),&inv); |
((MQ)inv)->cont = invm(((MQ)inv)->cont,mod); |
((MQ)inv)->cont = invm(((MQ)inv)->cont,mod); |
u = ptond(CO,vv,(P)ONE); |
u = ptond(CO,vv,(P)ONE); |
HCM(u) = ((MQ)inv)->cont; |
HCM(u) = ((MQ)inv)->cont; |
p[pi0] = u; |
p[pi0] = u; |
} |
} |
} |
} |
for ( t = trace,i=0; t; t = NEXT(t), i++ ) { |
for ( t = trace,i=0; t; t = NEXT(t), i++ ) { |
printf("%d ",i); fflush(stdout); |
printf("%d ",i); fflush(stdout); |
ti = BDY((LIST)BDY(t)); |
ti = BDY((LIST)BDY(t)); |
p[j=QTOS((Q)ARG0(ti))] = btog_one(BDY((LIST)ARG1(ti)),p,nb,mod); |
p[j=QTOS((Q)ARG0(ti))] = btog_one(BDY((LIST)ARG1(ti)),p,nb,mod); |
if ( Demand ) { |
if ( Demand ) { |
nd_save_mod(p[j],j); nd_free(p[j]); p[j] = 0; |
nd_save_mod(p[j],j); nd_free(p[j]); p[j] = 0; |
} |
|
} |
} |
|
} |
for ( t = intred, i=0; t; t = NEXT(t), i++ ) { |
for ( t = intred, i=0; t; t = NEXT(t), i++ ) { |
printf("%d ",i); fflush(stdout); |
printf("%d ",i); fflush(stdout); |
ti = BDY((LIST)BDY(t)); |
ti = BDY((LIST)BDY(t)); |
p[j=QTOS((Q)ARG0(ti))] = btog_one(BDY((LIST)ARG1(ti)),p,nb,mod); |
p[j=QTOS((Q)ARG0(ti))] = btog_one(BDY((LIST)ARG1(ti)),p,nb,mod); |
if ( Demand ) { |
if ( Demand ) { |
nd_save_mod(p[j],j); nd_free(p[j]); p[j] = 0; |
nd_save_mod(p[j],j); nd_free(p[j]); p[j] = 0; |
} |
|
} |
} |
|
} |
m = length(ind); |
m = length(ind); |
MKVECT(vect,m); |
MKVECT(vect,m); |
for ( j = 0, t = ind; j < m; j++, t = NEXT(t) ) { |
for ( j = 0, t = ind; j < m; j++, t = NEXT(t) ) { |
u = p[QTOS((Q)BDY(t))]; |
u = p[QTOS((Q)BDY(t))]; |
if ( !u ) { |
if ( !u ) { |
u = nd_load_mod(QTOS((Q)BDY(t))); |
u = nd_load_mod(QTOS((Q)BDY(t))); |
BDY(vect)[j] = ndtodp(mod,u); |
BDY(vect)[j] = ndtodp(mod,u); |
nd_free(u); |
nd_free(u); |
} else |
} else |
BDY(vect)[j] = ndtodp(mod,u); |
BDY(vect)[j] = ndtodp(mod,u); |
} |
} |
return vect; |
return vect; |
} |
} |
Line 8808 void nd_f4_lf_trace(LIST f,LIST v,int trace,int homo,s |
|
Line 9233 void nd_f4_lf_trace(LIST f,LIST v,int trace,int homo,s |
|
/* gbcheck : cand is a GB of Id(cand) ? */ |
/* gbcheck : cand is a GB of Id(cand) ? */ |
ret = nd_f4(-2,0,0); |
ret = nd_f4(-2,0,0); |
} |
} |
if ( !ret ) { |
if ( !ret ) { |
/* failure */ |
/* failure */ |
*rp = 0; return; |
*rp = 0; return; |
} |
} |
get_eg(&eg1); init_eg(&eg_check); add_eg(&eg_check,&eg0,&eg1); |
get_eg(&eg1); init_eg(&eg_check); add_eg(&eg_check,&eg0,&eg1); |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"check=%fsec\n",eg_check.exectime+eg_check.gctime); |
fprintf(asir_out,"check=%.3fsec\n",eg_check.exectime+eg_check.gctime); |
/* dp->p */ |
/* dp->p */ |
nd_bpe = cbpe; |
nd_bpe = cbpe; |
nd_setup_parameters(nd_nvar,0); |
nd_setup_parameters(nd_nvar,0); |
Line 8874 NODE nd_f4_lf_trace_main(int m,int **indp) |
|
Line 9299 NODE nd_f4_lf_trace_main(int m,int **indp) |
|
} |
} |
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); |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d,symb=%fsec,", |
fprintf(asir_out,"sugar=%d,symb=%.3fsec,", |
sugar,eg_f4.exectime+eg_f4.gctime); |
sugar,eg_f4.exectime+eg_f4.gctime); |
nflist = nd_f4_red(m,l,0,s0vect,col,rp0,&l0); |
nflist = nd_f4_red(m,l,0,s0vect,col,rp0,&l0); |
if ( !l0 ) continue; |
if ( !l0 ) continue; |
Line 8911 NODE nd_f4_lf_trace_main(int m,int **indp) |
|
Line 9336 NODE nd_f4_lf_trace_main(int m,int **indp) |
|
} |
} |
if ( r || rm ) return 0; |
if ( r || rm ) return 0; |
} |
} |
conv_ilist(nd_demand,1,g,indp); |
conv_ilist(nd_demand,1,g,indp); |
return g; |
return g; |
} |
} |
|
|