version 1.1, 1999/12/03 07:39:08 |
version 1.6, 2003/06/19 07:08:19 |
|
|
/* $OpenXM: OpenXM/src/asir99/engine/P.c,v 1.1.1.1 1999/11/10 08:12:26 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/P.c,v 1.5 2001/06/15 07:56:03 noro Exp $ |
|
*/ |
#ifndef FBASE |
#ifndef FBASE |
#define FBASE |
#define FBASE |
#endif |
#endif |
|
|
if ( !p ) |
if ( !p ) |
*pr = NULL; |
*pr = NULL; |
else if ( NUM(p) ) { |
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 |
#ifdef FBASE |
chsgnnum((Num)p,(Num *)pr); |
chsgnnum((Num)p,(Num *)pr); |
#else |
#else |
|
|
m = m1; |
m = m1; |
} |
} |
*d = m; |
*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; |
} |
} |
} |
} |
#endif |
#endif |