|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78193 - in trunk: boost/math/bindings boost/math/bindings/detail boost/math/concepts boost/math/constants boost/math/special_functions boost/math/special_functions/detail boost/math/tools libs/math/test
From: john_at_[hidden]
Date: 2012-04-25 13:16:12
Author: johnmaddock
Date: 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
New Revision: 78193
URL: http://svn.boost.org/trac/boost/changeset/78193
Log:
Add code to force initialization of constants prior to the start of main().
Rename "do_nothing" to "force_instantiate" which better describes what it does.
Fix up the resulting failures.
Text files modified:
trunk/boost/math/bindings/detail/big_lanczos.hpp | 11 ++++
trunk/boost/math/bindings/rr.hpp | 11 ++++
trunk/boost/math/concepts/real_concept.hpp | 7 ++
trunk/boost/math/concepts/std_real_concept.hpp | 7 ++
trunk/boost/math/constants/constants.hpp | 16 ++--
trunk/boost/math/special_functions/detail/bessel_i0.hpp | 30 +++++++++++
trunk/boost/math/special_functions/detail/bessel_i1.hpp | 31 +++++++++++
trunk/boost/math/special_functions/detail/bessel_j0.hpp | 30 +++++++++++
trunk/boost/math/special_functions/detail/bessel_j1.hpp | 30 +++++++++++
trunk/boost/math/special_functions/detail/bessel_k0.hpp | 30 +++++++++++
trunk/boost/math/special_functions/detail/bessel_k1.hpp | 30 +++++++++++
trunk/boost/math/special_functions/detail/bessel_y0.hpp | 30 +++++++++++
trunk/boost/math/special_functions/detail/bessel_y1.hpp | 30 +++++++++++
trunk/boost/math/special_functions/detail/erf_inv.hpp | 40 ++++++++++++++
trunk/boost/math/special_functions/detail/igamma_large.hpp | 1
trunk/boost/math/special_functions/digamma.hpp | 28 ++++++++++
trunk/boost/math/special_functions/erf.hpp | 57 +++++++++++++++++++++
trunk/boost/math/special_functions/expint.hpp | 92 ++++++++++++++++++++++++++++++++++
trunk/boost/math/special_functions/expm1.hpp | 43 +++++++--------
trunk/boost/math/special_functions/gamma.hpp | 108 ++++++++++++++++++++++++++++++++++++++++
trunk/boost/math/special_functions/lanczos.hpp | 53 +++++++++++++++++++
trunk/boost/math/special_functions/log1p.hpp | 31 +++++++++++
trunk/boost/math/special_functions/owens_t.hpp | 41 +++++++++++++++
trunk/boost/math/special_functions/zeta.hpp | 45 ++++++++++++++++
trunk/boost/math/tools/big_constant.hpp | 4 +
trunk/libs/math/test/pow_test.cpp | 8 +-
26 files changed, 808 insertions(+), 36 deletions(-)
Modified: trunk/boost/math/bindings/detail/big_lanczos.hpp
==============================================================================
--- trunk/boost/math/bindings/detail/big_lanczos.hpp (original)
+++ trunk/boost/math/bindings/detail/big_lanczos.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -32,6 +32,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos22UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[22] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 46198410803245094237463011094.12173081986)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 43735859291852324413622037436.321513777)),
@@ -86,6 +87,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos22UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[22] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 6939996264376682180.277485395074954356211)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 6570067992110214451.87201438870245659384)),
@@ -141,6 +143,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos22UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[21] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 8.318998691953337183034781139546384476554)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, -63.15415991415959158214140353299240638675)),
@@ -219,6 +222,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos31UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[31] = {
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 0.2579646553333513328235723061836959833277e46)),
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 0.2444796504337453845497419271639377138264e46)),
@@ -291,6 +295,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos31UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[31] = {
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 30137154810677525966583148469478.52374216)),
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 28561746428637727032849890123131.36314653)),
@@ -364,6 +369,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos31UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[30] = {
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 11.80038544942943603508206880307972596807)),
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, -130.6355975335626214564236363322099481079)),
@@ -407,6 +413,7 @@
template<class T>
static T lanczos_sum_near_2(const T& dz)
{
+ lanczos_initializer<lanczos31UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[30] = {
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 147.9979641587472136175636384176549713358)),
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, -1638.404318611773924210055619836375434296)),
@@ -461,6 +468,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos61UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
using namespace boost;
static const T d[61] = {
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 2.50662827463100050241576528481104525300698674060993831662992357634229365460784197494659584)),
@@ -536,6 +544,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos61UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
using namespace boost;
static const T d[61] = {
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 0.901751806425638853077358552989167785490911341809902155556127108480303870921448984935411583e-27)),
@@ -611,6 +620,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos61UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
using namespace boost;
static const T d[60] = {
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 23.2463658527729692390378860713647146932236940604550445351214987229819352880524561852919518)),
@@ -685,6 +695,7 @@
template<class T>
static T lanczos_sum_near_2(const T& dz)
{
+ lanczos_initializer<lanczos61UDT, T>::force_instantiate(); // Ensure our constants get initialized before main()
using namespace boost;
static const T d[60] = {
static_cast<T>(BOOST_MATH_HUGE_CONSTANT(T, 150, 557.56438192770795764344217888434355281097193198928944200046501607026919782564033547346298)),
Modified: trunk/boost/math/bindings/rr.hpp
==============================================================================
--- trunk/boost/math/bindings/rr.hpp (original)
+++ trunk/boost/math/bindings/rr.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -763,6 +763,17 @@
NTL::RR::precision());
}
+ inline RR atan2(RR y, RR x)
+ {
+ if(x > 0)
+ return atan(y / x);
+ if(x < 0)
+ {
+ return y < 0 ? atan(y / x) - boost::math::constants::pi<RR>() : atan(y / x) + boost::math::constants::pi<RR>();
+ }
+ return y < 0 ? -boost::math::constants::half_pi<RR>() : boost::math::constants::half_pi<RR>() ;
+ }
+
inline RR sinh(RR z)
{
return (expm1(z.value()) - expm1(-z.value())) / 2;
Modified: trunk/boost/math/concepts/real_concept.hpp
==============================================================================
--- trunk/boost/math/concepts/real_concept.hpp (original)
+++ trunk/boost/math/concepts/real_concept.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -28,6 +28,7 @@
#include <boost/math/special_functions/round.hpp>
#include <boost/math/special_functions/trunc.hpp>
#include <boost/math/special_functions/modf.hpp>
+#include <boost/math/tools/big_constant.hpp>
#include <boost/math/tools/precision.hpp>
#include <boost/math/policies/policy.hpp>
#if defined(__SGI_STL_PORT)
@@ -324,6 +325,12 @@
{
template <>
+inline concepts::real_concept make_big_value<concepts::real_concept>(long double val, const char* , mpl::false_ const&, mpl::false_ const&)
+{
+ return val; // Can't use lexical_cast here, sometimes it fails....
+}
+
+template <>
inline concepts::real_concept max_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
{
return max_value<concepts::real_concept_base_type>();
Modified: trunk/boost/math/concepts/std_real_concept.hpp
==============================================================================
--- trunk/boost/math/concepts/std_real_concept.hpp (original)
+++ trunk/boost/math/concepts/std_real_concept.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -323,12 +323,19 @@
}}
#include <boost/math/tools/precision.hpp>
+#include <boost/math/tools/big_constant.hpp>
namespace boost{ namespace math{
namespace tools
{
template <>
+inline concepts::std_real_concept make_big_value<concepts::std_real_concept>(long double val, const char* , mpl::false_ const&, mpl::false_ const&)
+{
+ return val; // Can't use lexical_cast here, sometimes it fails....
+}
+
+template <>
inline concepts::std_real_concept max_value<concepts::std_real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
{
return max_value<concepts::std_real_concept_base_type>();
Modified: trunk/boost/math/constants/constants.hpp
==============================================================================
--- trunk/boost/math/constants/constants.hpp (original)
+++ trunk/boost/math/constants/constants.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -107,9 +107,9 @@
template <class T, T (*F)(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(T))>
struct constant_initializer
{
- static void do_nothing()
+ static void force_instantiate()
{
- init.do_nothing();
+ init.force_instantiate();
}
private:
struct initializer
@@ -122,7 +122,7 @@
#endif
);
}
- void do_nothing()const{}
+ void force_instantiate()const{}
};
static const initializer init;
};
@@ -133,9 +133,9 @@
template <class T, int N, T (*F)(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))>
struct constant_initializer2
{
- static void do_nothing()
+ static void force_instantiate()
{
- init.do_nothing();
+ init.force_instantiate();
}
private:
struct initializer
@@ -148,7 +148,7 @@
#endif
);
}
- void do_nothing()const{}
+ void force_instantiate()const{}
};
static const initializer init;
};
@@ -174,7 +174,7 @@
public:\
static inline T get(const mpl::int_<construct_from_string>&)\
{\
- constant_initializer<T, & BOOST_JOIN(constant_, name)<T>::get_from_string >::do_nothing();\
+ constant_initializer<T, & BOOST_JOIN(constant_, name)<T>::get_from_string >::force_instantiate();\
return get_from_string();\
}\
static inline BOOST_CONSTEXPR T get(const mpl::int_<construct_from_float>)\
@@ -185,7 +185,7 @@
{ return BOOST_JOIN(x, L); }\
template <int N> static inline T get(const mpl::int_<N>& n)\
{\
- constant_initializer2<T, N, & BOOST_JOIN(constant_, name)<T>::template compute<N> >::do_nothing();\
+ constant_initializer2<T, N, & BOOST_JOIN(constant_, name)<T>::template compute<N> >::force_instantiate();\
return compute<N>(); \
}\
/* This one is for true arbitary precision, which may well vary at runtime: */ \
Modified: trunk/boost/math/special_functions/detail/bessel_i0.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_i0.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_i0.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -21,8 +21,38 @@
namespace boost { namespace math { namespace detail{
template <typename T>
+T bessel_i0(T x);
+
+template <class T>
+struct bessel_i0_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ bessel_i0(T(1));
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T>
+const typename bessel_i0_initializer<T>::init bessel_i0_initializer<T>::initializer;
+
+template <typename T>
T bessel_i0(T x)
{
+ bessel_i0_initializer<T>::force_instantiate();
+
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2335582639474375249e+15)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -5.5050369673018427753e+14)),
Modified: trunk/boost/math/special_functions/detail/bessel_i1.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_i1.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_i1.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -21,8 +21,39 @@
namespace boost { namespace math { namespace detail{
template <typename T>
+T bessel_i1(T x);
+
+template <class T>
+struct bessel_i1_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ bessel_i1(T(1));
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T>
+const typename bessel_i1_initializer<T>::init bessel_i1_initializer<T>::initializer;
+
+template <typename T>
T bessel_i1(T x)
{
+
+ bessel_i1_initializer<T>::force_instantiate();
+
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4577180278143463643e+15)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.7732037840791591320e+14)),
Modified: trunk/boost/math/special_functions/detail/bessel_j0.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_j0.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_j0.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -22,8 +22,38 @@
namespace boost { namespace math { namespace detail{
template <typename T>
+T bessel_j0(T x);
+
+template <class T>
+struct bessel_j0_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ bessel_j0(T(1));
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T>
+const typename bessel_j0_initializer<T>::init bessel_j0_initializer<T>::initializer;
+
+template <typename T>
T bessel_j0(T x)
{
+ bessel_j0_initializer<T>::force_instantiate();
+
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -4.1298668500990866786e+11)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.7282507878605942706e+10)),
Modified: trunk/boost/math/special_functions/detail/bessel_j1.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_j1.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_j1.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -22,8 +22,38 @@
namespace boost { namespace math{ namespace detail{
template <typename T>
+T bessel_j1(T x);
+
+template <class T>
+struct bessel_j1_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ bessel_j1(T(1));
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T>
+const typename bessel_j1_initializer<T>::init bessel_j1_initializer<T>::initializer;
+
+template <typename T>
T bessel_j1(T x)
{
+ bessel_j1_initializer<T>::force_instantiate();
+
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -1.4258509801366645672e+11)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 6.6781041261492395835e+09)),
Modified: trunk/boost/math/special_functions/detail/bessel_k0.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_k0.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_k0.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -22,10 +22,40 @@
namespace boost { namespace math { namespace detail{
template <typename T, typename Policy>
+T bessel_k0(T x, const Policy&);
+
+template <class T, class Policy>
+struct bessel_k0_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ bessel_k0(T(1), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy>
+const typename bessel_k0_initializer<T, Policy>::init bessel_k0_initializer<T, Policy>::initializer;
+
+template <typename T, typename Policy>
T bessel_k0(T x, const Policy& pol)
{
BOOST_MATH_INSTRUMENT_CODE(x);
+ bessel_k0_initializer<T, Policy>::force_instantiate();
+
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2.4708152720399552679e+03)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.9169059852270512312e+03)),
Modified: trunk/boost/math/special_functions/detail/bessel_k1.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_k1.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_k1.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -22,8 +22,38 @@
namespace boost { namespace math { namespace detail{
template <typename T, typename Policy>
+T bessel_k1(T x, const Policy&);
+
+template <class T, class Policy>
+struct bessel_k1_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ bessel_k1(T(1), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy>
+const typename bessel_k1_initializer<T, Policy>::init bessel_k1_initializer<T, Policy>::initializer;
+
+template <typename T, typename Policy>
T bessel_k1(T x, const Policy& pol)
{
+ bessel_k1_initializer<T, Policy>::force_instantiate();
+
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -2.2149374878243304548e+06)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 7.1938920065420586101e+05)),
Modified: trunk/boost/math/special_functions/detail/bessel_y0.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_y0.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_y0.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -24,8 +24,38 @@
namespace boost { namespace math { namespace detail{
template <typename T, typename Policy>
+T bessel_y0(T x, const Policy&);
+
+template <class T, class Policy>
+struct bessel_y0_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ bessel_y0(T(1), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy>
+const typename bessel_y0_initializer<T, Policy>::init bessel_y0_initializer<T, Policy>::initializer;
+
+template <typename T, typename Policy>
T bessel_y0(T x, const Policy& pol)
{
+ bessel_y0_initializer<T, Policy>::force_instantiate();
+
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1.0723538782003176831e+11)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -8.3716255451260504098e+09)),
Modified: trunk/boost/math/special_functions/detail/bessel_y1.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_y1.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_y1.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -24,8 +24,38 @@
namespace boost { namespace math { namespace detail{
template <typename T, typename Policy>
+T bessel_y1(T x, const Policy&);
+
+template <class T, class Policy>
+struct bessel_y1_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ bessel_y1(T(1), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy>
+const typename bessel_y1_initializer<T, Policy>::init bessel_y1_initializer<T, Policy>::initializer;
+
+template <typename T, typename Policy>
T bessel_y1(T x, const Policy& pol)
{
+ bessel_y1_initializer<T, Policy>::force_instantiate();
+
static const T P1[] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.0535726612579544093e+13)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 5.4708611716525426053e+12)),
Modified: trunk/boost/math/special_functions/detail/erf_inv.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/erf_inv.hpp (original)
+++ trunk/boost/math/special_functions/detail/erf_inv.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -322,12 +322,47 @@
return result;
}
+template <class T, class Policy>
+struct erf_inv_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init();
+ }
+ static void do_init()
+ {
+ boost::math::erf_inv(static_cast<T>(0.25), Policy());
+ boost::math::erf_inv(static_cast<T>(0.55), Policy());
+ boost::math::erf_inv(static_cast<T>(0.95), Policy());
+ boost::math::erfc_inv(static_cast<T>(1e-15), Policy());
+ if(static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1e-130)) != 0)
+ boost::math::erfc_inv(static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1e-130)), Policy());
+ if(static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1e-800)) != 0)
+ boost::math::erfc_inv(static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1e-800)), Policy());
+ if(static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1e-900)) != 0)
+ boost::math::erfc_inv(static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 1e-900)), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy>
+const typename erf_inv_initializer<T, Policy>::init erf_inv_initializer<T, Policy>::initializer;
+
} // namespace detail
template <class T, class Policy>
typename tools::promote_args<T>::type erfc_inv(T z, const Policy& pol)
{
typedef typename tools::promote_args<T>::type result_type;
+
//
// Begin by testing for domain errors, and other special cases:
//
@@ -378,6 +413,8 @@
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
+ detail::erf_inv_initializer<eval_type, forwarding_policy>::force_instantiate();
+
//
// And get the result, negating where required:
//
@@ -389,6 +426,7 @@
typename tools::promote_args<T>::type erf_inv(T z, const Policy& pol)
{
typedef typename tools::promote_args<T>::type result_type;
+
//
// Begin by testing for domain errors, and other special cases:
//
@@ -445,6 +483,8 @@
// precision internally if it's appropriate:
//
typedef typename policies::evaluation<result_type, Policy>::type eval_type;
+
+ detail::erf_inv_initializer<eval_type, forwarding_policy>::force_instantiate();
//
// And get the result, negating where required:
//
Modified: trunk/boost/math/special_functions/detail/igamma_large.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/igamma_large.hpp (original)
+++ trunk/boost/math/special_functions/detail/igamma_large.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -759,7 +759,6 @@
return result;
}
-
} // namespace detail
} // namespace math
} // namespace math
Modified: trunk/boost/math/special_functions/digamma.hpp
==============================================================================
--- trunk/boost/math/special_functions/digamma.hpp (original)
+++ trunk/boost/math/special_functions/digamma.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -407,6 +407,31 @@
return result;
}
+//
+// Initializer: ensure all our constants are initialized prior to the first call of main:
+//
+template <class T, class Policy>
+struct digamma_initializer
+{
+ struct init
+ {
+ init()
+ {
+ boost::math::digamma(T(1.5), Policy());
+ boost::math::digamma(T(500), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy>
+const typename digamma_initializer<T, Policy>::init digamma_initializer<T, Policy>::initializer;
+
} // namespace detail
template <class T, class Policy>
@@ -433,6 +458,9 @@
>::type
>::type tag_type;
+ // Force initialization of constants:
+ detail::digamma_initializer<result_type, Policy>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, Policy>(detail::digamma_imp(
static_cast<value_type>(x),
static_cast<const tag_type*>(0), pol), "boost::math::digamma<%1%>(%1%)");
Modified: trunk/boost/math/special_functions/erf.hpp
==============================================================================
--- trunk/boost/math/special_functions/erf.hpp (original)
+++ trunk/boost/math/special_functions/erf.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -978,6 +978,59 @@
return result;
} // template <class T, class Lanczos>T erf_imp(T z, bool invert, const Lanczos& l, const mpl::int_<113>& t)
+template <class T, class Policy, class tag>
+struct erf_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init(tag());
+ }
+ static void do_init(const mpl::int_<0>&){}
+ static void do_init(const mpl::int_<53>&)
+ {
+ boost::math::erf(static_cast<T>(1e-12), Policy());
+ boost::math::erf(static_cast<T>(0.25), Policy());
+ boost::math::erf(static_cast<T>(1.25), Policy());
+ boost::math::erf(static_cast<T>(2.25), Policy());
+ boost::math::erf(static_cast<T>(4.25), Policy());
+ boost::math::erf(static_cast<T>(5.25), Policy());
+ }
+ static void do_init(const mpl::int_<64>&)
+ {
+ boost::math::erf(static_cast<T>(1e-12), Policy());
+ boost::math::erf(static_cast<T>(0.25), Policy());
+ boost::math::erf(static_cast<T>(1.25), Policy());
+ boost::math::erf(static_cast<T>(2.25), Policy());
+ boost::math::erf(static_cast<T>(4.25), Policy());
+ boost::math::erf(static_cast<T>(5.25), Policy());
+ }
+ static void do_init(const mpl::int_<113>&)
+ {
+ boost::math::erf(static_cast<T>(1e-22), Policy());
+ boost::math::erf(static_cast<T>(0.25), Policy());
+ boost::math::erf(static_cast<T>(1.25), Policy());
+ boost::math::erf(static_cast<T>(2.125), Policy());
+ boost::math::erf(static_cast<T>(2.75), Policy());
+ boost::math::erf(static_cast<T>(3.25), Policy());
+ boost::math::erf(static_cast<T>(5.25), Policy());
+ boost::math::erf(static_cast<T>(7.25), Policy());
+ boost::math::erf(static_cast<T>(11.25), Policy());
+ boost::math::erf(static_cast<T>(12.5), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy, class tag>
+const typename erf_initializer<T, Policy, tag>::init erf_initializer<T, Policy, tag>::initializer;
+
} // namespace detail
template <class T, class Policy>
@@ -1017,6 +1070,8 @@
BOOST_MATH_INSTRUMENT_CODE("tag_type = " << typeid(tag_type).name());
+ detail::erf_initializer<value_type, forwarding_policy, tag_type>::force_instantiate(); // Force constants to be initialized before main
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::erf_imp(
static_cast<value_type>(z),
false,
@@ -1061,6 +1116,8 @@
BOOST_MATH_INSTRUMENT_CODE("tag_type = " << typeid(tag_type).name());
+ detail::erf_initializer<value_type, forwarding_policy, tag_type>::force_instantiate(); // Force constants to be initialized before main
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::erf_imp(
static_cast<value_type>(z),
true,
Modified: trunk/boost/math/special_functions/expint.hpp
==============================================================================
--- trunk/boost/math/special_functions/expint.hpp (original)
+++ trunk/boost/math/special_functions/expint.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -1473,6 +1473,94 @@
return result;
}
+template <class T, class Policy, class tag>
+struct expint_i_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init(tag());
+ }
+ static void do_init(const mpl::int_<0>&){}
+ static void do_init(const mpl::int_<53>&)
+ {
+ boost::math::expint(T(5));
+ boost::math::expint(T(7));
+ boost::math::expint(T(18));
+ boost::math::expint(T(38));
+ boost::math::expint(T(45));
+ }
+ static void do_init(const mpl::int_<64>&)
+ {
+ boost::math::expint(T(5));
+ boost::math::expint(T(7));
+ boost::math::expint(T(18));
+ boost::math::expint(T(38));
+ boost::math::expint(T(45));
+ }
+ static void do_init(const mpl::int_<113>&)
+ {
+ boost::math::expint(T(5));
+ boost::math::expint(T(7));
+ boost::math::expint(T(17));
+ boost::math::expint(T(25));
+ boost::math::expint(T(40));
+ boost::math::expint(T(50));
+ boost::math::expint(T(80));
+ boost::math::expint(T(200));
+ boost::math::expint(T(220));
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy, class tag>
+const typename expint_i_initializer<T, Policy, tag>::init expint_i_initializer<T, Policy, tag>::initializer;
+
+template <class T, class Policy, class tag>
+struct expint_1_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init(tag());
+ }
+ static void do_init(const mpl::int_<0>&){}
+ static void do_init(const mpl::int_<53>&)
+ {
+ boost::math::expint(1, T(0.5));
+ boost::math::expint(1, T(2));
+ }
+ static void do_init(const mpl::int_<64>&)
+ {
+ boost::math::expint(1, T(0.5));
+ boost::math::expint(1, T(2));
+ }
+ static void do_init(const mpl::int_<113>&)
+ {
+ boost::math::expint(1, T(0.5));
+ boost::math::expint(1, T(2));
+ boost::math::expint(1, T(6));
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy, class tag>
+const typename expint_1_initializer<T, Policy, tag>::init expint_1_initializer<T, Policy, tag>::initializer;
+
template <class T, class Policy>
inline typename tools::promote_args<T>::type
expint_forwarder(T z, const Policy& /*pol*/, mpl::true_ const&)
@@ -1504,6 +1592,8 @@
>::type
>::type tag_type;
+ expint_i_initializer<value_type, forwarding_policy, tag_type>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::expint_i_imp(
static_cast<value_type>(z),
forwarding_policy(),
@@ -1550,6 +1640,8 @@
>::type
>::type tag_type;
+ detail::expint_1_initializer<value_type, forwarding_policy, tag_type>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::expint_imp(
n,
static_cast<value_type>(z),
Modified: trunk/boost/math/special_functions/expm1.hpp
==============================================================================
--- trunk/boost/math/special_functions/expm1.hpp (original)
+++ trunk/boost/math/special_functions/expm1.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -65,34 +65,37 @@
expm1_series& operator=(const expm1_series&);
};
-template <class T, bool b = boost::is_pod<T>::value>
-struct expm1_init_on_startup
+template <class T, class Policy, class tag>
+struct expm1_initializer
{
struct init
{
init()
{
- boost::math::expm1(T(0.5f));
+ do_init(tag());
}
- void do_nothing()const{}
+ template <int N>
+ static void do_init(const mpl::int_<N>&){}
+ static void do_init(const mpl::int_<64>&)
+ {
+ expm1(T(0.5));
+ }
+ static void do_init(const mpl::int_<113>&)
+ {
+ expm1(T(0.5));
+ }
+ void force_instantiate()const{}
};
-
- static void do_nothing()
+ static const init initializer;
+ static void force_instantiate()
{
- initializer.do_nothing();
+ initializer.force_instantiate();
}
-
- static const init initializer;
};
-template <class T, bool b>
-const typename expm1_init_on_startup<T, b>::init expm1_init_on_startup<T, b>::initializer;
+template <class T, class Policy, class tag>
+const typename expm1_initializer<T, Policy, tag>::init expm1_initializer<T, Policy, tag>::initializer;
-template <class T>
-struct expm1_init_on_startup<T, true>
-{
- static void do_nothing(){}
-};
//
// Algorithm expm1 is part of C99, but is not yet provided by many compilers.
//
@@ -133,8 +136,6 @@
{
BOOST_MATH_STD_USING
- expm1_init_on_startup<T>::do_nothing();
-
T a = fabs(x);
if(a > T(0.5L))
{
@@ -162,8 +163,6 @@
{
BOOST_MATH_STD_USING
- expm1_init_on_startup<T>::do_nothing();
-
T a = fabs(x);
if(a > T(0.5L))
{
@@ -207,8 +206,6 @@
{
BOOST_MATH_STD_USING
- expm1_init_on_startup<T>::do_nothing();
-
T a = fabs(x);
if(a > T(0.5L))
{
@@ -287,6 +284,8 @@
>::type
>::type tag_type;
+ detail::expm1_initializer<value_type, forwarding_policy, tag_type>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::expm1_imp(
static_cast<value_type>(x),
tag_type(), forwarding_policy()), "boost::math::expm1<%1%>(%1%)");
Modified: trunk/boost/math/special_functions/gamma.hpp
==============================================================================
--- trunk/boost/math/special_functions/gamma.hpp (original)
+++ trunk/boost/math/special_functions/gamma.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -1258,6 +1258,101 @@
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::gamma_imp(static_cast<value_type>(z), forwarding_policy(), evaluation_type()), "boost::math::tgamma<%1%>(%1%)");
}
+template <class T, class Policy>
+struct igamma_initializer
+{
+ struct init
+ {
+ init()
+ {
+ typedef typename policies::precision<T, Policy>::type precision_type;
+
+ typedef typename mpl::if_<
+ mpl::or_<mpl::equal_to<precision_type, mpl::int_<0> >,
+ mpl::greater<precision_type, mpl::int_<113> > >,
+ mpl::int_<0>,
+ typename mpl::if_<
+ mpl::less_equal<precision_type, mpl::int_<53> >,
+ mpl::int_<53>,
+ typename mpl::if_<
+ mpl::less_equal<precision_type, mpl::int_<64> >,
+ mpl::int_<64>,
+ mpl::int_<113>
+ >::type
+ >::type
+ >::type tag_type;
+
+ do_init(tag_type());
+ }
+ template <int N>
+ static void do_init(const mpl::int_<N>&)
+ {
+ boost::math::gamma_p(static_cast<T>(400), static_cast<T>(400), Policy());
+ }
+ static void do_init(const mpl::int_<53>&){}
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy>
+const typename igamma_initializer<T, Policy>::init igamma_initializer<T, Policy>::initializer;
+
+template <class T, class Policy>
+struct lgamma_initializer
+{
+ struct init
+ {
+ init()
+ {
+ typedef typename policies::precision<T, Policy>::type precision_type;
+ typedef typename mpl::if_<
+ mpl::and_<
+ mpl::less_equal<precision_type, mpl::int_<64> >,
+ mpl::greater<precision_type, mpl::int_<0> >
+ >,
+ mpl::int_<64>,
+ typename mpl::if_<
+ mpl::and_<
+ mpl::less_equal<precision_type, mpl::int_<113> >,
+ mpl::greater<precision_type, mpl::int_<0> >
+ >,
+ mpl::int_<113>, mpl::int_<0> >::type
+ >::type tag_type;
+ do_init(tag_type());
+ }
+ static void do_init(const mpl::int_<64>&)
+ {
+ boost::math::lgamma(static_cast<T>(2.5), Policy());
+ boost::math::lgamma(static_cast<T>(1.25), Policy());
+ boost::math::lgamma(static_cast<T>(1.75), Policy());
+ }
+ static void do_init(const mpl::int_<113>&)
+ {
+ boost::math::lgamma(static_cast<T>(2.5), Policy());
+ boost::math::lgamma(static_cast<T>(1.25), Policy());
+ boost::math::lgamma(static_cast<T>(1.5), Policy());
+ boost::math::lgamma(static_cast<T>(1.75), Policy());
+ }
+ static void do_init(const mpl::int_<0>&)
+ {
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy>
+const typename lgamma_initializer<T, Policy>::init lgamma_initializer<T, Policy>::initializer;
+
template <class T1, class T2, class Policy>
inline typename tools::promote_args<T1, T2>::type
tgamma(T1 a, T2 z, const Policy&, const mpl::false_)
@@ -1272,6 +1367,9 @@
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
+
+ igamma_initializer<value_type, forwarding_policy>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(
detail::gamma_incomplete_imp(static_cast<value_type>(a),
static_cast<value_type>(z), false, true,
@@ -1285,6 +1383,7 @@
return tgamma(a, z, policies::policy<>(), tag);
}
+
} // namespace detail
template <class T>
@@ -1308,6 +1407,9 @@
policies::promote_double<false>,
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
+
+ detail::lgamma_initializer<value_type, forwarding_policy>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::lgamma_imp(static_cast<value_type>(z), forwarding_policy(), evaluation_type(), sign), "boost::math::lgamma<%1%>(%1%)");
}
@@ -1395,6 +1497,8 @@
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
+ detail::igamma_initializer<value_type, forwarding_policy>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(
detail::gamma_incomplete_imp(static_cast<value_type>(a),
static_cast<value_type>(z), false, false,
@@ -1424,6 +1528,8 @@
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
+ detail::igamma_initializer<value_type, forwarding_policy>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(
detail::gamma_incomplete_imp(static_cast<value_type>(a),
static_cast<value_type>(z), true, true,
@@ -1453,6 +1559,8 @@
policies::discrete_quantile<>,
policies::assert_undefined<> >::type forwarding_policy;
+ detail::igamma_initializer<value_type, forwarding_policy>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(
detail::gamma_incomplete_imp(static_cast<value_type>(a),
static_cast<value_type>(z), true, false,
Modified: trunk/boost/math/special_functions/lanczos.hpp
==============================================================================
--- trunk/boost/math/special_functions/lanczos.hpp (original)
+++ trunk/boost/math/special_functions/lanczos.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -34,6 +34,35 @@
// http://my.fit.edu/~gabdo/gamma.txt and elaborated by Toth at
// http://www.rskey.org/gamma.htm using NTL::RR at 1000 bit precision.
//
+// Begin with a small helper to force initialization of constants prior
+// to main. This makes the constant initialization thread safe, even
+// when called with a user-defined number type.
+//
+template <class Lanczos, class T>
+struct lanczos_initializer
+{
+ struct init
+ {
+ init()
+ {
+ T t(1);
+ Lanczos::lanczos_sum(t);
+ Lanczos::lanczos_sum_expG_scaled(t);
+ Lanczos::lanczos_sum_near_1(t);
+ Lanczos::lanczos_sum_near_2(t);
+ Lanczos::g();
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+template <class Lanczos, class T>
+typename lanczos_initializer<Lanczos, T>::init const lanczos_initializer<Lanczos, T>::initializer;
+//
// Lanczos Coefficients for N=6 G=5.581
// Max experimental error (with arbitary precision arithmetic) 9.516e-12
// Generated with compiler: Microsoft Visual C++ version 8.0 on Win32 at Mar 23 2006
@@ -47,6 +76,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos6, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[6] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 35, 8706.349592549009182288174442774377925882)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 35, 8523.650341121874633477483696775067709735)),
@@ -69,6 +99,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos6, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[6] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 35, 32.81244541029783471623665933780748627823)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 35, 32.12388941444332003446077108933558534361)),
@@ -92,6 +123,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos6, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[5] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 35, 2.044879010930422922760429926121241330235)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 35, -2.751366405578505366591317846728753993668)),
@@ -110,6 +142,7 @@
template<class T>
static T lanczos_sum_near_2(const T& dz)
{
+ lanczos_initializer<lanczos6, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[5] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 35, 5.748142489536043490764289256167080091892)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 35, -7.734074268282457156081021756682138251825)),
@@ -143,6 +176,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos11, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[11] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 60, 38474670393.31776828316099004518914832218)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 60, 36857665043.51950660081971227404959150474)),
@@ -175,6 +209,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos11, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[11] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 60, 709811.662581657956893540610814842699825)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 60, 679979.847415722640161734319823103390728)),
@@ -208,6 +243,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos11, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[10] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 60, 4.005853070677940377969080796551266387954)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 60, -13.17044315127646469834125159673527183164)),
@@ -231,6 +267,7 @@
template<class T>
static T lanczos_sum_near_2(const T& dz)
{
+ lanczos_initializer<lanczos11, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[10] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 60, 19.05889633808148715159575716844556056056)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 60, -62.66183664701721716960978577959655644762)),
@@ -269,6 +306,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos13, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[13] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 72, 44012138428004.60895436261759919070125699)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 72, 41590453358593.20051581730723108131357995)),
@@ -305,6 +343,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos13, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[13] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 72, 86091529.53418537217994842267760536134841)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 72, 81354505.17858011242874285785316135398567)),
@@ -342,6 +381,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos13, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[12] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 72, 4.832115561461656947793029596285626840312)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 72, -19.86441536140337740383120735104359034688)),
@@ -367,6 +407,7 @@
template<class T>
static T lanczos_sum_near_2(const T& dz)
{
+ lanczos_initializer<lanczos13, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[12] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 72, 26.96979819614830698367887026728396466395)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 72, -110.8705424709385114023884328797900204863)),
@@ -407,6 +448,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos22, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[22] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 46198410803245094237463011094.12173081986)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 43735859291852324413622037436.321513777)),
@@ -461,6 +503,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos22, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[22] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 6939996264376682180.277485395074954356211)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 6570067992110214451.87201438870245659384)),
@@ -516,6 +559,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos22, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[21] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 8.318998691953337183034781139546384476554)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, -63.15415991415959158214140353299240638675)),
@@ -550,6 +594,7 @@
template<class T>
static T lanczos_sum_near_2(const T& dz)
{
+ lanczos_initializer<lanczos22, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[21] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, 75.39272007105208086018421070699575462226)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 120, -572.3481967049935412452681346759966390319)),
@@ -830,6 +875,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos17m64, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[17] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 553681095419291969.2230556393350368550504)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 731918863887667017.2511276782146694632234)),
@@ -874,6 +920,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos17m64, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[17] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 2715894658327.717377557655133124376674911)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 3590179526097.912105038525528721129550434)),
@@ -919,6 +966,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos17m64, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[16] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 4.493645054286536365763334986866616581265)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -16.95716370392468543800733966378143997694)),
@@ -948,6 +996,7 @@
template<class T>
static T lanczos_sum_near_2(const T& dz)
{
+ lanczos_initializer<lanczos17m64, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[16] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, 23.56409085052261327114594781581930373708)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 64, -88.92116338946308797946237246006238652361)),
@@ -991,6 +1040,7 @@
template <class T>
static T lanczos_sum(const T& z)
{
+ lanczos_initializer<lanczos24m113, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[24] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 2029889364934367661624137213253.22102954656825019111612712252027267955023987678816620961507)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 2338599599286656537526273232565.2727349714338768161421882478417543004440597874814359063158)),
@@ -1049,6 +1099,7 @@
template <class T>
static T lanczos_sum_expG_scaled(const T& z)
{
+ lanczos_initializer<lanczos24m113, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T num[24] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 3035162425359883494754.02878223286972654682199012688209026810841953293372712802258398358538)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 3496756894406430103600.16057175075063458536101374170860226963245118484234495645518505519827)),
@@ -1108,6 +1159,7 @@
template<class T>
static T lanczos_sum_near_1(const T& dz)
{
+ lanczos_initializer<lanczos24m113, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[23] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 7.4734083002469026177867421609938203388868806387315406134072298925733950040583068760685908)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, -50.4225805042247530267317342133388132970816607563062253708655085754357843064134941138154171)),
@@ -1144,6 +1196,7 @@
template<class T>
static T lanczos_sum_near_2(const T& dz)
{
+ lanczos_initializer<lanczos24m113, T>::force_instantiate(); // Ensure our constants get initialized before main()
static const T d[23] = {
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, 61.4165001061101455341808888883960361969557848005400286332291451422461117307237198559485365)),
static_cast<T>(BOOST_MATH_BIG_CONSTANT(T, 113, -414.372973678657049667308134761613915623353625332248315105320470271523320700386200587519147)),
Modified: trunk/boost/math/special_functions/log1p.hpp
==============================================================================
--- trunk/boost/math/special_functions/log1p.hpp (original)
+++ trunk/boost/math/special_functions/log1p.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -258,6 +258,34 @@
return result;
}
+template <class T, class Policy, class tag>
+struct log1p_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init(tag());
+ }
+ template <int N>
+ static void do_init(const mpl::int_<N>&){}
+ static void do_init(const mpl::int_<64>&)
+ {
+ boost::math::log1p(static_cast<T>(0.25), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy, class tag>
+const typename log1p_initializer<T, Policy, tag>::init log1p_initializer<T, Policy, tag>::initializer;
+
+
} // namespace detail
template <class T, class Policy>
@@ -286,6 +314,9 @@
>::type
>::type
>::type tag_type;
+
+ detail::log1p_initializer<value_type, forwarding_policy, tag_type>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(
detail::log1p_imp(static_cast<value_type>(x), forwarding_policy(), tag_type()), "boost::math::log1p<%1%>(%1%)");
}
Modified: trunk/boost/math/special_functions/owens_t.hpp
==============================================================================
--- trunk/boost/math/special_functions/owens_t.hpp (original)
+++ trunk/boost/math/special_functions/owens_t.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -996,6 +996,34 @@
return val;
} // RealType owens_t(RealType h, RealType a)
+ template <class T, class Policy, class tag>
+ struct owens_t_initializer
+ {
+ struct init
+ {
+ init()
+ {
+ do_init(tag());
+ }
+ template <int N>
+ static void do_init(const mpl::int_<N>&){}
+ static void do_init(const mpl::int_<64>&)
+ {
+ boost::math::owens_t(static_cast<T>(7), static_cast<T>(0.96875), Policy());
+ boost::math::owens_t(static_cast<T>(2), static_cast<T>(0.5), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+ };
+
+ template <class T, class Policy, class tag>
+ const typename owens_t_initializer<T, Policy, tag>::init owens_t_initializer<T, Policy, tag>::initializer;
+
} // namespace detail
template <class T1, class T2, class Policy>
@@ -1003,6 +1031,19 @@
{
typedef typename tools::promote_args<T1, T2>::type result_type;
typedef typename policies::evaluation<result_type, Policy>::type value_type;
+ typedef typename policies::precision<value_type, Policy>::type precision_type;
+ typedef typename mpl::if_c<
+ precision_type::value == 0,
+ mpl::int_<0>,
+ typename mpl::if_c<
+ precision_type::value <= 64,
+ mpl::int_<64>,
+ mpl::int_<65>
+ >::type
+ >::type tag_type;
+
+ detail::owens_t_initializer<result_type, Policy, tag_type>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, Policy>(detail::owens_t(static_cast<value_type>(h), static_cast<value_type>(a), pol), "boost::math::owens_t<%1%>(%1%,%1%)");
}
Modified: trunk/boost/math/special_functions/zeta.hpp
==============================================================================
--- trunk/boost/math/special_functions/zeta.hpp (original)
+++ trunk/boost/math/special_functions/zeta.hpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -896,6 +896,49 @@
return result;
}
+template <class T, class Policy, class tag>
+struct zeta_initializer
+{
+ struct init
+ {
+ init()
+ {
+ do_init(tag());
+ }
+ static void do_init(const mpl::int_<0>&){}
+ static void do_init(const mpl::int_<53>&){}
+ static void do_init(const mpl::int_<64>&)
+ {
+ boost::math::zeta(static_cast<T>(0.5), Policy());
+ boost::math::zeta(static_cast<T>(1.5), Policy());
+ boost::math::zeta(static_cast<T>(3.5), Policy());
+ boost::math::zeta(static_cast<T>(6.5), Policy());
+ boost::math::zeta(static_cast<T>(14.5), Policy());
+ boost::math::zeta(static_cast<T>(40.5), Policy());
+ }
+ static void do_init(const mpl::int_<113>&)
+ {
+ boost::math::zeta(static_cast<T>(0.5), Policy());
+ boost::math::zeta(static_cast<T>(1.5), Policy());
+ boost::math::zeta(static_cast<T>(3.5), Policy());
+ boost::math::zeta(static_cast<T>(5.5), Policy());
+ boost::math::zeta(static_cast<T>(9.5), Policy());
+ boost::math::zeta(static_cast<T>(16.5), Policy());
+ boost::math::zeta(static_cast<T>(25), Policy());
+ boost::math::zeta(static_cast<T>(70), Policy());
+ }
+ void force_instantiate()const{}
+ };
+ static const init initializer;
+ static void force_instantiate()
+ {
+ initializer.force_instantiate();
+ }
+};
+
+template <class T, class Policy, class tag>
+const typename zeta_initializer<T, Policy, tag>::init zeta_initializer<T, Policy, tag>::initializer;
+
} // detail
template <class T, class Policy>
@@ -929,6 +972,8 @@
>::type tag_type;
//typedef mpl::int_<0> tag_type;
+ detail::zeta_initializer<value_type, forwarding_policy, tag_type>::force_instantiate();
+
return policies::checked_narrowing_cast<result_type, forwarding_policy>(detail::zeta_imp(
static_cast<value_type>(s),
static_cast<value_type>(1 - static_cast<value_type>(s)),
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-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -11,7 +11,9 @@
#include <boost/lexical_cast.hpp>
#include <boost/type_traits/is_convertible.hpp>
-namespace boost{ namespace math{ namespace tools{
+namespace boost{ namespace math{
+
+namespace tools{
template <class T>
inline BOOST_CONSTEXPR_OR_CONST T make_big_value(long double v, const char*, mpl::true_ const&, mpl::false_ const&)
Modified: trunk/libs/math/test/pow_test.cpp
==============================================================================
--- trunk/libs/math/test/pow_test.cpp (original)
+++ trunk/libs/math/test/pow_test.cpp 2012-04-25 13:16:09 EDT (Wed, 25 Apr 2012)
@@ -182,14 +182,14 @@
test_with_big_exponents<long double, -1>();
cout << "Testing with concepts::real_concept precision bases and positive small exponents" << endl;
- test_with_small_exponents<concepts::real_concept, 1>();
+ test_with_small_exponents<boost::math::concepts::real_concept, 1>();
cout << "Testing with concepts::real_concept precision bases and negative small exponents" << endl;
- test_with_small_exponents<concepts::real_concept, -1>();
+ test_with_small_exponents<boost::math::concepts::real_concept, -1>();
cout << "Testing with concepts::real_concept precision bases and positive big exponents" << endl;
- test_with_big_exponents<concepts::real_concept, 1>();
+ test_with_big_exponents<boost::math::concepts::real_concept, 1>();
cout << "Testing with concepts::real_concept precision bases and negative big exponents" << endl;
- test_with_big_exponents<concepts::real_concept, -1>();
+ test_with_big_exponents<boost::math::concepts::real_concept, -1>();
#endif
test_return_types();
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