static ex exp_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(exp(x))
+ if (is_exactly_a<numeric>(x))
+ return exp(ex_to<numeric>(x));
- return exp(ex_to<numeric>(x)); // -> numeric exp(numeric)
+ return exp(x).hold();
}
static ex exp_eval(const ex & x)
// exp(float)
if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
- return exp_evalf(x);
+ return exp(ex_to<numeric>(x));
return exp(x).hold();
}
static ex log_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(log(x))
+ if (is_exactly_a<numeric>(x))
+ return log(ex_to<numeric>(x));
- return log(ex_to<numeric>(x)); // -> numeric log(numeric)
+ return log(x).hold();
}
static ex log_eval(const ex & x)
return (Pi*I*_num_1_2());
// log(float)
if (!x.info(info_flags::crational))
- return log_evalf(x);
+ return log(ex_to<numeric>(x));
}
// log(exp(t)) -> t (if -Pi < t.imag() <= Pi):
if (is_ex_the_function(x, exp)) {
static ex sin_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(sin(x))
+ if (is_exactly_a<numeric>(x))
+ return sin(ex_to<numeric>(x));
- return sin(ex_to<numeric>(x)); // -> numeric sin(numeric)
+ return sin(x).hold();
}
static ex sin_eval(const ex & x)
return sign*_ex1();
}
- if (is_ex_exactly_of_type(x, function)) {
+ if (is_exactly_a<function>(x)) {
ex t = x.op(0);
// sin(asin(x)) -> x
if (is_ex_the_function(x, asin))
// sin(float) -> float
if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
- return sin_evalf(x);
+ return sin(ex_to<numeric>(x));
return sin(x).hold();
}
static ex cos_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(cos(x))
+ if (is_exactly_a<numeric>(x))
+ return cos(ex_to<numeric>(x));
- return cos(ex_to<numeric>(x)); // -> numeric cos(numeric)
+ return cos(x).hold();
}
static ex cos_eval(const ex & x)
return sign*_ex0();
}
- if (is_ex_exactly_of_type(x, function)) {
+ if (is_exactly_a<function>(x)) {
ex t = x.op(0);
// cos(acos(x)) -> x
if (is_ex_the_function(x, acos))
// cos(float) -> float
if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
- return cos_evalf(x);
+ return cos(ex_to<numeric>(x));
return cos(x).hold();
}
static ex tan_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(tan(x)) // -> numeric tan(numeric)
+ if (is_exactly_a<numeric>(x))
+ return tan(ex_to<numeric>(x));
- return tan(ex_to<numeric>(x));
+ return tan(x).hold();
}
static ex tan_eval(const ex & x)
throw (pole_error("tan_eval(): simple pole",1));
}
- if (is_ex_exactly_of_type(x, function)) {
+ if (is_exactly_a<function>(x)) {
ex t = x.op(0);
// tan(atan(x)) -> x
if (is_ex_the_function(x, atan))
// tan(float) -> float
if (x.info(info_flags::numeric) && !x.info(info_flags::crational)) {
- return tan_evalf(x);
+ return tan(ex_to<numeric>(x));
}
return tan(x).hold();
static ex asin_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(asin(x))
+ if (is_exactly_a<numeric>(x))
+ return asin(ex_to<numeric>(x));
- return asin(ex_to<numeric>(x)); // -> numeric asin(numeric)
+ return asin(x).hold();
}
static ex asin_eval(const ex & x)
return _num_1_2()*Pi;
// asin(float) -> float
if (!x.info(info_flags::crational))
- return asin_evalf(x);
+ return asin(ex_to<numeric>(x));
}
return asin(x).hold();
static ex acos_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(acos(x))
+ if (is_exactly_a<numeric>(x))
+ return acos(ex_to<numeric>(x));
- return acos(ex_to<numeric>(x)); // -> numeric acos(numeric)
+ return acos(x).hold();
}
static ex acos_eval(const ex & x)
return Pi;
// acos(float) -> float
if (!x.info(info_flags::crational))
- return acos_evalf(x);
+ return acos(ex_to<numeric>(x));
}
return acos(x).hold();
static ex atan_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(atan(x))
+ if (is_exactly_a<numeric>(x))
+ return atan(ex_to<numeric>(x));
- return atan(ex_to<numeric>(x)); // -> numeric atan(numeric)
+ return atan(x).hold();
}
static ex atan_eval(const ex & x)
throw (pole_error("atan_eval(): logarithmic pole",0));
// atan(float) -> float
if (!x.info(info_flags::crational))
- return atan_evalf(x);
+ return atan(ex_to<numeric>(x));
}
return atan(x).hold();
// inverse tangent (atan2(y,x))
//////////
-static ex atan2_evalf(const ex & y, const ex & x)
+static ex atan2_evalf(const ex &y, const ex &x)
{
- BEGIN_TYPECHECK
- TYPECHECK(y,numeric)
- TYPECHECK(x,numeric)
- END_TYPECHECK(atan2(y,x))
+ if (is_exactly_a<numeric>(y) && is_exactly_a<numeric>(x))
+ return atan2(ex_to<numeric>(y), ex_to<numeric>(x));
- return atan(ex_to<numeric>(y),ex_to<numeric>(x)); // -> numeric atan(numeric)
+ return atan2(y, x).hold();
}
static ex atan2_eval(const ex & y, const ex & x)
static ex sinh_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(sinh(x))
+ if (is_exactly_a<numeric>(x))
+ return sinh(ex_to<numeric>(x));
- return sinh(ex_to<numeric>(x)); // -> numeric sinh(numeric)
+ return sinh(x).hold();
}
static ex sinh_eval(const ex & x)
if (x.is_zero()) // sinh(0) -> 0
return _ex0();
if (!x.info(info_flags::crational)) // sinh(float) -> float
- return sinh_evalf(x);
+ return sinh(ex_to<numeric>(x));
}
if ((x/Pi).info(info_flags::numeric) &&
ex_to<numeric>(x/Pi).real().is_zero()) // sinh(I*x) -> I*sin(x)
return I*sin(x/I);
- if (is_ex_exactly_of_type(x, function)) {
+ if (is_exactly_a<function>(x)) {
ex t = x.op(0);
// sinh(asinh(x)) -> x
if (is_ex_the_function(x, asinh))
static ex cosh_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(cosh(x))
+ if (is_exactly_a<numeric>(x))
+ return cosh(ex_to<numeric>(x));
- return cosh(ex_to<numeric>(x)); // -> numeric cosh(numeric)
+ return cosh(x).hold();
}
static ex cosh_eval(const ex & x)
if (x.is_zero()) // cosh(0) -> 1
return _ex1();
if (!x.info(info_flags::crational)) // cosh(float) -> float
- return cosh_evalf(x);
+ return cosh(ex_to<numeric>(x));
}
if ((x/Pi).info(info_flags::numeric) &&
ex_to<numeric>(x/Pi).real().is_zero()) // cosh(I*x) -> cos(x)
return cos(x/I);
- if (is_ex_exactly_of_type(x, function)) {
+ if (is_exactly_a<function>(x)) {
ex t = x.op(0);
// cosh(acosh(x)) -> x
if (is_ex_the_function(x, acosh))
static ex tanh_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(tanh(x))
+ if (is_exactly_a<numeric>(x))
+ return tanh(ex_to<numeric>(x));
- return tanh(ex_to<numeric>(x)); // -> numeric tanh(numeric)
+ return tanh(x).hold();
}
static ex tanh_eval(const ex & x)
if (x.is_zero()) // tanh(0) -> 0
return _ex0();
if (!x.info(info_flags::crational)) // tanh(float) -> float
- return tanh_evalf(x);
+ return tanh(ex_to<numeric>(x));
}
if ((x/Pi).info(info_flags::numeric) &&
ex_to<numeric>(x/Pi).real().is_zero()) // tanh(I*x) -> I*tan(x);
return I*tan(x/I);
- if (is_ex_exactly_of_type(x, function)) {
+ if (is_exactly_a<function>(x)) {
ex t = x.op(0);
// tanh(atanh(x)) -> x
if (is_ex_the_function(x, atanh))
static ex asinh_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(asinh(x))
+ if (is_exactly_a<numeric>(x))
+ return asinh(ex_to<numeric>(x));
- return asinh(ex_to<numeric>(x)); // -> numeric asinh(numeric)
+ return asinh(x).hold();
}
static ex asinh_eval(const ex & x)
return _ex0();
// asinh(float) -> float
if (!x.info(info_flags::crational))
- return asinh_evalf(x);
+ return asinh(ex_to<numeric>(x));
}
return asinh(x).hold();
static ex acosh_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(acosh(x))
+ if (is_exactly_a<numeric>(x))
+ return acosh(ex_to<numeric>(x));
- return acosh(ex_to<numeric>(x)); // -> numeric acosh(numeric)
+ return acosh(x).hold();
}
static ex acosh_eval(const ex & x)
return Pi*I;
// acosh(float) -> float
if (!x.info(info_flags::crational))
- return acosh_evalf(x);
+ return acosh(ex_to<numeric>(x));
}
return acosh(x).hold();
static ex atanh_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(atanh(x))
+ if (is_exactly_a<numeric>(x))
+ return atanh(ex_to<numeric>(x));
- return atanh(ex_to<numeric>(x)); // -> numeric atanh(numeric)
+ return atanh(x).hold();
}
static ex atanh_eval(const ex & x)
throw (pole_error("atanh_eval(): logarithmic pole",0));
// atanh(float) -> float
if (!x.info(info_flags::crational))
- return atanh_evalf(x);
+ return atanh(ex_to<numeric>(x));
}
return atanh(x).hold();