=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/P.c,v retrieving revision 1.2 retrieving revision 1.8 diff -u -p -r1.2 -r1.8 --- OpenXM_contrib2/asir2000/engine/P.c 2000/08/21 08:31:25 1.2 +++ OpenXM_contrib2/asir2000/engine/P.c 2003/12/23 10:39:57 1.8 @@ -23,7 +23,7 @@ * 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@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 * SOFTWARE. * @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/engine/P.c,v 1.1.1.1 1999/12/03 07:39:08 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/engine/P.c,v 1.7 2003/06/24 09:49:36 noro Exp $ */ #ifndef FBASE #define FBASE @@ -335,7 +335,7 @@ P p,*pr; if ( !p ) *pr = NULL; else if ( NUM(p) ) { -#if defined(THINK_C) || defined(_PA_RISC1_1) || defined(__alpha) || defined(mips) +#if defined(_PA_RISC1_1) || defined(__alpha) || defined(mips) || defined(_IBMR2) #ifdef FBASE chsgnnum((Num)p,(Num *)pr); #else @@ -460,6 +460,50 @@ P *r; } } +/* Euler derivation */ +void ediffp(vl,p,v,r) +VL vl; +P p; +V v; +P *r; +{ + P t; + DCP dc,dcr,dcr0; + + if ( !p || NUM(p) ) + *r = 0; + else { + if ( v == VR(p) ) { + for ( dc = DC(p), dcr0 = 0; + dc && DEG(dc); dc = NEXT(dc) ) { + MULPQ(COEF(dc),(P)DEG(dc),&t); + if ( t ) { + NEXTDC(dcr0,dcr); + DEG(dcr) = DEG(dc); + COEF(dcr) = t; + } + } + if ( !dcr0 ) + *r = 0; + else { + NEXT(dcr) = 0; MKP(v,dcr0,*r); + } + } else { + for ( dc = DC(p), dcr0 = 0; dc; dc = NEXT(dc) ) { + ediffp(vl,COEF(dc),v,&t); + if ( t ) { + NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc); COEF(dcr) = t; + } + } + if ( !dcr0 ) + *r = 0; + else { + NEXT(dcr) = 0; MKP(VR(p),dcr0,*r); + } + } + } +} + void coefp(p,d,pr) P p; int d; @@ -567,6 +611,177 @@ Q *d; m = m1; } *d = m; + } +} + +void mulpc_trunc(VL vl,P p,P c,VN vn,P *pr); +void mulpq_trunc(P p,Q q,VN vn,P *pr); +void mulp_trunc(VL vl,P p1,P p2,VN vn,P *pr); + +void mulp_trunc(VL vl,P p1,P p2,VN vn,P *pr) +{ + register DCP dc,dct,dcr,dcr0; + V v1,v2; + P t,s,u; + int n1,n2,i,d,d1; + + if ( !p1 || !p2 ) *pr = 0; + else if ( NUM(p1) ) + mulpq_trunc(p2,(Q)p1,vn,pr); + else if ( NUM(p2) ) + mulpq_trunc(p1,(Q)p2,vn,pr); + else if ( ( v1 = VR(p1) ) == ( v2 = VR(p2) ) ) { + for ( ; vn->v && vn->v != v1; vn++ ) + if ( vn->n ) { + /* p1,p2 do not contain vn->v */ + *pr = 0; + return; + } + if ( !vn->v ) + error("mulp_trunc : invalid vn"); + d = vn->n; + for ( dc = DC(p2), s = 0; dc; dc = NEXT(dc) ) { + for ( dcr0 = 0, dct = DC(p1); dct; dct = NEXT(dct) ) { + d1 = QTOS(DEG(dct))+QTOS(DEG(dc)); + if ( d1 >= d ) { + mulp_trunc(vl,COEF(dct),COEF(dc),vn+1,&t); + if ( t ) { + NEXTDC(dcr0,dcr); + STOQ(d1,DEG(dcr)); + COEF(dcr) = t; + } + } + } + if ( dcr0 ) { + NEXT(dcr) = 0; MKP(v1,dcr0,t); + addp(vl,s,t,&u); s = u; t = u = 0; + } + } + *pr = s; + } else { + while ( v1 != VR(vl) && v2 != VR(vl) ) + vl = NEXT(vl); + if ( v1 == VR(vl) ) + mulpc_trunc(vl,p1,p2,vn,pr); + else + mulpc_trunc(vl,p2,p1,vn,pr); + } +} + +void mulpq_trunc(P p,Q q,VN vn,P *pr) +{ + DCP dc,dcr,dcr0; + P t; + int i,d; + V v; + + if (!p || !q) + *pr = 0; + else if ( NUM(p) ) { + for ( ; vn->v; vn++ ) + if ( vn->n ) { + *pr = 0; + return; + } + MULNUM(p,q,pr); + } else { + v = VR(p); + for ( ; vn->v && vn->v != v; vn++ ) { + if ( vn->n ) { + /* p does not contain vn->v */ + *pr = 0; + return; + } + } + if ( !vn->v ) + error("mulpq_trunc : invalid vn"); + d = vn->n; + for ( dcr0 = 0, dc = DC(p); dc && QTOS(DEG(dc)) >= d; dc = NEXT(dc) ) { + mulpq_trunc(COEF(dc),q,vn+1,&t); + if ( t ) { + NEXTDC(dcr0,dcr); COEF(dcr) = t; DEG(dcr) = DEG(dc); + } + } + if ( dcr0 ) { + NEXT(dcr) = 0; MKP(VR(p),dcr0,*pr); + } else + *pr = 0; + } +} + +void mulpc_trunc(VL vl,P p,P c,VN vn,P *pr) +{ + DCP dc,dcr,dcr0; + P t; + V v; + int i,d; + + if ( NUM(c) ) + mulpq_trunc(p,(Q)c,vn,pr); + else { + v = VR(p); + for ( ; vn->v && vn->v != v; vn++ ) + if ( vn->n ) { + /* p,c do not contain vn->v */ + *pr = 0; + return; + } + if ( !vn->v ) + error("mulpc_trunc : invalid vn"); + d = vn->n; + for ( dcr0 = 0, dc = DC(p); dc && QTOS(DEG(dc)) >= d; dc = NEXT(dc) ) { + mulp_trunc(vl,COEF(dc),c,vn+1,&t); + if ( t ) { + NEXTDC(dcr0,dcr); COEF(dcr) = t; DEG(dcr) = DEG(dc); + } + } + if ( dcr0 ) { + NEXT(dcr) = 0; MKP(VR(p),dcr0,*pr); + } else + *pr = 0; + } +} + +void quop_trunc(VL vl,P p1,P p2,VN vn,P *pr) +{ + DCP dc,dcq0,dcq; + P t,s,m,lc2,qt; + V v1,v2; + Q d2; + VN vn1; + + if ( !p1 ) + *pr = 0; + else if ( NUM(p2) ) + divsp(vl,p1,p2,pr); + else if ( (v1 = VR(p1)) != (v2 = VR(p2)) ) { + for ( dcq0 = 0, dc = DC(p1); dc; dc = NEXT(dc) ) { + NEXTDC(dcq0,dcq); + DEG(dcq) = DEG(dc); + quop_trunc(vl,COEF(dc),p2,vn,&COEF(dcq)); + } + NEXT(dcq) = 0; + MKP(v1,dcq0,*pr); + } else { + d2 = DEG(DC(p2)); + lc2 = COEF(DC(p2)); + t = p1; + dcq0 = 0; + /* vn1 = degree list of LC(p2) */ + for ( vn1 = vn; vn1->v != v1; vn1++ ); + vn1++; + while ( t ) { + dc = DC(t); + NEXTDC(dcq0,dcq); + subq(DEG(dc),d2,&DEG(dcq)); + quop_trunc(vl,COEF(dc),lc2,vn1,&COEF(dcq)); + NEXT(dcq) = 0; + MKP(v1,dcq,qt); + mulp_trunc(vl,p2,qt,vn,&m); + subp(vl,t,m,&s); t = s; + } + NEXT(dcq) = 0; + MKP(v1,dcq0,*pr); } } #endif