version 1.6, 2003/07/25 04:19:54 |
version 1.12, 2003/07/26 03:10:03 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.5 2003/07/24 03:45:41 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.11 2003/07/26 01:00:32 noro Exp $ */ |
|
|
#include "ca.h" |
#include "ca.h" |
#include "inline.h" |
#include "inline.h" |
Line 53 typedef struct oND_pairs { |
|
Line 53 typedef struct oND_pairs { |
|
unsigned int lcm[1]; |
unsigned int lcm[1]; |
} *ND_pairs; |
} *ND_pairs; |
|
|
static ND *nd_ps; |
|
static NDV *nd_psv; |
|
static unsigned int **nd_bound; |
static unsigned int **nd_bound; |
int nd_mod,nd_nvar; |
int nd_mod,nd_nvar; |
int is_rlex; |
int is_rlex; |
Line 71 extern int Top,Reverse; |
|
Line 69 extern int Top,Reverse; |
|
int nd_psn,nd_pslen; |
int nd_psn,nd_pslen; |
int nd_found,nd_create,nd_notfirst; |
int nd_found,nd_create,nd_notfirst; |
int *nd_psl; |
int *nd_psl; |
|
NM *nd_psh; |
|
|
void GC_gcollect(); |
void GC_gcollect(); |
NODE append_one(NODE,int); |
NODE append_one(NODE,int); |
Line 133 unsigned int *nd_compute_bound(ND p); |
|
Line 132 unsigned int *nd_compute_bound(ND p); |
|
unsigned int *dp_compute_bound(DP p); |
unsigned int *dp_compute_bound(DP p); |
ND_pairs nd_reconstruct(ND_pairs); |
ND_pairs nd_reconstruct(ND_pairs); |
void nd_setup_parameters(); |
void nd_setup_parameters(); |
ND nd_dup(ND p,int obpe); |
void nd_realloc(ND p,int obpe); |
ND nd_copy(ND p); |
ND nd_copy(ND p); |
void ndl_dup(int obpe,unsigned int *d,unsigned int *r); |
void ndl_dup(int obpe,unsigned int *d,unsigned int *r); |
|
|
#if USE_NDV |
#if USE_NDV |
|
static NDV *nd_ps; |
|
|
#define NMV_ADV(m) (m = (NMV)(((char *)m)+nmv_adv)) |
#define NMV_ADV(m) (m = (NMV)(((char *)m)+nmv_adv)) |
#define NEWNDV(d) ((d)=(NDV)MALLOC(sizeof(struct oNDV))) |
#define NEWNDV(d) ((d)=(NDV)MALLOC(sizeof(struct oNDV))) |
#define MKNDV(n,m,l,d) NEWNDV(d); (d)->nv=(n); BDY(d)=(m); (d)->len = l; |
#define MKNDV(n,m,l,d) NEWNDV(d); (d)->nv=(n); BDY(d)=(m); (d)->len = l; |
|
|
int nmv_len; |
int nmv_len; |
NDV ndv_red; |
NDV ndv_red; |
|
|
|
void ndv_mul_c(NDV p,int mul); |
ND ndv_add(ND p1,NDV p2); |
ND ndv_add(ND p1,NDV p2); |
NDV ndtondv(ND p); |
NDV ndtondv(ND p); |
void ndv_mul_nm(NDV pv,NM m,NDV r); |
void ndv_mul_nm(NDV pv,NM m,NDV r); |
|
ND ndv_mul_nm_create(NDV p,NM m0); |
|
void ndv_realloc(NDV p,int obpe,int oadv); |
|
NDV dptondv(DP); |
|
DP ndvtodp(NDV); |
|
#else |
|
static ND *nd_ps; |
|
ND dptond(DP); |
|
DP ndtodp(ND); |
#endif |
#endif |
|
|
void nd_free_private_storage() |
void nd_free_private_storage() |
Line 156 void nd_free_private_storage() |
|
Line 166 void nd_free_private_storage() |
|
_nd_free_list = 0; |
_nd_free_list = 0; |
_nm_free_list = 0; |
_nm_free_list = 0; |
_ndp_free_list = 0; |
_ndp_free_list = 0; |
nd_red = 0; |
bzero(nd_red,sizeof(REDTAB_LEN*sizeof(NM))); |
GC_gcollect(); |
GC_gcollect(); |
} |
} |
|
|
Line 165 void _NM_alloc() |
|
Line 175 void _NM_alloc() |
|
NM p; |
NM p; |
int i; |
int i; |
|
|
for ( i = 0; i < 16; i++ ) { |
for ( i = 0; i < 1024; 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 187 void _NDP_alloc() |
|
Line 197 void _NDP_alloc() |
|
ND_pairs p; |
ND_pairs p; |
int i; |
int i; |
|
|
for ( i = 0; i < 10240; i++ ) { |
for ( i = 0; i < 1024; i++ ) { |
p = (ND_pairs)GC_malloc(sizeof(struct oND_pairs) |
p = (ND_pairs)GC_malloc(sizeof(struct oND_pairs) |
+(nd_wpd-1)*sizeof(unsigned int)); |
+(nd_wpd-1)*sizeof(unsigned int)); |
p->next = _ndp_free_list; _ndp_free_list = p; |
p->next = _ndp_free_list; _ndp_free_list = p; |
Line 773 int ndl_check_bound2(int index,unsigned int *d2) |
|
Line 783 int ndl_check_bound2(int index,unsigned int *d2) |
|
} |
} |
} |
} |
|
|
int nd_sp(ND_pairs p,ND *rp) |
|
{ |
|
NM m; |
|
ND p1,p2,t1,t2; |
|
unsigned int *lcm; |
|
int td; |
|
|
|
p1 = nd_ps[p->i1]; |
|
p2 = nd_ps[p->i2]; |
|
lcm = p->lcm; |
|
td = p->td; |
|
NEWNM(m); |
|
C(m) = HC(p2); m->td = td-HTD(p1); ndl_sub(lcm,HDL(p1),m->dl); NEXT(m) = 0; |
|
if ( ndl_check_bound2(p->i1,m->dl) ) |
|
return 0; |
|
t1 = nd_mul_nm(p1,m); |
|
C(m) = nd_mod-HC(p1); m->td = td-HTD(p2); ndl_sub(lcm,HDL(p2),m->dl); |
|
if ( ndl_check_bound2(p->i2,m->dl) ) { |
|
nd_free(t1); |
|
return 0; |
|
} |
|
t2 = nd_mul_nm(p2,m); |
|
FREENM(m); |
|
*rp = nd_add(t1,t2); |
|
return 1; |
|
} |
|
|
|
INLINE int ndl_hash_value(int td,unsigned int *d) |
INLINE int ndl_hash_value(int td,unsigned int *d) |
{ |
{ |
int i; |
int i; |
Line 814 INLINE int ndl_hash_value(int td,unsigned int *d) |
|
Line 797 INLINE int ndl_hash_value(int td,unsigned int *d) |
|
INLINE int nd_find_reducer(ND g) |
INLINE int nd_find_reducer(ND g) |
{ |
{ |
NM m; |
NM m; |
ND p; |
|
int d,k,i; |
int d,k,i; |
|
|
d = ndl_hash_value(HTD(g),HDL(g)); |
d = ndl_hash_value(HTD(g),HDL(g)); |
Line 827 INLINE int nd_find_reducer(ND g) |
|
Line 809 INLINE int nd_find_reducer(ND g) |
|
} |
} |
|
|
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
p = nd_ps[i]; |
m = nd_psh[i]; |
if ( HTD(g) >= HTD(p) && ndl_reducible(HDL(g),HDL(p)) ) { |
if ( HTD(g) >= m->td && ndl_reducible(HDL(g),m->dl) ) { |
nd_create++; |
nd_create++; |
nd_append_red(HDL(g),HTD(g),i); |
nd_append_red(HDL(g),HTD(g),i); |
return i; |
return i; |
Line 837 INLINE int nd_find_reducer(ND g) |
|
Line 819 INLINE int nd_find_reducer(ND g) |
|
return -1; |
return -1; |
} |
} |
|
|
ND nd_find_monic_reducer(ND g) |
|
{ |
|
int *d; |
|
ND p,r; |
|
int i; |
|
|
|
for ( i = 0; i < nd_psn; i++ ) { |
|
p = nd_ps[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 915 ND nd_add(ND p1,ND p2) |
|
Line 879 ND nd_add(ND p1,ND p2) |
|
} |
} |
} |
} |
|
|
ND nd_mul_nm(ND p,NM m0) |
|
{ |
|
NM m,mr,mr0; |
|
unsigned int *d,*dt,*dm; |
|
int c,n,td,i,c1,c2; |
|
int *pt,*p1,*p2; |
|
ND r; |
|
|
|
if ( !p ) |
|
return 0; |
|
else { |
|
n = NV(p); m = BDY(p); |
|
d = m0->dl; td = m0->td; c = C(m0); |
|
mr0 = 0; |
|
for ( ; m; m = NEXT(m) ) { |
|
NEXTNM(mr0,mr); |
|
c1 = C(m); |
|
DMAR(c1,c,0,nd_mod,c2); |
|
C(mr) = c2; |
|
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; |
|
} |
|
} |
|
|
|
ND nd_mul_ind_nm(int index,NM m0) |
|
{ |
|
register int c1,c2,c; |
|
register NM m,new,prev; |
|
NM mr0; |
|
unsigned int *d; |
|
int n,td,i,len,d0,d1; |
|
ND p,r; |
|
|
|
p = nd_ps[index]; |
|
len = nd_psl[index]; |
|
n = NV(p); m = BDY(p); |
|
d = m0->dl; td = m0->td; c = C(m0); |
|
|
|
NEWNM(mr0); |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); C(mr0) = c2; |
|
mr0->td = m->td+td; ndl_add(m->dl,d,mr0->dl); |
|
prev = mr0; m = NEXT(m); |
|
len--; |
|
|
|
switch ( nd_wpd ) { |
|
case 1: |
|
d0 = d[0]; |
|
while ( len-- ) { |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); |
|
NEWNM(new); C(new) = c2; |
|
new->td = m->td+td; new->dl[0] = m->dl[0]+d0; |
|
m = NEXT(m); NEXT(prev) = new; prev = new; |
|
} |
|
break; |
|
case 2: |
|
d0 = d[0]; d1 = d[1]; |
|
while ( len-- ) { |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); |
|
NEWNM(new); C(new) = c2; |
|
new->td = m->td+td; |
|
new->dl[0] = m->dl[0]+d0; |
|
new->dl[1] = m->dl[1]+d1; |
|
m = NEXT(m); NEXT(prev) = new; prev = new; |
|
} |
|
break; |
|
default: |
|
while ( len-- ) { |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); |
|
NEWNM(new); C(new) = c2; |
|
new->td = m->td+td; ndl_add(m->dl,d,new->dl); |
|
m = NEXT(m); NEXT(prev) = new; prev = new; |
|
} |
|
break; |
|
} |
|
|
|
NEXT(prev) = 0; |
|
MKND(NV(p),mr0,r); |
|
r->sugar = p->sugar + td; |
|
return r; |
|
} |
|
|
|
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); |
|
for ( mr0 = 0; m; m = NEXT(m) ) { |
|
NEXTNM(mr0,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 |
/* ret=1 : success, ret=0 : overflow */ |
/* ret=1 : success, ret=0 : overflow */ |
int nd_nf(ND g,int full,ND *rp) |
int nd_nf(ND g,int full,ND *rp) |
{ |
{ |
ND p,d; |
ND d; |
NM m,mrd,tail; |
NM m,mrd,tail; |
struct oNM mul; |
NM mul; |
int n,sugar,psugar,stat,index; |
int n,sugar,psugar,sugar0,stat,index; |
int c,c1,c2; |
int c,c1,c2; |
#if USE_NDV |
#if USE_NDV |
NDV red; |
NDV p,red; |
#else |
#else |
ND red; |
ND p,red; |
#endif |
#endif |
|
|
if ( !g ) { |
if ( !g ) { |
*rp = 0; |
*rp = 0; |
return 1; |
return 1; |
} |
} |
sugar = g->sugar; |
sugar0 = sugar = g->sugar; |
n = NV(g); |
n = NV(g); |
|
mul = (NM)ALLOCA(sizeof(struct oNM)+(nd_wpd-1)*sizeof(unsigned int)); |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
index = nd_find_reducer(g); |
index = nd_find_reducer(g); |
if ( index >= 0 ) { |
if ( index >= 0 ) { |
p = nd_ps[index]; |
p = nd_ps[index]; |
ndl_sub(HDL(g),HDL(p),mul.dl); |
ndl_sub(HDL(g),HDL(p),mul->dl); |
mul.td = HTD(g)-HTD(p); |
mul->td = HTD(g)-HTD(p); |
if ( ndl_check_bound2(index,mul.dl) ) { |
#if 0 |
|
if ( d && (p->sugar+mul->td) > sugar ) { |
|
goto afo; |
|
} |
|
#endif |
|
if ( ndl_check_bound2(index,mul->dl) ) { |
nd_free(g); nd_free(d); |
nd_free(g); nd_free(d); |
return 0; |
return 0; |
} |
} |
c1 = invm(HC(p),nd_mod); c2 = nd_mod-HC(g); |
c1 = invm(HC(p),nd_mod); c2 = nd_mod-HC(g); |
DMAR(c1,c2,0,nd_mod,c); mul.c = c; |
DMAR(c1,c2,0,nd_mod,c); C(mul) = c; |
#if USE_NDV |
#if USE_NDV |
ndv_mul_nm(nd_psv[index],&mul,ndv_red); |
ndv_mul_nm(nd_ps[index],mul,ndv_red); |
g = ndv_add(g,ndv_red); |
g = ndv_add(g,ndv_red); |
sugar = MAX(sugar,ndv_red->sugar); |
sugar = MAX(sugar,ndv_red->sugar); |
#else |
#else |
red = nd_mul_ind_nm(index,&mul); |
red = nd_mul_ind_nm(index,mul); |
g = nd_add(g,red); |
g = nd_add(g,red); |
sugar = MAX(sugar,red->sugar); |
sugar = MAX(sugar,red->sugar); |
#endif |
#endif |
Line 1070 int nd_nf(ND g,int full,ND *rp) |
|
Line 931 int nd_nf(ND g,int full,ND *rp) |
|
*rp = g; |
*rp = g; |
return 1; |
return 1; |
} else { |
} else { |
|
afo: |
m = BDY(g); |
m = BDY(g); |
if ( NEXT(m) ) { |
if ( NEXT(m) ) { |
BDY(g) = NEXT(m); NEXT(m) = 0; |
BDY(g) = NEXT(m); NEXT(m) = 0; |
Line 1552 ND_pairs nd_minp( ND_pairs d, ND_pairs *prest ) |
|
Line 1414 ND_pairs nd_minp( ND_pairs d, ND_pairs *prest ) |
|
c = ndl_compare(p->lcm,lcm); |
c = ndl_compare(p->lcm,lcm); |
if ( c < 0 ) |
if ( c < 0 ) |
goto find; |
goto find; |
|
#if 0 |
else if ( c == 0 ) { |
else if ( c == 0 ) { |
tlen = nd_psl[p->i1]+nd_psl[p->i2]; |
tlen = nd_psl[p->i1]+nd_psl[p->i2]; |
if ( tlen < len ) |
if ( tlen < len ) |
goto find; |
goto find; |
} |
} |
|
#endif |
} |
} |
} |
} |
continue; |
continue; |
|
|
int nd_newps(ND a) |
int nd_newps(ND a) |
{ |
{ |
int len; |
int len; |
|
NM m; |
|
|
if ( nd_psn == nd_pslen ) { |
if ( nd_psn == nd_pslen ) { |
nd_pslen *= 2; |
nd_pslen *= 2; |
nd_ps = (ND *)REALLOC((char *)nd_ps,nd_pslen*sizeof(ND)); |
|
nd_psl = (int *)REALLOC((char *)nd_psl,nd_pslen*sizeof(int)); |
nd_psl = (int *)REALLOC((char *)nd_psl,nd_pslen*sizeof(int)); |
#if USE_NDV |
#if USE_NDV |
nd_psv = (NDV *)REALLOC((char *)nd_psv,nd_pslen*sizeof(NDV)); |
nd_ps = (NDV *)REALLOC((char *)nd_ps,nd_pslen*sizeof(NDV)); |
|
#else |
|
nd_ps = (ND *)REALLOC((char *)nd_ps,nd_pslen*sizeof(ND)); |
#endif |
#endif |
|
nd_psh = (NM *)REALLOC((char *)nd_psh,nd_pslen*sizeof(NM)); |
nd_bound = (unsigned int **) |
nd_bound = (unsigned int **) |
REALLOC((char *)nd_bound,nd_pslen*sizeof(unsigned int *)); |
REALLOC((char *)nd_bound,nd_pslen*sizeof(unsigned int *)); |
} |
} |
nd_monic(a); |
nd_monic(a); |
nd_ps[nd_psn] = a; |
|
nd_psl[nd_psn] = nd_length(a); |
|
nd_bound[nd_psn] = nd_compute_bound(a); |
nd_bound[nd_psn] = nd_compute_bound(a); |
|
NEWNM(m); m->td = HTD(a); ndl_copy(HDL(a),m->dl); nd_psh[nd_psn] = m; |
#if USE_NDV |
#if USE_NDV |
nd_psv[nd_psn] = ndtondv(a); |
nd_ps[nd_psn]= ndtondv(a); |
len = nd_psv[nd_psn]->len; |
nd_psl[nd_psn] = len = nd_ps[nd_psn]->len; |
if ( len > nmv_len ) { |
if ( len > nmv_len ) { |
nmv_len = 2*len; |
nmv_len = 2*len; |
BDY(ndv_red) = (NMV)REALLOC(BDY(ndv_red),nmv_len*nmv_adv); |
BDY(ndv_red) = (NMV)REALLOC(BDY(ndv_red),nmv_len*nmv_adv); |
} |
} |
|
#else |
|
nd_ps[nd_psn] = a; |
|
nd_psl[nd_psn] = nd_length(a); |
#endif |
#endif |
return nd_psn++; |
return nd_psn++; |
} |
} |
|
|
NODE NODE_sortb(NODE f,int); |
|
ND dptond(DP); |
|
DP ndtodp(ND); |
|
|
|
NODE nd_setup(NODE f) |
NODE nd_setup(NODE f) |
{ |
{ |
int i,j,td,len,max; |
int i,j,td,len,max; |
NODE s,s0,f0; |
NODE s,s0,f0; |
unsigned int *d; |
unsigned int *d; |
|
NM m; |
|
|
nd_found = 0; |
nd_found = 0; nd_notfirst = 0; nd_create = 0; |
nd_notfirst = 0; |
|
nd_create = 0; |
|
#if 0 |
|
f0 = f = NODE_sortb(f,1); |
|
#endif |
|
nd_psn = length(f); nd_pslen = 2*nd_psn; |
nd_psn = length(f); nd_pslen = 2*nd_psn; |
nd_ps = (ND *)MALLOC(nd_pslen*sizeof(ND)); |
|
nd_psl = (int *)MALLOC(nd_pslen*sizeof(int)); |
nd_psl = (int *)MALLOC(nd_pslen*sizeof(int)); |
#if USE_NDV |
#if USE_NDV |
nd_psv = (NDV *)MALLOC(nd_pslen*sizeof(NDV)); |
nd_ps = (NDV *)MALLOC(nd_pslen*sizeof(NDV)); |
|
#else |
|
nd_ps = (ND *)MALLOC(nd_pslen*sizeof(ND)); |
#endif |
#endif |
|
nd_psh = (NM *)MALLOC(nd_pslen*sizeof(NM)); |
nd_bound = (unsigned int **)MALLOC(nd_pslen*sizeof(unsigned int *)); |
nd_bound = (unsigned int **)MALLOC(nd_pslen*sizeof(unsigned int *)); |
for ( max = 0, i = 0, s = f; i < nd_psn; i++, s = NEXT(s) ) { |
for ( max = 0, i = 0, s = f; i < nd_psn; i++, s = NEXT(s) ) { |
nd_bound[i] = d = dp_compute_bound((DP)BDY(s)); |
nd_bound[i] = d = dp_compute_bound((DP)BDY(s)); |
for ( j = 0; j < nd_nvar; j++ ) |
for ( j = 0; j < nd_nvar; j++ ) |
max = MAX(d[j],max); |
max = MAX(d[j],max); |
} |
} |
|
if ( !nd_red ) |
|
nd_red = (NM *)MALLOC(REDTAB_LEN*sizeof(NM)); |
|
bzero(nd_red,REDTAB_LEN*sizeof(NM)); |
|
|
if ( max < 2 ) |
if ( max < 2 ) |
nd_bpe = 2; |
nd_bpe = 2; |
Line 1652 NODE nd_setup(NODE f) |
|
Line 1519 NODE nd_setup(NODE f) |
|
nd_free_private_storage(); |
nd_free_private_storage(); |
len = 0; |
len = 0; |
for ( i = 0; i < nd_psn; i++, f = NEXT(f) ) { |
for ( i = 0; i < nd_psn; i++, f = NEXT(f) ) { |
|
#if USE_NDV |
|
nd_ps[i] = dptondv((DP)BDY(f)); |
|
ndv_mul_c(nd_ps[i],invm(HC(nd_ps[i]),nd_mod)); |
|
len = MAX(len,nd_ps[i]->len); |
|
#else |
nd_ps[i] = dptond((DP)BDY(f)); |
nd_ps[i] = dptond((DP)BDY(f)); |
nd_monic(nd_ps[i]); |
nd_mul_c(nd_ps[i],1); |
nd_psl[i] = nd_length(nd_ps[i]); |
nd_psl[i] = nd_length(nd_ps[i]); |
#if USE_NDV |
|
nd_psv[i] = ndtondv(nd_ps[i]); |
|
len = MAX(len,nd_psv[i]->len); |
|
#endif |
#endif |
|
NEWNM(m); m->td = HTD(nd_ps[i]); ndl_copy(HDL(nd_ps[i]),m->dl); |
|
nd_psh[i] = m; |
} |
} |
nd_red = (NM *)MALLOC(REDTAB_LEN*sizeof(NM)); |
|
#if USE_NDV |
#if USE_NDV |
nmv_len = 16*len; |
nmv_len = 16*len; |
NEWNDV(ndv_red); |
NEWNDV(ndv_red); |
Line 1711 void nd_gr(LIST f,LIST v,int m,struct order_spec *ord, |
|
Line 1581 void nd_gr(LIST f,LIST v,int m,struct order_spec *ord, |
|
#endif |
#endif |
for ( r0 = 0; x; x = NEXT(x) ) { |
for ( r0 = 0; x; x = NEXT(x) ) { |
NEXTNODE(r0,r); |
NEXTNODE(r0,r); |
|
#if USE_NDV |
|
a = ndvtodp(nd_ps[(int)BDY(x)]); |
|
#else |
a = ndtodp(nd_ps[(int)BDY(x)]); |
a = ndtodp(nd_ps[(int)BDY(x)]); |
|
#endif |
_dtop_mod(CO,vv,a,(P *)&BDY(r)); |
_dtop_mod(CO,vv,a,(P *)&BDY(r)); |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
Line 1892 void nd_append_red(unsigned int *d,int td,int i) |
|
Line 1766 void nd_append_red(unsigned int *d,int td,int i) |
|
h = ndl_hash_value(td,d); |
h = ndl_hash_value(td,d); |
m->c = i; |
m->c = i; |
m->td = td; |
m->td = td; |
bcopy(d,m->dl,nd_wpd*sizeof(unsigned int)); |
ndl_copy(d,m->dl); |
NEXT(m) = nd_red[h]; |
NEXT(m) = nd_red[h]; |
nd_red[h] = m; |
nd_red[h] = m; |
} |
} |
Line 1901 unsigned int *dp_compute_bound(DP p) |
|
Line 1775 unsigned int *dp_compute_bound(DP p) |
|
{ |
{ |
unsigned int *d,*d1,*d2,*t; |
unsigned int *d,*d1,*d2,*t; |
MP m; |
MP m; |
int i; |
int i,l; |
|
|
if ( !p ) |
if ( !p ) |
return 0; |
return 0; |
Line 1915 unsigned int *dp_compute_bound(DP p) |
|
Line 1789 unsigned int *dp_compute_bound(DP p) |
|
d2[i] = d[i] > d1[i] ? d[i] : d1[i]; |
d2[i] = d[i] > d1[i] ? d[i] : d1[i]; |
t = d1; d1 = d2; d2 = t; |
t = d1; d1 = d2; d2 = t; |
} |
} |
t = (unsigned int *)MALLOC_ATOMIC(nd_nvar*sizeof(unsigned int)); |
l = nd_nvar+31; |
|
t = (unsigned int *)MALLOC_ATOMIC(l*sizeof(unsigned int)); |
|
bzero(t,l*sizeof(unsigned int)); |
bcopy(d1,t,nd_nvar*sizeof(unsigned int)); |
bcopy(d1,t,nd_nvar*sizeof(unsigned int)); |
return t; |
return t; |
} |
} |
Line 1923 unsigned int *dp_compute_bound(DP p) |
|
Line 1799 unsigned int *dp_compute_bound(DP p) |
|
unsigned int *nd_compute_bound(ND p) |
unsigned int *nd_compute_bound(ND p) |
{ |
{ |
unsigned int *d1,*d2,*t; |
unsigned int *d1,*d2,*t; |
int i; |
int i,l; |
NM m; |
NM m; |
|
|
if ( !p ) |
if ( !p ) |
Line 1935 unsigned int *nd_compute_bound(ND p) |
|
Line 1811 unsigned int *nd_compute_bound(ND p) |
|
ndl_lcm(m->dl,d1,d2); |
ndl_lcm(m->dl,d1,d2); |
t = d1; d1 = d2; d2 = t; |
t = d1; d1 = d2; d2 = t; |
} |
} |
t = (unsigned int *)MALLOC_ATOMIC(nd_nvar*sizeof(unsigned int)); |
l = nd_nvar+31; |
bzero(t,nd_nvar*sizeof(unsigned int)); |
t = (unsigned int *)MALLOC_ATOMIC(l*sizeof(unsigned int)); |
|
bzero(t,l*sizeof(unsigned int)); |
for ( i = 0; i < nd_nvar; i++ ) |
for ( i = 0; i < nd_nvar; i++ ) |
t[i] = (d1[i/nd_epw]>>((nd_epw-(i%nd_epw)-1)*nd_bpe))&nd_mask0; |
t[i] = (d1[i/nd_epw]>>((nd_epw-(i%nd_epw)-1)*nd_bpe))&nd_mask0; |
return t; |
return t; |
Line 1965 void nd_setup_parameters() { |
|
Line 1842 void nd_setup_parameters() { |
|
|
|
ND_pairs nd_reconstruct(ND_pairs d) |
ND_pairs nd_reconstruct(ND_pairs d) |
{ |
{ |
int i,obpe; |
int i,obpe,oadv; |
NM prev_nm_free_list,mr0,mr,m; |
NM prev_nm_free_list,mr0,mr,m; |
ND_pairs s0,s,t,prev_ndp_free_list; |
ND_pairs s0,s,t,prev_ndp_free_list; |
|
|
obpe = nd_bpe; |
obpe = nd_bpe; |
|
#if USE_NDV |
|
oadv = nmv_adv; |
|
#endif |
if ( obpe < 4 ) |
if ( obpe < 4 ) |
nd_bpe = 4; |
nd_bpe = 4; |
else if ( obpe < 6 ) |
else if ( obpe < 6 ) |
Line 1989 ND_pairs nd_reconstruct(ND_pairs d) |
|
Line 1869 ND_pairs nd_reconstruct(ND_pairs d) |
|
_nm_free_list = 0; |
_nm_free_list = 0; |
_ndp_free_list = 0; |
_ndp_free_list = 0; |
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
nd_ps[i] = nd_dup(nd_ps[i],obpe); |
|
#if USE_NDV |
#if USE_NDV |
nd_psv[i] = ndtondv(nd_ps[i]); |
ndv_realloc(nd_ps[i],obpe,oadv); |
|
#else |
|
nd_realloc(nd_ps[i],obpe); |
#endif |
#endif |
} |
} |
s0 = 0; |
s0 = 0; |
Line 2013 ND_pairs nd_reconstruct(ND_pairs d) |
|
Line 1894 ND_pairs nd_reconstruct(ND_pairs d) |
|
if ( mr0 ) NEXT(mr) = 0; |
if ( mr0 ) NEXT(mr) = 0; |
nd_red[i] = mr0; |
nd_red[i] = mr0; |
} |
} |
|
for ( i = 0; i < nd_psn; i++ ) { |
|
NEWNM(m); m->td = nd_psh[i]->td; ndl_dup(obpe,nd_psh[i]->dl,m->dl); |
|
nd_psh[i] = m; |
|
} |
if ( s0 ) NEXT(s) = 0; |
if ( s0 ) NEXT(s) = 0; |
prev_nm_free_list = 0; |
prev_nm_free_list = 0; |
prev_ndp_free_list = 0; |
prev_ndp_free_list = 0; |
Line 2045 void ndl_dup(int obpe,unsigned int *d,unsigned int *r) |
|
Line 1930 void ndl_dup(int obpe,unsigned int *d,unsigned int *r) |
|
} |
} |
} |
} |
|
|
ND nd_dup(ND p,int obpe) |
void nd_realloc(ND p,int obpe) |
{ |
{ |
NM m,mr,mr0; |
NM m,mr,mr0; |
int c,n; |
|
ND r; |
|
|
|
if ( !p ) |
if ( p ) { |
return 0; |
m = BDY(p); |
else { |
|
n = NV(p); m = BDY(p); |
|
for ( mr0 = 0; m; m = NEXT(m) ) { |
for ( mr0 = 0; m; m = NEXT(m) ) { |
NEXTNM(mr0,mr); |
NEXTNM(mr0,mr); |
C(mr) = C(m); |
C(mr) = C(m); |
Line 2062 ND nd_dup(ND p,int obpe) |
|
Line 1943 ND nd_dup(ND p,int obpe) |
|
ndl_dup(obpe,m->dl,mr->dl); |
ndl_dup(obpe,m->dl,mr->dl); |
} |
} |
NEXT(mr) = 0; |
NEXT(mr) = 0; |
MKND(NV(p),mr0,r); |
BDY(p) = mr0; |
r->sugar = p->sugar; |
|
return r; |
|
} |
} |
} |
} |
|
|
Line 2092 ND nd_copy(ND p) |
|
Line 1971 ND nd_copy(ND p) |
|
} |
} |
|
|
#if USE_NDV |
#if USE_NDV |
|
int nd_sp(ND_pairs p,ND *rp) |
|
{ |
|
NM m; |
|
NDV p1,p2; |
|
ND t1,t2; |
|
unsigned int *lcm; |
|
int td; |
|
|
|
p1 = nd_ps[p->i1]; |
|
p2 = nd_ps[p->i2]; |
|
lcm = p->lcm; |
|
td = p->td; |
|
NEWNM(m); |
|
C(m) = HC(p2); m->td = td-HTD(p1); ndl_sub(lcm,HDL(p1),m->dl); |
|
if ( ndl_check_bound2(p->i1,m->dl) ) |
|
return 0; |
|
t1 = ndv_mul_nm_create(p1,m); |
|
C(m) = nd_mod-HC(p1); m->td = td-HTD(p2); ndl_sub(lcm,HDL(p2),m->dl); |
|
if ( ndl_check_bound2(p->i2,m->dl) ) { |
|
nd_free(t1); |
|
return 0; |
|
} |
|
ndv_mul_nm(p2,m,ndv_red); |
|
FREENM(m); |
|
*rp = ndv_add(t1,ndv_red); |
|
return 1; |
|
} |
|
|
|
void ndv_mul_c(NDV p,int mul) |
|
{ |
|
NMV m; |
|
int c,c1,len,i; |
|
|
|
if ( !p ) |
|
return; |
|
len = p->len; |
|
for ( m = BDY(p), i = 0; i < len; i++, NMV_ADV(m) ) { |
|
c1 = C(m); |
|
DMAR(c1,mul,0,nd_mod,c); |
|
C(m) = c; |
|
} |
|
} |
|
|
void ndv_mul_nm(NDV p,NM m0,NDV r) |
void ndv_mul_nm(NDV p,NM m0,NDV r) |
{ |
{ |
NMV m,mr,mr0; |
NMV m,mr,mr0; |
Line 2105 void ndv_mul_nm(NDV p,NM m0,NDV r) |
|
Line 2027 void ndv_mul_nm(NDV p,NM m0,NDV r) |
|
n = NV(p); m = BDY(p); len = p->len; |
n = NV(p); m = BDY(p); len = p->len; |
d = m0->dl; td = m0->td; c = C(m0); |
d = m0->dl; td = m0->td; c = C(m0); |
mr = BDY(r); |
mr = BDY(r); |
for ( i = 0; i < len; i++, NMV_ADV(m), NMV_ADV(mr) ) { |
for ( ; len > 0; len--, NMV_ADV(m), NMV_ADV(mr) ) { |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); C(mr) = c2; |
|
mr->td = m->td+td; ndl_add(m->dl,d,mr->dl); |
|
} |
|
NV(r) = NV(p); |
|
r->len = p->len; |
|
r->sugar = p->sugar + td; |
|
} |
|
} |
|
|
|
ND ndv_mul_nm_create(NDV p,NM m0) |
|
{ |
|
NM mr,mr0; |
|
NMV m; |
|
unsigned int *d,*dt,*dm; |
|
int c,n,td,i,c1,c2,len; |
|
ND r; |
|
|
|
if ( !p ) |
|
return 0; |
|
else { |
|
n = NV(p); m = BDY(p); |
|
d = m0->dl; td = m0->td; c = C(m0); |
|
len = p->len; |
|
mr0 = 0; |
|
for ( i = 0; i < len; i++, NMV_ADV(m) ) { |
|
NEXTNM(mr0,mr); |
c1 = C(m); |
c1 = C(m); |
DMAR(c1,c,0,nd_mod,c2); |
DMAR(c1,c,0,nd_mod,c2); |
C(mr) = 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); |
} |
} |
NV(r) = NV(p); |
NEXT(mr) = 0; |
r->len = p->len; |
MKND(NV(p),mr0,r); |
r->sugar = p->sugar + td; |
r->sugar = p->sugar + td; |
|
return r; |
} |
} |
} |
} |
|
|
ND ndv_add(ND p1,NDV p2) |
ND ndv_add(ND p1,NDV p2) |
{ |
{ |
|
register NM prev,cur,new; |
int c,c1,c2,t,td,td2,mul,len,i; |
int c,c1,c2,t,td,td2,mul,len,i; |
NM prev,head,cur,new; |
NM head; |
unsigned int *d; |
unsigned int *d; |
NMV m2; |
NMV m2; |
|
|
Line 2129 ND ndv_add(ND p1,NDV p2) |
|
Line 2079 ND ndv_add(ND p1,NDV p2) |
|
return 0; |
return 0; |
else { |
else { |
prev = 0; head = cur = BDY(p1); |
prev = 0; head = cur = BDY(p1); |
NEWNM(new); |
NEWNM(new); len = p2->len; |
len = p2->len; |
for ( m2 = BDY(p2), i = 0; cur && i < len; ) { |
for ( m2 = BDY(p2), i = 0; i < len; ) { |
|
td2 = new->td = m2->td; |
td2 = new->td = m2->td; |
if ( !cur ) { |
if ( cur->td > td2 ) c = 1; |
C(new) = C(m2); |
else if ( cur->td < td2 ) c = -1; |
ndl_copy(m2->dl,new->dl); |
else c = ndl_compare(cur->dl,m2->dl); |
if ( !prev ) { |
|
prev = new; |
|
NEXT(prev) = 0; |
|
head = prev; |
|
} else { |
|
NEXT(prev) = new; |
|
NEXT(new) = 0; |
|
prev = new; |
|
} |
|
NMV_ADV(m2); i++; |
|
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 ) { |
switch ( c ) { |
case 0: |
case 0: |
t = C(m2)+C(cur)-nd_mod; |
t = C(m2)+C(cur)-nd_mod; |
if ( t < 0 ) |
if ( t < 0 ) t += nd_mod; |
t += nd_mod; |
if ( t ) C(cur) = t; |
if ( t ) |
|
C(cur) = t; |
|
else if ( !prev ) { |
else if ( !prev ) { |
head = NEXT(cur); |
head = NEXT(cur); FREENM(cur); cur = head; |
FREENM(cur); |
|
cur = head; |
|
} else { |
} else { |
NEXT(prev) = NEXT(cur); |
NEXT(prev) = NEXT(cur); FREENM(cur); cur = NEXT(prev); |
FREENM(cur); |
|
cur = NEXT(prev); |
|
} |
} |
NMV_ADV(m2); i++; |
NMV_ADV(m2); i++; |
break; |
break; |
case 1: |
case 1: |
prev = cur; |
prev = cur; cur = NEXT(cur); |
cur = NEXT(cur); |
|
break; |
break; |
case -1: |
case -1: |
ndl_copy(m2->dl,new->dl); |
ndl_copy(m2->dl,new->dl); |
|
C(new) = C(m2); |
if ( !prev ) { |
if ( !prev ) { |
/* cur = head */ |
/* cur = head */ |
prev = new; |
prev = new; NEXT(prev) = head; head = prev; |
C(prev) = C(m2); |
|
NEXT(prev) = head; |
|
head = prev; |
|
} else { |
} else { |
C(new) = C(m2); |
NEXT(prev) = new; NEXT(new) = cur; prev = new; |
NEXT(prev) = new; |
|
NEXT(new) = cur; |
|
prev = new; |
|
} |
} |
NEWNM(new); |
NEWNM(new); NMV_ADV(m2); i++; |
NMV_ADV(m2); i++; |
|
break; |
break; |
} |
} |
} |
} |
|
for ( ; i < len; i++, NMV_ADV(m2) ) { |
|
td2 = new->td = m2->td; C(new) = C(m2); ndl_copy(m2->dl,new->dl); |
|
if ( !prev ) { |
|
prev = new; NEXT(prev) = 0; head = prev; |
|
} else { |
|
NEXT(prev) = new; NEXT(new) = 0; prev = new; |
|
} |
|
NEWNM(new); |
|
} |
FREENM(new); |
FREENM(new); |
if ( head ) { |
if ( head ) { |
BDY(p1) = head; |
BDY(p1) = head; p1->sugar = MAX(p1->sugar,p2->sugar); |
p1->sugar = MAX(p1->sugar,p2->sugar+td); |
|
return p1; |
return p1; |
} else { |
} else { |
FREEND(p1); |
FREEND(p1); |
Line 2209 ND ndv_add(ND p1,NDV p2) |
|
Line 2134 ND ndv_add(ND p1,NDV p2) |
|
} |
} |
} |
} |
|
|
|
void ndv_realloc(NDV p,int obpe,int oadv) |
|
{ |
|
NMV m,mr,mr0; |
|
int len,i; |
|
|
|
#define NMV_OADV(m) (m = (NMV)(((char *)m)+oadv)) |
|
|
|
if ( p ) { |
|
m = BDY(p); len = p->len; |
|
mr0 = mr = (NMV)MALLOC_ATOMIC(len*nmv_adv); |
|
bzero(mr0,len*nmv_adv); |
|
for ( i = 0; i < len; i++, NMV_OADV(m), NMV_ADV(mr) ) { |
|
C(mr) = C(m); |
|
mr->td = m->td; |
|
ndl_dup(obpe,m->dl,mr->dl); |
|
} |
|
BDY(p) = mr0; |
|
} |
|
} |
|
|
NDV ndtondv(ND p) |
NDV ndtondv(ND p) |
{ |
{ |
NDV d; |
NDV d; |
Line 2222 NDV ndtondv(ND p) |
|
Line 2167 NDV ndtondv(ND p) |
|
m0 = m = (NMV)MALLOC_ATOMIC(len*nmv_adv); |
m0 = m = (NMV)MALLOC_ATOMIC(len*nmv_adv); |
for ( t = BDY(p), i = 0; t; t = NEXT(t), i++, NMV_ADV(m) ) { |
for ( t = BDY(p), i = 0; t; t = NEXT(t), i++, NMV_ADV(m) ) { |
m->td = t->td; |
m->td = t->td; |
bcopy(t->dl,m->dl,nd_wpd*sizeof(unsigned int)); |
ndl_copy(t->dl,m->dl); |
m->c = t->c; |
m->c = t->c; |
} |
} |
MKNDV(NV(p),m0,len,d); |
MKNDV(NV(p),m0,len,d); |
Line 2230 NDV ndtondv(ND p) |
|
Line 2175 NDV ndtondv(ND p) |
|
return d; |
return d; |
} |
} |
|
|
|
NDV dptondv(DP p) |
|
{ |
|
NDV d; |
|
NMV m0,m; |
|
MP t; |
|
int l,i,n; |
|
|
|
if ( !p ) |
|
return 0; |
|
for ( t = BDY(p), l = 0; t; t = NEXT(t), l++ ); |
|
m0 = m = (NMV)MALLOC_ATOMIC(l*nmv_adv); |
|
n = NV(p); |
|
for ( t = BDY(p), i = 0; i < l; i++, t = NEXT(t), NMV_ADV(m) ) { |
|
m->c = ITOS(t->c); |
|
m->td = t->dl->td; |
|
dltondl(n,t->dl,m->dl); |
|
} |
|
MKNDV(n,m0,l,d); |
|
d->sugar = p->sugar; |
|
return d; |
|
} |
|
|
|
DP ndvtodp(NDV p) |
|
{ |
|
DP d; |
|
MP m0,m; |
|
NMV t; |
|
int len,i,n; |
|
|
|
if ( !p ) |
|
return 0; |
|
m0 = 0; |
|
len = p->len; |
|
n = NV(p); |
|
for ( t = BDY(p), i = 0; i < len; i++, NMV_ADV(t) ) { |
|
NEXTMP(m0,m); |
|
m->c = STOI(t->c); |
|
m->dl = ndltodl(n,t->td,t->dl); |
|
} |
|
NEXT(m) = 0; |
|
MKDP(NV(p),m0,d); |
|
d->sugar = p->sugar; |
|
return d; |
|
} |
|
|
void ndv_print(NDV p) |
void ndv_print(NDV p) |
{ |
{ |
NMV m; |
NMV m; |
Line 2245 void ndv_print(NDV p) |
|
Line 2235 void ndv_print(NDV p) |
|
} |
} |
printf("\n"); |
printf("\n"); |
} |
} |
|
} |
|
#else |
|
int nd_sp(ND_pairs p,ND *rp) |
|
{ |
|
NM m; |
|
ND p1,p2; |
|
ND t1,t2; |
|
unsigned int *lcm; |
|
int td; |
|
|
|
p1 = nd_ps[p->i1]; |
|
p2 = nd_ps[p->i2]; |
|
lcm = p->lcm; |
|
td = p->td; |
|
NEWNM(m); |
|
C(m) = HC(p2); m->td = td-HTD(p1); ndl_sub(lcm,HDL(p1),m->dl); |
|
if ( ndl_check_bound2(p->i1,m->dl) ) |
|
return 0; |
|
t1 = nd_mul_ind_nm(p->i1,m); |
|
C(m) = nd_mod-HC(p1); m->td = td-HTD(p2); ndl_sub(lcm,HDL(p2),m->dl); |
|
if ( ndl_check_bound2(p->i2,m->dl) ) { |
|
nd_free(t1); |
|
return 0; |
|
} |
|
t2 = nd_mul_ind_nm(p->i2,m); |
|
FREENM(m); |
|
*rp = nd_add(t1,t2); |
|
return 1; |
|
} |
|
|
|
ND nd_mul_nm(ND p,NM m0) |
|
{ |
|
NM m,mr,mr0; |
|
unsigned int *d,*dt,*dm; |
|
int c,n,td,i,c1,c2; |
|
int *pt,*p1,*p2; |
|
ND r; |
|
|
|
if ( !p ) |
|
return 0; |
|
else { |
|
n = NV(p); m = BDY(p); |
|
d = m0->dl; td = m0->td; c = C(m0); |
|
mr0 = 0; |
|
for ( ; m; m = NEXT(m) ) { |
|
NEXTNM(mr0,mr); |
|
c1 = C(m); |
|
DMAR(c1,c,0,nd_mod,c2); |
|
C(mr) = c2; |
|
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; |
|
} |
|
} |
|
|
|
ND nd_mul_ind_nm(int index,NM m0) |
|
{ |
|
register int c1,c2,c; |
|
register NM m,new,prev; |
|
NM mr0; |
|
unsigned int *d; |
|
int n,td,i,len,d0,d1; |
|
ND p,r; |
|
|
|
p = nd_ps[index]; |
|
len = nd_psl[index]; |
|
n = NV(p); m = BDY(p); |
|
d = m0->dl; td = m0->td; c = C(m0); |
|
|
|
NEWNM(mr0); |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); C(mr0) = c2; |
|
mr0->td = m->td+td; ndl_add(m->dl,d,mr0->dl); |
|
prev = mr0; m = NEXT(m); |
|
len--; |
|
|
|
switch ( nd_wpd ) { |
|
case 1: |
|
d0 = d[0]; |
|
while ( len-- ) { |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); |
|
NEWNM(new); C(new) = c2; |
|
new->td = m->td+td; new->dl[0] = m->dl[0]+d0; |
|
m = NEXT(m); NEXT(prev) = new; prev = new; |
|
} |
|
break; |
|
case 2: |
|
d0 = d[0]; d1 = d[1]; |
|
while ( len-- ) { |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); |
|
NEWNM(new); C(new) = c2; |
|
new->td = m->td+td; |
|
new->dl[0] = m->dl[0]+d0; |
|
new->dl[1] = m->dl[1]+d1; |
|
m = NEXT(m); NEXT(prev) = new; prev = new; |
|
} |
|
break; |
|
default: |
|
while ( len-- ) { |
|
c1 = C(m); DMAR(c1,c,0,nd_mod,c2); |
|
NEWNM(new); C(new) = c2; |
|
new->td = m->td+td; ndl_add(m->dl,d,new->dl); |
|
m = NEXT(m); NEXT(prev) = new; prev = new; |
|
} |
|
break; |
|
} |
|
|
|
NEXT(prev) = 0; |
|
MKND(NV(p),mr0,r); |
|
r->sugar = p->sugar + td; |
|
return r; |
} |
} |
#endif |
#endif |