version 1.150, 2006/12/12 11:50:37 |
version 1.153, 2007/04/30 02:11:12 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.149 2006/12/04 01:40:51 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.152 2006/12/21 07:45:02 ohara Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 50 static int nd_demand; |
|
Line 50 static int nd_demand; |
|
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); |
void nd_det_reconstruct(NDV **dm,int n,int j,NDV d); |
void nd_det_reconstruct(NDV **dm,int n,int j,NDV d); |
|
void nd_heu_nezgcdnpz(VL vl,P *pl,int m,int full,P *pr); |
int nd_monic(int m,ND *p); |
int nd_monic(int m,ND *p); |
NDV plain_vect_to_ndv_q(Q *mat,int col,UINT *s0vect); |
NDV plain_vect_to_ndv_q(Q *mat,int col,UINT *s0vect); |
|
|
Line 1319 int ndv_check_candidate(NODE input,int obpe,int oadv,E |
|
Line 1320 int ndv_check_candidate(NODE input,int obpe,int oadv,E |
|
NODE t,s; |
NODE t,s; |
union oNDC dn; |
union oNDC dn; |
|
|
ndv_setup(0,0,cand,0); |
ndv_setup(0,0,cand,0,1); |
n = length(cand); |
n = length(cand); |
|
|
/* membercheck : list is a subset of Id(cand) ? */ |
/* membercheck : list is a subset of Id(cand) ? */ |
Line 1967 NODE ndv_reduceall(int m,NODE f) |
|
Line 1968 NODE ndv_reduceall(int m,NODE f) |
|
(int (*)(const void *,const void *))ndv_compare); |
(int (*)(const void *,const void *))ndv_compare); |
for ( t = f, i = 0; t; i++, t = NEXT(t) ) BDY(t) = (pointer)w[i]; |
for ( t = f, i = 0; t; i++, t = NEXT(t) ) BDY(t) = (pointer)w[i]; |
#endif |
#endif |
ndv_setup(m,0,f,0); |
ndv_setup(m,0,f,0,1); |
for ( i = 0; i < n; ) { |
for ( i = 0; i < n; ) { |
g = ndvtond(m,nd_ps[i]); |
g = ndvtond(m,nd_ps[i]); |
g = nd_separate_head(g,&head); |
g = nd_separate_head(g,&head); |
Line 2300 int ndv_newps(int m,NDV a,NDV aq) |
|
Line 2301 int ndv_newps(int m,NDV a,NDV aq) |
|
return nd_psn++; |
return nd_psn++; |
} |
} |
|
|
void ndv_setup(int mod,int trace,NODE f,int dont_sort) |
void ndv_setup(int mod,int trace,NODE f,int dont_sort,int dont_removecont) |
{ |
{ |
int i,j,td,len,max; |
int i,j,td,len,max; |
NODE s,s0,f0; |
NODE s,s0,f0; |
Line 2341 void ndv_setup(int mod,int trace,NODE f,int dont_sort) |
|
Line 2342 void ndv_setup(int mod,int trace,NODE f,int dont_sort) |
|
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
if ( trace ) { |
if ( trace ) { |
a = nd_ps_trace[i] = ndv_dup(0,w[i]); |
a = nd_ps_trace[i] = ndv_dup(0,w[i]); |
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); |
ndv_removecont(mod,am); |
ndv_removecont(mod,am); |
} else { |
} else { |
a = nd_ps[i] = ndv_dup(mod,w[i]); |
a = nd_ps[i] = ndv_dup(mod,w[i]); |
ndv_removecont(mod,a); |
if ( mod || !dont_removecont ) ndv_removecont(mod,a); |
if ( !mod ) register_hcf(a); |
if ( !mod ) register_hcf(a); |
} |
} |
NEWRHist(r); SG(r) = HTD(a); ndl_copy(HDL(a),DL(r)); |
NEWRHist(r); SG(r) = HTD(a); ndl_copy(HDL(a),DL(r)); |
Line 2536 void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe |
|
Line 2537 void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe |
|
if ( b ) { NEXTNODE(fd0,fd); BDY(fd) = (pointer)b; } |
if ( b ) { NEXTNODE(fd0,fd); BDY(fd) = (pointer)b; } |
} |
} |
if ( fd0 ) NEXT(fd) = 0; |
if ( fd0 ) NEXT(fd) = 0; |
ndv_setup(m,0,fd0,0); |
ndv_setup(m,0,fd0,0,0); |
x = f4?nd_f4(m):nd_gb(m,ishomo,0); |
x = f4?nd_f4(m):nd_gb(m,ishomo,0); |
nd_demand = 0; |
nd_demand = 0; |
x = ndv_reducebase(x); |
x = ndv_reducebase(x); |
Line 2611 void nd_gr_postproc(LIST f,LIST v,int m,struct order_s |
|
Line 2612 void nd_gr_postproc(LIST f,LIST v,int m,struct order_s |
|
if ( b ) { NEXTNODE(fd0,fd); BDY(fd) = (pointer)b; } |
if ( b ) { NEXTNODE(fd0,fd); BDY(fd) = (pointer)b; } |
} |
} |
if ( fd0 ) NEXT(fd) = 0; |
if ( fd0 ) NEXT(fd) = 0; |
ndv_setup(m,0,fd0,0); |
ndv_setup(m,0,fd0,0,1); |
for ( x = 0, i = 0; i < nd_psn; i++ ) |
for ( x = 0, i = 0; i < nd_psn; i++ ) |
x = update_base(x,i); |
x = update_base(x,i); |
if ( do_check ) { |
if ( do_check ) { |
Line 2729 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 2730 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
while ( 1 ) { |
while ( 1 ) { |
if ( Demand ) |
if ( Demand ) |
nd_demand = 1; |
nd_demand = 1; |
ndv_setup(m,1,fd0,0); |
ndv_setup(m,1,fd0,0,0); |
cand = f4?nd_f4_trace(m):nd_gb_trace(m,ishomo || homo); |
cand = f4?nd_f4_trace(m):nd_gb_trace(m,ishomo || homo); |
if ( !cand ) { |
if ( !cand ) { |
/* failure */ |
/* failure */ |
Line 4274 void nd_nf_p(P f,LIST g,LIST v,int m,struct order_spec |
|
Line 4275 void nd_nf_p(P f,LIST g,LIST v,int m,struct order_spec |
|
if ( m ) ndv_mod(m,(NDV)BDY(in)); |
if ( m ) ndv_mod(m,(NDV)BDY(in)); |
NEXT(in) = 0; |
NEXT(in) = 0; |
|
|
/* dont sort */ |
/* dont sort, dont removecont */ |
ndv_setup(m,0,in0,1); |
ndv_setup(m,0,in0,1,1); |
nd_psn--; |
nd_psn--; |
nd_scale=2; |
nd_scale=2; |
while ( 1 ) { |
while ( 1 ) { |
Line 5805 void nd_det(int mod,MAT f,P *rp) |
|
Line 5806 void nd_det(int mod,MAT f,P *rp) |
|
sgn = -sgn; |
sgn = -sgn; |
} |
} |
bound = nd_det_compute_bound(dm,n,j); |
bound = nd_det_compute_bound(dm,n,j); |
if ( ndl_check_bound(bound,bound) ) |
for ( k = 0; k < nd_nvar; k++ ) |
|
if ( bound[k]*2 > nd_mask0 ) break; |
|
if ( k < nd_nvar ) |
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++ ) { |
Line 5935 void nd_det_reconstruct(NDV **dm,int n,int j,NDV d) |
|
Line 5938 void nd_det_reconstruct(NDV **dm,int n,int j,NDV d) |
|
#endif |
#endif |
} |
} |
|
|
|
/* returns a UINT array containing degree bounds */ |
|
|
UINT *nd_det_compute_bound(NDV **dm,int n,int j) |
UINT *nd_det_compute_bound(NDV **dm,int n,int j) |
{ |
{ |
UINT *d0,*d1,*d,*t,*r; |
UINT *d0,*d1,*d,*t,*r; |
int k,l; |
int k,l,i; |
|
|
d0 = (UINT *)ALLOCA(nd_wpd*sizeof(UINT)); |
d0 = (UINT *)MALLOC(nd_nvar*sizeof(UINT)); |
d1 = (UINT *)ALLOCA(nd_wpd*sizeof(UINT)); |
for ( k = 0; k < nd_nvar; k++ ) d0[k] = 0; |
for ( k = 0; k < nd_wpd; k++ ) d0[k] = 0; |
|
for ( k = j; k < n; k++ ) |
for ( k = j; k < n; k++ ) |
for ( l = j; l < n; l++ ) |
for ( l = j; l < n; l++ ) |
if ( dm[k][l] ) { |
if ( dm[k][l] ) { |
d = ndv_compute_bound(dm[k][l]); |
d = ndv_compute_bound(dm[k][l]); |
ndl_lcm(d,d0,d1); |
for ( i = 0; i < nd_nvar; i++ ) |
t = d1; d1 = d0; d0 = t; |
d0[i] = MAX(d0[i],d[i]); |
} |
} |
r = (UINT *)ALLOCA(nd_wpd*sizeof(UINT)); |
return d0; |
for ( k = 0; k < nd_wpd; k++ ) r[k] = d0[k]; |
|
return r; |
|
} |
} |
|
|
DL nd_separate_d(UINT *d,UINT *trans) |
DL nd_separate_d(UINT *d,UINT *trans) |