Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78768 - trunk/boost/math/distributions
From: pbristow_at_[hidden]
Date: 2012-05-30 12:35:59


Author: pbristow
Date: 2012-05-30 12:35:59 EDT (Wed, 30 May 2012)
New Revision: 78768
URL: http://svn.boost.org/trac/boost/changeset/78768

Log:
Changed range to infinity if supported.
Text files modified:
   trunk/boost/math/distributions/normal.hpp | 19 ++++++++++++++++---
   1 files changed, 16 insertions(+), 3 deletions(-)

Modified: trunk/boost/math/distributions/normal.hpp
==============================================================================
--- trunk/boost/math/distributions/normal.hpp (original)
+++ trunk/boost/math/distributions/normal.hpp 2012-05-30 12:35:59 EDT (Wed, 30 May 2012)
@@ -74,17 +74,30 @@
 template <class RealType, class Policy>
 inline const std::pair<RealType, RealType> range(const normal_distribution<RealType, Policy>& /*dist*/)
 { // Range of permissible values for random variable x.
- using boost::math::tools::max_value;
- return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + max value.
+ 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 + max value.
+ }
 }
 
 template <class RealType, class Policy>
 inline const std::pair<RealType, RealType> support(const normal_distribution<RealType, Policy>& /*dist*/)
 { // 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.
-
+ 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 + max value.
+ }
 }
 
 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