X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Fmath%2Fspecial_functions%2Fexpm1.hpp;fp=boost%2Fmath%2Fspecial_functions%2Fexpm1.hpp;h=7423dc5c811abeba40878489851ea7a4a367f780;hp=04094a0bd878c814126f8e8ba5135bd268857439;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/math/special_functions/expm1.hpp b/boost/math/special_functions/expm1.hpp index 04094a0..7423dc5 100644 --- a/boost/math/special_functions/expm1.hpp +++ b/boost/math/special_functions/expm1.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,37 @@ namespace detail expm1_series& operator=(const expm1_series&); }; +template +struct expm1_initializer +{ + struct init + { + init() + { + do_init(tag()); + } + template + static void do_init(const mpl::int_&){} + 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 const init initializer; + static void force_instantiate() + { + initializer.force_instantiate(); + } +}; + +template +const typename expm1_initializer::init expm1_initializer::initializer; + // // Algorithm expm1 is part of C99, but is not yet provided by many compilers. // @@ -95,7 +127,7 @@ T expm1_imp(T x, const mpl::int_<0>&, const Policy& pol) T zero = 0; T result = tools::sum_series(s, policies::get_epsilon(), max_iter, zero); #endif - policies::check_series_iterations("boost::math::expm1<%1%>(%1%)", max_iter, pol); + policies::check_series_iterations("boost::math::expm1<%1%>(%1%)", max_iter, pol); return result; } @@ -119,8 +151,8 @@ T expm1_imp(T x, const mpl::int_<53>&, const P& pol) return x; static const float Y = 0.10281276702880859e1f; - static const T n[] = { -0.28127670288085937e-1, 0.51278186299064534e0, -0.6310029069350198e-1, 0.11638457975729296e-1, -0.52143390687521003e-3, 0.21491399776965688e-4 }; - static const T d[] = { 1, -0.45442309511354755e0, 0.90850389570911714e-1, -0.10088963629815502e-1, 0.63003407478692265e-3, -0.17976570003654402e-4 }; + static const T n[] = { static_cast(-0.28127670288085937e-1), static_cast(0.51278186299064534e0), static_cast(-0.6310029069350198e-1), static_cast(0.11638457975729296e-1), static_cast(-0.52143390687521003e-3), static_cast(0.21491399776965688e-4) }; + static const T d[] = { 1, static_cast(-0.45442309511354755e0), static_cast(0.90850389570911714e-1), static_cast(-0.10088963629815502e-1), static_cast(0.63003407478692265e-3), static_cast(-0.17976570003654402e-4) }; T result = x * Y + x * tools::evaluate_polynomial(n, x) / tools::evaluate_polynomial(d, x); return result; @@ -147,22 +179,22 @@ T expm1_imp(T x, const mpl::int_<64>&, const P& pol) static const float Y = 0.10281276702880859375e1f; static const T n[] = { - -0.281276702880859375e-1L, - 0.512980290285154286358e0L, - -0.667758794592881019644e-1L, - 0.131432469658444745835e-1L, - -0.72303795326880286965e-3L, - 0.447441185192951335042e-4L, - -0.714539134024984593011e-6L + BOOST_MATH_BIG_CONSTANT(T, 64, -0.281276702880859375e-1), + BOOST_MATH_BIG_CONSTANT(T, 64, 0.512980290285154286358e0), + BOOST_MATH_BIG_CONSTANT(T, 64, -0.667758794592881019644e-1), + BOOST_MATH_BIG_CONSTANT(T, 64, 0.131432469658444745835e-1), + BOOST_MATH_BIG_CONSTANT(T, 64, -0.72303795326880286965e-3), + BOOST_MATH_BIG_CONSTANT(T, 64, 0.447441185192951335042e-4), + BOOST_MATH_BIG_CONSTANT(T, 64, -0.714539134024984593011e-6) }; static const T d[] = { - 1, - -0.461477618025562520389e0L, - 0.961237488025708540713e-1L, - -0.116483957658204450739e-1L, - 0.873308008461557544458e-3L, - -0.387922804997682392562e-4L, - 0.807473180049193557294e-6L + BOOST_MATH_BIG_CONSTANT(T, 64, 1.0), + BOOST_MATH_BIG_CONSTANT(T, 64, -0.461477618025562520389e0), + BOOST_MATH_BIG_CONSTANT(T, 64, 0.961237488025708540713e-1), + BOOST_MATH_BIG_CONSTANT(T, 64, -0.116483957658204450739e-1), + BOOST_MATH_BIG_CONSTANT(T, 64, 0.873308008461557544458e-3), + BOOST_MATH_BIG_CONSTANT(T, 64, -0.387922804997682392562e-4), + BOOST_MATH_BIG_CONSTANT(T, 64, 0.807473180049193557294e-6) }; T result = x * Y + x * tools::evaluate_polynomial(n, x) / tools::evaluate_polynomial(d, x); @@ -190,29 +222,29 @@ T expm1_imp(T x, const mpl::int_<113>&, const P& pol) static const float Y = 0.10281276702880859375e1f; static const T n[] = { - -0.28127670288085937499999999999999999854e-1L, - 0.51278156911210477556524452177540792214e0L, - -0.63263178520747096729500254678819588223e-1L, - 0.14703285606874250425508446801230572252e-1L, - -0.8675686051689527802425310407898459386e-3L, - 0.88126359618291165384647080266133492399e-4L, - -0.25963087867706310844432390015463138953e-5L, - 0.14226691087800461778631773363204081194e-6L, - -0.15995603306536496772374181066765665596e-8L, - 0.45261820069007790520447958280473183582e-10L + BOOST_MATH_BIG_CONSTANT(T, 113, -0.28127670288085937499999999999999999854e-1), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.51278156911210477556524452177540792214e0), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.63263178520747096729500254678819588223e-1), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.14703285606874250425508446801230572252e-1), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.8675686051689527802425310407898459386e-3), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.88126359618291165384647080266133492399e-4), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.25963087867706310844432390015463138953e-5), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.14226691087800461778631773363204081194e-6), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.15995603306536496772374181066765665596e-8), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.45261820069007790520447958280473183582e-10) }; static const T d[] = { - 1, - -0.45441264709074310514348137469214538853e0L, - 0.96827131936192217313133611655555298106e-1L, - -0.12745248725908178612540554584374876219e-1L, - 0.11473613871583259821612766907781095472e-2L, - -0.73704168477258911962046591907690764416e-4L, - 0.34087499397791555759285503797256103259e-5L, - -0.11114024704296196166272091230695179724e-6L, - 0.23987051614110848595909588343223896577e-8L, - -0.29477341859111589208776402638429026517e-10L, - 0.13222065991022301420255904060628100924e-12L + BOOST_MATH_BIG_CONSTANT(T, 113, 1.0), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.45441264709074310514348137469214538853e0), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.96827131936192217313133611655555298106e-1), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.12745248725908178612540554584374876219e-1), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.11473613871583259821612766907781095472e-2), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.73704168477258911962046591907690764416e-4), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.34087499397791555759285503797256103259e-5), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.11114024704296196166272091230695179724e-6), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.23987051614110848595909588343223896577e-8), + BOOST_MATH_BIG_CONSTANT(T, 113, -0.29477341859111589208776402638429026517e-10), + BOOST_MATH_BIG_CONSTANT(T, 113, 0.13222065991022301420255904060628100924e-12) }; T result = x * Y + x * tools::evaluate_polynomial(n, x) / tools::evaluate_polynomial(d, x); @@ -252,6 +284,8 @@ inline typename tools::promote_args::type expm1(T x, const Policy& /* pol */) >::type >::type tag_type; + detail::expm1_initializer::force_instantiate(); + return policies::checked_narrowing_cast(detail::expm1_imp( static_cast(x), tag_type(), forwarding_policy()), "boost::math::expm1<%1%>(%1%)"); @@ -271,7 +305,7 @@ inline float expm1(float x, const policies::policy<>&){ return ::expm1f(x); } inline long double expm1(long double x, const policies::policy<>&){ return ::expm1l(x); } # endif # else -inline float expm1(float x, const policies::policy<>&){ return ::expm1(x); } +inline float expm1(float x, const policies::policy<>&){ return static_cast(::expm1(x)); } # endif inline double expm1(double x, const policies::policy<>&){ return ::expm1(x); } #endif