version 1.159, 2009/01/05 00:52:20 |
version 1.163, 2009/01/05 06:29:46 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.158 2009/01/04 10:02:00 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.162 2009/01/05 02:47:39 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 46 static int nd_worb_len; |
|
Line 46 static int nd_worb_len; |
|
static int nd_found,nd_create,nd_notfirst; |
static int nd_found,nd_create,nd_notfirst; |
static int nmv_adv; |
static int nmv_adv; |
static int nd_demand; |
static int nd_demand; |
static int nd_module,nd_istop,nd_mpos; |
static int nd_module,nd_ispot,nd_mpos; |
|
|
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 230 void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepo |
|
Line 230 void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepo |
|
} |
} |
w = TD(d); |
w = TD(d); |
PUT_EXP(r,nd_nvar-1,weight-w); |
PUT_EXP(r,nd_nvar-1,weight-w); |
|
if ( nd_module ) MPOS(r) = MPOS(d); |
TD(r) = weight; |
TD(r) = weight; |
if ( nd_blockmask ) ndl_weight_mask(r); |
if ( nd_blockmask ) ndl_weight_mask(r); |
if ( nd_module ) MPOS(r) = MPOS(d); |
|
} |
} |
|
|
void ndl_dehomogenize(UINT *d) |
void ndl_dehomogenize(UINT *d) |
Line 364 void ndl_lcm(UINT *d1,unsigned *d2,UINT *d) |
|
Line 364 void ndl_lcm(UINT *d1,unsigned *d2,UINT *d) |
|
d[i] = u; |
d[i] = u; |
} |
} |
#endif |
#endif |
|
if ( nd_module ) MPOS(d) = MPOS(d1); |
TD(d) = ndl_weight(d); |
TD(d) = ndl_weight(d); |
if ( nd_blockmask ) ndl_weight_mask(d); |
if ( nd_blockmask ) ndl_weight_mask(d); |
if ( nd_module ) MPOS(d) = MPOS(d1); |
|
} |
} |
|
|
void ndl_max(UINT *d1,unsigned *d2,UINT *d) |
void ndl_max(UINT *d1,unsigned *d2,UINT *d) |
Line 399 int ndl_weight(UINT *d) |
|
Line 399 int ndl_weight(UINT *d) |
|
for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) |
for ( j = 0; j < nd_epw; j++, u>>=nd_bpe ) |
t += (u&nd_mask0); |
t += (u&nd_mask0); |
} |
} |
|
if ( nd_module && current_module_weight_vector && MPOS(d) ) |
|
t += current_module_weight_vector[MPOS(d)]; |
return t; |
return t; |
} |
} |
|
|
Line 568 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
Line 570 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
{ |
{ |
int i; |
int i; |
|
|
if ( nd_istop ) { |
if ( nd_ispot ) { |
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 577 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
Line 579 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
for ( i = nd_nvar-1; i >= 0; i-- ) |
for ( i = nd_nvar-1; i >= 0; i-- ) |
if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return 1; |
if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return 1; |
else if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return -1; |
else if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return -1; |
if ( !nd_istop ) { |
if ( !nd_ispot ) { |
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 588 int ndl_module_glex_compare(UINT *d1,UINT *d2) |
|
Line 590 int ndl_module_glex_compare(UINT *d1,UINT *d2) |
|
{ |
{ |
int i; |
int i; |
|
|
if ( nd_istop ) { |
if ( nd_ispot ) { |
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 597 int ndl_module_glex_compare(UINT *d1,UINT *d2) |
|
Line 599 int ndl_module_glex_compare(UINT *d1,UINT *d2) |
|
for ( i = 0; i < nd_nvar; i++ ) |
for ( i = 0; i < nd_nvar; i++ ) |
if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return 1; |
if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return 1; |
else if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return -1; |
else if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return -1; |
if ( !nd_istop ) { |
if ( !nd_ispot ) { |
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 608 int ndl_module_lex_compare(UINT *d1,UINT *d2) |
|
Line 610 int ndl_module_lex_compare(UINT *d1,UINT *d2) |
|
{ |
{ |
int i; |
int i; |
|
|
if ( nd_istop ) { |
if ( nd_ispot ) { |
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; |
} |
} |
for ( i = 0; i < nd_nvar; i++ ) |
for ( i = 0; i < nd_nvar; i++ ) |
if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return 1; |
if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return 1; |
else if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return -1; |
else if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return -1; |
if ( !nd_istop ) { |
if ( !nd_ispot ) { |
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 626 int ndl_module_block_compare(UINT *d1,UINT *d2) |
|
Line 628 int ndl_module_block_compare(UINT *d1,UINT *d2) |
|
{ |
{ |
int i,c; |
int i,c; |
|
|
if ( nd_istop ) { |
if ( nd_ispot ) { |
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; |
} |
} |
if ( c = ndl_block_compare(d1,d2) ) return c; |
if ( c = ndl_block_compare(d1,d2) ) return c; |
if ( !nd_istop ) { |
if ( !nd_ispot ) { |
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 642 int ndl_module_matrix_compare(UINT *d1,UINT *d2) |
|
Line 644 int ndl_module_matrix_compare(UINT *d1,UINT *d2) |
|
{ |
{ |
int i,c; |
int i,c; |
|
|
if ( nd_istop ) { |
if ( nd_ispot ) { |
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; |
} |
} |
if ( c = ndl_matrix_compare(d1,d2) ) return c; |
if ( c = ndl_matrix_compare(d1,d2) ) return c; |
if ( !nd_istop ) { |
if ( !nd_ispot ) { |
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 658 int ndl_module_composite_compare(UINT *d1,UINT *d2) |
|
Line 660 int ndl_module_composite_compare(UINT *d1,UINT *d2) |
|
{ |
{ |
int i,c; |
int i,c; |
|
|
if ( nd_istop ) { |
if ( nd_ispot ) { |
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; |
} |
} |
if ( c = ndl_composite_compare(d1,d2) ) return c; |
if ( c = ndl_composite_compare(d1,d2) ) return c; |
if ( !nd_istop ) { |
if ( !nd_ispot ) { |
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 725 INLINE void ndl_add(UINT *d1,UINT *d2,UINT *d) |
|
Line 727 INLINE void ndl_add(UINT *d1,UINT *d2,UINT *d) |
|
{ |
{ |
int i; |
int i; |
|
|
|
if ( nd_module ) { |
|
if ( MPOS(d1) && MPOS(d2) && (MPOS(d1) != MPOS(d2)) ) |
|
error("ndl_add : invalid operation"); |
|
} |
#if 1 |
#if 1 |
switch ( nd_wpd ) { |
switch ( nd_wpd ) { |
case 2: |
case 2: |
Line 743 INLINE void ndl_add(UINT *d1,UINT *d2,UINT *d) |
|
Line 749 INLINE void ndl_add(UINT *d1,UINT *d2,UINT *d) |
|
#else |
#else |
for ( i = 0; i < nd_wpd; i++ ) d[i] = d1[i]+d2[i]; |
for ( i = 0; i < nd_wpd; i++ ) d[i] = d1[i]+d2[i]; |
#endif |
#endif |
if ( nd_module ) { |
|
if ( MPOS(d1) && MPOS(d2) && (MPOS(d1) != MPOS(d2)) ) |
|
error("ndl_add : invalid operation"); |
|
MPOS(d) = MPOS(d1); |
|
} |
|
} |
} |
|
|
/* d1 += d2 */ |
/* d1 += d2 */ |
Line 755 INLINE void ndl_addto(UINT *d1,UINT *d2) |
|
Line 756 INLINE void ndl_addto(UINT *d1,UINT *d2) |
|
{ |
{ |
int i; |
int i; |
|
|
|
if ( nd_module ) { |
|
if ( MPOS(d1) && MPOS(d2) && (MPOS(d1) != MPOS(d2)) ) |
|
error("ndl_addto : invalid operation"); |
|
} |
#if 1 |
#if 1 |
switch ( nd_wpd ) { |
switch ( nd_wpd ) { |
case 2: |
case 2: |
Line 773 INLINE void ndl_addto(UINT *d1,UINT *d2) |
|
Line 778 INLINE void ndl_addto(UINT *d1,UINT *d2) |
|
#else |
#else |
for ( i = 0; i < nd_wpd; i++ ) d1[i] += d2[i]; |
for ( i = 0; i < nd_wpd; i++ ) d1[i] += d2[i]; |
#endif |
#endif |
if ( nd_module ) { |
|
if ( MPOS(d1) && MPOS(d2) && (MPOS(d1) != MPOS(d2)) ) |
|
error("ndl_addto : invalid operation"); |
|
MPOS(d1) = MPOS(d2); |
|
} |
|
} |
} |
|
|
INLINE void ndl_sub(UINT *d1,UINT *d2,UINT *d) |
INLINE void ndl_sub(UINT *d1,UINT *d2,UINT *d) |
Line 2209 ND_pairs crit_B( ND_pairs d, int s ) |
|
Line 2209 ND_pairs crit_B( ND_pairs d, int s ) |
|
lcm = (UINT *)ALLOCA(nd_wpd*sizeof(UINT)); |
lcm = (UINT *)ALLOCA(nd_wpd*sizeof(UINT)); |
while ( cur ) { |
while ( cur ) { |
tl = cur->lcm; |
tl = cur->lcm; |
if ( ndl_reducible(tl,t) |
if ( ndl_reducible(tl,t) ) { |
&& (ndl_lcm(DL(nd_psh[cur->i1]),t,lcm),!ndl_equal(lcm,tl)) |
ndl_lcm(DL(nd_psh[cur->i1]),t,lcm); |
&& (ndl_lcm(DL(nd_psh[cur->i2]),t,lcm),!ndl_equal(lcm,tl)) ) { |
if ( !ndl_equal(lcm,tl) ) { |
remove = cur; |
ndl_lcm(DL(nd_psh[cur->i2]),t,lcm); |
if ( !prev ) { |
if (!ndl_equal(lcm,tl)) { |
head = cur = NEXT(cur); |
remove = cur; |
} else { |
if ( !prev ) { |
cur = NEXT(prev) = NEXT(cur); |
head = cur = NEXT(cur); |
} |
} else { |
FREENDP(remove); |
cur = NEXT(prev) = NEXT(cur); |
|
} |
|
FREENDP(remove); |
|
} else { |
|
prev = cur; cur = NEXT(cur); |
|
} |
|
} else { |
|
prev = cur; cur = NEXT(cur); |
|
} |
} else { |
} else { |
prev = cur; cur = NEXT(cur); |
prev = cur; cur = NEXT(cur); |
} |
} |
Line 2637 void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe |
|
Line 2645 void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe |
|
NumberField nf; |
NumberField nf; |
struct order_spec *ord1; |
struct order_spec *ord1; |
|
|
|
nd_module = 0; |
if ( !m && Demand ) nd_demand = 1; |
if ( !m && Demand ) nd_demand = 1; |
else nd_demand = 0; |
else nd_demand = 0; |
|
|
Line 2823 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 2832 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
struct order_spec *ord1; |
struct order_spec *ord1; |
struct oEGT eg_check,eg0,eg1; |
struct oEGT eg_check,eg0,eg1; |
|
|
|
nd_module = 0; |
if ( DP_Multiple ) |
if ( DP_Multiple ) |
nd_scale = ((double)DP_Multiple)/(double)(Denominator?Denominator:1); |
nd_scale = ((double)DP_Multiple)/(double)(Denominator?Denominator:1); |
|
|
Line 3773 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
Line 3783 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
} |
} |
if ( nd_module ) { |
if ( nd_module ) { |
mpos = MPOS(d1); |
mpos = MPOS(d1); |
|
TD(d1) = ndl_weight(d1); |
if ( MPOS(d0) ) error("weyl_mul_nm_nmv : invalid operation"); |
if ( MPOS(d0) ) error("weyl_mul_nm_nmv : invalid operation"); |
} |
} |
tab[0] = m; |
tab[0] = m; |
Line 3809 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
Line 3820 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
TD(d) = s; |
TD(d) = s; |
PUT_EXP(d,n-1,s-h); |
PUT_EXP(d,n-1,s-h); |
} else TD(d) = h; |
} else TD(d) = h; |
|
if ( nd_module ) { |
|
MPOS(d) = mpos; |
|
TD(d) = ndl_weight(d); |
|
} |
if ( nd_blockmask ) ndl_weight_mask(d); |
if ( nd_blockmask ) ndl_weight_mask(d); |
if ( nd_module ) MPOS(d) = mpos; |
|
if ( mod ) c = ctab[j]; |
if ( mod ) c = ctab[j]; |
else q = ctab_q[j]; |
else q = ctab_q[j]; |
p = tab+curlen*j; |
p = tab+curlen*j; |
Line 4150 NDV pltondv(VL vl,VL dvl,LIST p) |
|
Line 4164 NDV pltondv(VL vl,VL dvl,LIST p) |
|
r = 0; |
r = 0; |
for ( i = 1, t = BDY(p); t; t = NEXT(t), i++ ) { |
for ( i = 1, t = BDY(p); t; t = NEXT(t), i++ ) { |
ri = ptond(vl,dvl,(P)BDY(t)); |
ri = ptond(vl,dvl,(P)BDY(t)); |
if ( ri ) |
if ( ri ) |
for ( m = BDY(ri); m; m = NEXT(m) ) |
for ( m = BDY(ri); m; m = NEXT(m) ) { |
MPOS(DL(m)) = i; |
MPOS(DL(m)) = i; |
|
TD(DL(m)) = ndl_weight(DL(m)); |
|
if ( nd_blockmask ) ndl_weight_mask(DL(m)); |
|
} |
r = nd_add(0,r,ri); |
r = nd_add(0,r,ri); |
} |
} |
return ndtondv(0,r); |
return ndtondv(0,r); |
Line 4453 void nd_init_ord(struct order_spec *ord) |
|
Line 4470 void nd_init_ord(struct order_spec *ord) |
|
|
|
/* module order */ |
/* module order */ |
case 256: |
case 256: |
nd_istop = ord->istop; |
nd_ispot = ord->ispot; |
nd_dcomp = -1; |
nd_dcomp = -1; |
nd_isrlex = 0; |
nd_isrlex = 0; |
switch ( ord->ord.simple ) { |
switch ( ord->ord.simple ) { |
Line 6416 int nd_monic(int mod,ND *p) |
|
Line 6433 int nd_monic(int mod,ND *p) |
|
PUT_EXP(DL(mr),i+nd_ntrans,e); |
PUT_EXP(DL(mr),i+nd_ntrans,e); |
td += MUL_WEIGHT(e,i+nd_ntrans); |
td += MUL_WEIGHT(e,i+nd_ntrans); |
} |
} |
|
if ( nd_module ) MPOS(DL(mr)) = MPOS(DL(m)); |
TD(DL(mr)) = td; |
TD(DL(mr)) = td; |
if ( nd_blockmask) ndl_weight_mask(DL(mr)); |
if ( nd_blockmask) ndl_weight_mask(DL(mr)); |
if ( nd_module ) MPOS(DL(mr)) = MPOS(DL(m)); |
|
} |
} |
} |
} |
NEXT(mr) = 0; |
NEXT(mr) = 0; |