version 1.209, 2013/09/25 02:36:24 |
version 1.214, 2013/09/27 07:00:45 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.208 2013/09/15 04:30:28 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.213 2013/09/27 02:45:17 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
|
|
return 1; |
return 1; |
} |
} |
|
|
|
int check_splist_f4(int m,NODE splist) |
|
{ |
|
UINT *s0vect; |
|
PGeoBucket bucket; |
|
NODE p,rp0,t; |
|
ND_pairs d,r,l,ll; |
|
int col,stat; |
|
|
|
for ( d = 0, t = splist; t; t = NEXT(t) ) { |
|
p = BDY((LIST)BDY(t)); |
|
NEXTND_pairs(d,r); |
|
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); |
|
SG(r) = TD(LCM(r)); /* XXX */ |
|
} |
|
if ( d ) NEXT(r) = 0; |
|
|
|
while ( d ) { |
|
l = nd_minsugarp(d,&d); |
|
bucket = create_pbucket(); |
|
stat = nd_sp_f4(m,0,l,bucket); |
|
if ( !stat ) { |
|
for ( ll = l; NEXT(ll); ll = NEXT(ll) ); |
|
NEXT(ll) = d; d = l; |
|
d = nd_reconstruct(0,d); |
|
continue; |
|
} |
|
if ( bucket->m < 0 ) continue; |
|
col = nd_symbolic_preproc(bucket,0,&s0vect,&rp0); |
|
if ( !col ) { |
|
for ( ll = l; NEXT(ll); ll = NEXT(ll) ); |
|
NEXT(ll) = d; d = l; |
|
d = nd_reconstruct(0,d); |
|
continue; |
|
} |
|
if ( nd_f4_red(m,l,0,s0vect,col,rp0,0) ) return 0; |
|
} |
|
return 1; |
|
} |
|
|
int do_diagonalize_trace(int sugar,int m) |
int do_diagonalize_trace(int sugar,int m) |
{ |
{ |
int i,nh,stat; |
int i,nh,stat; |
Line 2980 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3020 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos,ompos); |
ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos,ompos); |
} |
} |
|
|
ndv_setup(m,0,fd0,(nd_gbblock||nd_splist)?1:0,0); |
ndv_setup(m,0,fd0,(nd_gbblock||nd_splist||nd_check_splist)?1:0,0); |
if ( nd_gentrace ) { |
if ( nd_gentrace ) { |
MKLIST(l1,nd_tracelist); MKNODE(nd_alltracelist,l1,0); |
MKLIST(l1,nd_tracelist); MKNODE(nd_alltracelist,l1,0); |
} |
} |
Line 2989 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
Line 3029 void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int |
|
return; |
return; |
} |
} |
if ( nd_check_splist ) { |
if ( nd_check_splist ) { |
if ( check_splist(m,nd_check_splist) ) *rp = (LIST)ONE; |
if ( f4 ) { |
else *rp = 0; |
if ( check_splist_f4(m,nd_check_splist) ) *rp = (LIST)ONE; |
|
else *rp = 0; |
|
} else { |
|
if ( check_splist(m,nd_check_splist) ) *rp = (LIST)ONE; |
|
else *rp = 0; |
|
} |
return; |
return; |
} |
} |
x = f4?nd_f4(m,&perm):nd_gb(m,ishomo || homo,0,0,&perm); |
x = f4?nd_f4(m,&perm):nd_gb(m,ishomo || homo,0,0,&perm); |
Line 5363 Q *nm_ind_pair_to_vect(int mod,UINT *s0,int n,NM_ind_p |
|
Line 5408 Q *nm_ind_pair_to_vect(int mod,UINT *s0,int n,NM_ind_p |
|
return r; |
return r; |
} |
} |
|
|
IndArray nm_ind_pair_to_vect_compress(int mod,UINT *s0,int n,NM_ind_pair pair) |
IndArray nm_ind_pair_to_vect_compress(int mod,UINT *s0,int n,int *s0hash,NM_ind_pair pair) |
{ |
{ |
NM m; |
NM m; |
NMV mr; |
NMV mr; |
Line 5372 IndArray nm_ind_pair_to_vect_compress(int mod,UINT *s0 |
|
Line 5417 IndArray nm_ind_pair_to_vect_compress(int mod,UINT *s0 |
|
unsigned char *ivc; |
unsigned char *ivc; |
unsigned short *ivs; |
unsigned short *ivs; |
UINT *v,*ivi,*s0v; |
UINT *v,*ivi,*s0v; |
int i,j,len,prev,diff,cdiff; |
int i,j,len,prev,diff,cdiff,h; |
IndArray r; |
IndArray r; |
struct oEGT eg0,eg1; |
struct oEGT eg0,eg1; |
|
|
Line 5385 struct oEGT eg0,eg1; |
|
Line 5430 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); |
for ( ; !ndl_equal(t,s); s += nd_wpd, i++ ); |
h = ndl_hash_value(t); |
|
for ( ; h != s0hash[i] || !ndl_equal(t,s); s += nd_wpd, i++ ); |
v[j] = i; |
v[j] = i; |
} |
} |
get_eg(&eg1); add_eg(&eg_search,&eg0,&eg1); |
get_eg(&eg1); add_eg(&eg_search,&eg0,&eg1); |
Line 5845 NODE nd_f4(int m,int **indp) |
|
Line 5891 NODE nd_f4(int m,int **indp) |
|
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d,symb=%fsec,", |
fprintf(asir_out,"sugar=%d,symb=%fsec,", |
sugar,eg_f4.exectime+eg_f4.gctime); |
sugar,eg_f4.exectime+eg_f4.gctime); |
if ( 1 ) |
nflist = nd_f4_red(m,l,0,s0vect,col,rp0,nd_gentrace?&ll:0); |
nflist = nd_f4_red(m,l,0,s0vect,col,rp0,nd_gentrace?&ll:0); |
|
else |
|
nflist = nd_f4_red_dist(m,l,s0vect,col,rp0,nd_gentrace?&ll:0); |
|
/* adding new bases */ |
/* adding new bases */ |
for ( r = nflist; r; r = NEXT(r) ) { |
for ( r = nflist; r; r = NEXT(r) ) { |
nf = (NDV)BDY(r); |
nf = (NDV)BDY(r); |
Line 6099 NODE nd_f4_red(int m,ND_pairs sp0,int trace,UINT *s0ve |
|
Line 6142 NODE nd_f4_red(int m,ND_pairs sp0,int trace,UINT *s0ve |
|
NODE r0,rp; |
NODE r0,rp; |
ND_pairs sp; |
ND_pairs sp; |
NM_ind_pair *rvect; |
NM_ind_pair *rvect; |
|
UINT *s; |
|
int *s0hash; |
|
|
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++ ); |
nred = length(rp0); |
nred = length(rp0); |
Line 6108 init_eg(&eg_search); |
|
Line 6154 init_eg(&eg_search); |
|
|
|
/* construction of index arrays */ |
/* construction of index arrays */ |
rvect = (NM_ind_pair *)ALLOCA(nred*sizeof(NM_ind_pair)); |
rvect = (NM_ind_pair *)ALLOCA(nred*sizeof(NM_ind_pair)); |
|
s0hash = (int *)ALLOCA(col*sizeof(int)); |
|
for ( i = 0, s = s0vect; i < col; i++, s += nd_wpd ) |
|
s0hash[i] = ndl_hash_value(s); |
for ( rp = rp0, i = 0; rp; i++, rp = NEXT(rp) ) { |
for ( rp = rp0, i = 0; rp; i++, rp = NEXT(rp) ) { |
rvect[i] = (NM_ind_pair)BDY(rp); |
rvect[i] = (NM_ind_pair)BDY(rp); |
imat[i] = nm_ind_pair_to_vect_compress(m,s0vect,col,rvect[i]); |
imat[i] = nm_ind_pair_to_vect_compress(m,s0vect,col,s0hash,rvect[i]); |
rhead[imat[i]->head] = 1; |
rhead[imat[i]->head] = 1; |
} |
} |
if ( m ) |
if ( m ) |
Line 6258 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
Line 6307 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
rank = nd_gauss_elim_q(spmat,spsugar,sprow,spcol,colstat); |
rank = nd_gauss_elim_q(spmat,spsugar,sprow,spcol,colstat); |
w = (pointer *)ALLOCA(rank*sizeof(pointer)); |
w = (pointer *)ALLOCA(rank*sizeof(pointer)); |
for ( i = 0; i < rank; i++ ) { |
for ( i = 0; i < rank; i++ ) { |
|
#if 0 |
w[rank-i-1] = (pointer)vect_to_ndv_q(spmat[i],spcol,col,rhead,s0vect); |
w[rank-i-1] = (pointer)vect_to_ndv_q(spmat[i],spcol,col,rhead,s0vect); |
SG((NDV)w[rank-i-1]) = spsugar[i]; |
SG((NDV)w[rank-i-1]) = spsugar[i]; |
|
#else |
|
w[i] = (pointer)vect_to_ndv_q(spmat[i],spcol,col,rhead,s0vect); |
|
SG((NDV)w[i]) = spsugar[i]; |
|
#endif |
/* GCFREE(spmat[i]); */ |
/* GCFREE(spmat[i]); */ |
} |
} |
#if 0 |
#if 0 |
Line 6435 int ox_exec_f4_red(Q proc) |
|
Line 6489 int ox_exec_f4_red(Q proc) |
|
return s; |
return s; |
} |
} |
|
|
|
#if 0 |
NODE nd_f4_red_dist(int m,ND_pairs sp0,UINT *s0vect,int col,NODE rp0,ND_pairs *nz) |
NODE nd_f4_red_dist(int m,ND_pairs sp0,UINT *s0vect,int col,NODE rp0,ND_pairs *nz) |
{ |
{ |
int nsp,nred; |
int nsp,nred; |
Line 6597 void nd_exec_f4_red_dist() |
|
Line 6652 void nd_exec_f4_red_dist() |
|
} |
} |
fflush(nd_write); |
fflush(nd_write); |
} |
} |
|
#endif |
|
|
int nd_gauss_elim_q(Q **mat0,int *sugar,int row,int col,int *colstat) |
int nd_gauss_elim_q(Q **mat0,int *sugar,int row,int col,int *colstat) |
{ |
{ |