Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62087 - in trunk: boost/math/special_functions libs/math/test
From: john_at_[hidden]
Date: 2010-05-18 13:24:02


Author: johnmaddock
Date: 2010-05-18 13:24:01 EDT (Tue, 18 May 2010)
New Revision: 62087
URL: http://svn.boost.org/trac/boost/changeset/62087

Log:
Fix cbrt's internal promotion rules.
Update tests to match.
Text files modified:
   trunk/boost/math/special_functions/cbrt.hpp | 3 +
   trunk/libs/math/test/test_cbrt.cpp | 43 +++++++++++++++++++++++++--------------
   2 files changed, 29 insertions(+), 17 deletions(-)

Modified: trunk/boost/math/special_functions/cbrt.hpp
==============================================================================
--- trunk/boost/math/special_functions/cbrt.hpp (original)
+++ trunk/boost/math/special_functions/cbrt.hpp 2010-05-18 13:24:01 EDT (Tue, 18 May 2010)
@@ -158,7 +158,8 @@
 inline typename tools::promote_args<T>::type cbrt(T z, const Policy& pol)
 {
    typedef typename tools::promote_args<T>::type result_type;
- return detail::cbrt_imp(result_type(z), pol);
+ typedef typename policies::evaluation<result_type, Policy>::type value_type;
+ return static_cast<result_type>(detail::cbrt_imp(value_type(z), pol));
 }
 
 template <class T>

Modified: trunk/libs/math/test/test_cbrt.cpp
==============================================================================
--- trunk/libs/math/test/test_cbrt.cpp (original)
+++ trunk/libs/math/test/test_cbrt.cpp 2010-05-18 13:24:01 EDT (Tue, 18 May 2010)
@@ -43,28 +43,39 @@
    // Define the max and mean errors expected for
    // various compilers and platforms.
    //
-
- //
- // Finish off by printing out the compiler/stdlib/platform names,
- // we do this to make it easier to mark up expected error rates.
- //
- std::cout << "Tests run with " << BOOST_COMPILER << ", "
- << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
-
+ const char* largest_type;
+#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
+ if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
+ {
+ largest_type = "(long\\s+)?double|real_concept";
+ }
+ else
+ {
+ largest_type = "long double|real_concept";
+ }
+#else
+ largest_type = "(long\\s+)?double|real_concept";
+#endif
    add_expected_result(
- "Borland.*", // compiler
- ".*", // stdlib
- ".*", // platform
+ "Borland.*", // compiler
+ ".*", // stdlib
+ ".*", // platform
       "long double", // test type(s)
- ".*", // test data group
- ".*", 10, 6); // test function
+ ".*", // test data group
+ ".*", 10, 6); // test function
    add_expected_result(
       ".*", // compiler
       ".*", // stdlib
       ".*", // platform
- "(long )?double|real_concept", // test type(s)
- ".*", // test data group
- ".*", 2, 2); // test function
+ largest_type, // test type(s)
+ ".*", // test data group
+ ".*", 2, 2); // test function
+ //
+ // Finish off by printing out the compiler/stdlib/platform names,
+ // we do this to make it easier to mark up expected error rates.
+ //
+ std::cout << "Tests run with " << BOOST_COMPILER << ", "
+ << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
 }
 
 struct negative_cbrt


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