|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78766 - trunk/boost/math/distributions
From: pbristow_at_[hidden]
Date: 2012-05-30 12:31:18
Author: pbristow
Date: 2012-05-30 12:31:18 EDT (Wed, 30 May 2012)
New Revision: 78766
URL: http://svn.boost.org/trac/boost/changeset/78766
Log:
Changed range to include infinity if supported.
Text files modified:
trunk/boost/math/distributions/cauchy.hpp | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
Modified: trunk/boost/math/distributions/cauchy.hpp
==============================================================================
--- trunk/boost/math/distributions/cauchy.hpp (original)
+++ trunk/boost/math/distributions/cauchy.hpp 2012-05-30 12:31:18 EDT (Wed, 30 May 2012)
@@ -180,15 +180,30 @@
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> range(const cauchy_distribution<RealType, Policy>&)
{ // Range of permissible values for random variable x.
+ if (std::numeric_limits<RealType>::has_infinity)
+ {
+ return std::pair<RealType, RealType>(-std::numeric_limits<RealType>::infinity(), std::numeric_limits<RealType>::infinity()); // - to + infinity.
+ }
+ else
+ { // Can only use max_value.
using boost::math::tools::max_value;
- return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + infinity.
+ return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max.
+ }
}
template <class RealType, class Policy>
inline const std::pair<RealType, RealType> support(const cauchy_distribution<RealType, Policy>& )
{ // 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<RealType, RealType>(-tools::max_value<RealType>(), tools::max_value<RealType>()); // - to + infinity.
+ if (std::numeric_limits<RealType>::has_infinity)
+ {
+ return std::pair<RealType, RealType>(-std::numeric_limits<RealType>::infinity(), std::numeric_limits<RealType>::infinity()); // - to + infinity.
+ }
+ else
+ { // Can only use max_value.
+ using boost::math::tools::max_value;
+ return std::pair<RealType, RealType>(-tools::max_value<RealType>(), max_value<RealType>()); // - to + max.
+ }
}
template <class RealType, class Policy>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk