summaryrefslogtreecommitdiff
path: root/boost/math/special_functions/detail
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 06:24:45 (GMT)
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 06:24:45 (GMT)
commit5ce1cfc2525b06c0a9e38531813781de0281c96d (patch)
tree19cc66c6cf6396db288813b2558cc350f1deede2 /boost/math/special_functions/detail
parent3c1df2168531ad5580076ae08d529054689aeedd (diff)
downloadboost-5ce1cfc2525b06c0a9e38531813781de0281c96d.zip
boost-5ce1cfc2525b06c0a9e38531813781de0281c96d.tar.gz
boost-5ce1cfc2525b06c0a9e38531813781de0281c96d.tar.bz2
Imported Upstream version 1.71.0upstream/1.71.0upstream
Diffstat (limited to 'boost/math/special_functions/detail')
-rw-r--r--boost/math/special_functions/detail/unchecked_factorial.hpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/boost/math/special_functions/detail/unchecked_factorial.hpp b/boost/math/special_functions/detail/unchecked_factorial.hpp
index 642df7c..aa5b484 100644
--- a/boost/math/special_functions/detail/unchecked_factorial.hpp
+++ b/boost/math/special_functions/detail/unchecked_factorial.hpp
@@ -775,18 +775,58 @@ inline T unchecked_factorial_imp(unsigned i, const mpl::int_<0>&)
}
template <class T>
+inline T unchecked_factorial_imp(unsigned i, const mpl::int_<std::numeric_limits<float>::digits>&)
+{
+ return unchecked_factorial<float>(i);
+}
+
+template <class T>
+inline T unchecked_factorial_imp(unsigned i, const mpl::int_<std::numeric_limits<double>::digits>&)
+{
+ return unchecked_factorial<double>(i);
+}
+
+#if DBL_MANT_DIG != LDBL_MANT_DIG
+template <class T>
+inline T unchecked_factorial_imp(unsigned i, const mpl::int_<LDBL_MANT_DIG>&)
+{
+ return unchecked_factorial<long double>(i);
+}
+#endif
+#ifdef BOOST_MATH_USE_FLOAT128
+template <class T>
+inline T unchecked_factorial_imp(unsigned i, const mpl::int_<113>&)
+{
+ return unchecked_factorial<BOOST_MATH_FLOAT128_TYPE>(i);
+}
+#endif
+
+template <class T>
inline T unchecked_factorial(unsigned i)
{
typedef typename boost::math::policies::precision<T, boost::math::policies::policy<> >::type tag_type;
return unchecked_factorial_imp<T>(i, tag_type());
}
+#ifdef BOOST_MATH_USE_FLOAT128
+#define BOOST_MATH_DETAIL_FLOAT128_MAX_FACTORIAL : std::numeric_limits<T>::digits == 113 ? max_factorial<BOOST_MATH_FLOAT128_TYPE>::value
+#else
+#define BOOST_MATH_DETAIL_FLOAT128_MAX_FACTORIAL
+#endif
+
template <class T>
struct max_factorial
{
- BOOST_STATIC_CONSTANT(unsigned, value = 100);
+ BOOST_STATIC_CONSTANT(unsigned, value =
+ std::numeric_limits<T>::digits == std::numeric_limits<float>::digits ? max_factorial<float>::value
+ : std::numeric_limits<T>::digits == std::numeric_limits<double>::digits ? max_factorial<double>::value
+ : std::numeric_limits<T>::digits == std::numeric_limits<long double>::digits ? max_factorial<long double>::value
+ BOOST_MATH_DETAIL_FLOAT128_MAX_FACTORIAL
+ : 100);
};
+#undef BOOST_MATH_DETAIL_FLOAT128_MAX_FACTORIAL
+
#else // BOOST_MATH_NO_LEXICAL_CAST
template <class T>