version 1.2, 2000/08/21 08:31:24 |
version 1.8, 2001/10/09 01:36:09 |
|
|
* shall be made on your publication or presentation in any form of the |
* shall be made on your publication or presentation in any form of the |
* results obtained by use of the SOFTWARE. |
* results obtained by use of the SOFTWARE. |
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
* e-mail at risa-admin@flab.fujitsu.co.jp of the detailed specification |
* 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 |
* for such modification or the source code of the modified part of the |
* SOFTWARE. |
* SOFTWARE. |
* |
* |
|
|
* 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/E.c,v 1.1.1.1 1999/12/03 07:39:07 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/E.c,v 1.7 2001/06/07 04:54:40 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
void henmv(vl,vn,f,g0,h0,a0,b0,lg,lh,lg0,lh0,q,k,gp,hp) |
void henmv(VL vl,VN vn,P f,P g0,P h0,P a0,P b0,P lg,P lh,P lg0,P lh0,Q q,int k,P *gp,P *hp) |
VL vl; |
|
VN vn; |
|
P f,g0,h0,a0,b0,lg,lh,lg0,lh0; |
|
Q q; |
|
int k; |
|
P *gp,*hp; |
|
{ |
{ |
P g1,h1,a1,b1; |
P g1,h1,a1,b1; |
N qn; |
N qn; |
|
|
henmvmain(vl,vn,f,g1,h1,b1,a1,lg,lh,q,q2,k,gp,hp); |
henmvmain(vl,vn,f,g1,h1,b1,a1,lg,lh,q,q2,k,gp,hp); |
} |
} |
|
|
void henmvmain(vl,vn,f,fi0,fi1,gi0,gi1,l0,l1,mod,mod2,k,fr0,fr1) |
void henmvmain(VL vl,VN vn,P f,P fi0,P fi1,P gi0,P gi1,P l0,P l1,Q mod,Q mod2,int k,P *fr0,P *fr1) |
VL vl; |
|
VN vn; |
|
P f,fi0,fi1,gi0,gi1,l0,l1; |
|
Q mod,mod2; |
|
int k; |
|
P *fr0,*fr1; |
|
{ |
{ |
V v; |
V v; |
int n,i,j; |
int n,i,j; |
|
|
output : gr1 * fr0 + gr0 * fr1 = 1 mod qr; ( qr = p^(2^(k-1)) ) |
output : gr1 * fr0 + gr0 * fr1 = 1 mod qr; ( qr = p^(2^(k-1)) ) |
*/ |
*/ |
|
|
void henzq(f,i0,fi0,i1,fi1,p,k,fr0p,fr1p,gr0p,gr1p,qrp) |
void henzq(P f,P i0,UM fi0,P i1,UM fi1,int p,int k,P *fr0p,P *fr1p,P *gr0p,P *gr1p,Q *qrp) |
P f; |
|
UM fi0,fi1; |
|
int p,k; |
|
P i0,i1; |
|
P *fr0p,*fr1p,*gr0p,*gr1p; |
|
Q *qrp; |
|
{ |
{ |
N qn; |
N qn; |
Q q,qq,q2; |
Q q,qq,q2; |
|
|
*fr0p = f0; *fr1p = f1; *gr0p = g0; *gr1p = g1; *qrp = q; |
*fr0p = f0; *fr1p = f1; *gr0p = g0; *gr1p = g1; *qrp = q; |
} |
} |
|
|
void henzq1(g,h,bound,gcp,hcp,qp) |
void henzq1(P g,P h,Q bound,P *gcp,P *hcp,Q *qp) |
P g,h; |
|
Q bound; |
|
P *gcp,*hcp; |
|
Q *qp; |
|
{ |
{ |
V v; |
V v; |
Q f,q,q1; |
Q f,q,q1; |
|
|
wm = W_UMALLOC(m+n); |
wm = W_UMALLOC(m+n); |
|
|
for ( q = ONE, t = 0, c = 0, index = 0; ; ) { |
for ( q = ONE, t = 0, c = 0, index = 0; ; ) { |
mod = lprime[index++]; |
mod = get_lprime(index++); |
if ( !mod ) |
|
error("henzq1 : lprime[] exhausted."); |
|
if ( !rem(NM((Q)LC(g)),mod) || !rem(NM((Q)LC(h)),mod) ) |
if ( !rem(NM((Q)LC(g)),mod) || !rem(NM((Q)LC(h)),mod) ) |
continue; |
continue; |
ptomp(mod,g,&tg); ptomp(mod,h,&th); |
ptomp(mod,g,&tg); ptomp(mod,h,&th); |
|
|
mulp(CO,gc0,(P)q,&c); gc0 = c; mulp(CO,hc0,(P)q,&c); hc0 = c; |
mulp(CO,gc0,(P)q,&c); gc0 = c; mulp(CO,hc0,(P)q,&c); hc0 = c; |
} |
} |
for ( index = 0; ; ) { |
for ( index = 0; ; ) { |
mod = lprime[index++]; |
mod = get_lprime(index++); |
if ( !mod ) |
|
error("henzq1 : lprime[] exhausted."); |
|
if ( !rem(NM((Q)zzz),mod) || |
if ( !rem(NM((Q)zzz),mod) || |
!rem(NM((Q)LC(g)),mod) || |
!rem(NM((Q)LC(g)),mod) || |
!rem(NM((Q)LC(h)),mod) ) |
!rem(NM((Q)LC(h)),mod) ) |
|
|
} |
} |
} |
} |
|
|
void addm2p(vl,mod,mod2,n1,n2,nr) |
void addm2p(VL vl,Q mod,Q mod2,P n1,P n2,P *nr) |
VL vl; |
|
Q mod,mod2; |
|
P n1,n2,*nr; |
|
{ |
{ |
P t; |
P t; |
|
|
|
|
cm2p(mod,mod2,t,nr); |
cm2p(mod,mod2,t,nr); |
} |
} |
|
|
void subm2p(vl,mod,mod2,n1,n2,nr) |
void subm2p(VL vl,Q mod,Q mod2,P n1,P n2,P *nr) |
VL vl; |
|
Q mod,mod2; |
|
P n1,n2,*nr; |
|
{ |
{ |
P t; |
P t; |
|
|
|
|
cm2p(mod,mod2,t,nr); |
cm2p(mod,mod2,t,nr); |
} |
} |
|
|
void mulm2p(vl,mod,mod2,n1,n2,nr) |
void mulm2p(VL vl,Q mod,Q mod2,P n1,P n2,P *nr) |
VL vl; |
|
Q mod,mod2; |
|
P n1,n2,*nr; |
|
{ |
{ |
P t; |
P t; |
|
|
|
|
cm2p(mod,mod2,t,nr); |
cm2p(mod,mod2,t,nr); |
} |
} |
|
|
void cmp(mod,p,pr) |
void cmp(Q mod,P p,P *pr) |
Q mod; |
|
P p,*pr; |
|
{ |
{ |
P t; |
P t; |
DCP dc,dcr,dcr0; |
DCP dc,dcr,dcr0; |
|
|
} |
} |
} |
} |
|
|
void cm2p(mod,m,p,pr) |
void cm2p(Q mod,Q m,P p,P *pr) |
Q mod,m; |
|
P p,*pr; |
|
{ |
{ |
P t; |
P t; |
DCP dc,dcr,dcr0; |
DCP dc,dcr,dcr0; |
|
|
} |
} |
} |
} |
|
|
void addm2q(mod,mod2,n1,n2,nr) |
void addm2q(Q mod,Q mod2,Q n1,Q n2,Q *nr) |
Q mod,mod2; |
|
Q n1,n2,*nr; |
|
{ |
{ |
Q t; |
Q t; |
|
|
|
|
rem2q(t,mod,mod2,nr); |
rem2q(t,mod,mod2,nr); |
} |
} |
|
|
void subm2q(mod,mod2,n1,n2,nr) |
void subm2q(Q mod,Q mod2,Q n1,Q n2,Q *nr) |
Q mod,mod2; |
|
Q n1,n2,*nr; |
|
{ |
{ |
Q t; |
Q t; |
|
|
|
|
rem2q(t,mod,mod2,nr); |
rem2q(t,mod,mod2,nr); |
} |
} |
|
|
void mulm2q(mod,mod2,n1,n2,nr) |
void mulm2q(Q mod,Q mod2,Q n1,Q n2,Q *nr) |
Q mod,mod2; |
|
Q n1,n2,*nr; |
|
{ |
{ |
Q t; |
Q t; |
|
|
|
|
rem2q(t,mod,mod2,nr); |
rem2q(t,mod,mod2,nr); |
} |
} |
|
|
void rem2q(n,m,m2,nr) |
void rem2q(Q n,Q m,Q m2,Q *nr) |
Q n,m,m2,*nr; |
|
{ |
{ |
N q,r,s; |
N q,r,s; |
int sgn; |
int sgn; |
|
|
} |
} |
} |
} |
|
|
void exthp(vl,p,d,pr) |
/* |
VL vl; |
extract d-homogeneous part with respect to vl - {v} |
P p; |
*/ |
int d; |
|
P *pr; |
void exthpc_generic(VL vl,P p,int d,V v,P *pr) |
{ |
{ |
|
P w,x,t,t1,a,xd; |
|
V v0; |
|
DCP dc; |
|
|
|
if ( d < 0 || !p ) |
|
*pr = 0; |
|
else if ( NUM(p) ) |
|
if ( d == 0 ) |
|
*pr = p; |
|
else |
|
*pr = 0; |
|
else if ( v == VR(p) ) |
|
exthpc(vl,v,p,d,pr); |
|
else { |
|
v0 = VR(p); |
|
for ( MKV(v0,x), dc = DC(p), w = 0; dc; dc = NEXT(dc) ) { |
|
exthpc_generic(vl,COEF(dc),d-QTOS(DEG(dc)),v,&t); |
|
pwrp(vl,x,DEG(dc),&xd); |
|
mulp(vl,xd,t,&t1); addp(vl,w,t1,&a); w = a; |
|
} |
|
*pr = w; |
|
} |
|
} |
|
|
|
void exthp(VL vl,P p,int d,P *pr) |
|
{ |
P t,t1,a,w,x,xd; |
P t,t1,a,w,x,xd; |
DCP dc; |
DCP dc; |
|
|
|
|
} |
} |
} |
} |
|
|
void exthpc(vl,v,p,d,pr) |
void exthpc(VL vl,V v,P p,int d,P *pr) |
VL vl; |
|
V v; |
|
P p; |
|
int d; |
|
P *pr; |
|
{ |
{ |
P t,t1,a,w,x,xd; |
P t,t1,a,w,x,xd; |
DCP dc; |
DCP dc; |
|
|
} |
} |
} |
} |
|
|
void cbound(vl,p,b) |
void cbound(VL vl,P p,Q *b) |
VL vl; |
|
P p; |
|
Q *b; |
|
{ |
{ |
Q n,e,t,m; |
Q n,e,t,m; |
int k; |
int k; |
|
|
mulq(m,n,b); |
mulq(m,n,b); |
} |
} |
|
|
int geldb(vl,p) |
int geldb(VL vl,P p) |
VL vl; |
|
P p; |
|
{ |
{ |
int m; |
int m; |
|
|
|
|
return ( m ); |
return ( m ); |
} |
} |
|
|
int getdeg(v,p) |
int getdeg(V v,P p) |
V v; |
|
P p; |
|
{ |
{ |
int m; |
int m,t; |
DCP dc; |
DCP dc; |
|
|
if ( !p || NUM(p) ) |
if ( !p || NUM(p) ) |
|
|
else if ( v == VR(p) ) |
else if ( v == VR(p) ) |
return ( deg(v,p) ); |
return ( deg(v,p) ); |
else { |
else { |
for ( dc = DC(p), m = 0; dc; dc = NEXT(dc) ) |
for ( dc = DC(p), m = 0; dc; dc = NEXT(dc) ) { |
m = MAX(m,getdeg(v,COEF(dc))); |
t = getdeg(v,COEF(dc)); |
|
m = MAX(m,t); |
|
} |
return ( m ); |
return ( m ); |
} |
} |
} |
} |
|
|
void cmax(p,b) |
void cmax(P p,Q *b) |
P p; |
|
Q *b; |
|
{ |
{ |
DCP dc; |
DCP dc; |
Q m,m1; |
Q m,m1; |
|
|
} |
} |
} |
} |
|
|
int nextbin(vn,n) |
int nextbin(VN vn,int n) |
VN vn; |
|
int n; |
|
{ |
{ |
int tmp,i,carry; |
int tmp,i,carry; |
|
|
|
|
return ( carry ); |
return ( carry ); |
} |
} |
|
|
void mulsgn(vn,vnt,n,vn1) |
void mulsgn(VN vn,VN vnt,int n,VN vn1) |
VN vn,vnt,vn1; |
|
int n; |
|
{ |
{ |
int i; |
int i; |
|
|
|
|
vn1[(int)vnt[i].v].n *= -1; |
vn1[(int)vnt[i].v].n *= -1; |
} |
} |
|
|
void next(vn) |
void next(VN vn) |
VN vn; |
|
{ |
{ |
int i,m,n,tmp,carry; |
int i,m,n,tmp,carry; |
|
|
|
|
} |
} |
} |
} |
|
|
void clctv(vl,p,nvlp) |
void clctv(VL vl,P p,VL *nvlp) |
VL vl; |
|
P p; |
|
VL *nvlp; |
|
{ |
{ |
int i,n; |
int i,n; |
VL tvl; |
VL tvl; |
|
|
vntovl(tvn,n,nvlp); |
vntovl(tvn,n,nvlp); |
} |
} |
|
|
void markv(vn,n,p) |
void markv(VN vn,int n,P p) |
VN vn; |
|
int n; |
|
P p; |
|
{ |
{ |
V v; |
V v; |
DCP dc; |
DCP dc; |
|
|
markv(vn,n,COEF(dc)); |
markv(vn,n,COEF(dc)); |
} |
} |
|
|
void vntovl(vn,n,vlp) |
void vntovl(VN vn,int n,VL *vlp) |
VN vn; |
|
int n; |
|
VL *vlp; |
|
{ |
{ |
int i; |
int i; |
VL tvl,tvl0; |
VL tvl,tvl0; |
|
|
*vlp = tvl0; |
*vlp = tvl0; |
} |
} |
|
|
int dbound(v,f) |
int dbound(V v,P f) |
V v; |
|
P f; |
|
{ |
{ |
int m; |
int m,t; |
DCP dc; |
DCP dc; |
|
|
if ( !f ) |
if ( !f ) |
|
|
else if ( v != VR(f) ) |
else if ( v != VR(f) ) |
return homdeg(f); |
return homdeg(f); |
else { |
else { |
for ( dc = DC(f), m = 0; dc; dc = NEXT(dc) ) |
for ( dc = DC(f), m = 0; dc; dc = NEXT(dc) ) { |
m = MAX(m,homdeg(COEF(dc))); |
t = homdeg(COEF(dc)); |
|
m = MAX(m,t); |
|
} |
return ( m ); |
return ( m ); |
} |
} |
} |
} |
|
|
int homdeg(f) |
int homdeg(P f) |
P f; |
|
{ |
{ |
int m; |
int m,t; |
DCP dc; |
DCP dc; |
|
|
if ( !f ) |
if ( !f ) |
|
|
else if ( NUM(f) ) |
else if ( NUM(f) ) |
return( 0 ); |
return( 0 ); |
else { |
else { |
for ( dc = DC(f), m = 0; dc; dc = NEXT(dc) ) |
for ( dc = DC(f), m = 0; dc; dc = NEXT(dc) ) { |
m = MAX(m,QTOS(DEG(dc))+homdeg(COEF(dc))); |
t = QTOS(DEG(dc))+homdeg(COEF(dc)); |
|
m = MAX(m,t); |
|
} |
return ( m ); |
return ( m ); |
} |
} |
} |
} |
|
|
int minhomdeg(f) |
int minhomdeg(P f) |
P f; |
|
{ |
{ |
int m; |
int m,t; |
DCP dc; |
DCP dc; |
|
|
if ( !f ) |
if ( !f ) |
|
|
else if ( NUM(f) ) |
else if ( NUM(f) ) |
return( 0 ); |
return( 0 ); |
else { |
else { |
for ( dc = DC(f), m = homdeg(f); dc; dc = NEXT(dc) ) |
for ( dc = DC(f), m = homdeg(f); dc; dc = NEXT(dc) ) { |
m = MIN(m,QTOS(DEG(dc))+minhomdeg(COEF(dc))); |
t = QTOS(DEG(dc))+minhomdeg(COEF(dc)); |
|
m = MIN(m,t); |
|
} |
return ( m ); |
return ( m ); |
} |
} |
} |
} |
|
|
void adjc(vl,f,a,lc0,q,fr,ar) |
void adjc(VL vl,P f,P a,P lc0,Q q,P *fr,P *ar) |
VL vl; |
|
P f,a,lc0; |
|
Q q; |
|
P *fr,*ar; |
|
{ |
{ |
P m,m1; |
P m,m1; |
Q t; |
Q t; |
|
|
} |
} |
|
|
#if 1 |
#if 1 |
void affinemain(vl,p,v0,n,pl,pr) |
void affinemain(VL vl,P p,V v0,int n,P *pl,P *pr) |
VL vl; |
|
V v0; |
|
int n; |
|
P *pl; |
|
P p; |
|
P *pr; |
|
{ |
{ |
P x,t,m,c,s,a; |
P x,t,m,c,s,a; |
DCP dc; |
DCP dc; |
|
|
#endif |
#endif |
|
|
#if 0 |
#if 0 |
affine(vl,p,vn,r) |
affine(VL vl,P p,VN vn,P *r) |
VL vl; |
|
P p; |
|
VN vn; |
|
P *r; |
|
{ |
{ |
int n,d,d1,i; |
int n,d,d1,i; |
Q *q; |
Q *q; |
|
|
} |
} |
} |
} |
|
|
afmain(vl,bc,p,vn,r) |
afmain(VL vl,Q **bc,P p,VN vn,P *r) |
VL vl; |
|
Q **bc; |
|
P p; |
|
VN vn; |
|
P *r; |
|
{ |
{ |
P t,s,u; |
P t,s,u; |
P *c,*rc; |
P *c,*rc; |
|
|
} |
} |
#endif |
#endif |
|
|
void restore(vl,f,vn,fr) |
void restore(VL vl,P f,VN vn,P *fr) |
VL vl; |
|
P f; |
|
VN vn; |
|
P *fr; |
|
{ |
{ |
int i; |
int i; |
P vv,g,g1,t; |
P vv,g,g1,t; |
|
|
*fr = g; |
*fr = g; |
} |
} |
|
|
void mergev(vl,vl1,vl2,nvlp) |
void mergev(VL vl,VL vl1,VL vl2,VL *nvlp) |
VL vl,vl1,vl2,*nvlp; |
|
{ |
{ |
int i,n; |
int i,n; |
VL tvl; |
VL tvl; |
Line 1010 VL vl,vl1,vl2,*nvlp; |
|
Line 942 VL vl,vl1,vl2,*nvlp; |
|
} |
} |
|
|
#if 0 |
#if 0 |
void substvp(vl,f,vn,g) |
void substvp(VL vl,P f,VN vn,P *g) |
VL vl; |
|
P f; |
|
VN vn; |
|
P *g; |
|
{ |
{ |
V v; |
V v; |
int i; |
int i; |
|
|
*g = h; |
*g = h; |
} |
} |
|
|
void affine(vl,f,vn,fr) |
void affine(VL vl,P f,VN vn,P *fr) |
VL vl; |
|
P f; |
|
VN vn; |
|
P *fr; |
|
{ |
{ |
int i,j,n; |
int i,j,n; |
P vv,g,g1,t,u; |
P vv,g,g1,t,u; |