Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85678 - in trunk/boost/math: special_functions tools
From: john_at_[hidden]
Date: 2013-09-15 12:56:43


Author: johnmaddock
Date: 2013-09-15 12:56:43 EDT (Sun, 15 Sep 2013)
New Revision: 85678
URL: http://svn.boost.org/trac/boost/changeset/85678

Log:
Suppress warning in fraction.hpp.
Fix internal consistency of argument reduction in elliptic integrals when the argument is very close to a multiple of PI/2.
Fixes #9107.
Fixes #9104.

Text files modified:
   trunk/boost/math/special_functions/ellint_1.hpp | 7 ++++---
   trunk/boost/math/special_functions/ellint_2.hpp | 7 ++++---
   trunk/boost/math/special_functions/ellint_3.hpp | 7 ++++---
   trunk/boost/math/tools/fraction.hpp | 2 +-
   4 files changed, 13 insertions(+), 10 deletions(-)

Modified: trunk/boost/math/special_functions/ellint_1.hpp
==============================================================================
--- trunk/boost/math/special_functions/ellint_1.hpp Sun Sep 15 12:13:47 2013 (r85677)
+++ trunk/boost/math/special_functions/ellint_1.hpp 2013-09-15 12:56:43 EDT (Sun, 15 Sep 2013) (r85678)
@@ -22,6 +22,7 @@
 #include <boost/math/constants/constants.hpp>
 #include <boost/math/policies/error_handling.hpp>
 #include <boost/math/tools/workaround.hpp>
+#include <boost/math/special_functions/round.hpp>
 
 // Elliptic integrals (complete and incomplete) of the first kind
 // Carlson, Numerische Mathematik, vol 33, 1 (1979)
@@ -88,16 +89,16 @@
        // so rewritten to use fmod instead:
        //
        BOOST_MATH_INSTRUMENT_CODE("pi/2 = " << constants::pi<T>() / 2);
- T rphi = boost::math::tools::fmod_workaround(phi, T(constants::pi<T>() / 2));
+ T rphi = boost::math::tools::fmod_workaround(phi, T(constants::half_pi<T>()));
        BOOST_MATH_INSTRUMENT_VARIABLE(rphi);
- T m = floor((2 * phi) / constants::pi<T>());
+ T m = boost::math::round((phi - rphi) / constants::half_pi<T>());
        BOOST_MATH_INSTRUMENT_VARIABLE(m);
        int s = 1;
        if(boost::math::tools::fmod_workaround(m, T(2)) > 0.5)
        {
           m += 1;
           s = -1;
- rphi = constants::pi<T>() / 2 - rphi;
+ rphi = constants::half_pi<T>() - rphi;
           BOOST_MATH_INSTRUMENT_VARIABLE(rphi);
        }
        T sinp = sin(rphi);

Modified: trunk/boost/math/special_functions/ellint_2.hpp
==============================================================================
--- trunk/boost/math/special_functions/ellint_2.hpp Sun Sep 15 12:13:47 2013 (r85677)
+++ trunk/boost/math/special_functions/ellint_2.hpp 2013-09-15 12:56:43 EDT (Sun, 15 Sep 2013) (r85678)
@@ -23,6 +23,7 @@
 #include <boost/math/constants/constants.hpp>
 #include <boost/math/policies/error_handling.hpp>
 #include <boost/math/tools/workaround.hpp>
+#include <boost/math/special_functions/round.hpp>
 
 // Elliptic integrals (complete and incomplete) of the second kind
 // Carlson, Numerische Mathematik, vol 33, 1 (1979)
@@ -74,14 +75,14 @@
        // but that fails if T has more digits than a long long,
        // so rewritten to use fmod instead:
        //
- T rphi = boost::math::tools::fmod_workaround(phi, T(constants::pi<T>() / 2));
- T m = floor((2 * phi) / constants::pi<T>());
+ T rphi = boost::math::tools::fmod_workaround(phi, T(constants::half_pi<T>()));
+ T m = boost::math::round((phi - rphi) / constants::half_pi<T>());
        int s = 1;
        if(boost::math::tools::fmod_workaround(m, T(2)) > 0.5)
        {
           m += 1;
           s = -1;
- rphi = constants::pi<T>() / 2 - rphi;
+ rphi = constants::half_pi<T>() - rphi;
        }
        T sinp = sin(rphi);
        T cosp = cos(rphi);

Modified: trunk/boost/math/special_functions/ellint_3.hpp
==============================================================================
--- trunk/boost/math/special_functions/ellint_3.hpp Sun Sep 15 12:13:47 2013 (r85677)
+++ trunk/boost/math/special_functions/ellint_3.hpp 2013-09-15 12:56:43 EDT (Sun, 15 Sep 2013) (r85678)
@@ -26,6 +26,7 @@
 #include <boost/math/constants/constants.hpp>
 #include <boost/math/policies/error_handling.hpp>
 #include <boost/math/tools/workaround.hpp>
+#include <boost/math/special_functions/round.hpp>
 
 // Elliptic integrals (complete and incomplete) of the third kind
 // Carlson, Numerische Mathematik, vol 33, 1 (1979)
@@ -182,14 +183,14 @@
     }
     else
     {
- T rphi = boost::math::tools::fmod_workaround(T(fabs(phi)), T(constants::pi<T>() / 2));
- T m = floor((2 * fabs(phi)) / constants::pi<T>());
+ T rphi = boost::math::tools::fmod_workaround(T(fabs(phi)), T(constants::half_pi<T>()));
+ T m = boost::math::round((fabs(phi) - rphi) / constants::half_pi<T>());
        int sign = 1;
        if(boost::math::tools::fmod_workaround(m, T(2)) > 0.5)
        {
           m += 1;
           sign = -1;
- rphi = constants::pi<T>() / 2 - rphi;
+ rphi = constants::half_pi<T>() - rphi;
        }
        T sinp = sin(rphi);
        T cosp = cos(rphi);

Modified: trunk/boost/math/tools/fraction.hpp
==============================================================================
--- trunk/boost/math/tools/fraction.hpp Sun Sep 15 12:13:47 2013 (r85677)
+++ trunk/boost/math/tools/fraction.hpp 2013-09-15 12:56:43 EDT (Sun, 15 Sep 2013) (r85678)
@@ -33,7 +33,7 @@
        typedef typename Gen::result_type result_type;
        typedef typename Gen::result_type value_type;
 
- static result_type a(const value_type& v)
+ static result_type a(const value_type&)
        {
           return 1;
        }


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