Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85601 - trunk/boost/math/distributions
From: john_at_[hidden]
Date: 2013-09-08 04:46:18


Author: johnmaddock
Date: 2013-09-08 04:46:18 EDT (Sun, 08 Sep 2013)
New Revision: 85601
URL: http://svn.boost.org/trac/boost/changeset/85601

Log:
Fix order of error checks.
Fixes #9042.

Text files modified:
   trunk/boost/math/distributions/normal.hpp | 28 ++++++++++++++--------------
   1 files changed, 14 insertions(+), 14 deletions(-)

Modified: trunk/boost/math/distributions/normal.hpp
==============================================================================
--- trunk/boost/math/distributions/normal.hpp Sun Sep 8 03:47:28 2013 (r85600)
+++ trunk/boost/math/distributions/normal.hpp 2013-09-08 04:46:18 EDT (Sun, 08 Sep 2013) (r85601)
@@ -109,15 +109,6 @@
    RealType mean = dist.mean();
 
    static const char* function = "boost::math::pdf(const normal_distribution<%1%>&, %1%)";
- if((boost::math::isinf)(x))
- {
- return 0; // pdf + and - infinity is zero.
- }
- // Below produces MSVC 4127 warnings, so the above used instead.
- //if(std::numeric_limits<RealType>::has_infinity && abs(x) == std::numeric_limits<RealType>::infinity())
- //{ // pdf + and - infinity is zero.
- // return 0;
- //}
 
    RealType result = 0;
    if(false == detail::check_scale(function, sd, &result, Policy()))
@@ -128,6 +119,15 @@
    {
       return result;
    }
+ if((boost::math::isinf)(x))
+ {
+ return 0; // pdf + and - infinity is zero.
+ }
+ // Below produces MSVC 4127 warnings, so the above used instead.
+ //if(std::numeric_limits<RealType>::has_infinity && abs(x) == std::numeric_limits<RealType>::infinity())
+ //{ // pdf + and - infinity is zero.
+ // return 0;
+ //}
    if(false == detail::check_x(function, x, &result, Policy()))
    {
       return result;
@@ -217,6 +217,11 @@
    RealType x = c.param;
    static const char* function = "boost::math::cdf(const complement(normal_distribution<%1%>&), %1%)";
 
+ RealType result = 0;
+ if(false == detail::check_scale(function, sd, &result, Policy()))
+ return result;
+ if(false == detail::check_location(function, mean, &result, Policy()))
+ return result;
    if((boost::math::isinf)(x))
    {
      if(x < 0) return 1; // cdf complement -infinity is unity.
@@ -231,11 +236,6 @@
    //{ // cdf complement -infinity is unity.
    // return 1;
    //}
- RealType result = 0;
- if(false == detail::check_scale(function, sd, &result, Policy()))
- return result;
- if(false == detail::check_location(function, mean, &result, Policy()))
- return result;
    if(false == detail::check_x(function, x, &result, Policy()))
       return result;
 


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