version 1.14, 2009/03/16 16:43:02 |
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.13 2002/07/24 07:38:55 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" |
|
|
dl_len += 1; |
dl_len += 1; |
#endif |
#endif |
for ( i = 0; i < 128; i++, p += dl_len ) { |
for ( i = 0; i < 128; i++, p += dl_len ) { |
p = (int *)GC_malloc(dl_len*sizeof(int)); |
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; |
} |
} |
|
|
|
|
/* fprintf(stderr,"MP_alloc : %d \n",++MP_alloc_count); */ |
/* fprintf(stderr,"MP_alloc : %d \n",++MP_alloc_count); */ |
for ( i = 0; i < 1024; i++ ) { |
for ( i = 0; i < 1024; i++ ) { |
p = (MP)GC_malloc(sizeof(struct oMP)); |
p = (MP)MALLOC(sizeof(struct oMP)); |
p->next = _mp_free_list; _mp_free_list = p; |
p->next = _mp_free_list; _mp_free_list = p; |
} |
} |
} |
} |
Line 108 void _DP_alloc() |
|
Line 108 void _DP_alloc() |
|
|
|
/* fprintf(stderr,"DP_alloc : %d \n",++DP_alloc_count); */ |
/* fprintf(stderr,"DP_alloc : %d \n",++DP_alloc_count); */ |
for ( i = 0; i < 1024; i++ ) { |
for ( i = 0; i < 1024; i++ ) { |
p = (DP)GC_malloc(sizeof(struct oDP)); |
p = (DP)MALLOC(sizeof(struct oDP)); |
p->body = (MP)_dp_free_list; _dp_free_list = p; |
p->body = (MP)_dp_free_list; _dp_free_list = p; |
} |
} |
} |
} |
Line 134 void _addmd_destructive(int mod,DP p1,DP p2,DP *pr) |
|
Line 134 void _addmd_destructive(int mod,DP p1,DP p2,DP *pr) |
|
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); |
} |
} |
Line 195 void _comm_mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
|
Line 195 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 222 void _weyl_mulmd_dup(int mod,DP p1,DP p2,DP *pr) |
|
Line 222 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 251 void _mulmdm_dup(int mod,DP p,MP m0,DP *pr) |
|
Line 251 void _mulmdm_dup(int mod,DP p,MP m0,DP *pr) |
|
_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; |
Line 280 void _weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
Line 280 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 292 void _weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
Line 292 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 305 void _weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
Line 305 void _weyl_mulmdm_dup(int mod,MP m0,DP p,DP *pr) |
|
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; |
} |
} |
} |
} |
Line 355 void _weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
Line 355 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 382 void _weyl_mulmmm_dup(int mod,MP m0,MP m1,int n,struct |
|
Line 382 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)); |
Line 650 void _addd_destructive(VL vl,DP p1,DP p2,DP *pr) |
|
Line 650 void _addd_destructive(VL vl,DP p1,DP p2,DP *pr) |
|
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); |
} |
} |
Line 714 void _comm_muld_dup(VL vl,DP p1,DP p2,DP *pr) |
|
Line 714 void _comm_muld_dup(VL vl,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 741 void _weyl_muld_dup(VL vl,DP p1,DP p2,DP *pr) |
|
Line 741 void _weyl_muld_dup(VL vl,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 766 void _muldm_dup(VL vl,DP p,MP m0,DP *pr) |
|
Line 766 void _muldm_dup(VL vl,DP p,MP m0,DP *pr) |
|
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; |
Line 798 void _weyl_muldm_dup(VL vl,MP m0,DP p,DP *pr) |
|
Line 798 void _weyl_muldm_dup(VL vl,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 810 void _weyl_muldm_dup(VL vl,MP m0,DP p,DP *pr) |
|
Line 810 void _weyl_muldm_dup(VL vl,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 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)); |
Line 857 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
Line 857 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
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; |
Line 868 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
Line 868 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
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; |
} |
} |
Line 899 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
Line 899 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
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 = (Q *)MALLOC(tablen*sizeof(P)); |
ctab = (Q *)MALLOC(tablen*sizeof(P)); |
Line 917 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
Line 917 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
d->td = s; |
d->td = s; |
d->d[n-1] = s-(MUL_WEIGHT(a-j,i)+MUL_WEIGHT(b-j,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 = (P)ctab[j]; |
tab[j].c = (Obj)ctab[j]; |
} |
} |
else |
else |
for ( j = 0; j <= min; j++ ) { |
for ( j = 0; j <= min; j++ ) { |
Line 925 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
Line 925 void _weyl_mulmm_dup(VL vl,MP m0,MP m1,int n,struct cd |
|
d->d[i] = a-j; d->d[n2+i] = b-j; |
d->d[i] = a-j; d->d[n2+i] = b-j; |
d->td = MUL_WEIGHT(a-j,i)+MUL_WEIGHT(b-j,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 = (P)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); |
Line 962 void _comm_muld_tab(VL vl,int nv,struct cdl *t,int n,s |
|
Line 962 void _comm_muld_tab(VL vl,int nv,struct cdl *t,int n,s |
|
|
|
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); |
} |
} |
} |
} |
Line 983 void _comm_muld_tab_destructive(VL vl,int nv,struct cd |
|
Line 983 void _comm_muld_tab_destructive(VL vl,int nv,struct cd |
|
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); |
} |
} |