diff options
Diffstat (limited to 'boost/math/special_functions/gamma.hpp')
-rw-r--r-- | boost/math/special_functions/gamma.hpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/boost/math/special_functions/gamma.hpp b/boost/math/special_functions/gamma.hpp index 4161a88395..1903b997cb 100644 --- a/boost/math/special_functions/gamma.hpp +++ b/boost/math/special_functions/gamma.hpp @@ -391,8 +391,8 @@ T gamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&) // Check if the argument of tgamma is identically zero. const bool is_at_zero = (z == 0); - if(is_at_zero) - return policies::raise_domain_error<T>(function, "Evaluation of tgamma at zero %1%.", z, pol); + if((is_at_zero) || ((boost::math::isinf)(z) && (z < 0))) + return policies::raise_domain_error<T>(function, "Evaluation of tgamma at %1%.", z, pol); const bool b_neg = (z < 0); @@ -538,6 +538,10 @@ T lgamma_imp(T z, const Policy& pol, const lanczos::undefined_lanczos&, int* sig if(is_at_zero) return policies::raise_domain_error<T>(function, "Evaluation of lgamma at zero %1%.", z, pol); + if((boost::math::isnan)(z)) + return policies::raise_domain_error<T>(function, "Evaluation of lgamma at %1%.", z, pol); + if((boost::math::isinf)(z)) + return policies::raise_overflow_error<T>(function, 0, pol); const bool b_neg = (z < 0); |