Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67469 - in trunk/boost/math: distributions special_functions special_functions/detail
From: john_at_[hidden]
Date: 2010-12-27 13:37:16


Author: johnmaddock
Date: 2010-12-27 13:37:15 EST (Mon, 27 Dec 2010)
New Revision: 67469
URL: http://svn.boost.org/trac/boost/changeset/67469

Log:
Fix bug in special-case handling of ibeta_inv.
Fix concept test failures with mpfr_class in legendre.hpp and non_central_t.hpp.
Fixes #5015.
Text files modified:
   trunk/boost/math/distributions/non_central_t.hpp | 2 +-
   trunk/boost/math/special_functions/detail/ibeta_inverse.hpp | 37 ++++++++++++++++++++-----------------
   trunk/boost/math/special_functions/legendre.hpp | 2 +-
   3 files changed, 22 insertions(+), 19 deletions(-)

Modified: trunk/boost/math/distributions/non_central_t.hpp
==============================================================================
--- trunk/boost/math/distributions/non_central_t.hpp (original)
+++ trunk/boost/math/distributions/non_central_t.hpp 2010-12-27 13:37:15 EST (Mon, 27 Dec 2010)
@@ -66,7 +66,7 @@
             if(k == 0)
             {
                beta = -boost::math::powm1(y, n / 2, pol);
- xterm = beta > 0.5f ? pow(y, n / 2) : 1 - beta;
+ xterm = beta > 0.5f ? T(pow(y, n / 2)) : T(1 - beta);
             }
             else
             {

Modified: trunk/boost/math/special_functions/detail/ibeta_inverse.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/ibeta_inverse.hpp (original)
+++ trunk/boost/math/special_functions/detail/ibeta_inverse.hpp 2010-12-27 13:37:15 EST (Mon, 27 Dec 2010)
@@ -455,6 +455,24 @@
    BOOST_MATH_STD_USING // For ADL of math functions.
 
    //
+ // Handle trivial cases first:
+ //
+ if(q == 0)
+ {
+ if(py) *py = 0;
+ return 1;
+ }
+ else if(p == 0)
+ {
+ if(py) *py = 1;
+ return 0;
+ }
+ else if((a == 1) && (b == 1))
+ {
+ if(py) *py = 1 - p;
+ return p;
+ }
+ //
    // The flag invert is set to true if we swap a for b and p for q,
    // in which case the result has to be subtracted from 1:
    //
@@ -484,24 +502,9 @@
       invert = !invert;
    }
    //
- // Handle trivial cases first:
+ // Select calculation method for the initial estimate:
    //
- if(q == 0)
- {
- if(py) *py = 0;
- return 1;
- }
- else if(p == 0)
- {
- if(py) *py = 1;
- return 0;
- }
- else if((a == 1) && (b == 1))
- {
- if(py) *py = 1 - p;
- return p;
- }
- else if((b == 0.5f) && (a >= 0.5f))
+ if((b == 0.5f) && (a >= 0.5f))
    {
       //
       // We have a Student's T distribution:

Modified: trunk/boost/math/special_functions/legendre.hpp
==============================================================================
--- trunk/boost/math/special_functions/legendre.hpp (original)
+++ trunk/boost/math/special_functions/legendre.hpp 2010-12-27 13:37:15 EST (Mon, 27 Dec 2010)
@@ -164,7 +164,7 @@
 {
    BOOST_MATH_STD_USING
    // TODO: we really could use that mythical "pow1p" function here:
- return legendre_p_imp(l, m, x, pow(1 - x*x, T(abs(m))/2), pol);
+ return legendre_p_imp(l, m, x, static_cast<T>(pow(1 - x*x, T(abs(m))/2)), pol);
 }
 
 }


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