version 1.4, 2000/04/25 04:07:59 |
version 1.5, 2000/05/29 08:54:46 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.3 2000/04/13 06:01:02 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.4 2000/04/25 04:07:59 noro Exp $ */ |
#include "ca.h" |
#include "ca.h" |
|
|
#define NV(p) ((p)->nv) |
#define NV(p) ((p)->nv) |
|
|
{ |
{ |
MP m; |
MP m; |
DP s,t,u; |
DP s,t,u; |
int i,l; |
int i,l,l1; |
MP *w; |
static MP *w; |
|
static int wlen; |
|
|
if ( !p1 || !p2 ) |
if ( !p1 || !p2 ) |
*pr = 0; |
*pr = 0; |
|
|
else if ( OID(p2) <= O_P ) |
else if ( OID(p2) <= O_P ) |
muldc(vl,p1,(P)p2,pr); |
muldc(vl,p1,(P)p2,pr); |
else { |
else { |
|
for ( m = BDY(p1), l1 = 0; m; m = NEXT(m), l1++ ); |
for ( m = BDY(p2), l = 0; m; m = NEXT(m), l++ ); |
for ( m = BDY(p2), l = 0; m; m = NEXT(m), l++ ); |
w = ALLOCA(l*sizeof(MP)); |
if ( l1 < l ) { |
|
t = p1; p1 = p2; p2 = t; |
|
l = l1; |
|
} |
|
if ( l > wlen ) { |
|
if ( w ) GC_free(w); |
|
w = (MP *)MALLOC(l*sizeof(MP)); |
|
wlen = l; |
|
} |
for ( m = BDY(p2), i = 0; i < l; m = NEXT(m), i++ ) |
for ( m = BDY(p2), i = 0; i < l; m = NEXT(m), i++ ) |
w[i] = m; |
w[i] = m; |
for ( s = 0, i = l-1; i >= 0; i-- ) { |
for ( s = 0, i = l-1; i >= 0; i-- ) { |
muldm(vl,p1,w[i],&t); addd(vl,s,t,&u); s = u; |
muldm(vl,p1,w[i],&t); addd(vl,s,t,&u); s = u; |
} |
} |
|
bzero(w,l*sizeof(MP)); |
*pr = s; |
*pr = s; |
} |
} |
} |
} |
|
|
MP m; |
MP m; |
DP s,t,u; |
DP s,t,u; |
int i,l; |
int i,l; |
MP *w; |
static MP *w; |
|
static int wlen; |
|
|
if ( !p1 || !p2 ) |
if ( !p1 || !p2 ) |
*pr = 0; |
*pr = 0; |
|
|
muldc(vl,p1,(P)p2,pr); |
muldc(vl,p1,(P)p2,pr); |
else { |
else { |
for ( m = BDY(p2), l = 0; m; m = NEXT(m), l++ ); |
for ( m = BDY(p2), l = 0; m; m = NEXT(m), l++ ); |
w = ALLOCA(l*sizeof(MP)); |
if ( l > wlen ) { |
|
if ( w ) GC_free(w); |
|
w = (MP *)MALLOC(l*sizeof(MP)); |
|
wlen = l; |
|
} |
for ( m = BDY(p2), i = 0; i < l; m = NEXT(m), i++ ) |
for ( m = BDY(p2), i = 0; i < l; m = NEXT(m), i++ ) |
w[i] = m; |
w[i] = m; |
for ( s = 0, i = l-1; i >= 0; i-- ) { |
for ( s = 0, i = l-1; i >= 0; i-- ) { |
weyl_muldm(vl,p1,w[i],&t); addd(vl,s,t,&u); s = u; |
weyl_muldm(vl,p1,w[i],&t); addd(vl,s,t,&u); s = u; |
} |
} |
|
bzero(w,l*sizeof(MP)); |
*pr = s; |
*pr = s; |
} |
} |
} |
} |
|
|
DP r,t,t1; |
DP r,t,t1; |
MP m; |
MP m; |
int n,l,i; |
int n,l,i; |
MP *w; |
static MP *w; |
|
static int wlen; |
|
|
if ( !p ) |
if ( !p ) |
*pr = 0; |
*pr = 0; |
else { |
else { |
for ( m = BDY(p), l = 0; m; m = NEXT(m), l++ ); |
for ( m = BDY(p), l = 0; m; m = NEXT(m), l++ ); |
w = ALLOCA(l*sizeof(MP)); |
if ( l > wlen ) { |
|
if ( w ) GC_free(w); |
|
w = (MP *)MALLOC(l*sizeof(MP)); |
|
wlen = l; |
|
} |
for ( m = BDY(p), i = 0; i < l; m = NEXT(m), i++ ) |
for ( m = BDY(p), i = 0; i < l; m = NEXT(m), i++ ) |
w[i] = m; |
w[i] = m; |
for ( r = 0, i = l-1, n = NV(p); i >= 0; i-- ) { |
for ( r = 0, i = l-1, n = NV(p); i >= 0; i-- ) { |
weyl_mulmm(vl,w[i],m0,n,&t); |
weyl_mulmm(vl,w[i],m0,n,&t); |
addd(vl,r,t,&t1); r = t1; |
addd(vl,r,t,&t1); r = t1; |
} |
} |
|
bzero(w,l*sizeof(MP)); |
if ( r ) |
if ( r ) |
r->sugar = p->sugar + m0->dl->td; |
r->sugar = p->sugar + m0->dl->td; |
*pr = r; |
*pr = r; |
|
|
DP r,t,t1; |
DP r,t,t1; |
P c,c0,c1,cc; |
P c,c0,c1,cc; |
DL d,d0,d1; |
DL d,d0,d1; |
int i,j,a,b,k,l,n2,s,min; |
int i,j,a,b,k,l,n2,s,min,h; |
Q *tab; |
static Q *tab; |
|
static int tablen; |
|
|
if ( !m0 || !m1 ) |
if ( !m0 || !m1 ) |
*pr = 0; |
*pr = 0; |
|
|
mulp(vl,c0,c1,&c); |
mulp(vl,c0,c1,&c); |
d0 = m0->dl; d1 = m1->dl; |
d0 = m0->dl; d1 = m1->dl; |
n2 = n>>1; |
n2 = n>>1; |
for ( i = 0, r = (DP)ONE; i < n2; i++ ) { |
if ( n & 1 ) { |
a = d0->d[i]; b = d1->d[n2+i]; |
/* homogenized computation; dx-xd=h^2 */ |
k = d0->d[n2+i]; l = d1->d[i]; |
/* offset of h-degree */ |
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
NEWDL(d,n); d->d[n-1] = d0->d[n-1]+d1->d[n-1]; d->td = d->d[n-1]; |
min = MIN(k,l); |
NEWMP(mr); mr->c = (P)ONE; mr->dl = d; |
tab = (Q *)ALLOCA((min+1)*sizeof(Q)); |
MKDP(n,mr,r); r->sugar = d->d[n-1]; |
mkwc(k,l,tab); |
|
for ( mr0 = 0, s = 0, j = 0; j <= min; j++ ) { |
for ( i = 0; i < n2; i++ ) { |
NEXTMP(mr0,mr); |
a = d0->d[i]; b = d1->d[n2+i]; |
NEWDL(d,n); |
k = d0->d[n2+i]; l = d1->d[i]; |
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
/* degree of xi^a*(Di^k*xi^l)*Di^b */ |
d->td = d->d[i]+d->d[n2+i]; /* XXX */ |
h = a+k+l+b; |
s = MAX(s,d->td); /* XXX */ |
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
mr->c = (P)tab[j]; |
min = MIN(k,l); |
mr->dl = d; |
|
|
if ( min+1 > tablen ) { |
|
if ( tab ) GC_free(tab); |
|
tab = (Q *)MALLOC((min+1)*sizeof(Q)); |
|
tablen = min+1; |
|
} |
|
mkwc(k,l,tab); |
|
for ( mr0 = 0, j = 0; j <= min; j++ ) { |
|
NEXTMP(mr0,mr); |
|
NEWDL(d,n); |
|
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
|
d->td = h; |
|
d->d[n-1] = h-(d->d[i]+d->d[n2+i]); |
|
mr->c = (P)tab[j]; |
|
mr->dl = d; |
|
} |
|
bzero(tab,(min+1)*sizeof(Q)); |
|
if ( mr0 ) |
|
NEXT(mr) = 0; |
|
MKDP(n,mr0,t); |
|
if ( t ) |
|
t->sugar = h; |
|
comm_muld(vl,r,t,&t1); r = t1; |
} |
} |
if ( mr0 ) |
} else |
NEXT(mr) = 0; |
for ( i = 0, r = (DP)ONE; i < n2; i++ ) { |
MKDP(n,mr0,t); |
a = d0->d[i]; b = d1->d[n2+i]; |
if ( t ) |
k = d0->d[n2+i]; l = d1->d[i]; |
t->sugar = s; |
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
comm_muld(vl,r,t,&t1); r = t1; |
min = MIN(k,l); |
} |
tab = (Q *)ALLOCA((min+1)*sizeof(Q)); |
|
mkwc(k,l,tab); |
|
for ( mr0 = 0, s = 0, j = 0; j <= min; j++ ) { |
|
NEXTMP(mr0,mr); |
|
NEWDL(d,n); |
|
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
|
d->td = d->d[i]+d->d[n2+i]; /* XXX */ |
|
s = MAX(s,d->td); /* XXX */ |
|
mr->c = (P)tab[j]; |
|
mr->dl = d; |
|
} |
|
if ( mr0 ) |
|
NEXT(mr) = 0; |
|
MKDP(n,mr0,t); |
|
if ( t ) |
|
t->sugar = s; |
|
comm_muld(vl,r,t,&t1); r = t1; |
|
} |
muldc(vl,r,c,pr); |
muldc(vl,r,c,pr); |
} |
} |
} |
} |