summaryrefslogtreecommitdiff
path: root/boost/math/special_functions/detail/unchecked_factorial.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/math/special_functions/detail/unchecked_factorial.hpp')
-rw-r--r--boost/math/special_functions/detail/unchecked_factorial.hpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/boost/math/special_functions/detail/unchecked_factorial.hpp b/boost/math/special_functions/detail/unchecked_factorial.hpp
index ca9a752291..17366742c4 100644
--- a/boost/math/special_functions/detail/unchecked_factorial.hpp
+++ b/boost/math/special_functions/detail/unchecked_factorial.hpp
@@ -10,7 +10,6 @@
#pragma once
#endif
-#include <boost/array.hpp>
#ifdef BOOST_MSVC
#pragma warning(push) // Temporary until lexical cast fixed.
#pragma warning(disable: 4127 4701)
@@ -21,9 +20,15 @@
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
-#include <boost/config/no_tr1/cmath.hpp>
+#include <cmath>
#include <boost/math/special_functions/math_fwd.hpp>
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+#include <array>
+#else
+#include <boost/array.hpp>
+#endif
+
namespace boost { namespace math
{
// Forward declarations:
@@ -32,9 +37,13 @@ struct max_factorial;
// Definitions:
template <>
-inline float unchecked_factorial<float>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(float))
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION float unchecked_factorial<float>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(float))
{
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<float, 35> factorials = { {
+#else
static const boost::array<float, 35> factorials = {{
+#endif
1.0F,
1.0F,
2.0F,
@@ -83,9 +92,13 @@ struct max_factorial<float>
template <>
-inline long double unchecked_factorial<long double>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(long double))
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION long double unchecked_factorial<long double>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(long double))
{
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<long double, 171> factorials = { {
+#else
static const boost::array<long double, 171> factorials = {{
+#endif
1L,
1L,
2L,
@@ -271,9 +284,13 @@ struct max_factorial<long double>
#ifdef BOOST_MATH_USE_FLOAT128
template <>
-inline BOOST_MATH_FLOAT128_TYPE unchecked_factorial<BOOST_MATH_FLOAT128_TYPE>(unsigned i)
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION BOOST_MATH_FLOAT128_TYPE unchecked_factorial<BOOST_MATH_FLOAT128_TYPE>(unsigned i)
{
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<BOOST_MATH_FLOAT128_TYPE, 171> factorials = { {
+#else
static const boost::array<BOOST_MATH_FLOAT128_TYPE, 171> factorials = { {
+#endif
1,
1,
2,
@@ -459,7 +476,7 @@ struct max_factorial<BOOST_MATH_FLOAT128_TYPE>
#endif
template <>
-inline double unchecked_factorial<double>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(double))
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION double unchecked_factorial<double>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(double))
{
return static_cast<double>(boost::math::unchecked_factorial<long double>(i));
}