version 1.241, 2017/09/16 08:02:35 |
version 1.244, 2018/03/05 06:43:09 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.240 2017/09/15 01:52:51 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.243 2018/03/05 01:56:17 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 3315 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 5824 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__) |
#if defined(__GNUC__) && SIZEOF_LONG==8 |
|
|
#define MOD128(a,c,m) ((a)=(((c)!=0||((a)>=(m)))?(((((U128)(c))<<64)+(a))%(m)):(a))) |
#define MOD128(a,c,m) ((a)=(((c)!=0||((a)>=(m)))?(((((U128)(c))<<64)+(a))%(m)):(a))) |
|
|
Line 6239 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__) |
#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 ndv_reduce_vect64(int m,U64 *svect,U64 *cvect,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
{ |
{ |
Line 6568 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__) |
#if defined(__GNUC__) && SIZEOF_LONG==8 |
NDV vect64_to_ndv(U64 *vect,int spcol,int col,int *rhead,UINT *s0vect) |
NDV vect64_to_ndv(U64 *vect,int spcol,int col,int *rhead,UINT *s0vect) |
{ |
{ |
int j,k,len; |
int j,k,len; |
Line 6804 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; |
Line 6822 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 6831 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 = 1; |
f4red = 1; |
nd_last_nonzero = 0; |
nd_last_nonzero = 0; |
while ( d || nzlist_t ) { |
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 = QTOS((Q)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 6877 NODE nd_f4(int m,int checkonly,int **indp) |
|
Line 6883 NODE nd_f4(int m,int checkonly,int **indp) |
|
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d,symb=%.3fsec,", |
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; |
if ( nflist ) nd_last_nonzero = f4red; |
Line 6893 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 ) { |
Line 7232 init_eg(&eg_search); |
|
Line 7238 init_eg(&eg_search); |
|
rhead[imat[i]->head] = 1; |
rhead[imat[i]->head] = 1; |
} |
} |
if ( m > 0 ) |
if ( m > 0 ) |
#if defined(__GNUC__) |
#if defined(__GNUC__) && SIZEOF_LONG==8 |
r0 = nd_f4_red_mod64_main(m,sp0,nsp,s0vect,col,rvect,rhead,imat,nred,nz); |
r0 = nd_f4_red_mod64_main(m,sp0,nsp,s0vect,col,rvect,rhead,imat,nred,nz); |
#else |
#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); |
Line 7341 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__) |
#if defined(__GNUC__) && SIZEOF_LONG==8 |
/* for Fp, 2^15=<p<2^29 */ |
/* for Fp, 2^15=<p<2^29 */ |
|
|
NODE nd_f4_red_mod64_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, |
NODE nd_f4_red_mod64_main(int m,ND_pairs sp0,int nsp,UINT *s0vect,int col, |
Line 8003 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__) |
#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 nd_gauss_elim_mod64(U64 **mat,int *sugar,ND_pairs *spactive,int row,int col,int md,int *colstat) |
{ |
{ |
Line 8794 void parse_nd_option(NODE opt) |
|
Line 8800 void parse_nd_option(NODE opt) |
|
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)); |
|
nd_bpe = QTOS((Q)ARG3(u)); |
|
} |
} else if ( !strcmp(key,"f4red") ) { |
} else if ( !strcmp(key,"f4red") ) { |
nd_f4red = QTOS((Q)value); |
nd_f4red = QTOS((Q)value); |
} else if ( !strcmp(key,"rank0") ) { |
} else if ( !strcmp(key,"rank0") ) { |