static ex lgamma_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(lgamma(x))
+ if (is_exactly_a<numeric>(x)) {
+ try {
+ return lgamma(ex_to<numeric>(x));
+ } catch (const dunno &e) { }
+ }
- return lgamma(ex_to<numeric>(x));
+ return lgamma(x).hold();
}
static ex tgamma_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(tgamma(x))
+ if (is_exactly_a<numeric>(x)) {
+ try {
+ return tgamma(ex_to<numeric>(x));
+ } catch (const dunno &e) { }
+ }
- return tgamma(ex_to<numeric>(x));
+ return tgamma(x).hold();
}
static ex beta_evalf(const ex & x, const ex & y)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- TYPECHECK(y,numeric)
- END_TYPECHECK(beta(x,y))
+ if (is_exactly_a<numeric>(x) && is_exactly_a<numeric>(y)) {
+ try {
+ return tgamma(ex_to<numeric>(x))*tgamma(ex_to<numeric>(y))/tgamma(ex_to<numeric>(x+y));
+ } catch (const dunno &e) { }
+ }
- return tgamma(ex_to<numeric>(x))*tgamma(ex_to<numeric>(y))/tgamma(ex_to<numeric>(x+y));
+ return beta(x,y).hold();
}
}
// no problem in numerator, but denominator has pole:
if ((nx+ny).is_real() &&
- (nx+ny).is_integer() &&
- !(nx+ny).is_positive())
+ (nx+ny).is_integer() &&
+ !(nx+ny).is_positive())
return _ex0();
- // everything is ok:
- return tgamma(x)*tgamma(y)/tgamma(x+y);
+ // beta_evalf should be called here once it becomes available
}
return beta(x,y).hold();
static ex psi1_evalf(const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(x,numeric)
- END_TYPECHECK(psi(x))
+ if (is_exactly_a<numeric>(x)) {
+ try {
+ return psi(ex_to<numeric>(x));
+ } catch (const dunno &e) { }
+ }
- return psi(ex_to<numeric>(x));
+ return psi(x).hold();
}
/** Evaluation of digamma-function psi(x).
static ex psi2_evalf(const ex & n, const ex & x)
{
- BEGIN_TYPECHECK
- TYPECHECK(n,numeric)
- TYPECHECK(x,numeric)
- END_TYPECHECK(psi(n,x))
+ if (is_exactly_a<numeric>(n) && is_exactly_a<numeric>(x)) {
+ try {
+ return psi(ex_to<numeric>(n),ex_to<numeric>(x));
+ } catch (const dunno &e) { }
+ }
- return psi(ex_to<numeric>(n), ex_to<numeric>(x));
+ return psi(n,x).hold();
}
/** Evaluation of polygamma-function psi(n,x).