summaryrefslogtreecommitdiff
path: root/boost/math/tools
diff options
context:
space:
mode:
Diffstat (limited to 'boost/math/tools')
-rw-r--r--boost/math/tools/big_constant.hpp40
-rw-r--r--boost/math/tools/config.hpp4
-rw-r--r--boost/math/tools/precision.hpp10
3 files changed, 43 insertions, 11 deletions
diff --git a/boost/math/tools/big_constant.hpp b/boost/math/tools/big_constant.hpp
index 423cc1b..3895638 100644
--- a/boost/math/tools/big_constant.hpp
+++ b/boost/math/tools/big_constant.hpp
@@ -12,31 +12,49 @@
#include <boost/lexical_cast.hpp>
#endif
#include <boost/type_traits/is_convertible.hpp>
-#include <boost/math/cstdfloat/cstdfloat_types.hpp>
namespace boost{ namespace math{
namespace tools{
template <class T>
-inline BOOST_CONSTEXPR_OR_CONST T make_big_value(boost::floatmax_t v, const char*, mpl::true_ const&, mpl::false_ const&)
+struct numeric_traits : public std::numeric_limits< T > {};
+
+#ifdef BOOST_MATH_USE_FLOAT128
+typedef __float128 largest_float;
+#define BOOST_MATH_LARGEST_FLOAT_C(x) x##Q
+template <>
+struct numeric_traits<__float128>
+{
+ static const int digits = 113;
+ static const int digits10 = 34;
+ static const int max_exponent = 16384;
+ static const bool is_specialized = true;
+};
+#else
+typedef long double largest_float;
+#define BOOST_MATH_LARGEST_FLOAT_C(x) x##L
+#endif
+
+template <class T>
+inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, mpl::true_ const&, mpl::false_ const&)
{
return static_cast<T>(v);
}
template <class T>
-inline BOOST_CONSTEXPR_OR_CONST T make_big_value(boost::floatmax_t v, const char*, mpl::true_ const&, mpl::true_ const&)
+inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, mpl::true_ const&, mpl::true_ const&)
{
return static_cast<T>(v);
}
#ifndef BOOST_MATH_NO_LEXICAL_CAST
template <class T>
-inline T make_big_value(boost::floatmax_t, const char* s, mpl::false_ const&, mpl::false_ const&)
+inline T make_big_value(largest_float, const char* s, mpl::false_ const&, mpl::false_ const&)
{
return boost::lexical_cast<T>(s);
}
#endif
template <class T>
-inline BOOST_CONSTEXPR const char* make_big_value(boost::floatmax_t, const char* s, mpl::false_ const&, mpl::true_ const&)
+inline BOOST_CONSTEXPR const char* make_big_value(largest_float, const char* s, mpl::false_ const&, mpl::true_ const&)
{
return s;
}
@@ -46,20 +64,20 @@ inline BOOST_CONSTEXPR const char* make_big_value(boost::floatmax_t, const char*
//
#define BOOST_MATH_BIG_CONSTANT(T, D, x)\
boost::math::tools::make_big_value<T>(\
- BOOST_FLOATMAX_C(x), \
+ BOOST_MATH_LARGEST_FLOAT_C(x), \
BOOST_STRINGIZE(x), \
- mpl::bool_< (is_convertible<boost::floatmax_t, T>::value) && \
- ((D <= std::numeric_limits<boost::floatmax_t>::digits) \
+ mpl::bool_< (is_convertible<boost::math::tools::largest_float, T>::value) && \
+ ((D <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::digits) \
|| is_floating_point<T>::value \
- || (std::numeric_limits<T>::is_specialized && \
- (std::numeric_limits<T>::digits10 <= std::numeric_limits<boost::floatmax_t>::digits10))) >(), \
+ || (boost::math::tools::numeric_traits<T>::is_specialized && \
+ (boost::math::tools::numeric_traits<T>::digits10 <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::digits10))) >(), \
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):
//
#define BOOST_MATH_HUGE_CONSTANT(T, D, x)\
boost::math::tools::make_big_value<T>(0.0L, BOOST_STRINGIZE(x), \
- mpl::bool_<is_floating_point<T>::value || (std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::max_exponent <= std::numeric_limits<long double>::max_exponent && std::numeric_limits<T>::digits <= std::numeric_limits<long double>::digits)>(), \
+ mpl::bool_<is_floating_point<T>::value || (boost::math::tools::numeric_traits<T>::is_specialized && boost::math::tools::numeric_traits<T>::max_exponent <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::max_exponent && boost::math::tools::numeric_traits<T>::digits <= boost::math::tools::numeric_traits<boost::math::tools::largest_float>::digits)>(), \
boost::is_convertible<const char*, T>())
}}} // namespaces
diff --git a/boost/math/tools/config.hpp b/boost/math/tools/config.hpp
index 4ec5768..23cba0c 100644
--- a/boost/math/tools/config.hpp
+++ b/boost/math/tools/config.hpp
@@ -50,6 +50,10 @@
// are disabled for now. (JM 2012).
# define BOOST_MATH_NO_REAL_CONCEPT_TESTS
#endif
+#ifdef sun
+// Any use of __float128 in program startup code causes a segfault (tested JM 2015, Solaris 11).
+# define BOOST_MATH_DISABLE_FLOAT128
+#endif
#if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
//
// Darwin's rather strange "double double" is rather hard to
diff --git a/boost/math/tools/precision.hpp b/boost/math/tools/precision.hpp
index 49e653d..ed146c4 100644
--- a/boost/math/tools/precision.hpp
+++ b/boost/math/tools/precision.hpp
@@ -134,7 +134,12 @@ inline T log_max_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_T
BOOST_ASSERT(::std::numeric_limits<T>::is_specialized);
#endif
BOOST_MATH_STD_USING
+#ifdef __SUNPRO_CC
+ static const T m = (std::numeric_limits<T>::max)();
+ static const T val = log(m);
+#else
static const T val = log((std::numeric_limits<T>::max)());
+#endif
return val;
}
@@ -147,7 +152,12 @@ inline T log_min_value(const mpl::int_<0>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_T
BOOST_ASSERT(::std::numeric_limits<T>::is_specialized);
#endif
BOOST_MATH_STD_USING
+#ifdef __SUNPRO_CC
+ static const T m = (std::numeric_limits<T>::min)();
+ static const T val = log(m);
+#else
static const T val = log((std::numeric_limits<T>::min)());
+#endif
return val;
}