Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2008-03-08 12:47:07


Author: pbristow
Date: 2008-03-08 12:47:07 EST (Sat, 08 Mar 2008)
New Revision: 43545
URL: http://svn.boost.org/trac/boost/changeset/43545

Log:
Changed logic of error as suggested by johneddy101_at_[hidden]
Text files modified:
   sandbox/math_toolkit/boost/math/distributions/uniform.hpp | 16 ++++++++++------
   1 files changed, 10 insertions(+), 6 deletions(-)

Modified: sandbox/math_toolkit/boost/math/distributions/uniform.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/distributions/uniform.hpp (original)
+++ sandbox/math_toolkit/boost/math/distributions/uniform.hpp 2008-03-08 12:47:07 EST (Sat, 08 Mar 2008)
@@ -89,19 +89,22 @@
       RealType upper,
       RealType* result, const Policy& pol)
     {
- if(check_uniform_lower(function, lower, result, pol)
- && check_uniform_upper(function, upper, result, pol)
- && (lower < upper)) // If lower == upper then 1 / (upper-lower) = 1/0 = +infinity!
+ if((check_uniform_lower(function, lower, result, pol) == false)
+ || (check_uniform_upper(function, upper, result, pol) = false))
       {
- return true;
+ return false;
       }
- else
+ else if (lower >= upper) // If lower == upper then 1 / (upper-lower) = 1/0 = +infinity!
       { // upper and lower have been checked before, so must be lower >= upper.
         *result = policies::raise_domain_error<RealType>(
           function,
           "lower parameter is %1%, but must be less than upper!", lower, pol);
         return false;
       }
+ else
+ { // All OK,
+ return true;
+ }
     } // bool check_uniform(
 
   } // namespace detail
@@ -141,7 +144,8 @@
   inline const std::pair<RealType, RealType> range(const uniform_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 + infinity
+ return std::pair<RealType, RealType>(-max_value<RealType>(), max_value<RealType>()); // - to + 'infinity'.
+ // Note RealType infinity is NOT permitted, only 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