version 1.158, 2009/01/04 10:02:00 |
version 1.165, 2009/02/02 02:40:42 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.157 2009/01/04 05:44:51 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.164 2009/01/07 05:33:18 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 57 NDV plain_vect_to_ndv_q(Q *mat,int col,UINT *s0vect); |
|
Line 57 NDV plain_vect_to_ndv_q(Q *mat,int col,UINT *s0vect); |
|
LIST ndvtopl(int mod,VL vl,VL dvl,NDV p,int rank); |
LIST ndvtopl(int mod,VL vl,VL dvl,NDV p,int rank); |
NDV pltondv(VL vl,VL dvl,LIST p); |
NDV pltondv(VL vl,VL dvl,LIST p); |
void pltozpl(LIST l,Q *cont,LIST *pp); |
void pltozpl(LIST l,Q *cont,LIST *pp); |
void ndl_lcm_nocheck(UINT *d1,unsigned *d2,UINT *d); |
void ndl_max(UINT *d1,unsigned *d2,UINT *d); |
|
pointer GC_malloc_atomic_ignore_off_page(int); |
|
|
extern int Denominator,DP_Multiple; |
extern int Denominator,DP_Multiple; |
|
|
Line 216 INLINE int ndl_reducible(UINT *d1,UINT *d2) |
|
Line 217 INLINE int ndl_reducible(UINT *d1,UINT *d2) |
|
* order is either 0 or 2. |
* order is either 0 or 2. |
*/ |
*/ |
|
|
void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepos,int weight) |
void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepos,int ompos,int weight) |
{ |
{ |
int w,i,e,n,omask0; |
int w,i,e,n,omask0; |
|
|
Line 229 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) = d[ompos]; |
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 363 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_lcm_nocheck(UINT *d1,unsigned *d2,UINT *d) |
void ndl_max(UINT *d1,unsigned *d2,UINT *d) |
{ |
{ |
UINT t1,t2,u,u1,u2; |
UINT t1,t2,u,u1,u2; |
int i,j,l; |
int i,j,l; |
|
|
#if USE_UNROLL |
|
switch ( nd_bpe ) { |
|
case 3: |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
t1 = (u1&0x38000000); t2 = (u2&0x38000000); u = t1>t2?t1:t2; |
|
t1 = (u1& 0x7000000); t2 = (u2& 0x7000000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xe00000); t2 = (u2& 0xe00000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0x1c0000); t2 = (u2& 0x1c0000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0x38000); t2 = (u2& 0x38000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0x7000); t2 = (u2& 0x7000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xe00); t2 = (u2& 0xe00); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0x1c0); t2 = (u2& 0x1c0); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0x38); t2 = (u2& 0x38); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0x7); t2 = (u2& 0x7); u |= t1>t2?t1:t2; |
|
d[i] = u; |
|
} |
|
break; |
|
case 4: |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
t1 = (u1&0xf0000000); t2 = (u2&0xf0000000); u = t1>t2?t1:t2; |
|
t1 = (u1& 0xf000000); t2 = (u2& 0xf000000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xf00000); t2 = (u2& 0xf00000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xf0000); t2 = (u2& 0xf0000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xf000); t2 = (u2& 0xf000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xf00); t2 = (u2& 0xf00); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xf0); t2 = (u2& 0xf0); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xf); t2 = (u2& 0xf); u |= t1>t2?t1:t2; |
|
d[i] = u; |
|
} |
|
break; |
|
case 6: |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
t1 = (u1&0x3f000000); t2 = (u2&0x3f000000); u = t1>t2?t1:t2; |
|
t1 = (u1& 0xfc0000); t2 = (u2& 0xfc0000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0x3f000); t2 = (u2& 0x3f000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xfc0); t2 = (u2& 0xfc0); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0x3f); t2 = (u2& 0x3f); u |= t1>t2?t1:t2; |
|
d[i] = u; |
|
} |
|
break; |
|
case 8: |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
t1 = (u1&0xff000000); t2 = (u2&0xff000000); u = t1>t2?t1:t2; |
|
t1 = (u1& 0xff0000); t2 = (u2& 0xff0000); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xff00); t2 = (u2& 0xff00); u |= t1>t2?t1:t2; |
|
t1 = (u1& 0xff); t2 = (u2& 0xff); u |= t1>t2?t1:t2; |
|
d[i] = u; |
|
} |
|
break; |
|
case 16: |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
t1 = (u1&0xffff0000); t2 = (u2&0xffff0000); u = t1>t2?t1:t2; |
|
t1 = (u1& 0xffff); t2 = (u2& 0xffff); u |= t1>t2?t1:t2; |
|
d[i] = u; |
|
} |
|
break; |
|
case 32: |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
d[i] = u1>u2?u1:u2; |
|
} |
|
break; |
|
default: |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
for ( j = 0, u = 0; j < nd_epw; j++ ) { |
|
t1 = (u1&nd_mask[j]); t2 = (u2&nd_mask[j]); u |= t1>t2?t1:t2; |
|
} |
|
d[i] = u; |
|
} |
|
break; |
|
} |
|
#else |
|
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
for ( i = nd_exporigin; i < nd_wpd; i++ ) { |
u1 = d1[i]; u2 = d2[i]; |
u1 = d1[i]; u2 = d2[i]; |
for ( j = 0, u = 0; j < nd_epw; j++ ) { |
for ( j = 0, u = 0; j < nd_epw; j++ ) { |
Line 458 void ndl_lcm_nocheck(UINT *d1,unsigned *d2,UINT *d) |
|
Line 381 void ndl_lcm_nocheck(UINT *d1,unsigned *d2,UINT *d) |
|
} |
} |
d[i] = u; |
d[i] = u; |
} |
} |
#endif |
|
TD(d) = ndl_weight(d); |
|
if ( nd_blockmask ) ndl_weight_mask(d); |
|
if ( nd_module ) MPOS(d) = MPOS(d1); |
|
} |
} |
|
|
int ndl_weight(UINT *d) |
int ndl_weight(UINT *d) |
Line 480 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 647 int ndl_ww_lex_compare(UINT *d1,UINT *d2) |
|
Line 568 int ndl_ww_lex_compare(UINT *d1,UINT *d2) |
|
|
|
int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
{ |
{ |
int i; |
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 ( 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; |
for ( i = nd_nvar-1; i >= 0; i-- ) |
if ( c = ndl_lex_compare(d1,d2) ) return c; |
if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return 1; |
if ( !nd_ispot ) { |
else if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return -1; |
|
if ( !nd_istop ) { |
|
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 667 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
Line 586 int ndl_module_grlex_compare(UINT *d1,UINT *d2) |
|
|
|
int ndl_module_glex_compare(UINT *d1,UINT *d2) |
int ndl_module_glex_compare(UINT *d1,UINT *d2) |
{ |
{ |
int i; |
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 ( 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; |
for ( i = 0; i < nd_nvar; i++ ) |
if ( c = ndl_lex_compare(d1,d2) ) return c; |
if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return 1; |
if ( !nd_ispot ) { |
else if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return -1; |
|
if ( !nd_istop ) { |
|
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 687 int ndl_module_glex_compare(UINT *d1,UINT *d2) |
|
Line 604 int ndl_module_glex_compare(UINT *d1,UINT *d2) |
|
|
|
int ndl_module_lex_compare(UINT *d1,UINT *d2) |
int ndl_module_lex_compare(UINT *d1,UINT *d2) |
{ |
{ |
int i; |
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; |
} |
} |
for ( i = 0; i < nd_nvar; i++ ) |
if ( c = ndl_lex_compare(d1,d2) ) return c; |
if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return 1; |
if ( !nd_ispot ) { |
else if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return -1; |
|
if ( !nd_istop ) { |
|
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 707 int ndl_module_block_compare(UINT *d1,UINT *d2) |
|
Line 622 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 723 int ndl_module_matrix_compare(UINT *d1,UINT *d2) |
|
Line 638 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 739 int ndl_module_composite_compare(UINT *d1,UINT *d2) |
|
Line 654 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 806 INLINE void ndl_add(UINT *d1,UINT *d2,UINT *d) |
|
Line 721 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 824 INLINE void ndl_add(UINT *d1,UINT *d2,UINT *d) |
|
Line 743 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 836 INLINE void ndl_addto(UINT *d1,UINT *d2) |
|
Line 750 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 854 INLINE void ndl_addto(UINT *d1,UINT *d2) |
|
Line 772 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) |
|
|
} |
} |
if ( nd_demand ) |
if ( nd_demand ) |
for ( t = g; t; t = NEXT(t) ) |
for ( t = g; t; t = NEXT(t) ) |
BDY(t) = (pointer)ndv_load((int)BDY(t)); |
BDY(t) = (pointer)ndv_load((long)BDY(t)); |
else |
else |
for ( t = g; t; t = NEXT(t) ) |
for ( t = g; t; t = NEXT(t) ) |
BDY(t) = (pointer)nd_ps[(int)BDY(t)]; |
BDY(t) = (pointer)nd_ps[(long)BDY(t)]; |
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; |
} |
} |
|
|
} |
} |
if ( nd_demand ) |
if ( nd_demand ) |
for ( t = g; t; t = NEXT(t) ) |
for ( t = g; t; t = NEXT(t) ) |
BDY(t) = (pointer)ndv_load((int)BDY(t)); |
BDY(t) = (pointer)ndv_load((long)BDY(t)); |
else |
else |
for ( t = g; t; t = NEXT(t) ) |
for ( t = g; t; t = NEXT(t) ) |
BDY(t) = (pointer)nd_ps_trace[(int)BDY(t)]; |
BDY(t) = (pointer)nd_ps_trace[(long)BDY(t)]; |
if ( nd_nalg ) { |
if ( nd_nalg ) { |
print_eg("monic",&eg_monic); |
print_eg("monic",&eg_monic); |
print_eg("invdalg",&eg_invdalg); |
print_eg("invdalg",&eg_invdalg); |
Line 2262 ND_pairs nd_newpairs( NODE g, int t ) |
|
Line 2175 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); |
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[(int)BDY(h)])) != MPOS(dl)) ) |
if ( nd_module && (MPOS(DL(nd_psh[(long)BDY(h)])) != MPOS(dl)) ) |
continue; |
continue; |
NEXTND_pairs(r0,r); |
NEXTND_pairs(r0,r); |
r->i1 = (int)BDY(h); |
r->i1 = (long)BDY(h); |
r->i2 = t; |
r->i2 = t; |
ndl_lcm(DL(nd_psh[r->i1]),dl,r->lcm); |
ndl_lcm(DL(nd_psh[r->i1]),dl,r->lcm); |
s = SG(nd_psh[r->i1])-TD(DL(nd_psh[r->i1])); |
s = SG(nd_psh[r->i1])-TD(DL(nd_psh[r->i1])); |
Line 2290 ND_pairs crit_B( ND_pairs d, int s ) |
|
Line 2203 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 2423 NODE update_base(NODE nd,int ndp) |
|
Line 2344 NODE update_base(NODE nd,int ndp) |
|
|
|
dl = DL(nd_psh[ndp]); |
dl = DL(nd_psh[ndp]); |
for ( head = last = 0, p = nd; p; ) { |
for ( head = last = 0, p = nd; p; ) { |
dln = DL(nd_psh[(int)BDY(p)]); |
dln = DL(nd_psh[(long)BDY(p)]); |
if ( ndl_reducible( dln, dl ) ) { |
if ( ndl_reducible( dln, dl ) ) { |
p = NEXT(p); |
p = NEXT(p); |
if ( last ) NEXT(last) = p; |
if ( last ) NEXT(last) = p; |
Line 2718 void nd_gr(LIST f,LIST v,int m,int f4,struct order_spe |
|
Line 2639 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 2871 void nd_gr_postproc(LIST f,LIST v,int m,struct order_s |
|
Line 2793 void nd_gr_postproc(LIST f,LIST v,int m,struct order_s |
|
} |
} |
} else { |
} else { |
for ( t = x; t; t = NEXT(t) ) |
for ( t = x; t; t = NEXT(t) ) |
BDY(t) = (pointer)nd_ps[(int)BDY(t)]; |
BDY(t) = (pointer)nd_ps[(long)BDY(t)]; |
} |
} |
x = ndv_reducebase(x); |
x = ndv_reducebase(x); |
x = ndv_reduceall(m,x); |
x = ndv_reduceall(m,x); |
Line 2895 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 2817 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
P p,zp; |
P p,zp; |
Q dmy; |
Q dmy; |
EPOS oepos; |
EPOS oepos; |
int obpe,oadv,wmax,i,len,cbpe,ishomo,nalg,mrank,trank; |
int obpe,oadv,wmax,i,len,cbpe,ishomo,nalg,mrank,trank,ompos; |
Alg alpha,dp; |
Alg alpha,dp; |
P poly; |
P poly; |
LIST f1,f2,zpl; |
LIST f1,f2,zpl; |
Line 2904 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 2826 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 2960 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 2883 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
} |
} |
} |
} |
nd_setup_parameters(nvar,max); |
nd_setup_parameters(nvar,max); |
obpe = nd_bpe; oadv = nmv_adv; oepos = nd_epos; |
obpe = nd_bpe; oadv = nmv_adv; oepos = nd_epos; ompos = nd_mpos; |
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 ) { |
Line 2989 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
Line 2912 void nd_gr_trace(LIST f,LIST v,int trace,int homo,int |
|
nd_init_ord(ord1); |
nd_init_ord(ord1); |
nd_setup_parameters(nvar+1,wmax); |
nd_setup_parameters(nvar+1,wmax); |
for ( t = fd0; t; t = NEXT(t) ) |
for ( t = fd0; t; t = NEXT(t) ) |
ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos); |
ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos,ompos); |
} |
} |
while ( 1 ) { |
while ( 1 ) { |
if ( Demand ) |
if ( Demand ) |
Line 3251 void ndv_removecont(int mod,NDV p) |
|
Line 3174 void ndv_removecont(int mod,NDV p) |
|
|
|
/* koko */ |
/* koko */ |
|
|
void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos) |
void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos,int ompos) |
{ |
{ |
int len,i,max; |
int len,i,max; |
NMV m,mr0,mr,t; |
NMV m,mr0,mr,t; |
Line 3264 void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos |
|
Line 3187 void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos |
|
mr = (NMV)((char *)mr0+(len-1)*nmv_adv); |
mr = (NMV)((char *)mr0+(len-1)*nmv_adv); |
t = (NMV)ALLOCA(nmv_adv); |
t = (NMV)ALLOCA(nmv_adv); |
for ( i = 0; i < len; i++, NMV_OPREV(m), NMV_PREV(mr) ) { |
for ( i = 0; i < len; i++, NMV_OPREV(m), NMV_PREV(mr) ) { |
ndl_homogenize(DL(m),DL(t),obpe,oepos,max); |
ndl_homogenize(DL(m),DL(t),obpe,oepos,ompos,max); |
CQ(mr) = CQ(m); |
CQ(mr) = CQ(m); |
ndl_copy(DL(t),DL(mr)); |
ndl_copy(DL(t),DL(mr)); |
} |
} |
Line 3274 void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos |
|
Line 3197 void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos |
|
|
|
void ndv_dehomogenize(NDV p,struct order_spec *ord) |
void ndv_dehomogenize(NDV p,struct order_spec *ord) |
{ |
{ |
int i,j,adj,len,newnvar,newwpd,newadv,newexporigin; |
int i,j,adj,len,newnvar,newwpd,newadv,newexporigin,newmpos; |
|
int pos; |
Q *w; |
Q *w; |
Q dvr,t; |
Q dvr,t; |
NMV m,r; |
NMV m,r; |
Line 3282 void ndv_dehomogenize(NDV p,struct order_spec *ord) |
|
Line 3206 void ndv_dehomogenize(NDV p,struct order_spec *ord) |
|
len = p->len; |
len = p->len; |
newnvar = nd_nvar-1; |
newnvar = nd_nvar-1; |
newexporigin = nd_get_exporigin(ord); |
newexporigin = nd_get_exporigin(ord); |
|
if ( nd_module ) newmpos = newexporigin-1; |
newwpd = newnvar/nd_epw+(newnvar%nd_epw?1:0)+newexporigin; |
newwpd = newnvar/nd_epw+(newnvar%nd_epw?1:0)+newexporigin; |
for ( m = BDY(p), i = 0; i < len; NMV_ADV(m), i++ ) |
for ( m = BDY(p), i = 0; i < len; NMV_ADV(m), i++ ) |
ndl_dehomogenize(DL(m)); |
ndl_dehomogenize(DL(m)); |
Line 3289 void ndv_dehomogenize(NDV p,struct order_spec *ord) |
|
Line 3214 void ndv_dehomogenize(NDV p,struct order_spec *ord) |
|
newadv = ROUND_FOR_ALIGN(sizeof(struct oNMV)+(newwpd-1)*sizeof(UINT)); |
newadv = ROUND_FOR_ALIGN(sizeof(struct oNMV)+(newwpd-1)*sizeof(UINT)); |
for ( m = r = BDY(p), i = 0; i < len; NMV_ADV(m), NDV_NADV(r), i++ ) { |
for ( m = r = BDY(p), i = 0; i < len; NMV_ADV(m), NDV_NADV(r), i++ ) { |
CQ(r) = CQ(m); |
CQ(r) = CQ(m); |
|
if ( nd_module ) pos = MPOS(DL(m)); |
for ( j = 0; j < newexporigin; j++ ) DL(r)[j] = DL(m)[j]; |
for ( j = 0; j < newexporigin; j++ ) DL(r)[j] = DL(m)[j]; |
adj = nd_exporigin-newexporigin; |
adj = nd_exporigin-newexporigin; |
for ( ; j < newwpd; j++ ) DL(r)[j] = DL(m)[j+adj]; |
for ( ; j < newwpd; j++ ) DL(r)[j] = DL(m)[j+adj]; |
|
if ( nd_module ) { |
|
DL(r)[newmpos] = pos; |
|
} |
} |
} |
} |
} |
NV(p)--; |
NV(p)--; |
Line 3474 UINT *ndv_compute_bound(NDV p) |
|
Line 3403 UINT *ndv_compute_bound(NDV p) |
|
len = LEN(p); |
len = LEN(p); |
m = BDY(p); ndl_copy(DL(m),d1); NMV_ADV(m); |
m = BDY(p); ndl_copy(DL(m),d1); NMV_ADV(m); |
for ( i = 1; i < len; i++, NMV_ADV(m) ) { |
for ( i = 1; i < len; i++, NMV_ADV(m) ) { |
ndl_lcm_nocheck(DL(m),d1,d2); |
ndl_max(DL(m),d1,d2); |
t = d1; d1 = d2; d2 = t; |
t = d1; d1 = d2; d2 = t; |
} |
} |
l = nd_nvar+31; |
l = nd_nvar+31; |
Line 3854 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 3869 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
Line 3799 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
if ( t = tab[j] ) { |
if ( t = tab[j] ) { |
dt = DL(t); |
dt = DL(t); |
PUT_EXP(dt,i,a); PUT_EXP(dt,n2+i,b); TD(dt) += s; |
PUT_EXP(dt,i,a); PUT_EXP(dt,n2+i,b); TD(dt) += s; |
|
if ( nd_module ) { |
|
MPOS(dt) = mpos; |
|
TD(dt) = ndl_weight(dt); |
|
} |
if ( nd_blockmask ) ndl_weight_mask(dt); |
if ( nd_blockmask ) ndl_weight_mask(dt); |
} |
} |
curlen *= k+1; |
curlen *= k+1; |
Line 3890 void weyl_mul_nm_nmv(int n,int mod,NM m0,NMV m1,NM *ta |
|
Line 3824 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 4231 NDV pltondv(VL vl,VL dvl,LIST p) |
|
Line 4168 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 4534 void nd_init_ord(struct order_spec *ord) |
|
Line 4474 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; |
|
switch ( ord->ord.simple ) { |
switch ( ord->ord.simple ) { |
case 0: |
case 0: |
|
nd_isrlex = 1; |
ndl_compare_function = ndl_module_grlex_compare; |
ndl_compare_function = ndl_module_grlex_compare; |
break; |
break; |
case 1: |
case 1: |
|
nd_isrlex = 0; |
ndl_compare_function = ndl_module_glex_compare; |
ndl_compare_function = ndl_module_glex_compare; |
break; |
break; |
case 2: |
case 2: |
|
nd_isrlex = 0; |
ndl_compare_function = ndl_module_lex_compare; |
ndl_compare_function = ndl_module_lex_compare; |
break; |
break; |
default: |
default: |
Line 4578 BlockMask nd_create_blockmask(struct order_spec *ord) |
|
Line 4520 BlockMask nd_create_blockmask(struct order_spec *ord) |
|
BlockMask bm; |
BlockMask bm; |
|
|
/* we only create mask table for block order */ |
/* we only create mask table for block order */ |
if ( ord->id != 1 ) |
if ( ord->id != 1 && ord->id != 257 ) |
return 0; |
return 0; |
n = ord->ord.block.length; |
n = ord->ord.block.length; |
bm = (BlockMask)MALLOC(sizeof(struct oBlockMask)); |
bm = (BlockMask)MALLOC(sizeof(struct oBlockMask)); |
Line 4602 EPOS nd_create_epos(struct order_spec *ord) |
|
Line 4544 EPOS nd_create_epos(struct order_spec *ord) |
|
|
|
epos = (EPOS)MALLOC_ATOMIC(nd_nvar*sizeof(struct oEPOS)); |
epos = (EPOS)MALLOC_ATOMIC(nd_nvar*sizeof(struct oEPOS)); |
switch ( ord->id ) { |
switch ( ord->id ) { |
case 0: |
case 0: case 256: |
if ( nd_isrlex ) { |
if ( nd_isrlex ) { |
for ( i = 0; i < nd_nvar; i++ ) { |
for ( i = 0; i < nd_nvar; i++ ) { |
epos[i].i = nd_exporigin + (nd_nvar-1-i)/nd_epw; |
epos[i].i = nd_exporigin + (nd_nvar-1-i)/nd_epw; |
Line 4615 EPOS nd_create_epos(struct order_spec *ord) |
|
Line 4557 EPOS nd_create_epos(struct order_spec *ord) |
|
} |
} |
} |
} |
break; |
break; |
case 1: |
case 1: case 257: |
/* block order */ |
/* block order */ |
l = ord->ord.block.length; |
l = ord->ord.block.length; |
op = ord->ord.block.order_pair; |
op = ord->ord.block.order_pair; |
Line 5244 NODE nd_f4(int m) |
|
Line 5186 NODE nd_f4(int m) |
|
g = update_base(g,nh); |
g = update_base(g,nh); |
} |
} |
} |
} |
for ( r = g; r; r = NEXT(r) ) BDY(r) = (pointer)nd_ps[(int)BDY(r)]; |
for ( r = g; r; r = NEXT(r) ) BDY(r) = (pointer)nd_ps[(long)BDY(r)]; |
#if 0 |
#if 0 |
fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc); |
fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc); |
#endif |
#endif |
Line 5344 NODE nd_f4_trace(int m) |
|
Line 5286 NODE nd_f4_trace(int m) |
|
g = update_base(g,nh); |
g = update_base(g,nh); |
} |
} |
} |
} |
for ( r = g; r; r = NEXT(r) ) BDY(r) = (pointer)nd_ps_trace[(int)BDY(r)]; |
for ( r = g; r; r = NEXT(r) ) BDY(r) = (pointer)nd_ps_trace[(long)BDY(r)]; |
#if 0 |
#if 0 |
fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc); |
fprintf(asir_out,"ndv_alloc=%d\n",ndv_alloc); |
#endif |
#endif |
Line 6497 int nd_monic(int mod,ND *p) |
|
Line 6439 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; |