From 7ef962fc6b349eee6bad26ce70cdb68ceb2e9a76 Mon Sep 17 00:00:00 2001 From: "Paul A. Bristow" Date: Wed, 30 May 2012 16:31:18 +0000 Subject: [PATCH] Changed range to include infinity if supported. [SVN r78766] --- include/boost/math/distributions/cauchy.hpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/include/boost/math/distributions/cauchy.hpp b/include/boost/math/distributions/cauchy.hpp index 0c93febaa..0e8c1deed 100644 --- a/include/boost/math/distributions/cauchy.hpp +++ b/include/boost/math/distributions/cauchy.hpp @@ -180,15 +180,30 @@ typedef cauchy_distribution cauchy; template inline const std::pair range(const cauchy_distribution&) { // Range of permissible values for random variable x. + if (std::numeric_limits::has_infinity) + { + return std::pair(-std::numeric_limits::infinity(), std::numeric_limits::infinity()); // - to + infinity. + } + else + { // Can only use max_value. using boost::math::tools::max_value; - return std::pair(-max_value(), max_value()); // - to + infinity. + return std::pair(-max_value(), max_value()); // - to + max. + } } template inline const std::pair support(const cauchy_distribution& ) { // Range of supported values for random variable x. // This is range where cdf rises from 0 to 1, and outside it, the pdf is zero. - return std::pair(-tools::max_value(), tools::max_value()); // - to + infinity. + if (std::numeric_limits::has_infinity) + { + return std::pair(-std::numeric_limits::infinity(), std::numeric_limits::infinity()); // - to + infinity. + } + else + { // Can only use max_value. + using boost::math::tools::max_value; + return std::pair(-tools::max_value(), max_value()); // - to + max. + } } template