version 1.12, 2003/07/20 08:55:23 |
version 1.14, 2003/07/22 07:12:41 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/engine/distm.c,v 1.11 2003/07/18 10:13:13 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/distm.c,v 1.13 2003/07/21 01:57:51 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "inline.h" |
#include "inline.h" |
Line 896 void adddl_dup(int n,DL d1,DL d2,DL *dr) |
|
Line 896 void adddl_dup(int n,DL d1,DL d2,DL *dr) |
|
#define INLINE |
#define INLINE |
#endif |
#endif |
|
|
|
#define REDTAB_LEN 32003 |
|
|
typedef struct oPGeoBucket { |
typedef struct oPGeoBucket { |
int m; |
int m; |
struct oND *body[32]; |
struct oND *body[32]; |
Line 930 unsigned int nd_mask0; |
|
Line 932 unsigned int nd_mask0; |
|
NM _nm_free_list; |
NM _nm_free_list; |
ND _nd_free_list; |
ND _nd_free_list; |
ND_pairs _ndp_free_list; |
ND_pairs _ndp_free_list; |
|
NM *nd_red; |
|
int nd_red_len; |
|
|
extern int Top,Reverse; |
extern int Top,Reverse; |
int nd_psn,nd_pslen; |
int nd_psn,nd_pslen; |
|
int nd_found,nd_create,nd_notfirst; |
|
|
void GC_gcollect(); |
void GC_gcollect(); |
NODE append_one(NODE,int); |
NODE append_one(NODE,int); |
Line 974 void _ND_alloc(); |
|
Line 979 void _ND_alloc(); |
|
int ndl_td(unsigned int *d); |
int ndl_td(unsigned int *d); |
ND nd_add(ND p1,ND p2); |
ND nd_add(ND p1,ND p2); |
ND nd_mul_nm(ND p,NM m0); |
ND nd_mul_nm(ND p,NM m0); |
|
ND nd_mul_term(ND p,int td,unsigned int *d); |
ND nd_sp(ND_pairs p); |
ND nd_sp(ND_pairs p); |
ND nd_reducer(ND p1,ND p2); |
|
ND nd_find_reducer(ND g); |
ND nd_find_reducer(ND g); |
ND nd_nf(ND g,int full); |
ND nd_nf(ND g,int full); |
|
ND nd_reduce(ND p1,ND p2); |
|
ND nd_reduce_special(ND p1,ND p2); |
|
void nd_free(ND p); |
void ndl_print(unsigned int *dl); |
void ndl_print(unsigned int *dl); |
void nd_print(ND p); |
void nd_print(ND p); |
void ndp_print(ND_pairs d); |
void ndp_print(ND_pairs d); |
int nd_length(ND p); |
int nd_length(ND p); |
void nd_monic(ND p); |
void nd_monic(ND p); |
|
void nd_mul_c(ND p,int mul); |
|
void nd_free_redlist(); |
|
void nd_append_red(unsigned int *d,int td,int i); |
|
|
void nd_free_private_storage() |
void nd_free_private_storage() |
{ |
{ |
_nd_free_list = 0; |
_nd_free_list = 0; |
_nm_free_list = 0; |
_nm_free_list = 0; |
|
nd_red = 0; |
GC_gcollect(); |
GC_gcollect(); |
} |
} |
|
|
Line 996 void _NM_alloc() |
|
Line 1008 void _NM_alloc() |
|
NM p; |
NM p; |
int i; |
int i; |
|
|
for ( i = 0; i < 10240; i++ ) { |
for ( i = 0; i < 16; i++ ) { |
p = (NM)GC_malloc(sizeof(struct oNM)+(nd_wpd-1)*sizeof(unsigned int)); |
p = (NM)GC_malloc(sizeof(struct oNM)+(nd_wpd-1)*sizeof(unsigned int)); |
p->next = _nm_free_list; _nm_free_list = p; |
p->next = _nm_free_list; _nm_free_list = p; |
} |
} |
Line 1007 void _ND_alloc() |
|
Line 1019 void _ND_alloc() |
|
ND p; |
ND p; |
int i; |
int i; |
|
|
for ( i = 0; i < 10240; i++ ) { |
for ( i = 0; i < 1024; i++ ) { |
p = (ND)GC_malloc(sizeof(struct oND)); |
p = (ND)GC_malloc(sizeof(struct oND)); |
p->body = (NM)_nd_free_list; _nd_free_list = p; |
p->body = (NM)_nd_free_list; _nd_free_list = p; |
} |
} |
Line 1058 INLINE int ndl_reducible(unsigned int *d1,unsigned int |
|
Line 1070 INLINE int ndl_reducible(unsigned int *d1,unsigned int |
|
} |
} |
return 1; |
return 1; |
break; |
break; |
|
case 6: |
|
for ( i = 0; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
if ( (u1&0x3f000000) < (u2&0x3f000000) ) return 0; |
|
if ( (u1&0xfc0000) < (u2&0xfc0000) ) return 0; |
|
if ( (u1&0x3f000) < (u2&0x3f000) ) return 0; |
|
if ( (u1&0xfc0) < (u2&0xfc0) ) return 0; |
|
if ( (u1&0x3f) < (u2&0x3f) ) return 0; |
|
} |
|
return 1; |
|
break; |
case 8: |
case 8: |
for ( i = 0; i < nd_wpd; i++ ) { |
for ( i = 0; i < nd_wpd; i++ ) { |
u1 = d1[i]; u2 = d2[i]; |
u1 = d1[i]; u2 = d2[i]; |
Line 1111 void ndl_lcm(unsigned int *d1,unsigned *d2,unsigned in |
|
Line 1134 void ndl_lcm(unsigned int *d1,unsigned *d2,unsigned in |
|
d[i] = u; |
d[i] = u; |
} |
} |
break; |
break; |
|
case 6: |
|
for ( i = 0; 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: |
case 8: |
for ( i = 0; i < nd_wpd; i++ ) { |
for ( i = 0; i < nd_wpd; i++ ) { |
u1 = d1[i]; u2 = d2[i]; |
u1 = d1[i]; u2 = d2[i]; |
Line 1218 int ndl_disjoint(unsigned int *d1,unsigned int *d2) |
|
Line 1252 int ndl_disjoint(unsigned int *d1,unsigned int *d2) |
|
} |
} |
return 1; |
return 1; |
break; |
break; |
|
case 6: |
|
for ( i = 0; i < nd_wpd; i++ ) { |
|
u1 = d1[i]; u2 = d2[i]; |
|
t1 = u1&0x3f000000; t2 = u2&0x3f000000; if ( t1&&t2 ) return 0; |
|
t1 = u1&0xfc0000; t2 = u2&0xfc0000; if ( t1&&t2 ) return 0; |
|
t1 = u1&0x3f000; t2 = u2&0x3f000; if ( t1&&t2 ) return 0; |
|
t1 = u1&0xfc0; t2 = u2&0xfc0; if ( t1&&t2 ) return 0; |
|
t1 = u1&0x3f; t2 = u2&0x3f; if ( t1&&t2 ) return 0; |
|
} |
|
return 1; |
|
break; |
case 8: |
case 8: |
for ( i = 0; i < nd_wpd; i++ ) { |
for ( i = 0; i < nd_wpd; i++ ) { |
u1 = d1[i]; u2 = d2[i]; |
u1 = d1[i]; u2 = d2[i]; |
Line 1256 int ndl_disjoint(unsigned int *d1,unsigned int *d2) |
|
Line 1301 int ndl_disjoint(unsigned int *d1,unsigned int *d2) |
|
|
|
ND nd_reduce(ND p1,ND p2) |
ND nd_reduce(ND p1,ND p2) |
{ |
{ |
int c,t,td,td2,mul; |
int c,c1,c2,t,td,td2,mul; |
NM m2,prev,head,cur,new; |
NM m2,prev,head,cur,new; |
unsigned int *d; |
unsigned int *d; |
|
|
if ( !p1 ) |
if ( !p1 ) |
return 0; |
return 0; |
else { |
else { |
mul = ((nd_mod-HC(p1))*invm(HC(p2),nd_mod))%nd_mod; |
c2 = invm(HC(p2),nd_mod); |
|
c1 = nd_mod-HC(p1); |
|
DMAR(c1,c2,0,nd_mod,mul); |
td = HTD(p1)-HTD(p2); |
td = HTD(p1)-HTD(p2); |
d = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int)); |
d = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int)); |
ndl_sub(HDL(p1),HDL(p2),d); |
ndl_sub(HDL(p1),HDL(p2),d); |
Line 1273 ND nd_reduce(ND p1,ND p2) |
|
Line 1320 ND nd_reduce(ND p1,ND p2) |
|
td2 = new->td = m2->td+td; |
td2 = new->td = m2->td+td; |
ndl_add(m2->dl,d,new->dl); |
ndl_add(m2->dl,d,new->dl); |
if ( !cur ) { |
if ( !cur ) { |
C(new) = (C(m2)*mul)%nd_mod; |
c1 = C(m2); |
|
DMAR(c1,mul,0,nd_mod,c2); |
|
C(new) = c2; |
if ( !prev ) { |
if ( !prev ) { |
prev = new; |
prev = new; |
NEXT(prev) = 0; |
NEXT(prev) = 0; |
Line 1295 ND nd_reduce(ND p1,ND p2) |
|
Line 1344 ND nd_reduce(ND p1,ND p2) |
|
c = ndl_compare(cur->dl,new->dl); |
c = ndl_compare(cur->dl,new->dl); |
switch ( c ) { |
switch ( c ) { |
case 0: |
case 0: |
t = (C(cur)+C(m2)*mul)%nd_mod; |
c2 = C(m2); |
|
c1 = C(cur); |
|
DMAR(c2,mul,c1,nd_mod,t); |
if ( t ) |
if ( t ) |
C(cur) = t; |
C(cur) = t; |
else if ( !prev ) { |
else if ( !prev ) { |
Line 1317 ND nd_reduce(ND p1,ND p2) |
|
Line 1368 ND nd_reduce(ND p1,ND p2) |
|
if ( !prev ) { |
if ( !prev ) { |
/* cur = head */ |
/* cur = head */ |
prev = new; |
prev = new; |
C(prev) = (C(m2)*mul)%nd_mod; |
c2 = C(m2); |
|
DMAR(c2,mul,0,nd_mod,c1); |
|
C(prev) = c1; |
NEXT(prev) = head; |
NEXT(prev) = head; |
head = prev; |
head = prev; |
} else { |
} else { |
C(new) = (C(m2)*mul)%nd_mod; |
c2 = C(m2); |
|
DMAR(c2,mul,0,nd_mod,c1); |
|
C(new) = c1; |
NEXT(prev) = new; |
NEXT(prev) = new; |
NEXT(new) = cur; |
NEXT(new) = cur; |
prev = new; |
prev = new; |
Line 1344 ND nd_reduce(ND p1,ND p2) |
|
Line 1399 ND nd_reduce(ND p1,ND p2) |
|
} |
} |
} |
} |
|
|
|
/* HDL(p1) = HDL(p2) */ |
|
|
|
ND nd_reduce_special(ND p1,ND p2) |
|
{ |
|
int c,c1,c2,t,td,td2,mul; |
|
NM m2,prev,head,cur,new; |
|
|
|
if ( !p1 ) |
|
return 0; |
|
else { |
|
c2 = invm(HC(p2),nd_mod); |
|
c1 = nd_mod-HC(p1); |
|
DMAR(c1,c2,0,nd_mod,mul); |
|
prev = 0; head = cur = BDY(p1); |
|
NEWNM(new); |
|
for ( m2 = BDY(p2); m2; ) { |
|
td2 = new->td = m2->td; |
|
if ( !cur ) { |
|
c1 = C(m2); |
|
DMAR(c1,mul,0,nd_mod,c2); |
|
C(new) = c2; |
|
bcopy(m2->dl,new->dl,nd_wpd*sizeof(unsigned int)); |
|
if ( !prev ) { |
|
prev = new; |
|
NEXT(prev) = 0; |
|
head = prev; |
|
} else { |
|
NEXT(prev) = new; |
|
NEXT(new) = 0; |
|
prev = new; |
|
} |
|
m2 = NEXT(m2); |
|
NEWNM(new); |
|
continue; |
|
} |
|
if ( cur->td > td2 ) |
|
c = 1; |
|
else if ( cur->td < td2 ) |
|
c = -1; |
|
else |
|
c = ndl_compare(cur->dl,m2->dl); |
|
switch ( c ) { |
|
case 0: |
|
c2 = C(m2); |
|
c1 = C(cur); |
|
DMAR(c2,mul,c1,nd_mod,t); |
|
if ( t ) |
|
C(cur) = t; |
|
else if ( !prev ) { |
|
head = NEXT(cur); |
|
FREENM(cur); |
|
cur = head; |
|
} else { |
|
NEXT(prev) = NEXT(cur); |
|
FREENM(cur); |
|
cur = NEXT(prev); |
|
} |
|
m2 = NEXT(m2); |
|
break; |
|
case 1: |
|
prev = cur; |
|
cur = NEXT(cur); |
|
break; |
|
case -1: |
|
bcopy(m2->dl,new->dl,nd_wpd*sizeof(unsigned int)); |
|
if ( !prev ) { |
|
/* cur = head */ |
|
prev = new; |
|
c2 = C(m2); |
|
DMAR(c2,mul,0,nd_mod,c1); |
|
C(prev) = c1; |
|
NEXT(prev) = head; |
|
head = prev; |
|
} else { |
|
c2 = C(m2); |
|
DMAR(c2,mul,0,nd_mod,c1); |
|
C(new) = c1; |
|
NEXT(prev) = new; |
|
NEXT(new) = cur; |
|
prev = new; |
|
} |
|
NEWNM(new); |
|
m2 = NEXT(m2); |
|
break; |
|
} |
|
} |
|
FREENM(new); |
|
if ( head ) { |
|
BDY(p1) = head; |
|
p1->sugar = MAX(p1->sugar,p2->sugar+td); |
|
return p1; |
|
} else { |
|
FREEND(p1); |
|
return 0; |
|
} |
|
|
|
} |
|
} |
|
|
ND nd_sp(ND_pairs p) |
ND nd_sp(ND_pairs p) |
{ |
{ |
NM m; |
NM m; |
Line 1364 ND nd_sp(ND_pairs p) |
|
Line 1518 ND nd_sp(ND_pairs p) |
|
return nd_add(t1,t2); |
return nd_add(t1,t2); |
} |
} |
|
|
ND nd_reducer(ND p1,ND p2) |
int ndl_hash_value(int td,unsigned int *d) |
{ |
{ |
NM m; |
int i; |
ND r; |
int r; |
|
|
|
r = td; |
NEWNM(m); |
for ( i = 0; i < nd_wpd; i++ ) |
C(m) = ((nd_mod-HC(p1))*invm(HC(p2),nd_mod))%nd_mod; |
r = ((r<<16)+d[i])%REDTAB_LEN; |
m->td = HTD(p1)-HTD(p2); |
|
ndl_sub(HDL(p1),HDL(p2),m->dl); |
|
NEXT(m) = 0; |
|
r = nd_mul_nm(p2,m); |
|
FREENM(m); |
|
return r; |
return r; |
} |
} |
|
|
Line 1384 ND nd_find_reducer(ND g) |
|
Line 1533 ND nd_find_reducer(ND g) |
|
{ |
{ |
NM m; |
NM m; |
ND r,p; |
ND r,p; |
int i; |
int i,c1,c2,c; |
|
int d,k; |
|
NM t; |
|
|
|
#if 1 |
|
d = ndl_hash_value(HTD(g),HDL(g)); |
|
for ( m = nd_red[d], k = 0; m; m = NEXT(m), k++ ) { |
|
if ( HTD(g) == m->td && ndl_equal(HDL(g),m->dl) ) { |
|
#if 1 |
|
if ( k > 0 ) nd_notfirst++; |
|
#endif |
|
nd_found++; |
|
p = nps[m->c]; |
|
#if 1 |
|
c1 = invm(HC(p),nd_mod); |
|
c2 = nd_mod-HC(g); |
|
DMAR(c1,c2,0,nd_mod,c); |
|
NEWNM(m); |
|
C(m) = c; |
|
m->td = HTD(g)-HTD(p); |
|
ndl_sub(HDL(g),HDL(p),m->dl); |
|
NEXT(m) = 0; |
|
r = nd_mul_nm(p,m); |
|
FREENM(m); |
|
return r; |
|
#else |
|
return p; |
|
#endif |
|
} |
|
} |
|
#endif |
|
|
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
p = nps[i]; |
p = nps[i]; |
if ( HTD(g) >= HTD(p) && ndl_reducible(HDL(g),HDL(p)) ) { |
if ( HTD(g) >= HTD(p) && ndl_reducible(HDL(g),HDL(p)) ) { |
|
nd_create++; |
#if 1 |
#if 1 |
NEWNM(m); |
NEWNM(m); |
C(m) = ((nd_mod-HC(g))*invm(HC(p),nd_mod))%nd_mod; |
c1 = invm(HC(p),nd_mod); |
|
c2 = nd_mod-HC(g); |
|
DMAR(c1,c2,0,nd_mod,c); |
|
C(m) = c; |
m->td = HTD(g)-HTD(p); |
m->td = HTD(g)-HTD(p); |
ndl_sub(HDL(g),HDL(p),m->dl); |
ndl_sub(HDL(g),HDL(p),m->dl); |
NEXT(m) = 0; |
NEXT(m) = 0; |
r = nd_mul_nm(p,m); |
r = nd_mul_nm(p,m); |
FREENM(m); |
FREENM(m); |
r->sugar = m->td + p->sugar; |
r->sugar = m->td + p->sugar; |
|
nd_append_red(HDL(g),HTD(g),i); |
return r; |
return r; |
#else |
#else |
|
nd_append_red(HDL(g),HTD(g),i); |
return p; |
return p; |
#endif |
#endif |
} |
} |
Line 1407 ND nd_find_reducer(ND g) |
|
Line 1592 ND nd_find_reducer(ND g) |
|
return 0; |
return 0; |
} |
} |
|
|
|
ND nd_find_monic_reducer(ND g) |
|
{ |
|
int *d; |
|
ND p,r; |
|
int i; |
|
|
|
for ( i = 0; i < nd_psn; i++ ) { |
|
p = nps[i]; |
|
if ( HTD(g) >= HTD(p) && ndl_reducible(HDL(g),HDL(p)) ) { |
|
d = (int *)ALLOCA(nd_wpd*sizeof(int)); |
|
ndl_sub(HDL(g),HDL(p),d); |
|
r = nd_mul_term(p,HTD(g)-HTD(p),d); |
|
return r; |
|
} |
|
} |
|
return 0; |
|
} |
|
|
ND nd_add(ND p1,ND p2) |
ND nd_add(ND p1,ND p2) |
{ |
{ |
int n,c; |
int n,c; |
Line 1471 ND nd_mul_nm(ND p,NM m0) |
|
Line 1674 ND nd_mul_nm(ND p,NM m0) |
|
{ |
{ |
NM m,mr,mr0; |
NM m,mr,mr0; |
unsigned int *d,*dt,*dm; |
unsigned int *d,*dt,*dm; |
int c,n,td; |
int c,n,td,i,c1,c2; |
int *pt,*p1,*p2; |
int *pt,*p1,*p2; |
ND r; |
ND r; |
|
|
Line 1483 ND nd_mul_nm(ND p,NM m0) |
|
Line 1686 ND nd_mul_nm(ND p,NM m0) |
|
mr0 = 0; |
mr0 = 0; |
for ( ; m; m = NEXT(m) ) { |
for ( ; m; m = NEXT(m) ) { |
NEXTNM(mr0,mr); |
NEXTNM(mr0,mr); |
C(mr) = (C(m)*c)%nd_mod; |
c1 = C(m); |
|
DMAR(c1,c,0,nd_mod,c2); |
|
C(mr) = c2; |
mr->td = m->td+td; |
mr->td = m->td+td; |
ndl_add(m->dl,d,mr->dl); |
ndl_add(m->dl,d,mr->dl); |
} |
} |
Line 1494 ND nd_mul_nm(ND p,NM m0) |
|
Line 1699 ND nd_mul_nm(ND p,NM m0) |
|
} |
} |
} |
} |
|
|
|
ND nd_mul_term(ND p,int td,unsigned int *d) |
|
{ |
|
NM m,mr,mr0; |
|
int c,n; |
|
ND r; |
|
|
|
if ( !p ) |
|
return 0; |
|
else { |
|
n = NV(p); m = BDY(p); |
|
mr0 = 0; |
|
NEWNM(mr0); |
|
C(mr0) = C(m); |
|
mr0->td = m->td+td; |
|
ndl_add(m->dl,d,mr0->dl); |
|
mr = mr0; |
|
m = NEXT(m); |
|
for ( ; m; m = NEXT(m) ) { |
|
NEWNM(NEXT(mr)); |
|
mr = NEXT(mr); |
|
C(mr) = C(m); |
|
mr->td = m->td+td; |
|
ndl_add(m->dl,d,mr->dl); |
|
} |
|
NEXT(mr) = 0; |
|
MKND(NV(p),mr0,r); |
|
r->sugar = p->sugar + td; |
|
return r; |
|
} |
|
} |
|
|
#if 1 |
#if 1 |
ND nd_nf(ND g,int full) |
ND nd_nf(ND g,int full) |
{ |
{ |
Line 1700 ND nd_nf(ND g,int full) |
|
Line 1936 ND nd_nf(ND g,int full) |
|
|
|
NODE nd_gb(NODE f) |
NODE nd_gb(NODE f) |
{ |
{ |
int i,nh; |
int i,nh,sugar; |
NODE r,g,gall; |
NODE r,g,gall; |
ND_pairs d; |
ND_pairs d; |
ND_pairs l; |
ND_pairs l; |
Line 1712 NODE nd_gb(NODE f) |
|
Line 1948 NODE nd_gb(NODE f) |
|
g = update_base(g,i); |
g = update_base(g,i); |
gall = append_one(gall,i); |
gall = append_one(gall,i); |
} |
} |
|
sugar = 0; |
while ( d ) { |
while ( d ) { |
#if 0 |
#if 0 |
ndp_print(d); |
ndp_print(d); |
#endif |
#endif |
l = nd_minp(d,&d); |
l = nd_minp(d,&d); |
|
if ( l->sugar != sugar ) { |
|
sugar = l->sugar; |
|
fprintf(asir_out,"%d",sugar); |
|
} |
h = nd_sp(l); |
h = nd_sp(l); |
nf = nd_nf(h,!Top); |
nf = nd_nf(h,!Top); |
if ( nf ) { |
if ( nf ) { |
|
|
|
|
NODE nd_setup(NODE f) |
NODE nd_setup(NODE f) |
{ |
{ |
int i; |
int i,td; |
NODE s,s0,f0; |
NODE s,s0,f0; |
|
|
|
nd_found = 0; |
|
nd_notfirst = 0; |
|
nd_create = 0; |
#if 0 |
#if 0 |
f0 = f = NODE_sortb(f,1); |
f0 = f = NODE_sortb(f,1); |
#endif |
#endif |
nd_psn = length(f); nd_pslen = 2*nd_psn; |
nd_psn = length(f); nd_pslen = 2*nd_psn; |
nps = (ND *)MALLOC(nd_pslen*sizeof(ND)); |
nps = (ND *)MALLOC(nd_pslen*sizeof(ND)); |
nd_bpe = 4; |
nd_bpe = 6; |
nd_epw = (sizeof(unsigned int)*8)/nd_bpe; |
nd_epw = (sizeof(unsigned int)*8)/nd_bpe; |
nd_wpd = nd_nvar/nd_epw+(nd_nvar%nd_epw?1:0); |
nd_wpd = nd_nvar/nd_epw+(nd_nvar%nd_epw?1:0); |
nd_mask0 = (1<<nd_bpe)-1; |
if ( nd_bpe < 32 ) { |
|
nd_mask0 = (1<<nd_bpe)-1; |
|
} else { |
|
nd_mask0 = 0xffffffff; |
|
} |
bzero(nd_mask,sizeof(nd_mask)); |
bzero(nd_mask,sizeof(nd_mask)); |
for ( i = 0; i < nd_epw; i++ ) |
for ( i = 0; i < nd_epw; i++ ) |
nd_mask[nd_epw-i-1] = (nd_mask0<<(i*nd_bpe)); |
nd_mask[nd_epw-i-1] = (nd_mask0<<(i*nd_bpe)); |
nd_free_private_storage(); |
nd_free_private_storage(); |
|
td = 0; |
for ( i = 0; i < nd_psn; i++, f = NEXT(f) ) { |
for ( i = 0; i < nd_psn; i++, f = NEXT(f) ) { |
nps[i] = dptond((DP)BDY(f)); |
nps[i] = dptond((DP)BDY(f)); |
|
td = MAX(td,HTD(nps[i])); |
nd_monic(nps[i]); |
nd_monic(nps[i]); |
} |
} |
|
nd_red = (NM *)MALLOC(REDTAB_LEN*sizeof(NM)); |
for ( s0 = 0, i = 0; i < nd_psn; i++ ) { |
for ( s0 = 0, i = 0; i < nd_psn; i++ ) { |
NEXTNODE(s0,s); BDY(s) = (pointer)i; |
NEXTNODE(s0,s); BDY(s) = (pointer)i; |
} |
} |
Line 2082 void nd_gr(LIST f,LIST v,int m,struct order_spec *ord, |
|
Line 2333 void nd_gr(LIST f,LIST v,int m,struct order_spec *ord, |
|
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
MKLIST(*rp,r0); |
MKLIST(*rp,r0); |
|
fprintf(asir_out,"found=%d,notfirst=%d,create=%d\n", |
|
nd_found,nd_notfirst,nd_create); |
} |
} |
|
|
void dltondl(int n,DL dl,unsigned int *r) |
void dltondl(int n,DL dl,unsigned int *r) |
Line 2212 void ndp_print(ND_pairs d) |
|
Line 2465 void ndp_print(ND_pairs d) |
|
|
|
void nd_monic(ND p) |
void nd_monic(ND p) |
{ |
{ |
int mul; |
if ( !p ) |
|
return; |
|
else |
|
nd_mul_c(p,invm(HC(p),nd_mod)); |
|
} |
|
|
|
void nd_mul_c(ND p,int mul) |
|
{ |
NM m; |
NM m; |
|
int c,c1; |
|
|
if ( !p ) |
if ( !p ) |
return; |
return; |
mul = invm(HC(p),nd_mod); |
for ( m = BDY(p); m; m = NEXT(m) ) { |
for ( m = BDY(p); m; m = NEXT(m) ) |
c1 = C(m); |
C(m) = (C(m)*mul)%nd_mod; |
DMAR(c1,mul,0,nd_mod,c); |
|
C(m) = c; |
|
} |
|
} |
|
|
|
void nd_free(ND p) |
|
{ |
|
NM t,s; |
|
|
|
if ( !p ) |
|
return; |
|
t = BDY(p); |
|
while ( t ) { |
|
s = NEXT(t); |
|
FREENM(t); |
|
t = s; |
|
} |
|
FREEND(p); |
|
} |
|
|
|
void nd_append_red(unsigned int *d,int td,int i) |
|
{ |
|
NM m,m0; |
|
int h; |
|
|
|
NEWNM(m); |
|
h = ndl_hash_value(td,d); |
|
m->c = i; |
|
m->td = td; |
|
bcopy(d,m->dl,nd_wpd*sizeof(unsigned int)); |
|
NEXT(m) = nd_red[h]; |
|
nd_red[h] = m; |
} |
} |