Boost logo

Boost-Commit :

From: pbristow_at_[hidden]
Date: 2007-09-17 06:05:27


Author: pbristow
Date: 2007-09-17 06:05:26 EDT (Mon, 17 Sep 2007)
New Revision: 39345
URL: http://svn.boost.org/trac/boost/changeset/39345

Log:
changed to use
if((boost::math::isinf)(x))
{
  if(x < 0) return 0;
  return 1;
}
 to get rid of 4127 warnings
Text files modified:
   sandbox/math_toolkit/boost/math/distributions/normal.hpp | 61 ++++++++++++++++++++++-----------------
   1 files changed, 34 insertions(+), 27 deletions(-)

Modified: sandbox/math_toolkit/boost/math/distributions/normal.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/distributions/normal.hpp (original)
+++ sandbox/math_toolkit/boost/math/distributions/normal.hpp 2007-09-17 06:05:26 EDT (Mon, 17 Sep 2007)
@@ -22,11 +22,6 @@
 
 #include <utility>
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4127) // conditional expression is constant
-#endif
-
 namespace boost{ namespace math{
 
 template <class RealType = double, class Policy = policies::policy<> >
@@ -101,11 +96,15 @@
    RealType mean = dist.mean();
 
    static const char* function = "boost::math::pdf(const normal_distribution<%1%>&, %1%)";
-
- if(std::numeric_limits<RealType>::has_infinity && abs(x) == std::numeric_limits<RealType>::infinity())
- { // pdf + and - infinity is zero.
- return 0;
+ if((boost::math::isinf)(x))
+ {
+ return 0; // pdf + and - infinity is zero.
    }
+ // Theis 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;
    if(false == detail::check_scale(function, sd, &result, Policy()))
@@ -148,14 +147,20 @@
    {
       return result;
    }
- if(std::numeric_limits<RealType>::has_infinity && x == std::numeric_limits<RealType>::infinity())
- { // cdf +infinity is unity.
- return 1;
- }
- if(std::numeric_limits<RealType>::has_infinity && x == -std::numeric_limits<RealType>::infinity())
- { // cdf -infinity is zero.
- return 0;
+ if((boost::math::isinf)(x))
+ {
+ if(x < 0) return 0; // -infinity
+ return 1; // + infinity
    }
+ // These produce MSVC 4127 warnings, so the above used instead.
+ //if(std::numeric_limits<RealType>::has_infinity && x == std::numeric_limits<RealType>::infinity())
+ //{ // cdf +infinity is unity.
+ // return 1;
+ //}
+ //if(std::numeric_limits<RealType>::has_infinity && x == -std::numeric_limits<RealType>::infinity())
+ //{ // cdf -infinity is zero.
+ // return 0;
+ //}
    if(false == detail::check_x(function, x, &result, Policy()))
    {
      return result;
@@ -199,14 +204,20 @@
    RealType x = c.param;
    static const char* function = "boost::math::cdf(const complement(normal_distribution<%1%>&), %1%)";
 
- if(std::numeric_limits<RealType>::has_infinity && x == std::numeric_limits<RealType>::infinity())
- { // cdf complement +infinity is zero.
- return 0;
- }
- if(std::numeric_limits<RealType>::has_infinity && x == -std::numeric_limits<RealType>::infinity())
- { // cdf complement -infinity is unity.
- return 1;
+ if((boost::math::isinf)(x))
+ {
+ if(x < 0) return 1; // cdf complement -infinity is unity.
+ return 0; // cdf complement +infinity is zero
    }
+ // These produce MSVC 4127 warnings, so the above used instead.
+ //if(std::numeric_limits<RealType>::has_infinity && x == std::numeric_limits<RealType>::infinity())
+ //{ // cdf complement +infinity is zero.
+ // return 0;
+ //}
+ //if(std::numeric_limits<RealType>::has_infinity && x == -std::numeric_limits<RealType>::infinity())
+ //{ // cdf complement -infinity is unity.
+ // return 1;
+ //}
    RealType result;
    if(false == detail::check_scale(function, sd, &result, Policy()))
       return result;
@@ -287,10 +298,6 @@
 } // namespace math
 } // namespace boost
 
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
 // This include must be at the end, *after* the accessors
 // for this distribution have been defined, in order to
 // keep compilers that support two-phase lookup happy.


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