version 1.34, 2003/08/20 06:06:07 |
version 1.37, 2003/08/20 08:38:20 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.33 2003/08/19 05:29:11 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.36 2003/08/20 07:55:45 noro Exp $ */ |
|
|
#include "ca.h" |
#include "ca.h" |
#include "inline.h" |
#include "inline.h" |
Line 288 INLINE int nd_length(ND p) |
|
Line 288 INLINE int nd_length(ND p) |
|
} |
} |
} |
} |
|
|
int ndl_reducible(unsigned int *d1,unsigned int *d2) |
INLINE int ndl_reducible(unsigned int *d1,unsigned int *d2) |
{ |
{ |
unsigned int u1,u2; |
unsigned int u1,u2; |
int i,j; |
int i,j; |
Line 372 void ndl_dehomogenize(unsigned int *d) |
|
Line 372 void ndl_dehomogenize(unsigned int *d) |
|
h = (d[1]>>((nd_epw-1)*nd_bpe))&nd_mask0; |
h = (d[1]>>((nd_epw-1)*nd_bpe))&nd_mask0; |
for ( i = 1; i <= nd_wpd; i++ ) |
for ( i = 1; i <= nd_wpd; i++ ) |
d[i] = ((d[i]<<nd_bpe)&mask) |
d[i] = ((d[i]<<nd_bpe)&mask) |
|(i+1<nd_wpd?((d[i+1]>>((nd_epw-1)*nd_bpe))&nd_mask0):0); |
|(i+1<=nd_wpd?((d[i+1]>>((nd_epw-1)*nd_bpe))&nd_mask0):0); |
TD(d) -= h; |
TD(d) -= h; |
} |
} |
} else |
} else |
Line 505 INLINE void ndl_copy(unsigned int *d1,unsigned int *d2 |
|
Line 505 INLINE void ndl_copy(unsigned int *d1,unsigned int *d2 |
|
} |
} |
} |
} |
|
|
/* XXX : TD is not added */ |
|
|
|
INLINE void ndl_add(unsigned int *d1,unsigned int *d2,unsigned int *d) |
INLINE void ndl_add(unsigned int *d1,unsigned int *d2,unsigned int *d) |
{ |
{ |
int i; |
int i; |
|
|
|
TD(d) = TD(d1)+TD(d2); |
switch ( nd_wpd ) { |
switch ( nd_wpd ) { |
case 1: |
case 1: |
d[1] = d1[1]+d2[1]; |
d[1] = d1[1]+d2[1]; |
Line 2078 void dltondl(int n,DL dl,unsigned int *r) |
|
Line 2077 void dltondl(int n,DL dl,unsigned int *r) |
|
int i; |
int i; |
|
|
d = dl->d; |
d = dl->d; |
bzero(r,(nd_wpd+1)*sizeof(unsigned int)); |
for ( i = 0; i <= nd_wpd; i++ ) r[i] = 0; |
if ( nd_isrlex ) |
if ( nd_isrlex ) |
for ( i = 0; i < n; i++ ) |
for ( i = 0; i < n; i++ ) |
r[(n-1-i)/nd_epw+1] |= (d[i]<<((nd_epw-((n-1-i)%nd_epw)-1)*nd_bpe)); |
r[(n-1-i)/nd_epw+1] |= (d[i]<<((nd_epw-((n-1-i)%nd_epw)-1)*nd_bpe)); |
Line 2409 unsigned int *dp_compute_bound(DP p) |
|
Line 2408 unsigned int *dp_compute_bound(DP p) |
|
d1 = (unsigned int *)ALLOCA(nd_nvar*sizeof(unsigned int)); |
d1 = (unsigned int *)ALLOCA(nd_nvar*sizeof(unsigned int)); |
d2 = (unsigned int *)ALLOCA(nd_nvar*sizeof(unsigned int)); |
d2 = (unsigned int *)ALLOCA(nd_nvar*sizeof(unsigned int)); |
m = BDY(p); |
m = BDY(p); |
bcopy(DL(m)->d,d1,nd_nvar*sizeof(unsigned int)); |
d = DL(m)->d; |
|
for ( i = 0; i < nd_nvar; i++ ) d1[i] = d[i]; |
for ( m = NEXT(BDY(p)); m; m = NEXT(m) ) { |
for ( m = NEXT(BDY(p)); m; m = NEXT(m) ) { |
d = DL(m)->d; |
d = DL(m)->d; |
for ( i = 0; i < nd_nvar; i++ ) |
for ( i = 0; i < nd_nvar; i++ ) |
Line 2418 unsigned int *dp_compute_bound(DP p) |
|
Line 2418 unsigned int *dp_compute_bound(DP p) |
|
} |
} |
l = (nd_nvar+31); |
l = (nd_nvar+31); |
t = (unsigned int *)MALLOC_ATOMIC(l*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++ ) t[i] = d1[i]; |
bcopy(d1,t,nd_nvar*sizeof(unsigned int)); |
for ( ; i < l; i++ ) t[i] = 0; |
return t; |
return t; |
} |
} |
|
|
Line 2433 unsigned int *nd_compute_bound(ND p) |
|
Line 2433 unsigned int *nd_compute_bound(ND p) |
|
return 0; |
return 0; |
d1 = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int)); |
d1 = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int)); |
d2 = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int)); |
d2 = (unsigned int *)ALLOCA(nd_wpd*sizeof(unsigned int)); |
bcopy(HDL(p),d1,nd_wpd*sizeof(unsigned int)); |
ndl_copy(HDL(p),d1); |
for ( m = NEXT(BDY(p)); m; m = NEXT(m) ) { |
for ( m = NEXT(BDY(p)); m; m = NEXT(m) ) { |
ndl_lcm(DL(m),d1,d2); |
ndl_lcm(DL(m),d1,d2); |
t = d1; d1 = d2; d2 = t; |
t = d1; d1 = d2; d2 = t; |
} |
} |
l = nd_nvar+31; |
l = nd_nvar+31; |
t = (unsigned int *)MALLOC_ATOMIC(l*sizeof(unsigned int)); |
t = (unsigned int *)MALLOC_ATOMIC(l*sizeof(unsigned int)); |
bzero(t,l*sizeof(unsigned int)); |
for ( i = 0; i < l; i++ ) t[i] = 0; |
for ( i = 0; i < nd_nvar; i++ ) |
for ( i = 0; i < nd_nvar; i++ ) |
t[i] = (d1[i/nd_epw+1]>>((nd_epw-(i%nd_epw)-1)*nd_bpe))&nd_mask0; |
t[i] = (d1[i/nd_epw+1]>>((nd_epw-(i%nd_epw)-1)*nd_bpe))&nd_mask0; |
|
for ( ; i < l; i++ ) t[i] = 0; |
return t; |
return t; |
} |
} |
|
|
Line 2470 void nd_setup_parameters() { |
|
Line 2471 void nd_setup_parameters() { |
|
|
|
ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d) |
ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d) |
{ |
{ |
int i,obpe,oadv; |
int i,obpe,oadv,h; |
NM prev_nm_free_list; |
NM prev_nm_free_list; |
RHist mr0,mr; |
RHist mr0,mr; |
RHist r; |
RHist r; |
|
RHist *old_red; |
ND_pairs s0,s,t,prev_ndp_free_list; |
ND_pairs s0,s,t,prev_ndp_free_list; |
|
|
obpe = nd_bpe; |
obpe = nd_bpe; |
Line 2502 ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d) |
|
Line 2504 ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d) |
|
SG(s) = SG(t); |
SG(s) = SG(t); |
ndl_dup(obpe,LCM(t),LCM(s)); |
ndl_dup(obpe,LCM(t),LCM(s)); |
} |
} |
|
|
|
old_red = (RHist *)ALLOCA(REDTAB_LEN*sizeof(RHist)); |
for ( i = 0; i < REDTAB_LEN; i++ ) { |
for ( i = 0; i < REDTAB_LEN; i++ ) { |
for ( mr0 = 0, r = nd_red[i]; r; r = NEXT(r) ) { |
old_red[i] = nd_red[i]; |
NEXTRHist(mr0,mr); |
nd_red[i] = 0; |
|
} |
|
for ( i = 0; i < REDTAB_LEN; i++ ) |
|
for ( r = old_red[i]; r; r = NEXT(r) ) { |
|
NEWRHist(mr); |
mr->index = r->index; |
mr->index = r->index; |
SG(mr) = SG(r); |
SG(mr) = SG(r); |
ndl_dup(obpe,DL(r),DL(mr)); |
ndl_dup(obpe,DL(r),DL(mr)); |
|
h = ndl_hash_value(DL(mr)); |
|
NEXT(mr) = nd_red[h]; |
|
nd_red[h] = mr; |
} |
} |
if ( mr0 ) NEXT(mr) = 0; |
for ( i = 0; i < REDTAB_LEN; i++ ) old_red[i] = 0; |
nd_red[i] = mr0; |
old_red = 0; |
} |
|
for ( i = 0; i < nd_psn; i++ ) { |
for ( i = 0; i < nd_psn; i++ ) { |
NEWRHist(r); SG(r) = SG(nd_psh[i]); |
NEWRHist(r); SG(r) = SG(nd_psh[i]); |
ndl_dup(obpe,DL(nd_psh[i]),DL(r)); |
ndl_dup(obpe,DL(nd_psh[i]),DL(r)); |
Line 2526 ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d) |
|
Line 2536 ND_pairs nd_reconstruct(int mod,int trace,ND_pairs d) |
|
|
|
void nd_reconstruct_direct(int mod,NDV *ps,int len) |
void nd_reconstruct_direct(int mod,NDV *ps,int len) |
{ |
{ |
int i,obpe,oadv; |
int i,obpe,oadv,h; |
NM prev_nm_free_list; |
NM prev_nm_free_list; |
RHist mr0,mr; |
RHist mr0,mr; |
RHist r; |
RHist r; |
|
RHist *old_red; |
ND_pairs s0,s,t,prev_ndp_free_list; |
ND_pairs s0,s,t,prev_ndp_free_list; |
|
|
obpe = nd_bpe; |
obpe = nd_bpe; |
Line 2547 void nd_reconstruct_direct(int mod,NDV *ps,int len) |
|
Line 2558 void nd_reconstruct_direct(int mod,NDV *ps,int len) |
|
_nm_free_list = 0; _ndp_free_list = 0; |
_nm_free_list = 0; _ndp_free_list = 0; |
if ( mod != 0 ) |
if ( mod != 0 ) |
for ( i = len-1; i >= 0; i-- ) ndv_realloc(ps[i],obpe,oadv); |
for ( i = len-1; i >= 0; i-- ) ndv_realloc(ps[i],obpe,oadv); |
|
old_red = (RHist *)ALLOCA(REDTAB_LEN*sizeof(RHist)); |
for ( i = 0; i < REDTAB_LEN; i++ ) { |
for ( i = 0; i < REDTAB_LEN; i++ ) { |
for ( mr0 = 0, r = nd_red[i]; r; r = NEXT(r) ) { |
old_red[i] = nd_red[i]; |
NEXTRHist(mr0,mr); |
nd_red[i] = 0; |
|
} |
|
for ( i = 0; i < REDTAB_LEN; i++ ) |
|
for ( r = old_red[i]; r; r = NEXT(r) ) { |
|
NEWRHist(mr); |
mr->index = r->index; |
mr->index = r->index; |
SG(mr) = SG(r); |
SG(mr) = SG(r); |
ndl_dup(obpe,DL(r),DL(mr)); |
ndl_dup(obpe,DL(r),DL(mr)); |
|
h = ndl_hash_value(DL(mr)); |
|
NEXT(mr) = nd_red[h]; |
|
nd_red[h] = mr; |
} |
} |
if ( mr0 ) NEXT(mr) = 0; |
for ( i = 0; i < REDTAB_LEN; i++ ) old_red[i] = 0; |
nd_red[i] = mr0; |
old_red = 0; |
} |
|
prev_nm_free_list = 0; |
prev_nm_free_list = 0; |
prev_ndp_free_list = 0; |
prev_ndp_free_list = 0; |
GC_gcollect(); |
GC_gcollect(); |
Line 2704 ND ndv_mul_nm(int mod,NDV p,NM m0) |
|
Line 2722 ND ndv_mul_nm(int mod,NDV p,NM m0) |
|
c1 = CM(m); |
c1 = CM(m); |
DMAR(c1,c,0,mod,c2); |
DMAR(c1,c,0,mod,c2); |
CM(mr) = c2; |
CM(mr) = c2; |
TD(DL(mr)) = TD(DL(m))+td; |
|
ndl_add(DL(m),d,DL(mr)); |
ndl_add(DL(m),d,DL(mr)); |
} |
} |
} else { |
} else { |
Line 2712 ND ndv_mul_nm(int mod,NDV p,NM m0) |
|
Line 2729 ND ndv_mul_nm(int mod,NDV p,NM m0) |
|
for ( i = 0; i < len; i++, NMV_ADV(m) ) { |
for ( i = 0; i < len; i++, NMV_ADV(m) ) { |
NEXTNM(mr0,mr); |
NEXTNM(mr0,mr); |
mulq(CQ(m),q,&CQ(mr)); |
mulq(CQ(m),q,&CQ(mr)); |
TD(DL(mr)) = TD(DL(m))+td; |
|
ndl_add(DL(m),d,DL(mr)); |
ndl_add(DL(m),d,DL(mr)); |
} |
} |
} |
} |