$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r66767 - in sandbox/math_constants: boost/math/constants boost/math/policies libs/math/test
From: john_at_[hidden]
Date: 2010-11-26 08:00:08
Author: johnmaddock
Date: 2010-11-26 08:00:07 EST (Fri, 26 Nov 2010)
New Revision: 66767
URL: http://svn.boost.org/trac/boost/changeset/66767
Log:
Some progress - tests the namespace versions, added tentative (currently do-nothing) Policy support.
Added:
   sandbox/math_constants/boost/math/policies/
      - copied from r66753, /trunk/boost/math/policies/
Text files modified: 
   sandbox/math_constants/boost/math/constants/constants.hpp |     3 +                                       
   sandbox/math_constants/libs/math/test/test_constants.cpp  |   107 ++++++++++++++++++++++++++++++++++++++++
   2 files changed, 110 insertions(+), 0 deletions(-)
Modified: sandbox/math_constants/boost/math/constants/constants.hpp
==============================================================================
--- sandbox/math_constants/boost/math/constants/constants.hpp	(original)
+++ sandbox/math_constants/boost/math/constants/constants.hpp	2010-11-26 08:00:07 EST (Fri, 26 Nov 2010)
@@ -8,6 +8,7 @@
 #define BOOST_MATH_CONSTANTS_CONSTANTS_INCLUDED
 
 #include <boost/math/tools/config.hpp>
+#include <boost/math/policies/policy.hpp>
 #ifdef BOOST_MSVC
 #pragma warning(push)
 #pragma warning(disable: 4127 4701)
@@ -85,6 +86,8 @@
    { static const T result = BOOST_JOIN(calculate_, name)<T>(); return result; }\
    /* The actual forwarding function: */ \
    template <class T> inline T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+   { return name<T, boost::math::policies::policy<> >(); }\
+   template <class T, class Policy> inline T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(Policy))\
    { return BOOST_JOIN(get_, name)<T>(mpl::int_<construction_traits<T>::value>()); }\
    /* Now the namespace specific versions: */ \
    } namespace float_constants{ static const float name = BOOST_JOIN(BOOST_JOIN(x, BOOST_JOIN(e, exp)), F); }\
Modified: sandbox/math_constants/libs/math/test/test_constants.cpp
==============================================================================
--- sandbox/math_constants/libs/math/test/test_constants.cpp	(original)
+++ sandbox/math_constants/libs/math/test/test_constants.cpp	2010-11-26 08:00:07 EST (Fri, 26 Nov 2010)
@@ -30,6 +30,7 @@
    using std::exp;
 
    BOOST_CHECK_CLOSE_FRACTION(static_cast<RealType>(3.14159265358979323846264338327950288419716939937510L), pi<RealType>(), tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<RealType>(3.14159265358979323846264338327950288419716939937510L), (pi<RealType, boost::math::policies::policy<> >)(), tolerance); 
    BOOST_CHECK_CLOSE_FRACTION(static_cast<RealType>(sqrt(3.14159265358979323846264338327950288419716939937510L)), root_pi<RealType>(), tolerance); 
    BOOST_CHECK_CLOSE_FRACTION(static_cast<RealType>(sqrt(3.14159265358979323846264338327950288419716939937510L/2)), root_half_pi<RealType>(), tolerance); 
    BOOST_CHECK_CLOSE_FRACTION(static_cast<RealType>(sqrt(3.14159265358979323846264338327950288419716939937510L * 2)), root_two_pi<RealType>(), tolerance); 
@@ -54,10 +55,116 @@
 
 } // template <class RealType>void test_spots(RealType)
 
+void test_float_spots()
+{
+   // Basic sanity checks for constants in boost::math::float_constants::
+
+   float tolerance = boost::math::tools::epsilon<float>() * 2;
+
+   using namespace boost::math::float_constants;
+   BOOST_MATH_STD_USING
+
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(3.14159265358979323846264338327950288419716939937510L), pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(sqrt(3.14159265358979323846264338327950288419716939937510L)), root_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(sqrt(3.14159265358979323846264338327950288419716939937510L/2)), root_half_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(sqrt(3.14159265358979323846264338327950288419716939937510L * 2)), root_two_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(sqrt(log(4.0L))), root_ln_four, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(2.71828182845904523536028747135266249775724709369995L), e, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(0.5), half, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(0.57721566490153286060651209008240243104259335L), euler, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(sqrt(2.0L)), root_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(log(2.0L)), ln_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(log(log(2.0L))), ln_ln_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(1)/3, third, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(2)/3, twothirds, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(0.14159265358979323846264338327950288419716939937510L), pi_minus_three, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(4. - 3.14159265358979323846264338327950288419716939937510L), four_minus_pi, tolerance); 
+#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(pow((4 - 3.14159265358979323846264338327950288419716939937510L), 1.5L)), pow23_four_minus_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(exp(-0.5L)), exp_minus_half, tolerance); 
+#else
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(pow((4 - 3.14159265358979323846264338327950288419716939937510), 1.5)), pow23_four_minus_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<float>(exp(-0.5)), exp_minus_half, tolerance); 
+#endif
+
+} // template <class RealType>void test_spots(RealType)
+
+void test_double_spots()
+{
+   // Basic sanity checks for constants in boost::math::double_constants::
+
+   double tolerance = boost::math::tools::epsilon<double>() * 2;
+
+   using namespace boost::math::double_constants;
+   BOOST_MATH_STD_USING
+
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(3.14159265358979323846264338327950288419716939937510L), pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(sqrt(3.14159265358979323846264338327950288419716939937510L)), root_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(sqrt(3.14159265358979323846264338327950288419716939937510L/2)), root_half_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(sqrt(3.14159265358979323846264338327950288419716939937510L * 2)), root_two_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(sqrt(log(4.0L))), root_ln_four, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(2.71828182845904523536028747135266249775724709369995L), e, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(0.5), half, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(0.57721566490153286060651209008240243104259335L), euler, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(sqrt(2.0L)), root_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(log(2.0L)), ln_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(log(log(2.0L))), ln_ln_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(1)/3, third, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(2)/3, twothirds, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(0.14159265358979323846264338327950288419716939937510L), pi_minus_three, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(4. - 3.14159265358979323846264338327950288419716939937510L), four_minus_pi, tolerance); 
+#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(pow((4 - 3.14159265358979323846264338327950288419716939937510L), 1.5L)), pow23_four_minus_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(exp(-0.5L)), exp_minus_half, tolerance); 
+#else
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(pow((4 - 3.14159265358979323846264338327950288419716939937510), 1.5)), pow23_four_minus_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(exp(-0.5)), exp_minus_half, tolerance); 
+#endif
+
+} // template <class RealType>void test_spots(RealType)
+
+void test_long_double_spots()
+{
+   // Basic sanity checks for constants in boost::math::long double_constants::
+
+   long double tolerance = boost::math::tools::epsilon<long double>() * 2;
+
+   using namespace boost::math::long_double_constants;
+   BOOST_MATH_STD_USING
+
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(3.14159265358979323846264338327950288419716939937510L), pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(sqrt(3.14159265358979323846264338327950288419716939937510L)), root_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(sqrt(3.14159265358979323846264338327950288419716939937510L/2)), root_half_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(sqrt(3.14159265358979323846264338327950288419716939937510L * 2)), root_two_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(sqrt(log(4.0L))), root_ln_four, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(2.71828182845904523536028747135266249775724709369995L), e, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(0.5), half, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(0.57721566490153286060651209008240243104259335L), euler, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(sqrt(2.0L)), root_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(log(2.0L)), ln_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(log(log(2.0L))), ln_ln_two, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(1)/3, third, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(2)/3, twothirds, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(0.14159265358979323846264338327950288419716939937510L), pi_minus_three, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(4. - 3.14159265358979323846264338327950288419716939937510L), four_minus_pi, tolerance); 
+#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(pow((4 - 3.14159265358979323846264338327950288419716939937510L), 1.5L)), pow23_four_minus_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(exp(-0.5L)), exp_minus_half, tolerance); 
+#else
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(pow((4 - 3.14159265358979323846264338327950288419716939937510), 1.5)), pow23_four_minus_pi, tolerance); 
+   BOOST_CHECK_CLOSE_FRACTION(static_cast<long double>(exp(-0.5)), exp_minus_half, tolerance); 
+#endif
+
+} // template <class RealType>void test_spots(RealType)
+
 int test_main(int, char* [])
 {
    // Basic sanity-check spot values.
 
+   test_float_spots();
+   test_double_spots();
+   test_long_double_spots();
+
    // (Parameter value, arbitrarily zero, only communicates the floating point type).
    test_spots(0.0F); // Test float. OK at decdigits = 0 tolerance = 0.0001 %
    test_spots(0.0); // Test double. OK at decdigits 7, tolerance = 1e07 %