Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78042 - trunk/boost/math/tools
From: john_at_[hidden]
Date: 2012-04-17 12:05:54


Author: johnmaddock
Date: 2012-04-17 12:05:52 EDT (Tue, 17 Apr 2012)
New Revision: 78042
URL: http://svn.boost.org/trac/boost/changeset/78042

Log:
Update test_data.hpp to improve definition of SC_ so it's compatible with multiprecision testing.
Update BOOST_MATH_BIG_CONSTANT to use a long double when the result is long double or smaller.
Text files modified:
   trunk/boost/math/tools/big_constant.hpp | 12 ++++++++----
   trunk/boost/math/tools/test_data.hpp | 4 ++--
   2 files changed, 10 insertions(+), 6 deletions(-)

Modified: trunk/boost/math/tools/big_constant.hpp
==============================================================================
--- trunk/boost/math/tools/big_constant.hpp (original)
+++ trunk/boost/math/tools/big_constant.hpp 2012-04-17 12:05:52 EDT (Tue, 17 Apr 2012)
@@ -14,12 +14,12 @@
 namespace boost{ namespace math{ namespace tools{
 
 template <class T>
-inline T make_big_value(long double v, const char*, mpl::true_ const&, mpl::false_ const&)
+inline BOOST_CONSTEXPR_OR_CONST T make_big_value(long double v, const char*, mpl::true_ const&, mpl::false_ const&)
 {
    return static_cast<T>(v);
 }
 template <class T>
-inline T make_big_value(long double v, const char*, mpl::true_ const&, mpl::true_ const&)
+inline BOOST_CONSTEXPR_OR_CONST T make_big_value(long double v, const char*, mpl::true_ const&, mpl::true_ const&)
 {
    return static_cast<T>(v);
 }
@@ -29,7 +29,7 @@
    return boost::lexical_cast<T>(s);
 }
 template <class T>
-inline const char* make_big_value(long double, const char* s, mpl::false_ const&, mpl::true_ const&)
+inline BOOST_CONSTEXPR_OR_CONST char* make_big_value(long double, const char* s, mpl::false_ const&, mpl::true_ const&)
 {
    return s;
 }
@@ -38,7 +38,11 @@
 // For constants which might fit in a long double (if it's big enough):
 //
 #define BOOST_MATH_BIG_CONSTANT(T, D, x)\
- boost::math::tools::make_big_value<T>(BOOST_JOIN(x, L), BOOST_STRINGIZE(x), mpl::bool_<D <= std::numeric_limits<long double>::digits>(), boost::is_convertible<const char*, T>())
+ boost::math::tools::make_big_value<T>(\
+ BOOST_JOIN(x, L), \
+ BOOST_STRINGIZE(x), \
+ mpl::bool_< (D <= std::numeric_limits<long double>::digits) || (std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::digits <= std::numeric_limits<long double>::digits)) >(), \
+ boost::is_convertible<const char*, T>())
 //
 // For constants too huge for any conceivable long double (and which generate compiler errors if we try and declare them as such):
 //

Modified: trunk/boost/math/tools/test_data.hpp
==============================================================================
--- trunk/boost/math/tools/test_data.hpp (original)
+++ trunk/boost/math/tools/test_data.hpp 2012-04-17 12:05:52 EDT (Tue, 17 Apr 2012)
@@ -726,7 +726,7 @@
    if(a == b)
       return os;
 
- os << "#define SC_(x) static_cast<T>(BOOST_JOIN(x, L))\n"
+ os << "#ifndef SC_\n# define SC_(x) static_cast<T>(BOOST_JOIN(x, L))\n#endif\n"
    " static const boost::array<boost::array<T, "
    << a->size() << ">, " << data.size() << "> " << name << " = {{\n";
 
@@ -749,7 +749,7 @@
       os << " }";
       ++a;
    }
- os << "\n }};\n#undef SC_\n\n";
+ os << "\n }};\n//#undef SC_\n\n";
    return os;
 }
 


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