version 1.10, 2001/09/17 01:18:35 |
version 1.16, 2017/08/31 02:36:21 |
|
|
* 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.9 2001/09/11 03:13:43 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/_distm.c,v 1.15 2012/12/17 07:20:44 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "inline.h" |
#include "inline.h" |
|
|
extern int (*cmpdl)(); |
extern int (*cmpdl)(); |
extern int do_weyl; |
extern int do_weyl; |
|
|
void dpto_dp(); |
|
void _dptodp(); |
|
void _adddl_dup(); |
|
void adddl_destructive(); |
|
void _mulmdm_dup(); |
|
void _free_dp(); |
|
void _comm_mulmd_dup(); |
|
void _weyl_mulmd_dup(); |
|
void _weyl_mulmmm_dup(); |
|
void _weyl_mulmdm_dup(); |
|
void _comm_mulmd_tab(); |
|
void _comm_mulmd_tab_destructive(); |
|
|
|
MP _mp_free_list; |
MP _mp_free_list; |
DP _dp_free_list; |
DP _dp_free_list; |
DL _dl_free_list; |
DL _dl_free_list; |
int current_dl_length; |
int current_dl_length; |
|
|
|
void GC_gcollect(); |
|
|
void _free_private_storage() |
void _free_private_storage() |
{ |
{ |
_mp_free_list = 0; |
_mp_free_list = 0; |
|
|
|
|
/* fprintf(stderr,"DL_alloc : %d \n",++DL_alloc_count); */ |
/* fprintf(stderr,"DL_alloc : %d \n",++DL_alloc_count); */ |
dl_len = (current_dl_length+1); |
dl_len = (current_dl_length+1); |
#if defined(LONG_IS_64BIT) |
#if SIZEOF_LONG == 8 |
if ( dl_len & 1 ) |
if ( dl_len & 1 ) |
dl_len += 1; |
dl_len += 1; |
#endif |
#endif |
p = (int *)GC_malloc(128*dl_len*sizeof(int)); |
|
for ( i = 0; i < 128; i++, p += dl_len ) { |
for ( i = 0; i < 128; i++, p += dl_len ) { |
|
p = (int *)MALLOC(dl_len*sizeof(int)); |
*(DL *)p = _dl_free_list; |
*(DL *)p = _dl_free_list; |
_dl_free_list = (DL)p; |
_dl_free_list = (DL)p; |
} |
} |
Line 105 void _MP_alloc() |
|
|
static int MP_alloc_count; |
static int MP_alloc_count; |
|
|
/* fprintf(stderr,"MP_alloc : %d \n",++MP_alloc_count); */ |
/* fprintf(stderr,"MP_alloc : %d \n",++MP_alloc_count); */ |
p = (MP)GC_malloc(1024*sizeof(struct oMP)); |
|
for ( i = 0; i < 1024; i++ ) { |
for ( i = 0; i < 1024; i++ ) { |
p[i].next = _mp_free_list; _mp_free_list = &p[i]; |
p = (MP)MALLOC(sizeof(struct oMP)); |
|
p->next = _mp_free_list; _mp_free_list = p; |
} |
} |
} |
} |
|
|
Line 118 void _DP_alloc() |
|
Line 107 void _DP_alloc() |
|
static int DP_alloc_count; |
static int DP_alloc_count; |
|
|
/* fprintf(stderr,"DP_alloc : %d \n",++DP_alloc_count); */ |
/* fprintf(stderr,"DP_alloc : %d \n",++DP_alloc_count); */ |
p = (DP)GC_malloc(1024*sizeof(struct oDP)); |
|
for ( i = 0; i < 1024; i++ ) { |
for ( i = 0; i < 1024; i++ ) { |
p[i].body = (MP)_dp_free_list; _dp_free_list = &p[i]; |
p = (DP)MALLOC(sizeof(struct oDP)); |
|
p->body = (MP)_dp_free_list; _dp_free_list = p; |
} |
} |
} |
} |
|
|
/* merge p1 and p2 into pr */ |
/* merge p1 and p2 into pr */ |
|
|
void _addmd_destructive(mod,p1,p2,pr) |
void _addmd_destructive(int mod,DP p1,DP p2,DP *pr) |
int mod; |
|
DP p1,p2,*pr; |
|
{ |
{ |
int n; |
int n; |
MP m1,m2,mr,mr0,s; |
MP m1,m2,mr,mr0,s; |
|
|
t += mod; |
t += mod; |
s = m1; m1 = NEXT(m1); |
s = m1; m1 = NEXT(m1); |
if ( t ) { |
if ( t ) { |
_NEXTMP2(mr0,mr,s); C(mr) = STOI(t); |
_NEXTMP2(mr0,mr,s); C(mr) = (Obj)STOI(t); |
} else { |
} else { |
_FREEDL(s->dl); _FREEMP(s); |
_FREEDL(s->dl); _FREEMP(s); |
} |
} |
|
|
} |
} |
} |
} |
|
|
void _mulmd_dup(mod,p1,p2,pr) |
void _mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
int mod; |
|
DP p1,p2,*pr; |
|
{ |
{ |
if ( !do_weyl ) |
if ( !do_weyl ) |
_comm_mulmd_dup(mod,p1,p2,pr); |
_comm_mulmd_dup(mod,p1,p2,pr); |
|
|
_weyl_mulmd_dup(mod,p1,p2,pr); |
_weyl_mulmd_dup(mod,p1,p2,pr); |
} |
} |
|
|
void _comm_mulmd_dup(mod,p1,p2,pr) |
void _comm_mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
int mod; |
|
DP p1,p2,*pr; |
|
{ |
{ |
MP m; |
MP m; |
DP s,t,u; |
DP s,t,u; |
|
|
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; |
} |
} |
|
|
} |
} |
} |
} |
|
|
void _weyl_mulmd_dup(mod,p1,p2,pr) |
void _weyl_mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
int mod; |
|
DP p1,p2,*pr; |
|
{ |
{ |
MP m; |
MP m; |
DP s,t,u; |
DP s,t,u; |
int i,l,l1; |
int i,l; |
static MP *w; |
static MP *w; |
static int wlen; |
static int wlen; |
|
|
|
|
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; |
} |
} |
|
|
} |
} |
} |
} |
|
|
void _mulmdm_dup(mod,p,m0,pr) |
void _mulmdm_dup(int mod,DP p,MP m0,DP *pr) |
int mod; |
|
DP p; |
|
MP m0; |
|
DP *pr; |
|
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
DL d,dt,dm; |
DL d,dt,dm; |
int c,n,r,i,c1,c2; |
int c,n,i,c1,c2; |
int *pt,*p1,*p2; |
int *pt,*p1,*p2; |
|
|
if ( !p ) |
if ( !p ) |
|
|
_NEXTMP(mr0,mr); |
_NEXTMP(mr0,mr); |
c1 = ITOS(C(m)); |
c1 = ITOS(C(m)); |
DMAR(c1,c,0,mod,c2); |
DMAR(c1,c,0,mod,c2); |
C(mr) = (P)STOI(c2); |
C(mr) = (Obj)STOI(c2); |
_NEWDL_NOINIT(dt,n); mr->dl = dt; |
_NEWDL_NOINIT(dt,n); mr->dl = dt; |
dm = m->dl; |
dm = m->dl; |
dt->td = d->td + dm->td; |
dt->td = d->td + dm->td; |
|
|
} |
} |
} |
} |
|
|
void _weyl_mulmmm_dup_bug(); |
void _weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
|
void _weyl_mulmdm_dup(mod,m0,p,pr) |
|
int mod; |
|
MP m0; |
|
DP p; |
|
DP *pr; |
|
{ |
{ |
DP r,t,t1; |
DP r,t,t1; |
MP m; |
MP m; |
|
|
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; |
} |
} |
|
|
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)); |
|
|
for ( j = 0; j < tlen; j++ ) { |
for ( j = 0; j < tlen; j++ ) { |
if ( tab[j].c ) { |
if ( tab[j].c ) { |
_NEWMP(m); m->dl = tab[j].d; |
_NEWMP(m); m->dl = tab[j].d; |
C(m) = STOI(tab[j].c); NEXT(m) = psum[j]; |
C(m) = (Obj)STOI(tab[j].c); NEXT(m) = psum[j]; |
psum[j] = m; |
psum[j] = m; |
} |
} |
} |
} |
|
|
|
|
/* m0 = x0^d0*x1^d1*... * dx0^d(n/2)*dx1^d(n/2+1)*... */ |
/* m0 = x0^d0*x1^d1*... * dx0^d(n/2)*dx1^d(n/2+1)*... */ |
|
|
void _weyl_mulmmm_dup(mod,m0,m1,n,rtab,rtablen) |
void _weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct cdlm *rtab,int rtablen) |
int mod; |
|
MP m0,m1; |
|
int n; |
|
struct cdlm *rtab; |
|
int rtablen; |
|
{ |
{ |
MP m,mr,mr0; |
int c,c0,c1; |
DP r,t,t1; |
|
int c,c0,c1,cc; |
|
DL d,d0,d1,dt; |
DL d,d0,d1,dt; |
int i,j,a,b,k,l,n2,s,min,h,curlen; |
int i,j,a,b,k,l,n2,s,min,curlen; |
struct cdlm *p; |
struct cdlm *p; |
static int *ctab; |
static int *ctab; |
static struct cdlm *tab; |
static struct cdlm *tab; |
|
|
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; |
} |
} |
|
|
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; |
|
|
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); |
|
|
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]; |
} |
} |
|
|
] |
] |
*/ |
*/ |
|
|
void _comm_mulmd_tab(mod,nv,t,n,t1,n1,rt) |
void _comm_mulmd_tab(int mod,int nv,struct cdlm *t,int n,struct cdlm *t1,int n1,struct cdlm *rt) |
int mod; |
|
int nv; |
|
struct cdlm *t; |
|
int n; |
|
struct cdlm *t1; |
|
int n1; |
|
struct cdlm *rt; |
|
{ |
{ |
int i,j; |
int i,j; |
struct cdlm *p; |
struct cdlm *p; |
Line 500 struct cdlm *rt; |
|
Line 458 struct cdlm *rt; |
|
} |
} |
} |
} |
|
|
void _comm_mulmd_tab_destructive(mod,nv,t,n,t1,n1) |
void _comm_mulmd_tab_destructive(int mod,int nv,struct cdlm *t,int n,struct cdlm *t1,int n1) |
int mod; |
|
int nv; |
|
struct cdlm *t; |
|
int n; |
|
struct cdlm *t1; |
|
int n1; |
|
{ |
{ |
int i,j; |
int i,j; |
struct cdlm *p; |
struct cdlm *p; |
|
|
} |
} |
} |
} |
|
|
void dlto_dl(d,dr) |
void dlto_dl(DL d,DL *dr) |
DL d; |
|
DL *dr; |
|
{ |
{ |
int i,n; |
int i,n; |
DL t; |
DL t; |
|
|
t->d[i] = d->d[i]; |
t->d[i] = d->d[i]; |
} |
} |
|
|
void _dltodl(d,dr) |
void _dltodl(DL d,DL *dr) |
DL d; |
|
DL *dr; |
|
{ |
{ |
int i,n; |
int i,n; |
DL t; |
DL t; |
|
|
t->d[i] = d->d[i]; |
t->d[i] = d->d[i]; |
} |
} |
|
|
void _adddl_dup(n,d1,d2,dr) |
void _adddl_dup(int n,DL d1,DL d2,DL *dr) |
int n; |
|
DL d1,d2; |
|
DL *dr; |
|
{ |
{ |
DL dt; |
DL dt; |
int i; |
int i; |
|
|
dt->d[i] = d1->d[i]+d2->d[i]; |
dt->d[i] = d1->d[i]+d2->d[i]; |
} |
} |
|
|
void _free_dlarray(a,n) |
void _free_dlarray(DL *a,int n) |
DL *a; |
|
int n; |
|
{ |
{ |
int i; |
int i; |
|
|
for ( i = 0; i < n; i++ ) { _FREEDL(a[i]); } |
for ( i = 0; i < n; i++ ) { _FREEDL(a[i]); } |
} |
} |
|
|
void _free_dp(f) |
void _free_dp(DP f) |
DP f; |
|
{ |
{ |
MP m,s; |
MP m,s; |
|
|
|
|
_FREEDP(f); |
_FREEDP(f); |
} |
} |
|
|
void dpto_dp(p,r) |
void dpto_dp(DP p,DP *r) |
DP p; |
|
DP *r; |
|
{ |
{ |
MP m,mr0,mr; |
MP m,mr0,mr; |
DL t; |
DL t; |
|
|
} |
} |
} |
} |
|
|
void _dptodp(p,r) |
void _dptodp(DP p,DP *r) |
DP p; |
|
DP *r; |
|
{ |
{ |
MP m,mr0,mr; |
MP m,mr0,mr; |
|
|
|
|
* return : a merged list |
* return : a merged list |
*/ |
*/ |
|
|
NODE _symb_merge(m1,m2,n) |
NODE _symb_merge(NODE m1,NODE m2,int n) |
NODE m1,m2; |
|
int n; |
|
{ |
{ |
NODE top,prev,cur,m,t; |
NODE top,prev,cur,m,t; |
|
|
|
|
} |
} |
} |
} |
|
|
/* XXX : bellow should be placed in another file */ |
|
|
|
void dpto_dp(); |
|
void _dptodp(); |
|
void _adddl_dup(); |
|
void adddl_destructive(); |
|
void _muldm_dup(); |
|
void _free_dp(); |
|
void _comm_muld_dup(); |
|
void _weyl_muld_dup(); |
|
void _weyl_mulmm_dup(); |
|
void _weyl_muldm_dup(); |
|
void _comm_muld_tab(); |
|
void _comm_muld_tab_destructive(); |
|
|
|
/* merge p1 and p2 into pr */ |
/* merge p1 and p2 into pr */ |
|
|
void _addd_destructive(vl,p1,p2,pr) |
void _addd_destructive(VL vl,DP p1,DP p2,DP *pr) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
int n; |
int n; |
MP m1,m2,mr,mr0,s; |
MP m1,m2,mr,mr0,s; |
|
|
for ( n = NV(p1), m1 = BDY(p1), m2 = BDY(p2), mr0 = 0; m1 && m2; ) |
for ( n = NV(p1), m1 = BDY(p1), m2 = BDY(p2), mr0 = 0; m1 && m2; ) |
switch ( (*cmpdl)(n,m1->dl,m2->dl) ) { |
switch ( (*cmpdl)(n,m1->dl,m2->dl) ) { |
case 0: |
case 0: |
addp(vl,C(m1),C(m2),&t); |
addp(vl,(P)C(m1),(P)C(m2),&t); |
s = m1; m1 = NEXT(m1); |
s = m1; m1 = NEXT(m1); |
if ( t ) { |
if ( t ) { |
_NEXTMP2(mr0,mr,s); C(mr) = t; |
_NEXTMP2(mr0,mr,s); C(mr) = (Obj)t; |
} else { |
} else { |
_FREEDL(s->dl); _FREEMP(s); |
_FREEDL(s->dl); _FREEMP(s); |
} |
} |
|
|
} |
} |
} |
} |
|
|
void _muld_dup(vl,p1,p2,pr) |
void _muld_dup(VL vl,DP p1,DP p2,DP *pr) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
if ( !do_weyl ) |
if ( !do_weyl ) |
_comm_muld_dup(vl,p1,p2,pr); |
_comm_muld_dup(vl,p1,p2,pr); |
|
|
_weyl_muld_dup(vl,p1,p2,pr); |
_weyl_muld_dup(vl,p1,p2,pr); |
} |
} |
|
|
void _comm_muld_dup(vl,p1,p2,pr) |
void _comm_muld_dup(VL vl,DP p1,DP p2,DP *pr) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
MP m; |
MP m; |
DP s,t,u; |
DP s,t,u; |
|
|
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; |
} |
} |
|
|
} |
} |
} |
} |
|
|
void _weyl_muld_dup(vl,p1,p2,pr) |
void _weyl_muld_dup(VL vl,DP p1,DP p2,DP *pr) |
VL vl; |
|
DP p1,p2,*pr; |
|
{ |
{ |
MP m; |
MP m; |
DP s,t,u; |
DP s,t,u; |
int i,l,l1; |
int i,l; |
static MP *w; |
static MP *w; |
static int wlen; |
static int wlen; |
|
|
|
|
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; |
} |
} |
|
|
} |
} |
} |
} |
|
|
void _muldm_dup(vl,p,m0,pr) |
void _muldm_dup(VL vl,DP p,MP m0,DP *pr) |
VL vl; |
|
DP p; |
|
MP m0; |
|
DP *pr; |
|
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
DL d,dt,dm; |
DL d,dt,dm; |
P c; |
P c; |
int n,r,i; |
int n,i; |
int *pt,*p1,*p2; |
int *pt,*p1,*p2; |
|
|
if ( !p ) |
if ( !p ) |
*pr = 0; |
*pr = 0; |
else { |
else { |
for ( mr0 = 0, m = BDY(p), c = C(m0), d = m0->dl, n = NV(p); |
for ( mr0 = 0, m = BDY(p), c = (P)C(m0), d = m0->dl, n = NV(p); |
m; m = NEXT(m) ) { |
m; m = NEXT(m) ) { |
_NEXTMP(mr0,mr); |
_NEXTMP(mr0,mr); |
mulp(vl,C(m),c,&C(mr)); |
mulp(vl,(P)C(m),c,(P *)&C(mr)); |
_NEWDL_NOINIT(dt,n); mr->dl = dt; |
_NEWDL_NOINIT(dt,n); mr->dl = dt; |
dm = m->dl; |
dm = m->dl; |
dt->td = d->td + dm->td; |
dt->td = d->td + dm->td; |
|
|
} |
} |
} |
} |
|
|
void _weyl_muldm_dup(vl,m0,p,pr) |
void _weyl_muldm_dup(VL vl,MP m0,DP p,DP *pr) |
VL vl; |
|
MP m0; |
|
DP p; |
|
DP *pr; |
|
{ |
{ |
DP r,t,t1; |
DP r,t,t1; |
MP m; |
MP m; |
|
|
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; |
} |
} |
|
|
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 cdl *)MALLOC(rtlen*sizeof(struct cdl)); |
tab = (struct cdl *)MALLOC(rtlen*sizeof(struct cdl)); |
psum = (MP *)MALLOC(rtlen*sizeof(MP)); |
psum = (MP *)MALLOC(rtlen*sizeof(MP)); |
|
|
|
|
/* m0 = x0^d0*x1^d1*... * dx0^d(n/2)*dx1^d(n/2+1)*... */ |
/* m0 = x0^d0*x1^d1*... * dx0^d(n/2)*dx1^d(n/2+1)*... */ |
|
|
void _weyl_mulmm_dup(vl,m0,m1,n,rtab,rtablen) |
void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cdl *rtab,int rtablen) |
VL vl; |
|
MP m0,m1; |
|
int n; |
|
struct cdl *rtab; |
|
int rtablen; |
|
{ |
{ |
MP m,mr,mr0; |
|
DP r,t,t1; |
|
P c; |
P c; |
int c0,c1,cc; |
|
DL d,d0,d1,dt; |
DL d,d0,d1,dt; |
int i,j,a,b,k,l,n2,s,min,h,curlen; |
int i,j,a,b,k,l,n2,s,min,curlen; |
struct cdl *p; |
struct cdl *p; |
static P *ctab; |
static Q *ctab; |
static struct cdl *tab; |
static struct cdl *tab; |
static int tablen; |
static int tablen; |
static struct cdl *tmptab; |
static struct cdl *tmptab; |
|
|
rtab[0].d = 0; |
rtab[0].d = 0; |
return; |
return; |
} |
} |
mulp(vl,C(m0),C(m1),&c); |
mulp(vl,(P)C(m0),(P)C(m1),&c); |
d0 = m0->dl; d1 = m1->dl; |
d0 = m0->dl; d1 = m1->dl; |
n2 = n>>1; |
n2 = n>>1; |
curlen = 1; |
curlen = 1; |
|
|
d->td = d->d[n-1] = d0->d[n-1]+d1->d[n-1]; |
d->td = d->d[n-1] = d0->d[n-1]+d1->d[n-1]; |
else |
else |
d->td = 0; |
d->td = 0; |
rtab[0].c = c; |
rtab[0].c = (Obj)c; |
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 cdl *)MALLOC(rtablen*sizeof(struct cdl)); |
tmptab = (struct cdl *)MALLOC(rtablen*sizeof(struct cdl)); |
tmptablen = rtablen; |
tmptablen = rtablen; |
} |
} |
|
|
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; |
|
|
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 cdl *)MALLOC(tablen*sizeof(struct cdl)); |
tab = (struct cdl *)MALLOC(tablen*sizeof(struct cdl)); |
ctab = (P *)MALLOC(tablen*sizeof(P)); |
ctab = (Q *)MALLOC(tablen*sizeof(P)); |
} |
} |
/* 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); |
mkwc(k,l,ctab); |
mkwc(k,l,ctab); |
|
|
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 = (Obj)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 = (Obj)ctab[j]; |
} |
} |
#if 0 |
#if 0 |
_comm_muld_tab(vl,n,rtab,curlen,tab,k+1,tmptab); |
_comm_muld_tab(vl,n,rtab,curlen,tab,k+1,tmptab); |
|
|
] |
] |
*/ |
*/ |
|
|
void _comm_muld_tab(vl,nv,t,n,t1,n1,rt) |
void _comm_muld_tab(VL vl,int nv,struct cdl *t,int n,struct cdl *t1,int n1,struct cdl *rt) |
VL vl; |
|
int nv; |
|
struct cdl *t; |
|
int n; |
|
struct cdl *t1; |
|
int n1; |
|
struct cdl *rt; |
|
{ |
{ |
int i,j; |
int i,j; |
struct cdl *p; |
struct cdl *p; |
Line 1071 struct cdl *rt; |
|
|
|
|
bzero(rt,n*n1*sizeof(struct cdl)); |
bzero(rt,n*n1*sizeof(struct cdl)); |
for ( j = 0, p = rt; j < n1; j++ ) { |
for ( j = 0, p = rt; j < n1; j++ ) { |
c = t1[j].c; |
c = (P)t1[j].c; |
d = t1[j].d; |
d = t1[j].d; |
if ( !c ) |
if ( !c ) |
break; |
break; |
for ( i = 0; i < n; i++, p++ ) { |
for ( i = 0; i < n; i++, p++ ) { |
if ( t[i].c ) { |
if ( t[i].c ) { |
mulp(vl,t[i].c,c,&p->c); |
mulp(vl,(P)t[i].c,c,(P *)&p->c); |
_adddl_dup(nv,t[i].d,d,&p->d); |
_adddl_dup(nv,t[i].d,d,&p->d); |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
void _comm_muld_tab_destructive(vl,nv,t,n,t1,n1) |
void _comm_muld_tab_destructive(VL vl,int nv,struct cdl *t,int n,struct cdl *t1,int n1) |
VL vl; |
|
int nv; |
|
struct cdl *t; |
|
int n; |
|
struct cdl *t1; |
|
int n1; |
|
{ |
{ |
int i,j; |
int i,j; |
struct cdl *p; |
struct cdl *p; |
|
|
DL d; |
DL d; |
|
|
for ( j = 1, p = t+n; j < n1; j++ ) { |
for ( j = 1, p = t+n; j < n1; j++ ) { |
c = t1[j].c; |
c = (P)t1[j].c; |
d = t1[j].d; |
d = t1[j].d; |
if ( !c ) |
if ( !c ) |
break; |
break; |
for ( i = 0; i < n; i++, p++ ) { |
for ( i = 0; i < n; i++, p++ ) { |
if ( t[i].c ) { |
if ( t[i].c ) { |
mulp(vl,t[i].c,c,&p->c); |
mulp(vl,(P)t[i].c,c,(P *)&p->c); |
_adddl_dup(nv,t[i].d,d,&p->d); |
_adddl_dup(nv,t[i].d,d,&p->d); |
} |
} |
} |
} |
} |
} |
c = t1[0].c; |
c = (P)t1[0].c; |
d = t1[0].d; |
d = t1[0].d; |
for ( i = 0, p = t; i < n; i++, p++ ) |
for ( i = 0, p = t; i < n; i++, p++ ) |
if ( t[i].c ) { |
if ( t[i].c ) { |
mulp(vl,t[i].c,c,&p->c); |
mulp(vl,(P)t[i].c,c,(P *)&p->c); |
/* t[i].d += d */ |
/* t[i].d += d */ |
adddl_destructive(nv,t[i].d,d); |
adddl_destructive(nv,t[i].d,d); |
} |
} |