summaryrefslogtreecommitdiff
path: root/boost/math/special_functions
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
commitb8cf34c691623e4ec329053cbbf68522a855882d (patch)
tree34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/math/special_functions
parent3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff)
downloadboost-upstream/1.67.0.tar.gz
boost-upstream/1.67.0.tar.bz2
boost-upstream/1.67.0.zip
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/math/special_functions')
-rw-r--r--boost/math/special_functions/chebyshev_transform.hpp10
-rw-r--r--boost/math/special_functions/detail/bernoulli_details.hpp9
-rw-r--r--boost/math/special_functions/detail/fp_traits.hpp3
-rw-r--r--boost/math/special_functions/detail/unchecked_bernoulli.hpp37
-rw-r--r--boost/math/special_functions/detail/unchecked_factorial.hpp29
-rw-r--r--boost/math/special_functions/ellint_d.hpp5
-rw-r--r--boost/math/special_functions/ellint_rd.hpp5
-rw-r--r--boost/math/special_functions/lanczos.hpp2
-rw-r--r--boost/math/special_functions/math_fwd.hpp2
-rw-r--r--boost/math/special_functions/next.hpp2
-rw-r--r--boost/math/special_functions/prime.hpp25
11 files changed, 101 insertions, 28 deletions
diff --git a/boost/math/special_functions/chebyshev_transform.hpp b/boost/math/special_functions/chebyshev_transform.hpp
index d4ce106d72..e50c40bd92 100644
--- a/boost/math/special_functions/chebyshev_transform.hpp
+++ b/boost/math/special_functions/chebyshev_transform.hpp
@@ -227,16 +227,6 @@ public:
return dzdx*(z*d1 - d2 + b1);
}
- void print_coefficients() const
- {
- std::cout << "{";
- for(auto const & coeff : m_coeffs) {
- std::cout << coeff << ", ";
- }
- std::cout << "}\n";
- }
-
-
private:
std::vector<Real> m_coeffs;
Real m_a;
diff --git a/boost/math/special_functions/detail/bernoulli_details.hpp b/boost/math/special_functions/detail/bernoulli_details.hpp
index 41a59e53c6..75fadbf34a 100644
--- a/boost/math/special_functions/detail/bernoulli_details.hpp
+++ b/boost/math/special_functions/detail/bernoulli_details.hpp
@@ -192,9 +192,18 @@ struct fixed_vector : private std::allocator<T>
}
~fixed_vector()
{
+#ifdef BOOST_NO_CXX11_ALLOCATOR
for(unsigned i = 0; i < m_used; ++i)
this->destroy(&m_data[i]);
this->deallocate(m_data, m_capacity);
+#else
+ typedef std::allocator<T> allocator_type;
+ typedef std::allocator_traits<allocator_type> allocator_traits;
+ allocator_type& alloc = *this;
+ for(unsigned i = 0; i < m_used; ++i)
+ allocator_traits::destroy(alloc, &m_data[i]);
+ allocator_traits::deallocate(alloc, m_data, m_capacity);
+#endif
}
T& operator[](unsigned n) { BOOST_ASSERT(n < m_used); return m_data[n]; }
const T& operator[](unsigned n)const { BOOST_ASSERT(n < m_used); return m_data[n]; }
diff --git a/boost/math/special_functions/detail/fp_traits.hpp b/boost/math/special_functions/detail/fp_traits.hpp
index 09dc5169aa..c957022223 100644
--- a/boost/math/special_functions/detail/fp_traits.hpp
+++ b/boost/math/special_functions/detail/fp_traits.hpp
@@ -556,7 +556,8 @@ struct select_native<long double>
&& !defined(__FAST_MATH__)\
&& !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY)\
&& !defined(BOOST_INTEL)\
- && !defined(sun)
+ && !defined(sun)\
+ && !defined(__VXWORKS__)
# define BOOST_MATH_USE_STD_FPCLASSIFY
#endif
diff --git a/boost/math/special_functions/detail/unchecked_bernoulli.hpp b/boost/math/special_functions/detail/unchecked_bernoulli.hpp
index 03c376678d..5a16d9df17 100644
--- a/boost/math/special_functions/detail/unchecked_bernoulli.hpp
+++ b/boost/math/special_functions/detail/unchecked_bernoulli.hpp
@@ -19,6 +19,13 @@
#include <boost/mpl/int.hpp>
#include <boost/type_traits/is_convertible.hpp>
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+#include <array>
+#else
+#include <boost/array.hpp>
+#endif
+
+
namespace boost { namespace math {
namespace detail {
@@ -83,9 +90,13 @@ struct max_bernoulli_b2n : public detail::max_bernoulli_index<detail::bernoulli_
namespace detail{
template <class T>
-inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<0>& )
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<0>& )
{
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<boost::int64_t, 1 + max_bernoulli_b2n<T>::value> numerators =
+#else
static const boost::array<boost::int64_t, 1 + max_bernoulli_b2n<T>::value> numerators =
+#endif
{{
boost::int64_t( +1LL),
boost::int64_t( +1LL),
@@ -107,7 +118,11 @@ inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<0>& )
boost::int64_t(+2577687858367LL)
}};
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<boost::int64_t, 1 + max_bernoulli_b2n<T>::value> denominators =
+#else
static const boost::array<boost::int64_t, 1 + max_bernoulli_b2n<T>::value> denominators =
+#endif
{{
boost::int64_t( 1LL),
boost::int64_t( 6LL),
@@ -132,9 +147,13 @@ inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<0>& )
}
template <class T>
-inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<1>& )
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<1>& )
{
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<float, 1 + max_bernoulli_b2n<T>::value> bernoulli_data =
+#else
static const boost::array<float, 1 + max_bernoulli_b2n<T>::value> bernoulli_data =
+#endif
{{
+1.00000000000000000000000000000000000000000F,
+0.166666666666666666666666666666666666666667F,
@@ -176,9 +195,13 @@ inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<1>& )
template <class T>
-inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<2>& )
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<2>& )
{
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<double, 1 + max_bernoulli_b2n<T>::value> bernoulli_data =
+#else
static const boost::array<double, 1 + max_bernoulli_b2n<T>::value> bernoulli_data =
+#endif
{{
+1.00000000000000000000000000000000000000000,
+0.166666666666666666666666666666666666666667,
@@ -316,9 +339,13 @@ inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<2>& )
}
template <class T>
-inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<3>& )
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<3>& )
{
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<long double, 1 + max_bernoulli_b2n<T>::value> bernoulli_data =
+#else
static const boost::array<long double, 1 + max_bernoulli_b2n<T>::value> bernoulli_data =
+#endif
{{
+1.00000000000000000000000000000000000000000L,
+0.166666666666666666666666666666666666666667L,
@@ -688,7 +715,7 @@ inline T unchecked_bernoulli_imp(std::size_t n, const mpl::int_<4>& )
} // namespace detail
template<class T>
-inline T unchecked_bernoulli_b2n(const std::size_t n)
+inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION T unchecked_bernoulli_b2n(const std::size_t n)
{
typedef mpl::int_<detail::bernoulli_imp_variant<T>::value> tag_type;
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));
}
diff --git a/boost/math/special_functions/ellint_d.hpp b/boost/math/special_functions/ellint_d.hpp
index bc5a4b2a56..fa5c53db18 100644
--- a/boost/math/special_functions/ellint_d.hpp
+++ b/boost/math/special_functions/ellint_d.hpp
@@ -82,8 +82,12 @@ T ellint_d_imp(T phi, T k, const Policy& pol)
s = -1;
rphi = constants::half_pi<T>() - rphi;
}
+ BOOST_MATH_INSTRUMENT_VARIABLE(rphi);
+ BOOST_MATH_INSTRUMENT_VARIABLE(m);
T sinp = sin(rphi);
T cosp = cos(rphi);
+ BOOST_MATH_INSTRUMENT_VARIABLE(sinp);
+ BOOST_MATH_INSTRUMENT_VARIABLE(cosp);
T c = 1 / (sinp * sinp);
T cm1 = cosp * cosp / (sinp * sinp); // c - 1
T k2 = k * k;
@@ -99,6 +103,7 @@ T ellint_d_imp(T phi, T k, const Policy& pol)
{
// http://dlmf.nist.gov/19.25#E10
result = s * ellint_rd_imp(cm1, T(c - k2), c, pol) / 3;
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
}
if(m != 0)
result += m * ellint_d_imp(k, pol);
diff --git a/boost/math/special_functions/ellint_rd.hpp b/boost/math/special_functions/ellint_rd.hpp
index 03b73b159f..c08430d545 100644
--- a/boost/math/special_functions/ellint_rd.hpp
+++ b/boost/math/special_functions/ellint_rd.hpp
@@ -133,6 +133,7 @@ T ellint_rd_imp(T x, T y, T z, const Policy& pol)
T A0 = An;
// This has an extra 1.2 fudge factor which is really only needed when x, y and z are close in magnitude:
T Q = pow(tools::epsilon<T>() / 4, -T(1) / 8) * (std::max)((std::max)(An - x, An - y), An - z) * 1.2f;
+ BOOST_MATH_INSTRUMENT_VARIABLE(Q);
T lambda, rx, ry, rz;
unsigned k = 0;
T fn = 1;
@@ -151,6 +152,9 @@ T ellint_rd_imp(T x, T y, T z, const Policy& pol)
zn = (zn + lambda) / 4;
fn /= 4;
Q /= 4;
+ BOOST_MATH_INSTRUMENT_VARIABLE(k);
+ BOOST_MATH_INSTRUMENT_VARIABLE(RD_sum);
+ BOOST_MATH_INSTRUMENT_VARIABLE(Q);
if(Q < An)
break;
}
@@ -168,6 +172,7 @@ T ellint_rd_imp(T x, T y, T z, const Policy& pol)
T result = fn * pow(An, T(-3) / 2) *
(1 - 3 * E2 / 14 + E3 / 6 + 9 * E2 * E2 / 88 - 3 * E4 / 22 - 9 * E2 * E3 / 52 + 3 * E5 / 26 - E2 * E2 * E2 / 16
+ 3 * E3 * E3 / 40 + 3 * E2 * E4 / 20 + 45 * E2 * E2 * E3 / 272 - 9 * (E3 * E4 + E2 * E5) / 68);
+ BOOST_MATH_INSTRUMENT_VARIABLE(result);
result += 3 * RD_sum;
return result;
diff --git a/boost/math/special_functions/lanczos.hpp b/boost/math/special_functions/lanczos.hpp
index c9f4f90dcf..c1ff86930b 100644
--- a/boost/math/special_functions/lanczos.hpp
+++ b/boost/math/special_functions/lanczos.hpp
@@ -1284,7 +1284,7 @@ struct lanczos
} // namespace boost
#if !defined(_CRAYC) && !defined(__CUDACC__) && (!defined(__GNUC__) || (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 3)))
-#if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64)
+#if ((defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64)) && !defined(_MANAGED)
#include <boost/math/special_functions/detail/lanczos_sse2.hpp>
#endif
#endif
diff --git a/boost/math/special_functions/math_fwd.hpp b/boost/math/special_functions/math_fwd.hpp
index 03c55bd1a4..4f44f56113 100644
--- a/boost/math/special_functions/math_fwd.hpp
+++ b/boost/math/special_functions/math_fwd.hpp
@@ -1057,7 +1057,7 @@ namespace boost
typename tools::promote_args<T, U>::type epsilon_difference(const T&, const U&);
template<class T>
- T unchecked_bernoulli_b2n(const std::size_t n);
+ BOOST_MATH_CONSTEXPR_TABLE_FUNCTION T unchecked_bernoulli_b2n(const std::size_t n);
template <class T, class Policy>
T bernoulli_b2n(const int i, const Policy &pol);
template <class T>
diff --git a/boost/math/special_functions/next.hpp b/boost/math/special_functions/next.hpp
index 606b356542..a63983e1c3 100644
--- a/boost/math/special_functions/next.hpp
+++ b/boost/math/special_functions/next.hpp
@@ -30,7 +30,7 @@ namespace boost{ namespace math{
namespace concepts {
class real_concept;
- struct std_real_concept;
+ class std_real_concept;
}
diff --git a/boost/math/special_functions/prime.hpp b/boost/math/special_functions/prime.hpp
index 94c28f9842..858d96d10b 100644
--- a/boost/math/special_functions/prime.hpp
+++ b/boost/math/special_functions/prime.hpp
@@ -8,15 +8,19 @@
#ifndef BOOST_MATH_SF_PRIME_HPP
#define BOOST_MATH_SF_PRIME_HPP
-#include <boost/array.hpp>
#include <boost/cstdint.hpp>
#include <boost/math/policies/error_handling.hpp>
#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{
template <class Policy>
- boost::uint32_t prime(unsigned n, const Policy& pol)
+ BOOST_MATH_CONSTEXPR_TABLE_FUNCTION boost::uint32_t prime(unsigned n, const Policy& pol)
{
//
// This is basically three big tables which together
@@ -26,10 +30,17 @@ namespace boost{ namespace math{
// That gives us the first 10000 primes with the largest
// being 104729:
//
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr unsigned b1 = 53;
+ constexpr unsigned b2 = 6541;
+ constexpr unsigned b3 = 10000;
+ constexpr std::array<unsigned char, 54> a1 = {{
+#else
static const unsigned b1 = 53;
static const unsigned b2 = 6541;
static const unsigned b3 = 10000;
static const boost::array<unsigned char, 54> a1 = {{
+#endif
2u, 3u, 5u, 7u, 11u, 13u, 17u, 19u, 23u, 29u, 31u,
37u, 41u, 43u, 47u, 53u, 59u, 61u, 67u, 71u, 73u,
79u, 83u, 89u, 97u, 101u, 103u, 107u, 109u, 113u,
@@ -37,7 +48,11 @@ namespace boost{ namespace math{
167u, 173u, 179u, 181u, 191u, 193u, 197u, 199u,
211u, 223u, 227u, 229u, 233u, 239u, 241u, 251u
}};
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<boost::uint16_t, 6488> a2 = {{
+#else
static const boost::array<boost::uint16_t, 6488> a2 = {{
+#endif
257u, 263u, 269u, 271u, 277u, 281u, 283u, 293u,
307u, 311u, 313u, 317u, 331u, 337u, 347u, 349u, 353u,
359u, 367u, 373u, 379u, 383u, 389u, 397u, 401u, 409u,
@@ -760,7 +775,11 @@ namespace boost{ namespace math{
65323u, 65327u, 65353u, 65357u, 65371u, 65381u, 65393u, 65407u, 65413u,
65419u, 65423u, 65437u, 65447u, 65449u, 65479u, 65497u, 65519u, 65521u
}};
+#ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES
+ constexpr std::array<boost::uint16_t, 3458> a3 = {{
+#else
static const boost::array<boost::uint16_t, 3458> a3 = {{
+#endif
2u, 4u, 8u, 16u, 22u, 28u, 44u,
46u, 52u, 64u, 74u, 82u, 94u, 98u, 112u,
116u, 122u, 142u, 152u, 164u, 166u, 172u, 178u,
@@ -1208,7 +1227,7 @@ namespace boost{ namespace math{
return static_cast<boost::uint32_t>(a3[n - b2 - 1]) + 0xFFFFu;
}
- inline boost::uint32_t prime(unsigned n)
+ inline BOOST_MATH_CONSTEXPR_TABLE_FUNCTION boost::uint32_t prime(unsigned n)
{
return boost::math::prime(n, boost::math::policies::policy<>());
}