version 1.9, 2001/10/09 01:36:11 |
version 1.19, 2012/12/17 07:20:44 |
|
|
* 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.8 2000/12/05 08:29:44 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/distm.c,v 1.18 2003/12/26 02:38:10 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "inline.h" |
#include "inline.h" |
Line 91 void mptomd(VL vl,int mod,VL dvl,P p,DP *pr) |
|
Line 91 void mptomd(VL vl,int mod,VL dvl,P p,DP *pr) |
|
} else { |
} else { |
for ( dc = DC(p), s = 0; dc; dc = NEXT(dc) ) { |
for ( dc = DC(p), s = 0; dc; dc = NEXT(dc) ) { |
mptomd(vl,mod,dvl,COEF(dc),&t); |
mptomd(vl,mod,dvl,COEF(dc),&t); |
NEWDL(d,n); d->td = QTOS(DEG(dc)); d->d[i] = d->td; |
NEWDL(d,n); d->d[i] = QTOS(DEG(dc)); |
|
d->td = MUL_WEIGHT(d->d[i],i); |
NEWMP(m); m->dl = d; C(m) = (P)ONEM; NEXT(m) = 0; MKDP(n,m,u); |
NEWMP(m); m->dl = d; C(m) = (P)ONEM; NEXT(m) = 0; MKDP(n,m,u); |
comm_mulmd(vl,mod,t,u,&r); addmd(vl,mod,r,s,&t); s = t; |
comm_mulmd(vl,mod,t,u,&r); addmd(vl,mod,r,s,&t); s = t; |
} |
} |
Line 101 void mptomd(VL vl,int mod,VL dvl,P p,DP *pr) |
|
Line 102 void mptomd(VL vl,int mod,VL dvl,P p,DP *pr) |
|
} |
} |
} |
} |
|
|
|
void mdtodp(DP p,DP *pr) |
|
{ |
|
MP m,mr0,mr; |
|
|
|
if ( !p ) |
|
*pr = 0; |
|
else { |
|
for ( m = BDY(p), mr0 = 0; m; m = NEXT(m) ) { |
|
NEXTMP(mr0,mr); mr->dl = m->dl; |
|
mptop(C(m),&C(mr)); |
|
} |
|
NEXT(mr) = 0; |
|
MKDP(NV(p),mr0,*pr); |
|
(*pr)->sugar = p->sugar; |
|
} |
|
} |
|
|
|
void _mdtodp(DP p,DP *pr) |
|
{ |
|
MP m,mr0,mr; |
|
int i; |
|
Q q; |
|
|
|
if ( !p ) |
|
*pr = 0; |
|
else { |
|
for ( m = BDY(p), mr0 = 0; m; m = NEXT(m) ) { |
|
NEXTMP(mr0,mr); mr->dl = m->dl; |
|
i = ITOS(m->c); STOQ(i,q); C(mr) = (P)q; |
|
} |
|
NEXT(mr) = 0; |
|
MKDP(NV(p),mr0,*pr); |
|
(*pr)->sugar = p->sugar; |
|
} |
|
} |
|
|
void mdtop(VL vl,int mod,VL dvl,DP p,P *pr) |
void mdtop(VL vl,int mod,VL dvl,DP p,P *pr) |
{ |
{ |
int n,i; |
int n,i; |
Line 240 void comm_mulmd(VL vl,int mod,DP p1,DP p2,DP *pr) |
|
Line 277 void comm_mulmd(VL vl,int mod,DP p1,DP p2,DP *pr) |
|
l = l1; |
l = l1; |
} |
} |
if ( l > wlen ) { |
if ( l > wlen ) { |
if ( w ) GC_free(w); |
if ( w ) GCFREE(w); |
w = (MP *)MALLOC(l*sizeof(MP)); |
w = (MP *)MALLOC(l*sizeof(MP)); |
wlen = l; |
wlen = l; |
} |
} |
Line 271 void weyl_mulmd(VL vl,int mod,DP p1,DP p2,DP *pr) |
|
Line 308 void weyl_mulmd(VL vl,int mod,DP p1,DP p2,DP *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++ ); |
if ( l > wlen ) { |
if ( l > wlen ) { |
if ( w ) GC_free(w); |
if ( w ) GCFREE(w); |
w = (MP *)MALLOC(l*sizeof(MP)); |
w = (MP *)MALLOC(l*sizeof(MP)); |
wlen = l; |
wlen = l; |
} |
} |
Line 325 void weyl_mulmdm(VL vl,int mod,DP p,MP m0,DP *pr) |
|
Line 362 void weyl_mulmdm(VL vl,int mod,DP p,MP m0,DP *pr) |
|
else { |
else { |
for ( m = BDY(p), l = 0; m; m = NEXT(m), l++ ); |
for ( m = BDY(p), l = 0; m; m = NEXT(m), l++ ); |
if ( l > wlen ) { |
if ( l > wlen ) { |
if ( w ) GC_free(w); |
if ( w ) GCFREE(w); |
w = (MP *)MALLOC(l*sizeof(MP)); |
w = (MP *)MALLOC(l*sizeof(MP)); |
wlen = l; |
wlen = l; |
} |
} |
Line 374 void weyl_mulmmm(VL vl,int mod,MP m0,MP m1,int n,DP *p |
|
Line 411 void weyl_mulmmm(VL vl,int mod,MP m0,MP m1,int n,DP *p |
|
for ( i = 0; i < n2; i++ ) { |
for ( i = 0; i < n2; i++ ) { |
a = d0->d[i]; b = d1->d[n2+i]; |
a = d0->d[i]; b = d1->d[n2+i]; |
k = d0->d[n2+i]; l = d1->d[i]; |
k = d0->d[n2+i]; l = d1->d[i]; |
|
|
/* degree of xi^a*(Di^k*xi^l)*Di^b */ |
/* degree of xi^a*(Di^k*xi^l)*Di^b */ |
s = a+k+l+b; |
a += l; |
|
b += k; |
|
s = MUL_WEIGHT(a,i)+MUL_WEIGHT(b,n2+i); |
|
|
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
min = MIN(k,l); |
min = MIN(k,l); |
|
|
if ( min+1 > tablen ) { |
if ( min+1 > tablen ) { |
if ( tab ) GC_free(tab); |
if ( tab ) GCFREE(tab); |
tab = (int *)MALLOC((min+1)*sizeof(int)); |
tab = (int *)MALLOC((min+1)*sizeof(int)); |
tablen = min+1; |
tablen = min+1; |
} |
} |
Line 388 void weyl_mulmmm(VL vl,int mod,MP m0,MP m1,int n,DP *p |
|
Line 429 void weyl_mulmmm(VL vl,int mod,MP m0,MP m1,int n,DP *p |
|
if ( n & 1 ) |
if ( n & 1 ) |
for ( mr0 = 0, j = 0; j <= min; j++ ) { |
for ( mr0 = 0, j = 0; j <= min; j++ ) { |
NEXTMP(mr0,mr); NEWDL(d,n); |
NEXTMP(mr0,mr); NEWDL(d,n); |
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
d->d[i] = a-j; d->d[n2+i] = b-j; |
d->td = s; |
d->td = s; |
d->d[n-1] = s-(d->d[i]+d->d[n2+i]); |
d->d[n-1] = s-(MUL_WEIGHT(a-j,i)+MUL_WEIGHT(b-j,n2+i)); |
STOMQ(tab[j],mq); mr->c = (P)mq; mr->dl = d; |
STOMQ(tab[j],mq); mr->c = (P)mq; mr->dl = d; |
} |
} |
else |
else |
for ( mr0 = 0, s = 0, j = 0; j <= min; j++ ) { |
for ( mr0 = 0, s = 0, j = 0; j <= min; j++ ) { |
NEXTMP(mr0,mr); NEWDL(d,n); |
NEXTMP(mr0,mr); NEWDL(d,n); |
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
d->d[i] = a-j; d->d[n2+i] = b-j; |
d->td = d->d[i]+d->d[n2+i]; /* XXX */ |
d->td = MUL_WEIGHT(a-j,i)+MUL_WEIGHT(b-j,n2+i); /* XXX */ |
s = MAX(s,d->td); /* XXX */ |
s = MAX(s,d->td); /* XXX */ |
STOMQ(tab[j],mq); mr->c = (P)mq; mr->dl = d; |
STOMQ(tab[j],mq); mr->c = (P)mq; mr->dl = d; |
} |
} |
Line 622 void comm_mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
|
Line 663 void comm_mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
|
l = l1; |
l = l1; |
} |
} |
if ( l > wlen ) { |
if ( l > wlen ) { |
if ( w ) GC_free(w); |
if ( w ) GCFREE(w); |
w = (MP *)MALLOC(l*sizeof(MP)); |
w = (MP *)MALLOC(l*sizeof(MP)); |
wlen = l; |
wlen = l; |
} |
} |
Line 649 void weyl_mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
|
Line 690 void weyl_mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
|
else { |
else { |
for ( m = BDY(p1), l = 0; m; m = NEXT(m), l++ ); |
for ( m = BDY(p1), l = 0; m; m = NEXT(m), l++ ); |
if ( l > wlen ) { |
if ( l > wlen ) { |
if ( w ) GC_free(w); |
if ( w ) GCFREE(w); |
w = (MP *)MALLOC(l*sizeof(MP)); |
w = (MP *)MALLOC(l*sizeof(MP)); |
wlen = l; |
wlen = l; |
} |
} |
Line 705 void weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
Line 746 void weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
else { |
else { |
for ( m = BDY(p), l = 0; m; m = NEXT(m), l++ ); |
for ( m = BDY(p), l = 0; m; m = NEXT(m), l++ ); |
if ( l > wlen ) { |
if ( l > wlen ) { |
if ( w ) GC_free(w); |
if ( w ) GCFREE(w); |
w = (MP *)MALLOC(l*sizeof(MP)); |
w = (MP *)MALLOC(l*sizeof(MP)); |
wlen = l; |
wlen = l; |
} |
} |
Line 717 void weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
Line 758 void weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
for ( i = 0, tlen = 1; i < n2; i++ ) |
for ( i = 0, tlen = 1; i < n2; i++ ) |
tlen *= d0->d[n2+i]+1; |
tlen *= d0->d[n2+i]+1; |
if ( tlen > rtlen ) { |
if ( tlen > rtlen ) { |
if ( tab ) GC_free(tab); |
if ( tab ) GCFREE(tab); |
if ( psum ) GC_free(psum); |
if ( psum ) GCFREE(psum); |
rtlen = tlen; |
rtlen = tlen; |
tab = (struct cdlm *)MALLOC(rtlen*sizeof(struct cdlm)); |
tab = (struct cdlm *)MALLOC(rtlen*sizeof(struct cdlm)); |
psum = (MP *)MALLOC(rtlen*sizeof(MP)); |
psum = (MP *)MALLOC(rtlen*sizeof(MP)); |
Line 780 void weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
Line 821 void weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
rtab[0].d = d; |
rtab[0].d = d; |
|
|
if ( rtablen > tmptablen ) { |
if ( rtablen > tmptablen ) { |
if ( tmptab ) GC_free(tmptab); |
if ( tmptab ) GCFREE(tmptab); |
tmptab = (struct cdlm *)MALLOC(rtablen*sizeof(struct cdlm)); |
tmptab = (struct cdlm *)MALLOC(rtablen*sizeof(struct cdlm)); |
tmptablen = rtablen; |
tmptablen = rtablen; |
} |
} |
Line 788 void weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
Line 829 void weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
for ( i = 0; i < n2; i++ ) { |
for ( i = 0; i < n2; i++ ) { |
a = d0->d[i]; b = d1->d[n2+i]; |
a = d0->d[i]; b = d1->d[n2+i]; |
k = d0->d[n2+i]; l = d1->d[i]; |
k = d0->d[n2+i]; l = d1->d[i]; |
|
|
|
/* degree of xi^a*(Di^k*xi^l)*Di^b */ |
|
a += l; |
|
b += k; |
|
s = MUL_WEIGHT(a,i)+MUL_WEIGHT(b,n2+i); |
|
|
if ( !k || !l ) { |
if ( !k || !l ) { |
a += l; |
|
b += k; |
|
s = a+b; |
|
for ( j = 0, p = rtab; j < curlen; j++, p++ ) { |
for ( j = 0, p = rtab; j < curlen; j++, p++ ) { |
if ( p->c ) { |
if ( p->c ) { |
dt = p->d; |
dt = p->d; |
Line 804 void weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
Line 848 void weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
continue; |
continue; |
} |
} |
if ( k+1 > tablen ) { |
if ( k+1 > tablen ) { |
if ( tab ) GC_free(tab); |
if ( tab ) GCFREE(tab); |
if ( ctab ) GC_free(ctab); |
if ( ctab ) GCFREE(ctab); |
tablen = k+1; |
tablen = k+1; |
tab = (struct cdlm *)MALLOC(tablen*sizeof(struct cdlm)); |
tab = (struct cdlm *)MALLOC(tablen*sizeof(struct cdlm)); |
ctab = (int *)MALLOC(tablen*sizeof(int)); |
ctab = (int *)MALLOC(tablen*sizeof(int)); |
} |
} |
/* degree of xi^a*(Di^k*xi^l)*Di^b */ |
|
s = a+k+l+b; |
|
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
min = MIN(k,l); |
min = MIN(k,l); |
mkwcm(k,l,mod,ctab); |
mkwcm(k,l,mod,ctab); |
Line 820 void weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
Line 862 void weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
if ( n & 1 ) |
if ( n & 1 ) |
for ( j = 0; j <= min; j++ ) { |
for ( j = 0; j <= min; j++ ) { |
NEWDL(d,n); |
NEWDL(d,n); |
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
d->d[i] = a-j; d->d[n2+i] = b-j; |
d->td = s; |
d->td = s; |
d->d[n-1] = s-(d->d[i]+d->d[n2+i]); |
d->d[n-1] = s-(MUL_WEIGHT(a-j,i)+MUL_WEIGHT(b-j,n2+i)); |
tab[j].d = d; |
tab[j].d = d; |
tab[j].c = ctab[j]; |
tab[j].c = ctab[j]; |
} |
} |
else |
else |
for ( j = 0; j <= min; j++ ) { |
for ( j = 0; j <= min; j++ ) { |
NEWDL(d,n); |
NEWDL(d,n); |
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
d->d[i] = a-j; d->d[n2+i] = b-j; |
d->td = d->d[i]+d->d[n2+i]; /* XXX */ |
d->td = MUL_WEIGHT(a-j,i)+MUL_WEIGHT(b-j,n2+i); /* XXX */ |
tab[j].d = d; |
tab[j].d = d; |
tab[j].c = ctab[j]; |
tab[j].c = ctab[j]; |
} |
} |