version 1.1, 1999/12/03 07:39:12 |
version 1.6, 2004/03/11 09:52:56 |
|
|
/* $OpenXM: OpenXM/src/asir99/parse/puref.c,v 1.1.1.1 1999/11/10 08:12:34 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/parse/puref.c,v 1.5 2003/05/20 06:15:01 noro Exp $ |
|
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
NODE pflist; |
NODE pflist; |
|
|
void searchpf(name,fp) |
void searchpf(char *name,FUNC *fp) |
char *name; |
|
FUNC *fp; |
|
{ |
{ |
NODE node; |
NODE node; |
PF pf; |
PF pf; |
|
|
pf = (PF)node->body; |
pf = (PF)node->body; |
*fp = t = (FUNC)MALLOC(sizeof(struct oFUNC)); |
*fp = t = (FUNC)MALLOC(sizeof(struct oFUNC)); |
t->name = name; t->id = A_PURE; t->argc = pf->argc; |
t->name = name; t->id = A_PURE; t->argc = pf->argc; |
t->f.puref = pf; |
t->f.puref = pf; t->fullname = name; |
return; |
return; |
} |
} |
*fp = 0; |
*fp = 0; |
} |
} |
|
|
void searchc(name,fp) |
void searchc(char *name,FUNC *fp) |
char *name; |
|
FUNC *fp; |
|
{ |
{ |
NODE node; |
NODE node; |
PF pf; |
PF pf; |
|
|
pf = (PF)node->body; |
pf = (PF)node->body; |
*fp = t = (FUNC)MALLOC(sizeof(struct oFUNC)); |
*fp = t = (FUNC)MALLOC(sizeof(struct oFUNC)); |
t->name = name; t->id = A_PURE; t->argc = pf->argc; |
t->name = name; t->id = A_PURE; t->argc = pf->argc; |
t->f.puref = pf; |
t->f.puref = pf; t->fullname = name; |
return; |
return; |
} |
} |
*fp = 0; |
*fp = 0; |
} |
} |
|
|
void mkpf(name,body,argc,args,parif,libmf,simp,pfp) |
void mkpf(char *name,Obj body,int argc,V *args, |
char *name; |
int (*parif)(),double (*libmf)(), int (*simp)(),PF *pfp) |
Obj body; |
|
int argc; |
|
V *args; |
|
int (*parif)(),(*simp)(); |
|
double (*libmf)(); |
|
PF *pfp; |
|
{ |
{ |
PF pf; |
PF pf; |
NODE node; |
NODE node; |
|
|
each arg. |
each arg. |
*/ |
*/ |
|
|
void mkpfins(pf,args,vp) |
void mkpfins(PF pf,V *args,V *vp) |
PF pf; |
|
V *args; |
|
V *vp; |
|
{ |
{ |
V v; |
V v; |
PFINS ins; |
PFINS ins; |
|
|
|
|
/* the same as above. Argements are given as an array of Obj */ |
/* the same as above. Argements are given as an array of Obj */ |
|
|
void _mkpfins(pf,args,vp) |
void _mkpfins(PF pf,Obj *args,V *vp) |
PF pf; |
|
Obj *args; |
|
V *vp; |
|
{ |
{ |
V v; |
V v; |
PFINS ins; |
PFINS ins; |
|
|
|
|
/* the same as above. darray is also given */ |
/* the same as above. darray is also given */ |
|
|
void _mkpfins_with_darray(pf,args,darray,vp) |
void _mkpfins_with_darray(PF pf,Obj *args,int *darray,V *vp) |
PF pf; |
|
Obj *args; |
|
int *darray; |
|
V *vp; |
|
{ |
{ |
V v; |
V v; |
PFINS ins; |
PFINS ins; |
|
|
appendpfins(v,vp); |
appendpfins(v,vp); |
} |
} |
|
|
void appendpfins(v,vp) |
void appendpfins(V v,V *vp) |
V v; |
|
V *vp; |
|
{ |
{ |
PF fdef; |
PF fdef; |
PFAD ad,tad; |
PFAD ad,tad; |
|
|
for ( node = fdef->ins; node; node = NEXT(node) ) { |
for ( node = fdef->ins; node; node = NEXT(node) ) { |
for ( i = 0, tad = ((PFINS)((V)node->body)->priv)->ad; |
for ( i = 0, tad = ((PFINS)((V)node->body)->priv)->ad; |
i < fdef->argc; i++ ) |
i < fdef->argc; i++ ) |
if ( (ad[i].d != tad[i].d) || compr(CO,ad[i].arg,tad[i].arg) ) |
if ( (ad[i].d != tad[i].d) || !equalr(CO,ad[i].arg,tad[i].arg) ) |
break; |
break; |
if ( i == fdef->argc ) { |
if ( i == fdef->argc ) { |
*vp = (V)node->body; |
*vp = (V)node->body; |
|
|
fdef->ins = node; appendvar(CO,v); *vp = v; |
fdef->ins = node; appendvar(CO,v); *vp = v; |
} |
} |
|
|
void duppfins(v,vp) |
void duppfins(V v,V *vp) |
V v; |
|
V *vp; |
|
{ |
{ |
V tv; |
V tv; |
PFINS tins; |
PFINS tins; |
|
|
*vp = tv; |
*vp = tv; |
} |
} |
|
|
void derivvar(vl,pf,v,a) |
void derivvar(VL vl,V pf,V v,Obj *a) |
VL vl; |
|
V pf,v; |
|
Obj *a; |
|
{ |
{ |
Obj t,s,u,w,u1; |
Obj t,s,u,w,u1; |
P p; |
P p; |
|
|
} |
} |
} |
} |
|
|
void derivr(vl,a,v,b) |
void derivr(VL vl,Obj a,V v,Obj *b) |
VL vl; |
|
V v; |
|
Obj a,*b; |
|
{ |
{ |
VL tvl,svl; |
VL tvl,svl; |
Obj r,s,t,u,nm,dn,dnm,ddn,m; |
Obj r,s,t,u,nm,dn,dnm,ddn,m; |
|
|
} |
} |
} |
} |
|
|
void substr(vl,partial,a,v,b,c) |
void substr(VL vl,int partial,Obj a,V v,Obj b,Obj *c) |
VL vl; |
|
int partial; |
|
Obj a; |
|
V v; |
|
Obj b; |
|
Obj *c; |
|
{ |
{ |
Obj nm,dn,t; |
Obj nm,dn,t; |
|
|
|
|
} |
} |
} |
} |
|
|
void substpr(vl,partial,p,v0,p0,pr) |
void substpr(VL vl,int partial,Obj p,V v0,Obj p0,Obj *pr) |
VL vl; |
|
int partial; |
|
V v0; |
|
Obj p; |
|
Obj p0; |
|
Obj *pr; |
|
{ |
{ |
P x; |
P x; |
Obj t,m,c,s,a; |
Obj t,m,c,s,a; |
|
|
} |
} |
} |
} |
|
|
void evalr(vl,a,prec,c) |
void evalr(VL vl,Obj a,int prec,Obj *c) |
VL vl; |
|
Obj a; |
|
int prec; |
|
Obj *c; |
|
{ |
{ |
Obj nm,dn; |
Obj nm,dn; |
|
|
|
|
} |
} |
} |
} |
|
|
void evalp(vl,p,prec,pr) |
void evalp(VL vl,P p,int prec,P *pr) |
VL vl; |
|
P p; |
|
int prec; |
|
P *pr; |
|
{ |
{ |
P t; |
P t; |
DCP dc,dcr0,dcr; |
DCP dc,dcr0,dcr; |
|
|
} |
} |
} |
} |
|
|
void evalv(vl,v,prec,rp) |
void evalv(VL vl,V v,int prec,Obj *rp) |
VL vl; |
|
V v; |
|
int prec; |
|
Obj *rp; |
|
{ |
{ |
PFINS ins,tins; |
PFINS ins,tins; |
PFAD ad,tad; |
PFAD ad,tad; |
|
|
} |
} |
} |
} |
|
|
void evalins(ins,prec,rp) |
void evalins(PFINS ins,int prec,Obj *rp) |
PFINS ins; |
|
int prec; |
|
Obj *rp; |
|
{ |
{ |
PF pf; |
PF pf; |
PFAD ad; |
PFAD ad; |
|
|
} |
} |
} |
} |
|
|
void devalins(PFINS,Obj *); |
void devalr(VL vl,Obj a,Obj *c) |
void devalv(VL,V,Obj *); |
|
void devalp(VL,P,P *); |
|
void devalr(VL,Obj,Obj *); |
|
|
|
void devalr(vl,a,c) |
|
VL vl; |
|
Obj a; |
|
Obj *c; |
|
{ |
{ |
Obj nm,dn; |
Obj nm,dn; |
double d; |
double d; |
|
|
} |
} |
} |
} |
|
|
void devalp(vl,p,pr) |
void devalp(VL vl,P p,P *pr) |
VL vl; |
|
P p; |
|
P *pr; |
|
{ |
{ |
P t; |
P t; |
DCP dc,dcr0,dcr; |
DCP dc,dcr0,dcr; |
|
|
} |
} |
} |
} |
|
|
void devalv(vl,v,rp) |
void devalv(VL vl,V v,Obj *rp) |
VL vl; |
|
V v; |
|
Obj *rp; |
|
{ |
{ |
PFINS ins,tins; |
PFINS ins,tins; |
PFAD ad,tad; |
PFAD ad,tad; |
PF pf; |
PF pf; |
P t; |
P t; |
Obj s; |
|
int i; |
int i; |
|
|
if ( (vid)v->attr != V_PF ) { |
if ( (vid)v->attr != V_PF ) { |
|
|
} |
} |
} |
} |
|
|
void devalins(ins,rp) |
void devalins(PFINS ins,Obj *rp) |
PFINS ins; |
|
Obj *rp; |
|
{ |
{ |
PF pf; |
PF pf; |
PFAD ad; |
PFAD ad; |
int i; |
int i; |
Real r; |
Real r; |
double d; |
double d; |
Q q; |
|
V v; |
V v; |
P x; |
P x; |
|
|
|
|
} |
} |
} |
} |
|
|
void simplify_ins(ins,rp) |
void simplify_ins(PFINS ins,Obj *rp) |
PFINS ins; |
|
Obj *rp; |
|
{ |
{ |
V v; |
V v; |
P t; |
P t; |
|
|
} |
} |
} |
} |
|
|
void instov(ins,vp) |
void instov(PFINS ins,V *vp) |
PFINS ins; |
|
V *vp; |
|
{ |
{ |
V v; |
V v; |
|
|
|
|
appendpfins(v,vp); |
appendpfins(v,vp); |
} |
} |
|
|
void substfr(vl,a,u,f,c) |
void substfr(VL vl,Obj a,PF u,PF f,Obj *c) |
VL vl; |
|
Obj a; |
|
PF u,f; |
|
Obj *c; |
|
{ |
{ |
Obj nm,dn; |
Obj nm,dn; |
|
|
|
|
} |
} |
} |
} |
|
|
void substfp(vl,p,u,f,pr) |
void substfp(VL vl,Obj p,PF u,PF f,Obj *pr) |
VL vl; |
|
Obj p; |
|
PF u,f; |
|
Obj *pr; |
|
{ |
{ |
V v; |
V v; |
DCP dc; |
DCP dc; |
|
|
} |
} |
} |
} |
|
|
void substfv(vl,v,u,f,c) |
void substfv(VL vl,V v,PF u,PF f,Obj *c) |
VL vl; |
|
V v; |
|
PF u,f; |
|
Obj *c; |
|
{ |
{ |
P t; |
P t; |
Obj r,s,w; |
Obj r,s,w; |