version 1.21, 2015/08/06 10:01:52 |
version 1.24, 2018/03/28 05:27:22 |
|
|
* 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/builtin/pf.c,v 1.20 2015/08/04 06:20:44 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/pf.c,v 1.23 2018/03/27 06:29:19 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "math.h" |
#include "math.h" |
|
|
#include <alloca.h> |
#include <alloca.h> |
#endif |
#endif |
|
|
double const_pi(),const_e(); |
double const_pi(),const_e(), double_factorial(); |
|
|
void make_ihyp(void); |
void make_ihyp(void); |
void make_hyp(void); |
void make_hyp(void); |
Line 94 int mp_pi(),mp_e(); |
|
Line 94 int mp_pi(),mp_e(); |
|
int mp_exp(), mp_log(), mp_pow(); |
int mp_exp(), mp_log(), mp_pow(); |
int mp_sin(),mp_cos(),mp_tan(),mp_asin(),mp_acos(),mp_atan(); |
int mp_sin(),mp_cos(),mp_tan(),mp_asin(),mp_acos(),mp_atan(); |
int mp_sinh(),mp_cosh(),mp_tanh(),mp_asinh(),mp_acosh(),mp_atanh(); |
int mp_sinh(),mp_cosh(),mp_tanh(),mp_asinh(),mp_acosh(),mp_atanh(); |
|
int mp_factorial(),mp_abs(); |
|
|
|
|
static V *uarg,*darg; |
static V *uarg,*darg; |
static P x,y; |
static P x,y; |
static PF pidef,edef; |
static PF pidef,edef; |
Line 104 static PF sindef,cosdef,tandef; |
|
Line 104 static PF sindef,cosdef,tandef; |
|
static PF asindef,acosdef,atandef; |
static PF asindef,acosdef,atandef; |
static PF sinhdef,coshdef,tanhdef; |
static PF sinhdef,coshdef,tanhdef; |
static PF asinhdef,acoshdef,atanhdef; |
static PF asinhdef,acoshdef,atanhdef; |
|
static PF factorialdef,absdef; |
|
|
#define OALLOC(p,n) ((p)=(Obj *)CALLOC((n),sizeof(Obj))) |
#define OALLOC(p,n) ((p)=(Obj *)CALLOC((n),sizeof(Obj))) |
|
|
double const_pi() { return 3.14159265358979323846264338327950288; } |
double const_pi() { return 3.14159265358979323846264338327950288; } |
double const_e() { return 2.718281828459045235360287471352662497; } |
double const_e() { return 2.718281828459045235360287471352662497; } |
|
|
|
double double_factorial(double x) |
|
{ |
|
return tgamma(x+1); |
|
} |
|
|
int simplify_elemfunc_ins(); |
int simplify_elemfunc_ins(); |
|
int simplify_factorial_ins(); |
|
int simplify_abs_ins(); |
|
|
void pf_init() { |
void pf_init() { |
uarg = (V *)CALLOC(1,sizeof(V)); |
uarg = (V *)CALLOC(1,sizeof(V)); |
Line 120 void pf_init() { |
|
Line 128 void pf_init() { |
|
darg[0] = &oVAR[26]; |
darg[0] = &oVAR[26]; |
darg[1] = &oVAR[27]; MKV(darg[1],y); |
darg[1] = &oVAR[27]; MKV(darg[1],y); |
|
|
mkpf("@pi",0,0,0,(int (*)())mp_pi,const_pi,0,&pidef); |
mkpf("@pi",0,0,0,(int (*)())mp_pi,const_pi,simplify_elemfunc_ins,&pidef); |
mkpf("@e",0,0,0,(int (*)())mp_e,const_e,0,&edef); |
mkpf("@e",0,0,0,(int (*)())mp_e,const_e,simplify_elemfunc_ins,&edef); |
|
|
|
mkpf("factorial",0,1,uarg,(int (*)())mp_factorial,double_factorial,simplify_factorial_ins,&factorialdef); |
|
mkpf("abs",0,1,uarg,(int (*)())mp_abs,fabs,simplify_abs_ins,&absdef); |
|
|
mkpf("log",0,1,uarg,(int (*)())mp_log,log,simplify_elemfunc_ins,&logdef); |
mkpf("log",0,1,uarg,(int (*)())mp_log,log,simplify_elemfunc_ins,&logdef); |
mkpf("exp",0,1,uarg,(int (*)())mp_exp,exp,simplify_elemfunc_ins,&expdef); |
mkpf("exp",0,1,uarg,(int (*)())mp_exp,exp,simplify_elemfunc_ins,&expdef); |
mkpf("pow",0,2,darg,(int (*)())mp_pow,pow,(int (*)())simplify_pow,&powdef); |
mkpf("pow",0,2,darg,(int (*)())mp_pow,pow,(int (*)())simplify_pow,&powdef); |
Line 137 void pf_init() { |
|
Line 148 void pf_init() { |
|
mkpf("sinh",0,1,uarg,(int (*)())mp_sinh,sinh,simplify_elemfunc_ins,&sinhdef); |
mkpf("sinh",0,1,uarg,(int (*)())mp_sinh,sinh,simplify_elemfunc_ins,&sinhdef); |
mkpf("cosh",0,1,uarg,(int (*)())mp_cosh,cosh,simplify_elemfunc_ins,&coshdef); |
mkpf("cosh",0,1,uarg,(int (*)())mp_cosh,cosh,simplify_elemfunc_ins,&coshdef); |
mkpf("tanh",0,1,uarg,(int (*)())mp_tanh,tanh,simplify_elemfunc_ins,&tanhdef); |
mkpf("tanh",0,1,uarg,(int (*)())mp_tanh,tanh,simplify_elemfunc_ins,&tanhdef); |
#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
mkpf("asinh",0,1,uarg,(int (*)())mp_asinh,asinh,simplify_elemfunc_ins,&asinhdef); |
mkpf("asinh",0,1,uarg,(int (*)())mp_asinh,asinh,simplify_elemfunc_ins,&asinhdef); |
mkpf("acosh",0,1,uarg,(int (*)())mp_acosh,acosh,simplify_elemfunc_ins,&acoshdef); |
mkpf("acosh",0,1,uarg,(int (*)())mp_acosh,acosh,simplify_elemfunc_ins,&acoshdef); |
mkpf("atanh",0,1,uarg,(int (*)())mp_atanh,atanh,simplify_elemfunc_ins,&atanhdef); |
mkpf("atanh",0,1,uarg,(int (*)())mp_atanh,atanh,simplify_elemfunc_ins,&atanhdef); |
Line 146 void pf_init() { |
|
Line 157 void pf_init() { |
|
make_tri(); |
make_tri(); |
make_itri(); |
make_itri(); |
make_hyp(); |
make_hyp(); |
#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
make_ihyp(); |
make_ihyp(); |
#endif |
#endif |
} |
} |
|
|
simplify_ins(ins,r); |
simplify_ins(ins,r); |
} |
} |
|
|
|
extern int evalef; |
|
|
void simplify_pow(ins,rp) |
void simplify_pow(ins,rp) |
PFINS ins; |
PFINS ins; |
Obj *rp; |
Obj *rp; |
|
|
V v; |
V v; |
P t; |
P t; |
|
|
|
if ( evalef ) { |
|
simplify_elemfunc_ins(ins,rp); |
|
return; |
|
} |
pf = ins->pf; ad = ins->ad; a0 = ad[0].arg; a1 = ad[1].arg; |
pf = ins->pf; ad = ins->ad; a0 = ad[0].arg; a1 = ad[1].arg; |
if ( !a1 ) |
if ( !a1 ) |
*rp = (Obj)ONE; |
*rp = (Obj)ONE; |
|
|
else if ( RATN(a1) && SGN((Q)a1) < 0 ) |
else if ( RATN(a1) && SGN((Q)a1) < 0 ) |
error("simplify_pow : division by 0"); |
error("simplify_pow : division by 0"); |
else { |
else { |
instov(ins,&v); MKV(v,t); *rp = (Obj)t; |
instoobj(ins,rp); |
} |
} |
} else if ( NUM(a1) && INT(a1) ) |
} else if ( NUM(a1) && INT(a1) ) |
arf_pwr(CO,a0,a1,rp); |
arf_pwr(CO,a0,a1,rp); |
else { |
else { |
instov(ins,&v); MKV(v,t); *rp = (Obj)t; |
instoobj(ins,rp); |
} |
} |
} |
} |
|
|