version 1.5, 2000/05/29 08:54:46 |
version 1.18, 2001/09/13 03:04:28 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.4 2000/04/25 04:07:59 noro Exp $ */ |
/* |
|
* Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED |
|
* All rights reserved. |
|
* |
|
* FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, |
|
* non-exclusive and royalty-free license to use, copy, modify and |
|
* redistribute, solely for non-commercial and non-profit purposes, the |
|
* computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and |
|
* conditions of this Agreement. For the avoidance of doubt, you acquire |
|
* only a limited right to use the SOFTWARE hereunder, and FLL or any |
|
* third party developer retains all rights, including but not limited to |
|
* copyrights, in and to the SOFTWARE. |
|
* |
|
* (1) FLL does not grant you a license in any way for commercial |
|
* purposes. You may use the SOFTWARE only for non-commercial and |
|
* non-profit purposes only, such as academic, research and internal |
|
* business use. |
|
* (2) The SOFTWARE is protected by the Copyright Law of Japan and |
|
* international copyright treaties. If you make copies of the SOFTWARE, |
|
* with or without modification, as permitted hereunder, you shall affix |
|
* to all such copies of the SOFTWARE the above copyright notice. |
|
* (3) An explicit reference to this SOFTWARE and its copyright owner |
|
* shall be made on your publication or presentation in any form of the |
|
* results obtained by use of the SOFTWARE. |
|
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
|
* e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification |
|
* for such modification or the source code of the modified part of the |
|
* SOFTWARE. |
|
* |
|
* THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL |
|
* MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND |
|
* EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS |
|
* FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' |
|
* RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY |
|
* MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. |
|
* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, |
|
* OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY |
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL |
|
* DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES |
|
* ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES |
|
* FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY |
|
* DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF |
|
* SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART |
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
|
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
|
* |
|
* $OpenXM: OpenXM_contrib2/asir2000/engine/dist.c,v 1.17 2001/09/04 08:48:20 noro Exp $ |
|
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
#define NV(p) ((p)->nv) |
|
#define C(p) ((p)->c) |
|
|
|
#define ORD_REVGRADLEX 0 |
#define ORD_REVGRADLEX 0 |
#define ORD_GRADLEX 1 |
#define ORD_GRADLEX 1 |
#define ORD_LEX 2 |
#define ORD_LEX 2 |
|
|
#define ORD_BGRADREV 7 |
#define ORD_BGRADREV 7 |
#define ORD_BLEXREV 8 |
#define ORD_BLEXREV 8 |
#define ORD_ELIM 9 |
#define ORD_ELIM 9 |
|
#define ORD_WEYL_ELIM 10 |
|
#define ORD_HOMO_WW_DRL 11 |
|
|
int (*cmpdl)()=cmpdl_revgradlex; |
int (*cmpdl)()=cmpdl_revgradlex; |
int (*primitive_cmpdl[3])() = {cmpdl_revgradlex,cmpdl_gradlex,cmpdl_lex}; |
int (*primitive_cmpdl[3])() = {cmpdl_revgradlex,cmpdl_gradlex,cmpdl_lex}; |
|
|
void comm_muld(VL,DP,DP,DP *); |
void comm_muld(VL,DP,DP,DP *); |
void weyl_muld(VL,DP,DP,DP *); |
void weyl_muld(VL,DP,DP,DP *); |
void weyl_muldm(VL,DP,MP,DP *); |
void weyl_muldm(VL,MP,DP,DP *); |
void weyl_mulmm(VL,MP,MP,int,DP *); |
void weyl_mulmm(VL,MP,MP,int,struct cdl *,int); |
|
void comm_muld_tab(VL,int,struct cdl *,int,struct cdl *,int,struct cdl *); |
|
|
void mkwc(int,int,Q *); |
void mkwc(int,int,Q *); |
|
|
|
int cmpdl_weyl_elim(); |
|
int cmpdl_homo_ww_drl(); |
|
|
int do_weyl; |
int do_weyl; |
|
|
int dp_nelim,dp_fcoeffs; |
int dp_nelim,dp_fcoeffs; |
|
|
if ( !f ) |
if ( !f ) |
return 0; |
return 0; |
else if ( NUM(f) ) |
else if ( NUM(f) ) |
return (NID((Num)f) == N_LM || NID((Num)f) == N_GF2N) ? 1 : 0; |
return (NID((Num)f) == N_LM |
|
|| NID((Num)f) == N_GF2N |
|
|| NID((Num)f) == N_GFPN |
|
|| NID((Num)f) == N_GFS) ? 1 : 0; |
else { |
else { |
for ( dc = DC(f); dc; dc = NEXT(dc) ) |
for ( dc = DC(f); dc; dc = NEXT(dc) ) |
if ( has_fcoef_p(COEF(dc)) ) |
if ( has_fcoef_p(COEF(dc)) ) |
Line 94 struct order_spec *spec; |
|
Line 149 struct order_spec *spec; |
|
cmpdl = cmpdl_blexrev; break; |
cmpdl = cmpdl_blexrev; break; |
case ORD_ELIM: |
case ORD_ELIM: |
cmpdl = cmpdl_elim; break; |
cmpdl = cmpdl_elim; break; |
|
case ORD_WEYL_ELIM: |
|
cmpdl = cmpdl_weyl_elim; break; |
|
case ORD_HOMO_WW_DRL: |
|
cmpdl = cmpdl_homo_ww_drl; break; |
case ORD_LEX: default: |
case ORD_LEX: default: |
cmpdl = cmpdl_lex; break; |
cmpdl = cmpdl_lex; break; |
} |
} |
|
|
DP *pr; |
DP *pr; |
{ |
{ |
int isconst = 0; |
int isconst = 0; |
int n,i; |
int n,i,j,k; |
VL tvl; |
VL tvl; |
V v; |
V v; |
DL d; |
DL d; |
MP m; |
MP m; |
DCP dc; |
DCP dc; |
|
DCP *w; |
DP r,s,t,u; |
DP r,s,t,u; |
P x,c; |
P x,c; |
|
|
|
|
for ( i = 0, tvl = dvl, v = VR(p); |
for ( i = 0, tvl = dvl, v = VR(p); |
tvl && tvl->v != v; tvl = NEXT(tvl), i++ ); |
tvl && tvl->v != v; tvl = NEXT(tvl), i++ ); |
if ( !tvl ) { |
if ( !tvl ) { |
for ( dc = DC(p), s = 0, MKV(v,x); dc; dc = NEXT(dc) ) { |
for ( dc = DC(p), k = 0; dc; dc = NEXT(dc), k++ ); |
ptod(vl,dvl,COEF(dc),&t); pwrp(vl,x,DEG(dc),&c); |
w = (DCP *)ALLOCA(k*sizeof(DCP)); |
|
for ( dc = DC(p), j = 0; j < k; dc = NEXT(dc), j++ ) |
|
w[j] = dc; |
|
|
|
for ( j = k-1, s = 0, MKV(v,x); j >= 0; j-- ) { |
|
ptod(vl,dvl,COEF(w[j]),&t); pwrp(vl,x,DEG(w[j]),&c); |
muldc(vl,t,c,&r); addd(vl,r,s,&t); s = t; |
muldc(vl,t,c,&r); addd(vl,r,s,&t); s = t; |
} |
} |
*pr = s; |
*pr = s; |
} else { |
} else { |
for ( dc = DC(p), s = 0; dc; dc = NEXT(dc) ) { |
for ( dc = DC(p), k = 0; dc; dc = NEXT(dc), k++ ); |
ptod(vl,dvl,COEF(dc),&t); |
w = (DCP *)ALLOCA(k*sizeof(DCP)); |
NEWDL(d,n); d->td = QTOS(DEG(dc)); d->d[i] = d->td; |
for ( dc = DC(p), j = 0; j < k; dc = NEXT(dc), j++ ) |
|
w[j] = dc; |
|
|
|
for ( j = k-1, s = 0; j >= 0; j-- ) { |
|
ptod(vl,dvl,COEF(w[j]),&t); |
|
NEWDL(d,n); d->td = QTOS(DEG(w[j])); d->d[i] = d->td; |
NEWMP(m); m->dl = d; C(m) = (P)ONE; NEXT(m) = 0; MKDP(n,m,u); u->sugar = d->td; |
NEWMP(m); m->dl = d; C(m) = (P)ONE; NEXT(m) = 0; MKDP(n,m,u); u->sugar = d->td; |
comm_muld(vl,t,u,&r); addd(vl,r,s,&t); s = t; |
comm_muld(vl,t,u,&r); addd(vl,r,s,&t); s = t; |
} |
} |
|
|
} |
} |
} |
} |
} |
} |
|
#if 0 |
if ( !dp_fcoeffs && has_fcoef(*pr) ) |
if ( !dp_fcoeffs && has_fcoef(*pr) ) |
dp_fcoeffs = 1; |
dp_fcoeffs = 1; |
|
#endif |
} |
} |
|
|
void dtop(vl,dvl,p,pr) |
void dtop(vl,dvl,p,pr) |
|
|
DP p; |
DP p; |
P *pr; |
P *pr; |
{ |
{ |
int n,i; |
int n,i,j,k; |
DL d; |
DL d; |
MP m; |
MP m; |
|
MP *a; |
P r,s,t,u,w; |
P r,s,t,u,w; |
Q q; |
Q q; |
VL tvl; |
VL tvl; |
|
|
if ( !p ) |
if ( !p ) |
*pr = 0; |
*pr = 0; |
else { |
else { |
for ( n = p->nv, m = BDY(p), s = 0; m; m = NEXT(m) ) { |
for ( k = 0, m = BDY(p); m; m = NEXT(m), k++ ); |
|
a = (MP *)ALLOCA(k*sizeof(MP)); |
|
for ( j = 0, m = BDY(p); j < k; m = NEXT(m), j++ ) |
|
a[j] = m; |
|
|
|
for ( n = p->nv, j = k-1, s = 0; j >= 0; j-- ) { |
|
m = a[j]; |
t = C(m); |
t = C(m); |
if ( NUM(t) && NID((Num)t) == N_M ) { |
if ( NUM(t) && NID((Num)t) == N_M ) { |
mptop(t,&u); t = u; |
mptop(t,&u); t = u; |
|
|
} |
} |
} |
} |
|
|
|
DLBUCKET symb_merge_bucket(m1,m2,n) |
|
DLBUCKET m1,m2; |
|
int n; |
|
{ |
|
DLBUCKET top,prev,cur,m,t; |
|
|
|
if ( !m1 ) |
|
return m2; |
|
else if ( !m2 ) |
|
return m1; |
|
else { |
|
if ( m1->td == m2->td ) { |
|
top = m1; |
|
BDY(top) = symb_merge(BDY(top),BDY(m2),n); |
|
m = NEXT(m2); |
|
} else if ( m1->td > m2->td ) { |
|
top = m1; m = m2; |
|
} else { |
|
top = m2; m = m1; |
|
} |
|
prev = top; cur = NEXT(top); |
|
/* prev->td > m->td always holds */ |
|
while ( cur && m ) { |
|
if ( cur->td == m->td ) { |
|
BDY(cur) = symb_merge(BDY(cur),BDY(m),n); |
|
m = NEXT(m); |
|
prev = cur; cur = NEXT(cur); |
|
} else if ( cur->td > m->td ) { |
|
t = NEXT(cur); NEXT(cur) = m; m = t; |
|
prev = cur; cur = NEXT(cur); |
|
} else { |
|
NEXT(prev) = m; m = cur; |
|
prev = NEXT(prev); cur = NEXT(prev); |
|
} |
|
} |
|
if ( !cur ) |
|
NEXT(prev) = m; |
|
return top; |
|
} |
|
} |
|
|
void subd(vl,p1,p2,pr) |
void subd(vl,p1,p2,pr) |
VL vl; |
VL vl; |
DP p1,p2,*pr; |
DP p1,p2,*pr; |
|
|
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(p2), 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 ) GC_free(w); |
w = (MP *)MALLOC(l*sizeof(MP)); |
w = (MP *)MALLOC(l*sizeof(MP)); |
wlen = l; |
wlen = l; |
} |
} |
for ( m = BDY(p2), i = 0; i < l; m = NEXT(m), i++ ) |
for ( m = BDY(p1), 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,w[i],p2,&t); addd(vl,s,t,&u); s = u; |
} |
} |
bzero(w,l*sizeof(MP)); |
bzero(w,l*sizeof(MP)); |
*pr = s; |
*pr = s; |
} |
} |
} |
} |
|
|
void weyl_muldm(vl,p,m0,pr) |
/* monomial * polynomial */ |
|
|
|
void weyl_muldm(vl,m0,p,pr) |
VL vl; |
VL vl; |
DP p; |
|
MP m0; |
MP m0; |
|
DP p; |
DP *pr; |
DP *pr; |
{ |
{ |
DP r,t,t1; |
DP r,t,t1; |
MP m; |
MP m; |
int n,l,i; |
DL d0; |
static MP *w; |
int n,n2,l,i,j,tlen; |
|
static MP *w,*psum; |
|
static struct cdl *tab; |
static int wlen; |
static int wlen; |
|
static int rtlen; |
|
|
if ( !p ) |
if ( !p ) |
*pr = 0; |
*pr = 0; |
|
|
} |
} |
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-- ) { |
|
weyl_mulmm(vl,w[i],m0,n,&t); |
n = NV(p); n2 = n>>1; |
addd(vl,r,t,&t1); r = t1; |
d0 = m0->dl; |
|
for ( i = 0, tlen = 1; i < n2; i++ ) |
|
tlen *= d0->d[n2+i]+1; |
|
if ( tlen > rtlen ) { |
|
if ( tab ) GC_free(tab); |
|
if ( psum ) GC_free(psum); |
|
rtlen = tlen; |
|
tab = (struct cdl *)MALLOC(rtlen*sizeof(struct cdl)); |
|
psum = (MP *)MALLOC(rtlen*sizeof(MP)); |
} |
} |
bzero(w,l*sizeof(MP)); |
bzero(psum,tlen*sizeof(MP)); |
|
for ( i = l-1; i >= 0; i-- ) { |
|
bzero(tab,tlen*sizeof(struct cdl)); |
|
weyl_mulmm(vl,m0,w[i],n,tab,tlen); |
|
for ( j = 0; j < tlen; j++ ) { |
|
if ( tab[j].c ) { |
|
NEWMP(m); m->dl = tab[j].d; C(m) = tab[j].c; NEXT(m) = psum[j]; |
|
psum[j] = m; |
|
} |
|
} |
|
} |
|
for ( j = tlen-1, r = 0; j >= 0; j-- ) |
|
if ( psum[j] ) { |
|
MKDP(n,psum[j],t); addd(vl,r,t,&t1); r = t1; |
|
} |
if ( r ) |
if ( r ) |
r->sugar = p->sugar + m0->dl->td; |
r->sugar = p->sugar + m0->dl->td; |
*pr = r; |
*pr = r; |
} |
} |
} |
} |
|
|
/* m0 = x0^d0*x1^d1*... * dx0^d(n/2)*dx1^d(n/2+1)*... */ |
/* m0 = x0^d0*x1^d1*... * dx0^e0*dx1^e1*... */ |
|
/* rtab : array of length (e0+1)*(e1+1)*... */ |
|
|
void weyl_mulmm(vl,m0,m1,n,pr) |
void weyl_mulmm(vl,m0,m1,n,rtab,rtablen) |
VL vl; |
VL vl; |
MP m0,m1; |
MP m0,m1; |
int n; |
int n; |
DP *pr; |
struct cdl *rtab; |
|
int rtablen; |
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
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,dt; |
int i,j,a,b,k,l,n2,s,min,h; |
int i,j,a,b,k,l,n2,s,min,curlen; |
static Q *tab; |
struct cdl *p; |
|
static Q *ctab; |
|
static struct cdl *tab; |
static int tablen; |
static int tablen; |
|
static struct cdl *tmptab; |
|
static int tmptablen; |
|
|
if ( !m0 || !m1 ) |
|
*pr = 0; |
if ( !m0 || !m1 ) { |
else { |
rtab[0].c = 0; |
c0 = C(m0); c1 = C(m1); |
rtab[0].d = 0; |
mulp(vl,c0,c1,&c); |
return; |
d0 = m0->dl; d1 = m1->dl; |
} |
n2 = n>>1; |
c0 = C(m0); c1 = C(m1); |
if ( n & 1 ) { |
mulp(vl,c0,c1,&c); |
/* homogenized computation; dx-xd=h^2 */ |
d0 = m0->dl; d1 = m1->dl; |
/* offset of h-degree */ |
n2 = n>>1; |
NEWDL(d,n); d->d[n-1] = d0->d[n-1]+d1->d[n-1]; d->td = d->d[n-1]; |
curlen = 1; |
NEWMP(mr); mr->c = (P)ONE; mr->dl = d; |
NEWDL(d,n); |
MKDP(n,mr,r); r->sugar = d->d[n-1]; |
if ( n & 1 ) |
|
/* offset of h-degree */ |
|
d->td = d->d[n-1] = d0->d[n-1]+d1->d[n-1]; |
|
else |
|
d->td = 0; |
|
rtab[0].c = c; |
|
rtab[0].d = d; |
|
|
for ( i = 0; i < n2; i++ ) { |
if ( rtablen > tmptablen ) { |
a = d0->d[i]; b = d1->d[n2+i]; |
if ( tmptab ) GC_free(tmptab); |
k = d0->d[n2+i]; l = d1->d[i]; |
tmptab = (struct cdl *)MALLOC(rtablen*sizeof(struct cdl)); |
/* degree of xi^a*(Di^k*xi^l)*Di^b */ |
tmptablen = rtablen; |
h = a+k+l+b; |
} |
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
for ( i = 0; i < n2; i++ ) { |
min = MIN(k,l); |
a = d0->d[i]; b = d1->d[n2+i]; |
|
k = d0->d[n2+i]; l = d1->d[i]; |
if ( min+1 > tablen ) { |
if ( !k || !l ) { |
if ( tab ) GC_free(tab); |
a += l; |
tab = (Q *)MALLOC((min+1)*sizeof(Q)); |
b += k; |
tablen = min+1; |
s = a+b; |
|
for ( j = 0, p = rtab; j < curlen; j++, p++ ) { |
|
if ( p->c ) { |
|
dt = p->d; |
|
dt->d[i] = a; |
|
dt->d[n2+i] = b; |
|
dt->td += s; |
} |
} |
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; |
|
} |
} |
} else |
curlen *= k+1; |
for ( i = 0, r = (DP)ONE; i < n2; i++ ) { |
continue; |
a = d0->d[i]; b = d1->d[n2+i]; |
} |
k = d0->d[n2+i]; l = d1->d[i]; |
if ( k+1 > tablen ) { |
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
if ( tab ) GC_free(tab); |
min = MIN(k,l); |
if ( ctab ) GC_free(ctab); |
tab = (Q *)ALLOCA((min+1)*sizeof(Q)); |
tablen = k+1; |
mkwc(k,l,tab); |
tab = (struct cdl *)MALLOC(tablen*sizeof(struct cdl)); |
for ( mr0 = 0, s = 0, j = 0; j <= min; j++ ) { |
ctab = (Q *)MALLOC(tablen*sizeof(Q)); |
NEXTMP(mr0,mr); |
} |
NEWDL(d,n); |
/* degree of xi^a*(Di^k*xi^l)*Di^b */ |
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
s = a+k+l+b; |
d->td = d->d[i]+d->d[n2+i]; /* XXX */ |
/* compute xi^a*(Di^k*xi^l)*Di^b */ |
s = MAX(s,d->td); /* XXX */ |
min = MIN(k,l); |
mr->c = (P)tab[j]; |
mkwc(k,l,ctab); |
mr->dl = d; |
bzero(tab,(k+1)*sizeof(struct cdl)); |
} |
if ( n & 1 ) |
if ( mr0 ) |
for ( j = 0; j <= min; j++ ) { |
NEXT(mr) = 0; |
NEWDL(d,n); |
MKDP(n,mr0,t); |
d->d[i] = l-j+a; d->d[n2+i] = k-j+b; |
if ( t ) |
d->td = s; |
t->sugar = s; |
d->d[n-1] = s-(d->d[i]+d->d[n2+i]); |
comm_muld(vl,r,t,&t1); r = t1; |
tab[j].d = d; |
|
tab[j].c = (P)ctab[j]; |
} |
} |
muldc(vl,r,c,pr); |
else |
|
for ( j = 0; j <= min; j++ ) { |
|
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 */ |
|
tab[j].d = d; |
|
tab[j].c = (P)ctab[j]; |
|
} |
|
bzero(ctab,(min+1)*sizeof(Q)); |
|
comm_muld_tab(vl,n,rtab,curlen,tab,k+1,tmptab); |
|
curlen *= k+1; |
|
bcopy(tmptab,rtab,curlen*sizeof(struct cdl)); |
} |
} |
} |
} |
|
|
|
/* direct product of two cdl tables |
|
rt[] = [ |
|
t[0]*t1[0],...,t[n-1]*t1[0], |
|
t[0]*t1[1],...,t[n-1]*t1[1], |
|
... |
|
t[0]*t1[n1-1],...,t[n-1]*t1[n1-1] |
|
] |
|
*/ |
|
|
|
void comm_muld_tab(vl,nv,t,n,t1,n1,rt) |
|
VL vl; |
|
int nv; |
|
struct cdl *t; |
|
int n; |
|
struct cdl *t1; |
|
int n1; |
|
struct cdl *rt; |
|
{ |
|
int i,j; |
|
struct cdl *p; |
|
P c; |
|
DL d; |
|
|
|
bzero(rt,n*n1*sizeof(struct cdl)); |
|
for ( j = 0, p = rt; j < n1; j++ ) { |
|
c = t1[j].c; |
|
d = t1[j].d; |
|
if ( !c ) |
|
break; |
|
for ( i = 0; i < n; i++, p++ ) { |
|
if ( t[i].c ) { |
|
mulp(vl,t[i].c,c,&p->c); |
|
adddl(nv,t[i].d,d,&p->d); |
|
} |
|
} |
|
} |
|
} |
|
|
void muldc(vl,p,c,pr) |
void muldc(vl,p,c,pr) |
VL vl; |
VL vl; |
DP p; |
DP p; |
|
|
} |
} |
} |
} |
|
|
|
/* d1 += d2 */ |
|
|
|
void adddl_destructive(n,d1,d2) |
|
int n; |
|
DL d1,d2; |
|
{ |
|
DL dt; |
|
int i; |
|
|
|
d1->td += d2->td; |
|
for ( i = 0; i < n; i++ ) |
|
d1->d[i] += d2->d[i]; |
|
} |
|
|
int compd(vl,p1,p2) |
int compd(vl,p1,p2) |
VL vl; |
VL vl; |
DP p1,p2; |
DP p1,p2; |
Line 764 int cmpdl_revgradlex(n,d1,d2) |
|
Line 976 int cmpdl_revgradlex(n,d1,d2) |
|
int n; |
int n; |
DL d1,d2; |
DL d1,d2; |
{ |
{ |
|
register int i; |
|
register int *p1,*p2; |
|
|
if ( d1->td > d2->td ) |
if ( d1->td > d2->td ) |
return 1; |
return 1; |
else if ( d1->td < d2->td ) |
else if ( d1->td < d2->td ) |
return -1; |
return -1; |
else |
else { |
return cmpdl_revlex(n,d1,d2); |
for ( i= n - 1, p1 = d1->d+n-1, p2 = d2->d+n-1; |
|
i >= 0 && *p1 == *p2; i--, p1--, p2-- ); |
|
return i < 0 ? 0 : (*p1 < *p2 ? 1 : -1); |
|
} |
} |
} |
|
|
int cmpdl_blex(n,d1,d2) |
int cmpdl_blex(n,d1,d2) |
|
|
return -1; |
return -1; |
else |
else |
return cmpdl_revgradlex(n,d1,d2); |
return cmpdl_revgradlex(n,d1,d2); |
|
} |
|
|
|
int cmpdl_weyl_elim(n,d1,d2) |
|
int n; |
|
DL d1,d2; |
|
{ |
|
int e1,e2,i; |
|
|
|
for ( i = 1, e1 = 0, e2 = 0; i <= dp_nelim; i++ ) { |
|
e1 += d1->d[n-i]; e2 += d2->d[n-i]; |
|
} |
|
if ( e1 > e2 ) |
|
return 1; |
|
else if ( e1 < e2 ) |
|
return -1; |
|
else if ( d1->td > d2->td ) |
|
return 1; |
|
else if ( d1->td < d2->td ) |
|
return -1; |
|
else return -cmpdl_revlex(n,d1,d2); |
|
} |
|
|
|
/* |
|
a special ordering |
|
1. total order |
|
2. (-w,w) for the first 2*m variables |
|
3. DRL for the first 2*m variables |
|
*/ |
|
|
|
extern int *current_weight_vector; |
|
|
|
int cmpdl_homo_ww_drl(n,d1,d2) |
|
int n; |
|
DL d1,d2; |
|
{ |
|
int e1,e2,m,i; |
|
int *p1,*p2; |
|
|
|
if ( d1->td > d2->td ) |
|
return 1; |
|
else if ( d1->td < d2->td ) |
|
return -1; |
|
|
|
m = n>>1; |
|
for ( i = 0, e1 = e2 = 0; i < m; i++ ) { |
|
e1 += current_weight_vector[i]*(d1->d[m+i] - d1->d[i]); |
|
e2 += current_weight_vector[i]*(d2->d[m+i] - d2->d[i]); |
|
} |
|
if ( e1 > e2 ) |
|
return 1; |
|
else if ( e1 < e2 ) |
|
return -1; |
|
|
|
e1 = d1->td - d1->d[n-1]; |
|
e2 = d2->td - d2->d[n-1]; |
|
if ( e1 > e2 ) |
|
return 1; |
|
else if ( e1 < e2 ) |
|
return -1; |
|
|
|
for ( i= n - 1, p1 = d1->d+n-1, p2 = d2->d+n-1; |
|
i >= 0 && *p1 == *p2; i--, p1--, p2-- ); |
|
return i < 0 ? 0 : (*p1 < *p2 ? 1 : -1); |
} |
} |
|
|
int cmpdl_order_pair(n,d1,d2) |
int cmpdl_order_pair(n,d1,d2) |