From 86d2843fa41900fcc461a8b7c78f9cd53f3fb28b Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 3 Feb 2021 20:14:25 +0300 Subject: [PATCH 01/15] Fix for unable to find numeric literal operator Q --- test/test_cstdfloat.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_cstdfloat.cpp b/test/test_cstdfloat.cpp index 5fcf5a4c1..f32d68152 100644 --- a/test/test_cstdfloat.cpp +++ b/test/test_cstdfloat.cpp @@ -304,6 +304,8 @@ namespace test_cstdfloat } s = 8 * std::numeric_limits::epsilon(); val = 2.5; + + #ifndef __STRICT_ANSI__ BOOST_CHECK_CLOSE_FRACTION(std::asinh(val), T(1.6472311463710957106248586104436196635044144301932365282203100930843983757633104078778420255069424907777006132075516484778755360595913172299093829522950397895699619540523579875476513967578478619028438291006578604823887119907434Q), s); BOOST_CHECK_CLOSE_FRACTION(std::acosh(val), T(1.5667992369724110786640568625804834938620823510926588639329459980122148134693922696279968499622201141051039184050936311066453565386393240356562374302417843319480223211857615778787272615171906055455922537080327062362258846337050Q), s); val = 0.5; @@ -315,6 +317,7 @@ namespace test_cstdfloat BOOST_CHECK_CLOSE_FRACTION(std::erfc(val), T(0.0001006219221196368369043919750869567650647378577359344838904205345473577974091038552671703318943107024785655220699265379744608317286480734951503800965036293023579017150401810928534333133630603234998927812461267199856054467512Q), s); val = 0.125; BOOST_CHECK_CLOSE_FRACTION(std::expm1(val), T(0.1331484530668263168290072278117938725655031317451816259128200360788235778800483865139399907949417285732315270156473075657048210452584733998785564025916995261162759280700397984729320345630340659469435372721057879969170503978449Q), s); + #endif val = 20; s = 2; @@ -396,6 +399,8 @@ namespace test_cstdfloat T tol = 8 * std::numeric_limits::epsilon(); s = 2; + + #ifndef __STRICT_ANSI__ BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, s)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, 2)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, 2.0)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); @@ -410,18 +415,21 @@ namespace test_cstdfloat BOOST_CHECK_CLOSE_FRACTION(std::lgamma(val), T(39.339884187199494036224652394567381081691457206897853119937969989377572554993874476249340525204204720861169039582Q), tol); BOOST_CHECK_CLOSE_FRACTION(std::lgamma(val + 0), T(39.339884187199494036224652394567381081691457206897853119937969989377572554993874476249340525204204720861169039582Q), tol); + #endif BOOST_CHECK_EQUAL(std::lrint(val), 20); BOOST_CHECK_EQUAL(std::lrint(val * 2), 40); BOOST_CHECK_EQUAL(std::llrint(val), 20); BOOST_CHECK_EQUAL(std::llrint(val * 2), 40); + #ifndef __STRICT_ANSI__ val = 0.125; BOOST_CHECK_CLOSE_FRACTION(std::log1p(val), T(0.117783035656383454538794109470521705068480712564733141107348638794807720528133786929641528638208114949935615070Q), tol); BOOST_CHECK_CLOSE_FRACTION(std::log1p(val + 0), T(0.117783035656383454538794109470521705068480712564733141107348638794807720528133786929641528638208114949935615070Q), tol); val = 20; BOOST_CHECK_CLOSE_FRACTION(T(std::log2(val)), T(4.321928094887362347870319429489390175864831393024580612054756395815934776608625215850139743359370155099657371710Q), tol); BOOST_CHECK_CLOSE_FRACTION(T(std::log2(val + 0)), T(4.321928094887362347870319429489390175864831393024580612054756395815934776608625215850139743359370155099657371710Q), tol); + #endif BOOST_CHECK_EQUAL(T(std::nearbyint(val)), 20); BOOST_CHECK_EQUAL(T(std::nearbyint(val + 0.25)), 20); @@ -475,11 +483,15 @@ namespace test_cstdfloat i = 0; val = 5.25; tol = 3000; + + #ifndef __STRICT_ANSI__ BOOST_CHECK_CLOSE_FRACTION(std::tgamma(val), T(35.211611852799685705225257690531248115026311138908448314086859575901217653313145619623624570033258659272301335544Q), tol); BOOST_CHECK_CLOSE_FRACTION(std::tgamma(val + 1), T(184.86096222719834995243260287528905260388813347926935364895601277348139267989401450302402899267460796117958201160Q), tol); BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val)), T(38.054627680087074134959999057935229289375106958842157216608071191022933383261349115865003025220405558913196632792Q), tol); BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val + 1)), T(76.109255360174148269919998115870458578750213917684314433216142382045866766522698231730006050440811117826393265585Q), tol); + #endif + val = 15; BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val)), T(32768uL), tol); BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val + 1)), T(65536uL), tol); From 46a11ea6bb9bd003983a7924ab579f2724414f2c Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 3 Feb 2021 21:47:29 +0300 Subject: [PATCH 02/15] Use BOOST_MATH_LARGEST_FLOAT_C --- test/test_cstdfloat.cpp | 65 ++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/test/test_cstdfloat.cpp b/test/test_cstdfloat.cpp index f32d68152..cf80a7f79 100644 --- a/test/test_cstdfloat.cpp +++ b/test/test_cstdfloat.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef _MSC_VER # pragma warning(disable : 4127) // conditional expression is constant. @@ -305,19 +306,17 @@ namespace test_cstdfloat s = 8 * std::numeric_limits::epsilon(); val = 2.5; - #ifndef __STRICT_ANSI__ - BOOST_CHECK_CLOSE_FRACTION(std::asinh(val), T(1.6472311463710957106248586104436196635044144301932365282203100930843983757633104078778420255069424907777006132075516484778755360595913172299093829522950397895699619540523579875476513967578478619028438291006578604823887119907434Q), s); - BOOST_CHECK_CLOSE_FRACTION(std::acosh(val), T(1.5667992369724110786640568625804834938620823510926588639329459980122148134693922696279968499622201141051039184050936311066453565386393240356562374302417843319480223211857615778787272615171906055455922537080327062362258846337050Q), s); + BOOST_CHECK_CLOSE_FRACTION(std::asinh(val), T(BOOST_MATH_LARGEST_FLOAT_C(1.6472311463710957106248586104436196635044144301932365282203100930843983757633104078778420255069424907777006132075516484778755360595913172299093829522950397895699619540523579875476513967578478619028438291006578604823887119907434)), s); + BOOST_CHECK_CLOSE_FRACTION(std::acosh(val), T(BOOST_MATH_LARGEST_FLOAT_C(1.5667992369724110786640568625804834938620823510926588639329459980122148134693922696279968499622201141051039184050936311066453565386393240356562374302417843319480223211857615778787272615171906055455922537080327062362258846337050)), s); val = 0.5; - BOOST_CHECK_CLOSE_FRACTION(std::atanh(val), T(0.5493061443340548456976226184612628523237452789113747258673471668187471466093044834368078774068660443939850145329789328711840021129652599105264009353836387053015813845916906835896868494221804799518712851583979557605727959588753Q), s); + BOOST_CHECK_CLOSE_FRACTION(std::atanh(val), T(BOOST_MATH_LARGEST_FLOAT_C(0.5493061443340548456976226184612628523237452789113747258673471668187471466093044834368078774068660443939850145329789328711840021129652599105264009353836387053015813845916906835896868494221804799518712851583979557605727959588753)), s); val = 55.25; - BOOST_CHECK_CLOSE_FRACTION(std::cbrt(val), T(3.8087058015466360309383876359583281382991983919300128125378938779672144843676192684301168479657279498120767424724024965319869248797423276064015643361426189576415670917818313417529572608229017809069355688606687557031643655896118Q), s); + BOOST_CHECK_CLOSE_FRACTION(std::cbrt(val), T(BOOST_MATH_LARGEST_FLOAT_C(3.8087058015466360309383876359583281382991983919300128125378938779672144843676192684301168479657279498120767424724024965319869248797423276064015643361426189576415670917818313417529572608229017809069355688606687557031643655896118)), s); val = 2.75; - BOOST_CHECK_CLOSE_FRACTION(std::erf(val), T(0.9998993780778803631630956080249130432349352621422640655161095794654526422025908961447328296681056892975214344779300734620255391682713519265048496199034963706976420982849598189071465666866369396765001072187538732800143945532487Q), s); - BOOST_CHECK_CLOSE_FRACTION(std::erfc(val), T(0.0001006219221196368369043919750869567650647378577359344838904205345473577974091038552671703318943107024785655220699265379744608317286480734951503800965036293023579017150401810928534333133630603234998927812461267199856054467512Q), s); + BOOST_CHECK_CLOSE_FRACTION(std::erf(val), T(BOOST_MATH_LARGEST_FLOAT_C(0.9998993780778803631630956080249130432349352621422640655161095794654526422025908961447328296681056892975214344779300734620255391682713519265048496199034963706976420982849598189071465666866369396765001072187538732800143945532487)), s); + BOOST_CHECK_CLOSE_FRACTION(std::erfc(val), T(BOOST_MATH_LARGEST_FLOAT_C(0.0001006219221196368369043919750869567650647378577359344838904205345473577974091038552671703318943107024785655220699265379744608317286480734951503800965036293023579017150401810928534333133630603234998927812461267199856054467512)), s); val = 0.125; - BOOST_CHECK_CLOSE_FRACTION(std::expm1(val), T(0.1331484530668263168290072278117938725655031317451816259128200360788235778800483865139399907949417285732315270156473075657048210452584733998785564025916995261162759280700397984729320345630340659469435372721057879969170503978449Q), s); - #endif + BOOST_CHECK_CLOSE_FRACTION(std::expm1(val), T(BOOST_MATH_LARGEST_FLOAT_C(0.1331484530668263168290072278117938725655031317451816259128200360788235778800483865139399907949417285732315270156473075657048210452584733998785564025916995261162759280700397984729320345630340659469435372721057879969170503978449)), s); val = 20; s = 2; @@ -400,36 +399,32 @@ namespace test_cstdfloat T tol = 8 * std::numeric_limits::epsilon(); s = 2; - #ifndef __STRICT_ANSI__ - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, s)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, 2)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, 2.0)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(20, s)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(20.0, s)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val * 1, s)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val * 1, s * 1)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val * 1, 2)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val * 1, 2.0)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(20, s * 1)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(20.0, s * 1)), T(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530Q), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, s)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, 2)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val, 2.0)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(20, s)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(20.0, s)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val * 1, s)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val * 1, s * 1)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val * 1, 2)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(val * 1, 2.0)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(20, s * 1)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::hypot(20.0, s * 1)), T(BOOST_MATH_LARGEST_FLOAT_C(20.099751242241780540438529825519152373890046940052754581145656594656982463103940762472355384907904704732599006530)), tol); - BOOST_CHECK_CLOSE_FRACTION(std::lgamma(val), T(39.339884187199494036224652394567381081691457206897853119937969989377572554993874476249340525204204720861169039582Q), tol); - BOOST_CHECK_CLOSE_FRACTION(std::lgamma(val + 0), T(39.339884187199494036224652394567381081691457206897853119937969989377572554993874476249340525204204720861169039582Q), tol); - #endif + BOOST_CHECK_CLOSE_FRACTION(std::lgamma(val), T(BOOST_MATH_LARGEST_FLOAT_C(39.339884187199494036224652394567381081691457206897853119937969989377572554993874476249340525204204720861169039582)), tol); + BOOST_CHECK_CLOSE_FRACTION(std::lgamma(val + 0), T(BOOST_MATH_LARGEST_FLOAT_C(39.339884187199494036224652394567381081691457206897853119937969989377572554993874476249340525204204720861169039582)), tol); BOOST_CHECK_EQUAL(std::lrint(val), 20); BOOST_CHECK_EQUAL(std::lrint(val * 2), 40); BOOST_CHECK_EQUAL(std::llrint(val), 20); BOOST_CHECK_EQUAL(std::llrint(val * 2), 40); - #ifndef __STRICT_ANSI__ val = 0.125; - BOOST_CHECK_CLOSE_FRACTION(std::log1p(val), T(0.117783035656383454538794109470521705068480712564733141107348638794807720528133786929641528638208114949935615070Q), tol); - BOOST_CHECK_CLOSE_FRACTION(std::log1p(val + 0), T(0.117783035656383454538794109470521705068480712564733141107348638794807720528133786929641528638208114949935615070Q), tol); + BOOST_CHECK_CLOSE_FRACTION(std::log1p(val), T(BOOST_MATH_LARGEST_FLOAT_C(0.117783035656383454538794109470521705068480712564733141107348638794807720528133786929641528638208114949935615070)), tol); + BOOST_CHECK_CLOSE_FRACTION(std::log1p(val + 0), T(BOOST_MATH_LARGEST_FLOAT_C(0.117783035656383454538794109470521705068480712564733141107348638794807720528133786929641528638208114949935615070)), tol); val = 20; - BOOST_CHECK_CLOSE_FRACTION(T(std::log2(val)), T(4.321928094887362347870319429489390175864831393024580612054756395815934776608625215850139743359370155099657371710Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::log2(val + 0)), T(4.321928094887362347870319429489390175864831393024580612054756395815934776608625215850139743359370155099657371710Q), tol); - #endif + BOOST_CHECK_CLOSE_FRACTION(T(std::log2(val)), T(BOOST_MATH_LARGEST_FLOAT_C(4.321928094887362347870319429489390175864831393024580612054756395815934776608625215850139743359370155099657371710)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::log2(val + 0)), T(BOOST_MATH_LARGEST_FLOAT_C(4.321928094887362347870319429489390175864831393024580612054756395815934776608625215850139743359370155099657371710)), tol); BOOST_CHECK_EQUAL(T(std::nearbyint(val)), 20); BOOST_CHECK_EQUAL(T(std::nearbyint(val + 0.25)), 20); @@ -484,13 +479,11 @@ namespace test_cstdfloat val = 5.25; tol = 3000; - #ifndef __STRICT_ANSI__ - BOOST_CHECK_CLOSE_FRACTION(std::tgamma(val), T(35.211611852799685705225257690531248115026311138908448314086859575901217653313145619623624570033258659272301335544Q), tol); - BOOST_CHECK_CLOSE_FRACTION(std::tgamma(val + 1), T(184.86096222719834995243260287528905260388813347926935364895601277348139267989401450302402899267460796117958201160Q), tol); + BOOST_CHECK_CLOSE_FRACTION(std::tgamma(val), T(BOOST_MATH_LARGEST_FLOAT_C(35.211611852799685705225257690531248115026311138908448314086859575901217653313145619623624570033258659272301335544)), tol); + BOOST_CHECK_CLOSE_FRACTION(std::tgamma(val + 1), T(BOOST_MATH_LARGEST_FLOAT_C(184.86096222719834995243260287528905260388813347926935364895601277348139267989401450302402899267460796117958201160)), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val)), T(38.054627680087074134959999057935229289375106958842157216608071191022933383261349115865003025220405558913196632792Q), tol); - BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val + 1)), T(76.109255360174148269919998115870458578750213917684314433216142382045866766522698231730006050440811117826393265585Q), tol); - #endif + BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val)), T(BOOST_MATH_LARGEST_FLOAT_C(38.054627680087074134959999057935229289375106958842157216608071191022933383261349115865003025220405558913196632792)), tol); + BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val + 1)), T(BOOST_MATH_LARGEST_FLOAT_C(76.109255360174148269919998115870458578750213917684314433216142382045866766522698231730006050440811117826393265585)), tol); val = 15; BOOST_CHECK_CLOSE_FRACTION(T(std::exp2(val)), T(32768uL), tol); From 75706cb4c28da9ed577317930e064e3f5bb9d27c Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Tue, 9 Feb 2021 20:59:43 +0300 Subject: [PATCH 03/15] Remove MPL from lambert_w --- .../math/special_functions/lambert_w.hpp | 286 +++++++++--------- 1 file changed, 139 insertions(+), 147 deletions(-) diff --git a/include/boost/math/special_functions/lambert_w.hpp b/include/boost/math/special_functions/lambert_w.hpp index bd40bcd88..f161fc1b5 100644 --- a/include/boost/math/special_functions/lambert_w.hpp +++ b/include/boost/math/special_functions/lambert_w.hpp @@ -58,7 +58,6 @@ BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES_ITERATIONS // Show evaluation of #include // series functor. //#include // polynomial. #include // evaluate_polynomial. -#include #include #include // boost::math::tools::max_value(). #include @@ -68,13 +67,16 @@ BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES_ITERATIONS // Show evaluation of #include #include #include +#include +#include +#include // Needed for testing and diagnostics only. #include #include #include // For float_distance. -typedef double lookup_t; // Type for lookup table (double or float, or even long double?) +using lookup_t = double; // Type for lookup table (double or float, or even long double?) //#include "J:\Cpp\Misc\lambert_w_lookup_table_generator\lambert_w_lookup_table.ipp" // #include "lambert_w_lookup_table.ipp" // Boost.Math version. @@ -104,14 +106,14 @@ namespace lambert_w_detail { //! \param z Argument z for Lambert_w function. //! \returns New estimate of Lambert W, hopefully improved. //! -template +template inline T lambert_w_halley_step(T w_est, const T z) { BOOST_MATH_STD_USING T e = exp(w_est); w_est -= 2 * (w_est + 1) * (e * w_est - z) / (z * (w_est + 2) + e * (w_est * (w_est + 2) + 2)); return w_est; -} // template lambert_w_halley_step(T w_est, T z) +} // template lambert_w_halley_step(T w_est, T z) //! \brief Halley iterate to refine Lambert_w estimate, //! taking at least one Halley_step. @@ -121,9 +123,8 @@ inline T lambert_w_halley_step(T w_est, const T z) //! \tparam T floating-point (or fixed-point) type. //! \param z Argument z for Lambert_w function. //! \param w_est Lambert w estimate. -template -inline - T lambert_w_halley_iterate(T w_est, const T z) +template +inline T lambert_w_halley_iterate(T w_est, const T z) { BOOST_MATH_STD_USING static const T max_diff = boost::math::tools::root_epsilon() * fabs(w_est); @@ -137,21 +138,19 @@ inline diff = fabs(w_est - w_new); } return w_new; -} // template lambert_w_halley_iterate(T w_est, T z) +} // template lambert_w_halley_iterate(T w_est, T z) // Two Halley function versions that either -// single step (if boost::false_type) or iterate (if boost::true_type). +// single step (if std::false_type) or iterate (if std::true_type). // Selected at compile-time using parameter 3. -template -inline -T lambert_w_maybe_halley_iterate(T z, T w, boost::false_type const&) +template +inline T lambert_w_maybe_halley_iterate(T z, T w, std::false_type const&) { return lambert_w_halley_step(z, w); // Single step. } -template -inline -T lambert_w_maybe_halley_iterate(T z, T w, boost::true_type const&) +template +inline T lambert_w_maybe_halley_iterate(T z, T w, std::true_type const&) { return lambert_w_halley_iterate(z, w); // Iterate steps. } @@ -161,30 +160,26 @@ T lambert_w_maybe_halley_iterate(T z, T w, boost::true_type const&) //! reduce argument z to double precision (if true_type). //! Version is selected at compile-time using parameter 2. -template -inline -double maybe_reduce_to_double(const T& z, const boost::true_type&) +template +inline double maybe_reduce_to_double(const T& z, const std::true_type&) { return static_cast(z); // Reduce to double precision. } -template -inline -T maybe_reduce_to_double(const T& z, const boost::false_type&) +template +inline T maybe_reduce_to_double(const T& z, const std::false_type&) { // Don't reduce to double. return z; } -template -inline -double must_reduce_to_double(const T& z, const boost::true_type&) +template +inline double must_reduce_to_double(const T& z, const std::true_type&) { return static_cast(z); // Reduce to double precision. } -template -inline -double must_reduce_to_double(const T& z, const boost::false_type&) +template +inline double must_reduce_to_double(const T& z, const std::false_type&) { // try a lexical_cast and hope for the best: return boost::lexical_cast(z); } @@ -201,8 +196,7 @@ double must_reduce_to_double(const T& z, const boost::false_type&) // Schroeder refinement, called unless NOT required by precision policy. template -inline -T schroeder_update(const T w, const T y) +inline T schroeder_update(const T w, const T y) { // Compute derivatives using 5th order Schroeder refinement. // Since this is the final step, it will always use the highest precision type T. @@ -496,28 +490,28 @@ T lambert_w_singularity_series(const T p) //! but for the tag_type selection to work, they all must include Policy in their signature. // Forward declaration of variants of lambert_w0_small_z. -template -T lambert_w0_small_z(T x, const Policy&, boost::integral_constant const&); // for float (32-bit) type. +template +T lambert_w0_small_z(T x, const Policy&, std::integral_constant const&); // for float (32-bit) type. -template -T lambert_w0_small_z(T x, const Policy&, boost::integral_constant const&); // for double (64-bit) type. +template +T lambert_w0_small_z(T x, const Policy&, std::integral_constant const&); // for double (64-bit) type. -template -T lambert_w0_small_z(T x, const Policy&, boost::integral_constant const&); // for long double (double extended 80-bit) type. +template +T lambert_w0_small_z(T x, const Policy&, std::integral_constant const&); // for long double (double extended 80-bit) type. -template -T lambert_w0_small_z(T x, const Policy&, boost::integral_constant const&); // for long double (128-bit) type. +template +T lambert_w0_small_z(T x, const Policy&, std::integral_constant const&); // for long double (128-bit) type. -template -T lambert_w0_small_z(T x, const Policy&, boost::integral_constant const&); // for float128 quadmath Q type. +template +T lambert_w0_small_z(T x, const Policy&, std::integral_constant const&); // for float128 quadmath Q type. -template -T lambert_w0_small_z(T x, const Policy&, boost::integral_constant const&); // Generic multiprecision T. +template +T lambert_w0_small_z(T x, const Policy&, std::integral_constant const&); // Generic multiprecision T. // Set tag_type depending on max_digits10. -template +template T lambert_w0_small_z(T x, const Policy& pol) { //std::numeric_limits::max_digits10 == 36 ? 3 : // 128-bit long double. - typedef boost::integral_constant::is_specialized == 0 ? 5 : #ifndef BOOST_NO_CXX11_NUMERIC_LIMITS std::numeric_limits::max_digits10 <= 9 ? 0 : // for float 32-bit. @@ -531,11 +525,10 @@ T lambert_w0_small_z(T x, const Policy& pol) std::numeric_limits::digits <= 64 ? 2 : // for 80-bit double extended. std::numeric_limits::digits <= 113 ? 4 // for both 128-bit long double (3) and 128-bit quad suffix Q type (4). #endif - : 5 // All Generic multiprecision types. - > tag_type; + : 5>; // All Generic multiprecision types. // std::cout << "\ntag type = " << tag_type << std::endl; // error C2275: 'tag_type': illegal use of this type as an expression. return lambert_w0_small_z(x, pol, tag_type()); -} // template T lambert_w0_small_z(T x) +} // template T lambert_w0_small_z(T x) //! Specialization of float (32-bit) series expansion used for small z (abs(z) < 0.05). // Only 9 Coefficients are computed to 21 decimal digits precision, ample for 32-bit float used by most platforms. @@ -543,8 +536,8 @@ T lambert_w0_small_z(T x, const Policy& pol) // N[InverseSeries[Series[z Exp[z],{z,0,34}]],50], // as proposed by Tosio Fukushima and implemented by Darko Veberic. -template -T lambert_w0_small_z(T z, const Policy&, boost::integral_constant const&) +template +T lambert_w0_small_z(T z, const Policy&, std::integral_constant const&) { #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES std::streamsize prec = std::cout.precision(std::numeric_limits::max_digits10); // Save. @@ -568,15 +561,15 @@ T lambert_w0_small_z(T z, const Policy&, boost::integral_constant const& #endif // BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES return result; -} // template T lambert_w0_small_z(T x, boost::integral_constant const&) +} // template T lambert_w0_small_z(T x, std::integral_constant const&) //! Specialization of double (64-bit double) series expansion used for small z (abs(z) < 0.05). // 17 Coefficients are computed to 21 decimal digits precision suitable for 64-bit double used by most platforms. // Taylor series coefficients used are computed by Wolfram to 50 decimal digits using instruction // N[InverseSeries[Series[z Exp[z],{z,0,34}]],50], as proposed by Tosio Fukushima and implemented by Veberic. -template -T lambert_w0_small_z(const T z, const Policy&, boost::integral_constant const&) +template +T lambert_w0_small_z(const T z, const Policy&, std::integral_constant const&) { #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES std::streamsize prec = std::cout.precision(std::numeric_limits::max_digits10); // Save. @@ -608,15 +601,15 @@ T lambert_w0_small_z(const T z, const Policy&, boost::integral_constant #endif // BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES return result; -} // T lambert_w0_small_z(const T z, boost::integral_constant const&) +} // T lambert_w0_small_z(const T z, std::integral_constant const&) //! Specialization of long double (80-bit double extended) series expansion used for small z (abs(z) < 0.05). // 21 Coefficients are computed to 21 decimal digits precision suitable for 80-bit long double used by some // platforms including GCC and Clang when generating for Intel X86 floating-point processors with 80-bit operations enabled (the default). // (This is NOT used by Microsoft Visual Studio where double and long always both use only 64-bit type. // Nor used for 128-bit float128.) -template -T lambert_w0_small_z(const T z, const Policy&, boost::integral_constant const&) +template +T lambert_w0_small_z(const T z, const Policy&, std::integral_constant const&) { #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES std::streamsize precision = std::cout.precision(std::numeric_limits::max_digits10); // Save. @@ -676,7 +669,7 @@ z * (2.154990206091088289321708745358647e6L // z^20 distance -5 without term 20 std::cout.precision(precision); // Restore. #endif // BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES return result; -} // long double lambert_w0_small_z(const T z, boost::integral_constant const&) +} // long double lambert_w0_small_z(const T z, std::integral_constant const&) //! Specialization of 128-bit long double series expansion used for small z (abs(z) < 0.05). // 34 Taylor series coefficients used are computed by Wolfram to 50 decimal digits using instruction @@ -686,8 +679,8 @@ z * (2.154990206091088289321708745358647e6L // z^20 distance -5 without term 20 // nor multiprecision type cpp_bin_float_quad that can only be initialised at full precision of the type // constructed with a decimal digit string like "2.6666666666666666666666666666666666666666666666667".) -template -T lambert_w0_small_z(const T z, const Policy&, boost::integral_constant const&) +template +T lambert_w0_small_z(const T z, const Policy&, std::integral_constant const&) { #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES std::streamsize precision = std::cout.precision(std::numeric_limits::max_digits10); // Save. @@ -719,7 +712,7 @@ T lambert_w0_small_z(const T z, const Policy&, boost::integral_constant std::cout.precision(precision); // Restore. #endif // BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES return result; -} // T lambert_w0_small_z(const T z, boost::integral_constant const&) +} // T lambert_w0_small_z(const T z, std::integral_constant const&) //! Specialization of 128-bit quad series expansion used for small z (abs(z) < 0.05). // 34 Taylor series coefficients used were computed by Wolfram to 50 decimal digits using instruction @@ -732,8 +725,8 @@ T lambert_w0_small_z(const T z, const Policy&, boost::integral_constant // it is slightly slower than getting a double approximation followed by a single Halley step. #ifdef BOOST_HAS_FLOAT128 -template -T lambert_w0_small_z(const T z, const Policy&, boost::integral_constant const&) +template +T lambert_w0_small_z(const T z, const Policy&, std::integral_constant const&) { #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES std::streamsize precision = std::cout.precision(std::numeric_limits::max_digits10); // Save. @@ -784,24 +777,24 @@ T lambert_w0_small_z(const T z, const Policy&, boost::integral_constant #endif // BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES return result; -} // T lambert_w0_small_z(const T z, boost::integral_constant const&) float128 +} // T lambert_w0_small_z(const T z, std::integral_constant const&) float128 #else -template -inline T lambert_w0_small_z(const T z, const Policy& pol, boost::integral_constant const&) +template +inline T lambert_w0_small_z(const T z, const Policy& pol, std::integral_constant const&) { - return lambert_w0_small_z(z, pol, boost::integral_constant()); + return lambert_w0_small_z(z, pol, std::integral_constant()); } #endif // BOOST_HAS_FLOAT128 //! Series functor to compute series term using pow and factorial. //! \details Functor is called after evaluating polynomial with the coefficients as rationals below. -template +template struct lambert_w0_small_z_series_term { - typedef T result_type; + using result_type = T; //! \param _z Lambert W argument z. //! \param -term -pow<18>(z) / 6402373705728000uLL //! \param _k number of terms == initially 18 @@ -825,11 +818,11 @@ private: int k; T z; T term; -}; // template struct lambert_w0_small_z_series_term +}; // template struct lambert_w0_small_z_series_term //! Generic variant for T a User-defined types like Boost.Multiprecision. -template -inline T lambert_w0_small_z(T z, const Policy& pol, boost::integral_constant const&) +template +inline T lambert_w0_small_z(T z, const Policy& pol, std::integral_constant const&) { #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES std::streamsize precision = std::cout.precision(std::numeric_limits::max_digits10); // Save. @@ -913,7 +906,7 @@ inline T lambert_w0_small_z(T z, const Policy& pol, boost::integral_constant::max_digits10); T result = evaluate_polynomial(coeff, z); - // template + // template // V evaluate_polynomial(const T(&poly)[N], const V& val); // Size of coeff found from N //std::cout << "evaluate_polynomial(coeff, z); == " << result << std::endl; @@ -942,7 +935,7 @@ inline T lambert_w0_small_z(T z, const Policy& pol, boost::integral_constant(); // Max iterations from policy. + std::uintmax_t max_iter = policies::get_max_series_iterations(); // Max iterations from policy. #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES std::cout << "max iter from policy = " << max_iter << std::endl; // // max iter from policy = 1000000 is default. @@ -950,7 +943,7 @@ inline T lambert_w0_small_z(T z, const Policy& pol, boost::integral_constant(), max_iter, result); // result == evaluate_polynomial. - //sum_series(Functor& func, int bits, boost::uintmax_t& max_terms, const U& init_value) + //sum_series(Functor& func, int bits, std::uintmax_t& max_terms, const U& init_value) // std::cout << "sum_series(s, get_epsilon(), max_iter, result); = " << result << std::endl; //T epsilon = get_epsilon(); @@ -965,13 +958,12 @@ inline T lambert_w0_small_z(T z, const Policy& pol, boost::integral_constant inline T lambert_w0_small_z_series(T z, const Policy& pol) +} // template inline T lambert_w0_small_z_series(T z, const Policy& pol) // Approximate lambert_w0 (used for z values that are outside range of lookup table or rational functions) // Corless equation 4.19, page 349, and Chapeau-Blondeau equation 20, page 2162. template -inline -T lambert_w0_approx(T z) +inline T lambert_w0_approx(T z) { BOOST_MATH_STD_USING T lz = log(z); @@ -995,7 +987,7 @@ T lambert_w0_approx(T z) //! For higher precisions, a 64-bit double approximation is computed first, //! and then refined using Halley iterations. -template +template inline T do_get_near_singularity_param(T z) { BOOST_MATH_STD_USING @@ -1003,24 +995,24 @@ inline T do_get_near_singularity_param(T z) const T p = sqrt(p2); return p; } -template +template inline T get_near_singularity_param(T z, const Policy) { - typedef typename policies::evaluation::type value_type; + using value_type = typename policies::evaluation::type; return static_cast(do_get_near_singularity_param(static_cast(z))); } // Forward declarations: -//template T lambert_w0_small_z(T z, const Policy& pol); -//template -//T lambert_w0_imp(T w, const Policy& pol, const boost::integral_constant&); // 32 bit usually float. -//template -//T lambert_w0_imp(T w, const Policy& pol, const boost::integral_constant&); // 64 bit usually double. -//template -//T lambert_w0_imp(T w, const Policy& pol, const boost::integral_constant&); // 80-bit long double. +//template T lambert_w0_small_z(T z, const Policy& pol); +//template +//T lambert_w0_imp(T w, const Policy& pol, const std::integral_constant&); // 32 bit usually float. +//template +//T lambert_w0_imp(T w, const Policy& pol, const std::integral_constant&); // 64 bit usually double. +//template +//T lambert_w0_imp(T w, const Policy& pol, const std::integral_constant&); // 80-bit long double. -template +template T lambert_w_positive_rational_float(T z) { BOOST_MATH_STD_USING @@ -1164,7 +1156,7 @@ T lambert_w_positive_rational_float(T z) } } -template +template T lambert_w_negative_rational_float(T z, const Policy& pol) { BOOST_MATH_STD_USING @@ -1223,19 +1215,19 @@ T lambert_w_negative_rational_float(T z, const Policy& pol) } //! Lambert_w0 @b 'float' implementation, selected when T is 32-bit precision. -template -inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant&) +template +inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) { - static const char* function = "boost::math::lambert_w0<%1%>"; // For error messages. + static std::string function = "boost::math::lambert_w0<%1%>"; // For error messages. BOOST_MATH_STD_USING // Aid ADL of std functions. if ((boost::math::isnan)(z)) { - return boost::math::policies::raise_domain_error(function, "Expected a value > -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function.c_str(), "Expected a value > -e^-1 (-0.367879...) but got %1%.", z, pol); } if ((boost::math::isinf)(z)) { - return boost::math::policies::raise_overflow_error(function, "Expected a finite value but got %1%.", z, pol); + return boost::math::policies::raise_overflow_error(function.c_str(), "Expected a finite value but got %1%.", z, pol); } if (z >= 0.05) // Fukushima switch point. @@ -1246,16 +1238,16 @@ inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant(function, "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function.c_str(), "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); return -1; } else // z < 0.05 { return lambert_w_negative_rational_float(z, pol); } -} // T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant&) for 32-bit usually float. +} // T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) for 32-bit usually float. -template +template T lambert_w_positive_rational_double(T z) { BOOST_MATH_STD_USING @@ -1491,7 +1483,7 @@ T lambert_w_positive_rational_double(T z) } } -template +template T lambert_w_negative_rational_double(T z, const Policy& pol) { BOOST_MATH_STD_USING @@ -1622,10 +1614,10 @@ T lambert_w_negative_rational_double(T z, const Policy& pol) } //! Lambert_w0 @b 'double' implementation, selected when T is 64-bit precision. -template -inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant&) +template +inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) { - static const char* function = "boost::math::lambert_w0<%1%>"; + static std::string function = "boost::math::lambert_w0<%1%>"; BOOST_MATH_STD_USING // Aid ADL of std functions. // Detect unusual case of 32-bit double with a wider/64-bit long double @@ -1637,11 +1629,11 @@ inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant(function, "Expected a value > -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function.c_str(), "Expected a value > -e^-1 (-0.367879...) but got %1%.", z, pol); } if ((boost::math::isinf)(z)) { - return boost::math::policies::raise_overflow_error(function, "Expected a finite value but got %1%.", z, pol); + return boost::math::policies::raise_overflow_error(function.c_str(), "Expected a finite value but got %1%.", z, pol); } if (z >= 0.05) @@ -1652,7 +1644,7 @@ inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant(function, "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function.c_str(), "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); } return -1; } @@ -1660,22 +1652,22 @@ inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant&) 64-bit precision, usually double. +} // T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) 64-bit precision, usually double. //! lambert_W0 implementation for extended precision types including //! long double (80-bit and 128-bit), ??? //! quad float128, Boost.Multiprecision types like cpp_bin_float_quad, cpp_bin_float_50... -template -inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant&) +template +inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) { - static const char* function = "boost::math::lambert_w0<%1%>"; + static std::string function = "boost::math::lambert_w0<%1%>"; BOOST_MATH_STD_USING // Aid ADL of std functions. // Filter out special cases first: if ((boost::math::isnan)(z)) { - return boost::math::policies::raise_domain_error(function, "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function.c_str(), "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); } if (fabs(z) <= 0.05f) { @@ -1686,7 +1678,7 @@ inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant(function, 0, pol); + return policies::raise_overflow_error(function.c_str(), 0, pol); // Or might return infinity if available else max_value, // but other Boost.Math special functions raise overflow. } @@ -1707,7 +1699,7 @@ inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant(function, "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function.c_str(), "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); } // z is very close (within 0.01) of the branch singularity at -e^-1 // so use a series approximation proposed by Corless et al. @@ -1723,27 +1715,27 @@ inline T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant::type precision_type; - typedef boost::integral_constant::type; + using tag_type = std::integral_constant 113) ? true // Unknown at compile-time, variable/arbitrary, or more than float128 or cpp_bin_quad 128-bit precision. : false // float, double, float128, cpp_bin_quad 128-bit, so single Halley step. - > tag_type; + >; // For speed, we also cast z to type double when that is possible - // if (boost::is_constructible() == true). - T w = lambert_w0_imp(maybe_reduce_to_double(z, boost::is_constructible()), pol, boost::integral_constant()); + // if (std::is_constructible() == true). + T w = lambert_w0_imp(maybe_reduce_to_double(z, std::is_constructible()), pol, std::integral_constant()); return lambert_w_maybe_halley_iterate(w, z, tag_type()); -} // T lambert_w0_imp(T z, const Policy& pol, const boost::integral_constant&) all extended precision types. +} // T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) all extended precision types. // Lambert w-1 implementation // ============================================================================================== //! Lambert W for W-1 branch, -max(z) < z <= -1/e. // TODO is -max(z) allowed? -template +template T lambert_wm1_imp(const T z, const Policy& pol) { // Catch providing an integer value as parameter x to lambert_w, for example, lambert_w(1). @@ -1758,19 +1750,19 @@ T lambert_wm1_imp(const T z, const Policy& pol) BOOST_MATH_STD_USING // Aid argument dependent lookup (ADL) of abs. - const char* function = "boost::math::lambert_wm1()"; // Used for error messages. + std::string function = "boost::math::lambert_wm1()"; // Used for error messages. // Check for edge and corner cases first: if ((boost::math::isnan)(z)) { - return policies::raise_domain_error(function, + return policies::raise_domain_error(function.c_str(), "Argument z is NaN!", z, pol); } // isnan if ((boost::math::isinf)(z)) { - return policies::raise_domain_error(function, + return policies::raise_domain_error(function.c_str(), "Argument z is infinite!", z, pol); } // isinf @@ -1790,7 +1782,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) { // All real types except arbitrary precision. if (!(boost::math::isnormal)(z)) { // Almost zero - might also just return infinity like z == 0 or max_value? - return policies::raise_overflow_error(function, + return policies::raise_overflow_error(function.c_str(), "Argument z = %1% is denormalized! (must be z > (std::numeric_limits::min)() or z == 0)", z, pol); } @@ -1798,7 +1790,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) if (z > static_cast(0)) { // - return policies::raise_domain_error(function, + return policies::raise_domain_error(function.c_str(), "Argument z = %1% is out of range (z <= 0) for Lambert W-1 branch! (Try Lambert W0 branch?)", z, pol); } @@ -1806,7 +1798,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) { // z is denormalized, so cannot be computed. // -std::numeric_limits::min() is smallest for type T, // for example, for double: lambert_wm1(-2.2250738585072014e-308) = -714.96865723796634 - return policies::raise_overflow_error(function, + return policies::raise_overflow_error(function.c_str(), "Argument z = %1% is too small (z < -std::numeric_limits::min so denormalized) for Lambert W-1 branch!", z, pol); } @@ -1817,7 +1809,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) // z is too negative for the W-1 (or W0) branch. if (z < -boost::math::constants::exp_minus_one()) // > singularity/branch point z = -exp(-1) = -3.6787944. { - return policies::raise_domain_error(function, + return policies::raise_domain_error(function.c_str(), "Argument z = %1% is out of range (z < -exp(-1) = -3.6787944... <= 0) for Lambert W-1 (or W0) branch!", z, pol); } @@ -1843,7 +1835,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) return w_series; } // Should not get here. - return policies::raise_domain_error(function, + return policies::raise_domain_error(function.c_str(), "Argument z = %1% is out of range for Lambert W-1 branch. (Should not get here - please report!)", z, pol); } // if (z < -0.35) @@ -1919,7 +1911,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) using boost::math::policies::digits2; using boost::math::policies::policy; // Compute a 50-bit precision approximate W0 in a double (no Halley refinement). - T double_approx(static_cast(lambert_wm1_imp(must_reduce_to_double(z, boost::is_constructible()), policy >()))); + T double_approx(static_cast(lambert_wm1_imp(must_reduce_to_double(z, std::is_constructible()), policy>()))); #ifdef BOOST_MATH_INSTRUMENT_LAMBERT_WM1_NOT_BUILTIN std::streamsize saved_precision = std::cout.precision(std::numeric_limits::max_digits10); std::cout << "Lambert_wm1 Argument Type " << typeid(T).name() << " approximation double = " << double_approx << std::endl; @@ -1955,7 +1947,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) } // else z < g[63] == -1.0264389699511303e-26, so Lambert W-1 integer part > 64. // This should not now occur (should be caught by test and code above) so should be a logic_error? - return policies::raise_domain_error(function, + return policies::raise_domain_error(function.c_str(), "Argument z = %1% is too small (< -1.026439e-26) (logic error - please report!)", z, pol); overshot: @@ -2009,7 +2001,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) using lambert_w_lookup::halves; using lambert_w_lookup::sqrtwm1s; - typedef typename mpl::if_c::value, lookup_t, T>::type calc_type; + using calc_type = typename std::conditional::value, lookup_t, T>::type; calc_type w = -static_cast(n); // Equation 25, calc_type y = static_cast(z * wm1es[n - 1]); // Equation 26, @@ -2045,82 +2037,82 @@ T lambert_wm1_imp(const T z, const Policy& pol) ///////////////////////////// User Lambert w functions. ////////////////////////////// //! Lambert W0 using User-defined policy. - template + template inline typename boost::math::tools::promote_args::type lambert_w0(T z, const Policy& pol) { // Promote integer or expression template arguments to double, // without doing any other internal promotion like float to double. - typedef typename tools::promote_args::type result_type; + using result_type = typename tools::promote_args::type; // Work out what precision has been selected, // based on the Policy and the number type. - typedef typename policies::precision::type precision_type; + using precision_type = typename policies::precision::type; // and then select the correct implementation based on that precision (not the type T): - typedef boost::integral_constant 53) ? 0 // either variable precision (0), or greater than 64-bit precision. : (precision_type::value <= 24) ? 1 // 32-bit (probably float) precision. : 2 // 64-bit (probably double) precision. - > tag_type; + >; return lambert_w_detail::lambert_w0_imp(result_type(z), pol, tag_type()); // } // lambert_w0(T z, const Policy& pol) //! Lambert W0 using default policy. - template + template inline typename tools::promote_args::type lambert_w0(T z) { // Promote integer or expression template arguments to double, // without doing any other internal promotion like float to double. - typedef typename tools::promote_args::type result_type; + using result_type = typename tools::promote_args::type; // Work out what precision has been selected, based on the Policy and the number type. // For the default policy version, we want the *default policy* precision for T. - typedef typename policies::precision >::type precision_type; + using precision_type = typename policies::precision>::type; // and then select the correct implementation based on that (not the type T): - typedef boost::integral_constant 53) ? 0 // either variable precision (0), or greater than 64-bit precision. : (precision_type::value <= 24) ? 1 // 32-bit (probably float) precision. : 2 // 64-bit (probably double) precision. - > tag_type; + >; return lambert_w_detail::lambert_w0_imp(result_type(z), policies::policy<>(), tag_type()); } // lambert_w0(T z) using default policy. //! W-1 branch (-max(z) < z <= -1/e). //! Lambert W-1 using User-defined policy. - template + template inline typename tools::promote_args::type lambert_wm1(T z, const Policy& pol) { // Promote integer or expression template arguments to double, // without doing any other internal promotion like float to double. - typedef typename tools::promote_args::type result_type; + using result_type = typename tools::promote_args::type; return lambert_w_detail::lambert_wm1_imp(result_type(z), pol); // } //! Lambert W-1 using default policy. - template + template inline typename tools::promote_args::type lambert_wm1(T z) { - typedef typename tools::promote_args::type result_type; + using result_type = typename tools::promote_args::type; return lambert_w_detail::lambert_wm1_imp(result_type(z), policies::policy<>()); } // lambert_wm1(T z) // First derivative of Lambert W0 and W-1. - template + template inline typename tools::promote_args::type lambert_w0_prime(T z, const Policy& pol) { - typedef typename tools::promote_args::type result_type; + using result_type = typename tools::promote_args::type; using std::numeric_limits; if (z == 0) { @@ -2144,19 +2136,19 @@ T lambert_wm1_imp(const T z, const Policy& pol) return w / (z * (1 + w)); } // lambert_w0_prime(T z) - template + template inline typename tools::promote_args::type lambert_w0_prime(T z) { return lambert_w0_prime(z, policies::policy<>()); } - template + template inline typename tools::promote_args::type lambert_wm1_prime(T z, const Policy& pol) { using std::numeric_limits; - typedef typename tools::promote_args::type result_type; + using result_type = typename tools::promote_args::type; //if (z == 0) //{ // return static_cast(1); @@ -2171,7 +2163,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) return w/(z*(1+w)); } // lambert_wm1_prime(T z) - template + template inline typename tools::promote_args::type lambert_wm1_prime(T z) { From e2066c363ac6e10c78d6b94c2f6579374e1b04c3 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Tue, 9 Feb 2021 22:13:59 +0300 Subject: [PATCH 04/15] Replace integral_constant in calculate_constants --- .../math/constants/calculate_constants.hpp | 157 +++++++++--------- 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/include/boost/math/constants/calculate_constants.hpp b/include/boost/math/constants/calculate_constants.hpp index a64215a7a..8ccab356c 100644 --- a/include/boost/math/constants/calculate_constants.hpp +++ b/include/boost/math/constants/calculate_constants.hpp @@ -8,12 +8,13 @@ #ifndef BOOST_MATH_CALCULATE_CONSTANTS_CONSTANTS_INCLUDED #define BOOST_MATH_CALCULATE_CONSTANTS_CONSTANTS_INCLUDED #include +#include namespace boost{ namespace math{ namespace constants{ namespace detail{ template template -inline T constant_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING @@ -68,21 +69,21 @@ inline T constant_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost:: template template -inline T constant_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return 2 * pi > >(); } template // 2 / pi template -inline T constant_two_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_two_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return 2 / pi > >(); } template // sqrt(2/pi) template -inline T constant_root_two_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_two_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt((2 / pi > >())); @@ -90,14 +91,14 @@ inline T constant_root_two_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_ template template -inline T constant_one_div_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return 1 / two_pi > >(); } template template -inline T constant_root_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(pi > >()); @@ -105,7 +106,7 @@ inline T constant_root_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((bo template template -inline T constant_root_half_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_half_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(pi > >() / 2); @@ -113,7 +114,7 @@ inline T constant_root_half_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPE template template -inline T constant_root_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(two_pi > >()); @@ -121,7 +122,7 @@ inline T constant_root_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC template template -inline T constant_log_root_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_log_root_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return log(root_two_pi > >()); @@ -129,7 +130,7 @@ inline T constant_log_root_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_ template template -inline T constant_root_ln_four::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_ln_four::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(log(static_cast(4))); @@ -137,7 +138,7 @@ inline T constant_root_ln_four::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPE template template -inline T constant_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // // Although we can clearly calculate this from first principles, this hooks into @@ -150,14 +151,14 @@ inline T constant_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::i template template -inline T constant_half::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_half::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return static_cast(1) / static_cast(2); } template template -inline T constant_euler::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_euler::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING // @@ -192,7 +193,7 @@ inline T constant_euler::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boos template template -inline T constant_euler_sqr::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_euler_sqr::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return euler > >() @@ -201,7 +202,7 @@ inline T constant_euler_sqr::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(( template template -inline T constant_one_div_euler::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_euler::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(1) @@ -211,7 +212,7 @@ inline T constant_one_div_euler::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SP template template -inline T constant_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(static_cast(2)); @@ -220,7 +221,7 @@ inline T constant_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_root_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(static_cast(3)); @@ -228,7 +229,7 @@ inline T constant_root_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC( template template -inline T constant_half_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_half_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(static_cast(2)) / 2; @@ -236,7 +237,7 @@ inline T constant_half_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SP template template -inline T constant_ln_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_ln_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // // Although there are good ways to calculate this from scratch, this hooks into @@ -249,7 +250,7 @@ inline T constant_ln_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boo template template -inline T constant_ln_ten::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_ln_ten::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return log(static_cast(10)); @@ -257,7 +258,7 @@ inline T constant_ln_ten::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boo template template -inline T constant_ln_ln_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_ln_ln_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return log(log(static_cast(2))); @@ -265,7 +266,7 @@ inline T constant_ln_ln_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(( template template -inline T constant_third::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_third::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(1) / static_cast(3); @@ -273,7 +274,7 @@ inline T constant_third::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boos template template -inline T constant_twothirds::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_twothirds::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(2) / static_cast(3); @@ -281,7 +282,7 @@ inline T constant_twothirds::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(( template template -inline T constant_two_thirds::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_two_thirds::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(2) / static_cast(3); @@ -289,7 +290,7 @@ inline T constant_two_thirds::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC( template template -inline T constant_three_quarters::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_three_quarters::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(3) / static_cast(4); @@ -297,7 +298,7 @@ inline T constant_three_quarters::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S template template -inline T constant_sixth::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_sixth::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(1) / static_cast(6); @@ -306,21 +307,21 @@ inline T constant_sixth::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boos // Pi and related constants. template template -inline T constant_pi_minus_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_pi_minus_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return pi > >() - static_cast(3); } template template -inline T constant_four_minus_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_four_minus_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return static_cast(4) - pi > >(); } template template -inline T constant_exp_minus_half::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_exp_minus_half::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return exp(static_cast(-0.5)); @@ -328,7 +329,7 @@ inline T constant_exp_minus_half::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S template template -inline T constant_exp_minus_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_exp_minus_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return exp(static_cast(-1.)); @@ -336,28 +337,28 @@ inline T constant_exp_minus_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SP template template -inline T constant_one_div_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return static_cast(1) / root_two > >(); } template template -inline T constant_one_div_root_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_root_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return static_cast(1) / root_pi > >(); } template template -inline T constant_one_div_root_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_root_two_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return static_cast(1) / root_two_pi > >(); } template template -inline T constant_root_one_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_one_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(static_cast(1) / pi > >()); @@ -365,7 +366,7 @@ inline T constant_root_one_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_ template template -inline T constant_four_thirds_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_four_thirds_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() * static_cast(4) / static_cast(3); @@ -373,7 +374,7 @@ inline T constant_four_thirds_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S template template -inline T constant_half_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_half_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() / static_cast(2); @@ -381,7 +382,7 @@ inline T constant_half_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((bo template template -inline T constant_third_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_third_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() / static_cast(3); @@ -389,7 +390,7 @@ inline T constant_third_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_sixth_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_sixth_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() / static_cast(6); @@ -397,7 +398,7 @@ inline T constant_sixth_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_two_thirds_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_two_thirds_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() * static_cast(2) / static_cast(3); @@ -405,7 +406,7 @@ inline T constant_two_thirds_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SP template template -inline T constant_three_quarters_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_three_quarters_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() * static_cast(3) / static_cast(4); @@ -413,7 +414,7 @@ inline T constant_three_quarters_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYP template template -inline T constant_pi_pow_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_pi_pow_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pow(pi > >(), e > >()); // @@ -421,7 +422,7 @@ inline T constant_pi_pow_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_pi_sqr::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_pi_sqr::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() @@ -430,7 +431,7 @@ inline T constant_pi_sqr::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boo template template -inline T constant_pi_sqr_div_six::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_pi_sqr_div_six::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() @@ -440,7 +441,7 @@ inline T constant_pi_sqr_div_six::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S template template -inline T constant_pi_cubed::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_pi_cubed::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() @@ -451,7 +452,7 @@ inline T constant_pi_cubed::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_cbrt_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_cbrt_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pow(pi > >(), static_cast(1)/ static_cast(3)); @@ -459,7 +460,7 @@ inline T constant_cbrt_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((bo template template -inline T constant_one_div_cbrt_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_cbrt_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(1) @@ -470,7 +471,7 @@ inline T constant_one_div_cbrt_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_ template template -inline T constant_e_pow_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_e_pow_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pow(e > >(), pi > >()); // @@ -478,7 +479,7 @@ inline T constant_e_pow_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_root_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_root_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sqrt(e > >()); @@ -486,7 +487,7 @@ inline T constant_root_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boo template template -inline T constant_log10_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_log10_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return log10(e > >()); @@ -494,7 +495,7 @@ inline T constant_log10_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((bo template template -inline T constant_one_div_log10_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_log10_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(1) / @@ -505,7 +506,7 @@ inline T constant_one_div_log10_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_ template template -inline T constant_degree::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_degree::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return pi > >() @@ -515,7 +516,7 @@ inline T constant_degree::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boo template template -inline T constant_radian::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_radian::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(180) @@ -525,7 +526,7 @@ inline T constant_radian::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boo template template -inline T constant_sin_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_sin_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sin(static_cast(1)) ; // @@ -533,7 +534,7 @@ inline T constant_sin_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((bo template template -inline T constant_cos_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_cos_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return cos(static_cast(1)) ; // @@ -541,7 +542,7 @@ inline T constant_cos_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((bo template template -inline T constant_sinh_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_sinh_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return sinh(static_cast(1)) ; // @@ -549,7 +550,7 @@ inline T constant_sinh_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_cosh_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_cosh_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return cosh(static_cast(1)) ; // @@ -557,7 +558,7 @@ inline T constant_cosh_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return (static_cast(1) + sqrt(static_cast(5)) )/static_cast(2) ; // @@ -565,7 +566,7 @@ inline T constant_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost: template template -inline T constant_ln_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_ln_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return log((static_cast(1) + sqrt(static_cast(5)) )/static_cast(2) ); @@ -573,7 +574,7 @@ inline T constant_ln_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boo template template -inline T constant_one_div_ln_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_ln_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING return static_cast(1) / @@ -584,7 +585,7 @@ inline T constant_one_div_ln_phi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S template template -inline T constant_zeta_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_zeta_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING @@ -595,7 +596,7 @@ inline T constant_zeta_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_zeta_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_zeta_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // http://mathworld.wolfram.com/AperysConstant.html // http://en.wikipedia.org/wiki/Mathematical_constant @@ -655,7 +656,7 @@ inline T constant_zeta_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC( template template -inline T constant_catalan::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_catalan::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // http://oeis.org/A006752/constant //T c("0.915965594177219015054603514932384110774" //"149374281672134266498119621763019776254769479356512926115106248574"); @@ -755,7 +756,7 @@ T khinchin(int digits) template template -inline T constant_khinchin::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_khinchin::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { int n = N ? (std::min)(N, tools::digits()) : tools::digits(); return khinchin_detail::khinchin(n); @@ -763,7 +764,7 @@ inline T constant_khinchin::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_extreme_value_skewness::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_extreme_value_skewness::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // from e_float constants.cpp // Mathematica: N[12 Sqrt[6] Zeta[3]/Pi^3, 1101] BOOST_MATH_STD_USING @@ -870,7 +871,7 @@ inline T zeta_derivative_2(unsigned n) template template -inline T constant_glaisher::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_glaisher::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { BOOST_MATH_STD_USING @@ -910,7 +911,7 @@ inline T constant_glaisher::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((b template template -inline T constant_rayleigh_skewness::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_rayleigh_skewness::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // From e_float // 1100 digits of the Rayleigh distribution skewness // Mathematica: N[2 Sqrt[Pi] (Pi - 3)/((4 - Pi)^(3/2)), 1100] @@ -938,7 +939,7 @@ inline T constant_rayleigh_skewness::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYP template template -inline T constant_rayleigh_kurtosis_excess::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_rayleigh_kurtosis_excess::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // - (6 Pi^2 - 24 Pi + 16)/((Pi - 4)^2) // Might provide and calculate this using pi_minus_four. BOOST_MATH_STD_USING @@ -953,7 +954,7 @@ inline T constant_rayleigh_kurtosis_excess::compute(BOOST_MATH_EXPLICIT_TEMPL template template -inline T constant_rayleigh_kurtosis::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_rayleigh_kurtosis::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // 3 - (6 Pi^2 - 24 Pi + 16)/((Pi - 4)^2) // Might provide and calculate this using pi_minus_four. BOOST_MATH_STD_USING @@ -968,28 +969,28 @@ inline T constant_rayleigh_kurtosis::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYP template template -inline T constant_log2_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_log2_e::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return 1 / boost::math::constants::ln_two(); } template template -inline T constant_quarter_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_quarter_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return boost::math::constants::pi() / 4; } template template -inline T constant_one_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_one_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return 1 / boost::math::constants::pi(); } template template -inline T constant_two_div_root_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_two_div_root_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { return 2 * boost::math::constants::one_div_root_pi(); } @@ -997,7 +998,7 @@ inline T constant_two_div_root_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_ #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) template template -inline T constant_first_feigenbaum::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_first_feigenbaum::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // We know the constant to 1018 decimal digits. // See: http://www.plouffe.fr/simon/constants/feigenbaum.txt @@ -1011,7 +1012,7 @@ inline T constant_first_feigenbaum::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE template template -inline T constant_plastic::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_plastic::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { using std::cbrt; using std::sqrt; @@ -1021,7 +1022,7 @@ inline T constant_plastic::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((bo template template -inline T constant_gauss::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_gauss::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { using std::sqrt; T a = sqrt(T(2)); @@ -1039,7 +1040,7 @@ inline T constant_gauss::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boos template template -inline T constant_dottie::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_dottie::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // Error analysis: cos(x(1+d)) - x(1+d) = -(sin(x)+1)xd; plug in x = 0.739 gives -1.236d; take d as half an ulp gives the termination criteria we want. using std::cos; @@ -1057,7 +1058,7 @@ inline T constant_dottie::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boo template template -inline T constant_reciprocal_fibonacci::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_reciprocal_fibonacci::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // Wikipedia says Gosper has deviced a faster algorithm for this, but I read the linked paper and couldn't see it! // In any case, k bits per iteration is fine, though it would be better to sum from smallest to largest. @@ -1078,7 +1079,7 @@ inline T constant_reciprocal_fibonacci::compute(BOOST_MATH_EXPLICIT_TEMPLATE_ template template -inline T constant_laplace_limit::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((boost::integral_constant))) +inline T constant_laplace_limit::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC((std::integral_constant))) { // If x is the exact root, then the approximate root is given by x(1+delta). // Plugging this into the equation for the Laplace limit gives the residual of approximately From b5031bc9c436438fdfe3496b384490c6414dcbb6 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 10 Feb 2021 19:35:04 +0300 Subject: [PATCH 05/15] revert conversion to string [CI SKIP] --- .../math/special_functions/lambert_w.hpp | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/include/boost/math/special_functions/lambert_w.hpp b/include/boost/math/special_functions/lambert_w.hpp index f161fc1b5..09ebbcc90 100644 --- a/include/boost/math/special_functions/lambert_w.hpp +++ b/include/boost/math/special_functions/lambert_w.hpp @@ -68,7 +68,6 @@ BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES_ITERATIONS // Show evaluation of #include #include #include -#include #include // Needed for testing and diagnostics only. @@ -1218,16 +1217,16 @@ T lambert_w_negative_rational_float(T z, const Policy& pol) template inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) { - static std::string function = "boost::math::lambert_w0<%1%>"; // For error messages. + static const char* function = "boost::math::lambert_w0<%1%>"; // For error messages. BOOST_MATH_STD_USING // Aid ADL of std functions. if ((boost::math::isnan)(z)) { - return boost::math::policies::raise_domain_error(function.c_str(), "Expected a value > -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function, "Expected a value > -e^-1 (-0.367879...) but got %1%.", z, pol); } if ((boost::math::isinf)(z)) { - return boost::math::policies::raise_overflow_error(function.c_str(), "Expected a finite value but got %1%.", z, pol); + return boost::math::policies::raise_overflow_error(function, "Expected a finite value but got %1%.", z, pol); } if (z >= 0.05) // Fukushima switch point. @@ -1238,7 +1237,7 @@ inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant(function.c_str(), "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function, "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); return -1; } else // z < 0.05 @@ -1617,7 +1616,7 @@ T lambert_w_negative_rational_double(T z, const Policy& pol) template inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) { - static std::string function = "boost::math::lambert_w0<%1%>"; + static const char* function = "boost::math::lambert_w0<%1%>"; BOOST_MATH_STD_USING // Aid ADL of std functions. // Detect unusual case of 32-bit double with a wider/64-bit long double @@ -1629,11 +1628,11 @@ inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant(function.c_str(), "Expected a value > -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function, "Expected a value > -e^-1 (-0.367879...) but got %1%.", z, pol); } if ((boost::math::isinf)(z)) { - return boost::math::policies::raise_overflow_error(function.c_str(), "Expected a finite value but got %1%.", z, pol); + return boost::math::policies::raise_overflow_error(function, "Expected a finite value but got %1%.", z, pol); } if (z >= 0.05) @@ -1644,7 +1643,7 @@ inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant(function.c_str(), "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function, "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); } return -1; } @@ -1661,13 +1660,13 @@ inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant&) { - static std::string function = "boost::math::lambert_w0<%1%>"; + static const char* function = "boost::math::lambert_w0<%1%>"; BOOST_MATH_STD_USING // Aid ADL of std functions. // Filter out special cases first: if ((boost::math::isnan)(z)) { - return boost::math::policies::raise_domain_error(function.c_str(), "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function, "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); } if (fabs(z) <= 0.05f) { @@ -1678,7 +1677,7 @@ inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant(function.c_str(), 0, pol); + return policies::raise_overflow_error(function, 0, pol); // Or might return infinity if available else max_value, // but other Boost.Math special functions raise overflow. } @@ -1699,7 +1698,7 @@ inline T lambert_w0_imp(T z, const Policy& pol, const std::integral_constant(function.c_str(), "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); + return boost::math::policies::raise_domain_error(function, "Expected z >= -e^-1 (-0.367879...) but got %1%.", z, pol); } // z is very close (within 0.01) of the branch singularity at -e^-1 // so use a series approximation proposed by Corless et al. @@ -1750,19 +1749,19 @@ T lambert_wm1_imp(const T z, const Policy& pol) BOOST_MATH_STD_USING // Aid argument dependent lookup (ADL) of abs. - std::string function = "boost::math::lambert_wm1()"; // Used for error messages. + const char* function = "boost::math::lambert_wm1()"; // Used for error messages. // Check for edge and corner cases first: if ((boost::math::isnan)(z)) { - return policies::raise_domain_error(function.c_str(), + return policies::raise_domain_error(function, "Argument z is NaN!", z, pol); } // isnan if ((boost::math::isinf)(z)) { - return policies::raise_domain_error(function.c_str(), + return policies::raise_domain_error(function, "Argument z is infinite!", z, pol); } // isinf @@ -1782,7 +1781,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) { // All real types except arbitrary precision. if (!(boost::math::isnormal)(z)) { // Almost zero - might also just return infinity like z == 0 or max_value? - return policies::raise_overflow_error(function.c_str(), + return policies::raise_overflow_error(function, "Argument z = %1% is denormalized! (must be z > (std::numeric_limits::min)() or z == 0)", z, pol); } @@ -1790,7 +1789,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) if (z > static_cast(0)) { // - return policies::raise_domain_error(function.c_str(), + return policies::raise_domain_error(function, "Argument z = %1% is out of range (z <= 0) for Lambert W-1 branch! (Try Lambert W0 branch?)", z, pol); } @@ -1798,7 +1797,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) { // z is denormalized, so cannot be computed. // -std::numeric_limits::min() is smallest for type T, // for example, for double: lambert_wm1(-2.2250738585072014e-308) = -714.96865723796634 - return policies::raise_overflow_error(function.c_str(), + return policies::raise_overflow_error(function, "Argument z = %1% is too small (z < -std::numeric_limits::min so denormalized) for Lambert W-1 branch!", z, pol); } @@ -1809,7 +1808,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) // z is too negative for the W-1 (or W0) branch. if (z < -boost::math::constants::exp_minus_one()) // > singularity/branch point z = -exp(-1) = -3.6787944. { - return policies::raise_domain_error(function.c_str(), + return policies::raise_domain_error(function, "Argument z = %1% is out of range (z < -exp(-1) = -3.6787944... <= 0) for Lambert W-1 (or W0) branch!", z, pol); } @@ -1835,7 +1834,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) return w_series; } // Should not get here. - return policies::raise_domain_error(function.c_str(), + return policies::raise_domain_error(function, "Argument z = %1% is out of range for Lambert W-1 branch. (Should not get here - please report!)", z, pol); } // if (z < -0.35) @@ -1947,7 +1946,7 @@ T lambert_wm1_imp(const T z, const Policy& pol) } // else z < g[63] == -1.0264389699511303e-26, so Lambert W-1 integer part > 64. // This should not now occur (should be caught by test and code above) so should be a logic_error? - return policies::raise_domain_error(function.c_str(), + return policies::raise_domain_error(function, "Argument z = %1% is too small (< -1.026439e-26) (logic error - please report!)", z, pol); overshot: From d071804eb3da5ef372e0ee99ba557b4a32e3156c Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 10 Feb 2021 19:56:39 +0300 Subject: [PATCH 06/15] Remove MPL from pow --- include/boost/math/special_functions/pow.hpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/include/boost/math/special_functions/pow.hpp b/include/boost/math/special_functions/pow.hpp index 2706fc1b5..f46f68939 100644 --- a/include/boost/math/special_functions/pow.hpp +++ b/include/boost/math/special_functions/pow.hpp @@ -17,7 +17,6 @@ #include #include #include -#include namespace boost { @@ -113,12 +112,7 @@ struct power_if_positive<0, true> template struct select_power_if_positive { - typedef typename mpl::greater_equal< - boost::integral_constant, - boost::integral_constant - >::type is_positive; - - typedef power_if_positive type; + using type = power_if_positive= 0)>; }; @@ -128,7 +122,7 @@ struct select_power_if_positive template BOOST_CXX14_CONSTEXPR inline typename tools::promote_args::type pow(T base, const Policy& policy) { - typedef typename tools::promote_args::type result_type; + using result_type = typename tools::promote_args::type; return detail::select_power_if_positive::type::result(static_cast(base), policy); } From c89bda8d58210aab36d6a4cac6713071a0b413ea Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 10 Feb 2021 21:14:26 +0300 Subject: [PATCH 07/15] Remove MPL from cbrt --- include/boost/math/special_functions/cbrt.hpp | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/include/boost/math/special_functions/cbrt.hpp b/include/boost/math/special_functions/cbrt.hpp index 148963353..0066222a9 100644 --- a/include/boost/math/special_functions/cbrt.hpp +++ b/include/boost/math/special_functions/cbrt.hpp @@ -14,10 +14,8 @@ #include #include #include -#include -#include -#include -#include +#include +#include namespace boost{ namespace math{ @@ -26,20 +24,20 @@ namespace detail struct big_int_type { - operator boost::uintmax_t()const; + operator std::uintmax_t() const; }; -template +template struct largest_cbrt_int_type { - typedef typename mpl::if_c< - boost::is_convertible::value, - boost::uintmax_t, + using type = typename std::conditional< + std::is_convertible::value, + std::uintmax_t, unsigned int - >::type type; + >::type; }; -template +template T cbrt_imp(T z, const Policy& pol) { BOOST_MATH_STD_USING @@ -87,7 +85,7 @@ T cbrt_imp(T z, const Policy& pol) guess = tools::evaluate_polynomial(P, guess); int i_exp3 = i_exp / 3; - typedef typename largest_cbrt_int_type::type shift_type; + using shift_type = typename largest_cbrt_int_type::type; BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); @@ -111,15 +109,15 @@ T cbrt_imp(T z, const Policy& pol) // checking of the boilerplate version as we know in advance that the function // is well behaved... // - typedef typename policies::precision::type prec; - typedef typename mpl::divides >::type prec3; - typedef typename mpl::plus >::type new_prec; - typedef typename policies::normalise >::type new_policy; + using prec = typename policies::precision::type; + constexpr auto prec3 = prec::value / 3; + constexpr auto new_prec = prec3 + 3; + using new_policy = typename policies::normalise>::type; // // Epsilon calculation uses compile time arithmetic when it's available for type T, // otherwise uses ldexp to calculate at runtime: // - T eps = (new_prec::value > 3) ? policies::get_epsilon() : ldexp(T(1), -2 - tools::digits() / 3); + T eps = (new_prec > 3) ? policies::get_epsilon() : ldexp(T(1), -2 - tools::digits() / 3); T diff; if(original_i_exp < std::numeric_limits::max_exponent - 3) @@ -155,15 +153,15 @@ T cbrt_imp(T z, const Policy& pol) } // namespace detail -template +template inline typename tools::promote_args::type cbrt(T z, const Policy& pol) { - typedef typename tools::promote_args::type result_type; - typedef typename policies::evaluation::type value_type; + using result_type = typename tools::promote_args::type; + using value_type = typename policies::evaluation::type; return static_cast(detail::cbrt_imp(value_type(z), pol)); } -template +template inline typename tools::promote_args::type cbrt(T z) { return cbrt(z, policies::policy<>()); From 8b81fba92dd1ac5ed61953acf50d7ab491ed41c2 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 11 Feb 2021 20:27:50 +0300 Subject: [PATCH 08/15] Replace boost types with std types --- .../boost/math/special_functions/lanczos.hpp | 266 +++++++++--------- 1 file changed, 133 insertions(+), 133 deletions(-) diff --git a/include/boost/math/special_functions/lanczos.hpp b/include/boost/math/special_functions/lanczos.hpp index 5a68ad953..89317b5c6 100644 --- a/include/boost/math/special_functions/lanczos.hpp +++ b/include/boost/math/special_functions/lanczos.hpp @@ -13,13 +13,13 @@ #include #include #include -#include -#include #include #include #include - -#include +#include +#include +#include +#include #if defined(__GNUC__) && defined(BOOST_MATH_USE_FLOAT128) // @@ -77,7 +77,7 @@ typename lanczos_initializer::init const lanczos_initializer +struct lanczos6 : public std::integral_constant { // // Produces slightly better than float precision when evaluated at @@ -95,13 +95,13 @@ struct lanczos6 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 35, 63.99951844938187085666201263218840287667)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 35, 2.506628274631006311133031631822390264407)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint16_t) denom[6] = { - static_cast(0u), - static_cast(24u), - static_cast(50u), - static_cast(35u), - static_cast(10u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint16_t) denom[6] = { + static_cast(0u), + static_cast(24u), + static_cast(50u), + static_cast(35u), + static_cast(10u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -118,13 +118,13 @@ struct lanczos6 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 35, 0.2412010548258800231126240760264822486599)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 35, 0.009446967704539249494420221613134244048319)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint16_t) denom[6] = { - static_cast(0u), - static_cast(24u), - static_cast(50u), - static_cast(35u), - static_cast(10u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint16_t) denom[6] = { + static_cast(0u), + static_cast(24u), + static_cast(50u), + static_cast(35u), + static_cast(10u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -177,7 +177,7 @@ struct lanczos6 : public boost::integral_constant // Max experimental error (with arbitrary precision arithmetic) 2.16676e-19 // Generated with compiler: Microsoft Visual C++ version 8.0 on Win32 at Mar 23 2006 // -struct lanczos11 : public boost::integral_constant +struct lanczos11 : public std::integral_constant { // // Produces slightly better than double precision when evaluated at @@ -200,18 +200,18 @@ struct lanczos11 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 60, 261.6140441641668190791708576058805625502)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 60, 2.506628274631000502415573855452633787834)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint32_t) denom[11] = { - static_cast(0u), - static_cast(362880u), - static_cast(1026576u), - static_cast(1172700u), - static_cast(723680u), - static_cast(269325u), - static_cast(63273u), - static_cast(9450u), - static_cast(870u), - static_cast(45u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint32_t) denom[11] = { + static_cast(0u), + static_cast(362880u), + static_cast(1026576u), + static_cast(1172700u), + static_cast(723680u), + static_cast(269325u), + static_cast(63273u), + static_cast(9450u), + static_cast(870u), + static_cast(45u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -233,18 +233,18 @@ struct lanczos11 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 60, 0.004826466289237661857584712046231435101741)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 60, 0.4624429436045378766270459638520555557321e-4)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint32_t) denom[11] = { - static_cast(0u), - static_cast(362880u), - static_cast(1026576u), - static_cast(1172700u), - static_cast(723680u), - static_cast(269325u), - static_cast(63273u), - static_cast(9450u), - static_cast(870u), - static_cast(45u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint32_t) denom[11] = { + static_cast(0u), + static_cast(362880u), + static_cast(1026576u), + static_cast(1172700u), + static_cast(723680u), + static_cast(269325u), + static_cast(63273u), + static_cast(9450u), + static_cast(870u), + static_cast(45u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -307,7 +307,7 @@ struct lanczos11 : public boost::integral_constant // Max experimental error (with arbitrary precision arithmetic) 9.2213e-23 // Generated with compiler: Microsoft Visual C++ version 8.0 on Win32 at Mar 23 2006 // -struct lanczos13 : public boost::integral_constant +struct lanczos13 : public std::integral_constant { // // Produces slightly better than extended-double precision when evaluated at @@ -332,20 +332,20 @@ struct lanczos13 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 72, 381.8801248632926870394389468349331394196)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 72, 2.506628274631000502415763426076722427007)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint32_t) denom[13] = { - static_cast(0u), - static_cast(39916800u), - static_cast(120543840u), - static_cast(150917976u), - static_cast(105258076u), - static_cast(45995730u), - static_cast(13339535u), - static_cast(2637558u), - static_cast(357423u), - static_cast(32670u), - static_cast(1925u), - static_cast(66u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint32_t) denom[13] = { + static_cast(0u), + static_cast(39916800u), + static_cast(120543840u), + static_cast(150917976u), + static_cast(105258076u), + static_cast(45995730u), + static_cast(13339535u), + static_cast(2637558u), + static_cast(357423u), + static_cast(32670u), + static_cast(1925u), + static_cast(66u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -369,20 +369,20 @@ struct lanczos13 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 72, 0.0007469903808915448316510079585999893674101)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 72, 0.4903180573459871862552197089738373164184e-5)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint32_t) denom[13] = { - static_cast(0u), - static_cast(39916800u), - static_cast(120543840u), - static_cast(150917976u), - static_cast(105258076u), - static_cast(45995730u), - static_cast(13339535u), - static_cast(2637558u), - static_cast(357423u), - static_cast(32670u), - static_cast(1925u), - static_cast(66u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint32_t) denom[13] = { + static_cast(0u), + static_cast(39916800u), + static_cast(120543840u), + static_cast(150917976u), + static_cast(105258076u), + static_cast(45995730u), + static_cast(13339535u), + static_cast(2637558u), + static_cast(357423u), + static_cast(32670u), + static_cast(1925u), + static_cast(66u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -449,7 +449,7 @@ struct lanczos13 : public boost::integral_constant // Max experimental error (with arbitrary precision arithmetic) 2.9524e-38 // Generated with compiler: Microsoft Visual C++ version 8.0 on Win32 at Mar 23 2006 // -struct lanczos22 : public boost::integral_constant +struct lanczos22 : public std::integral_constant { // // Produces slightly better than 128-bit long-double precision when @@ -483,7 +483,7 @@ struct lanczos22 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 120, 1167.501919472435718934219997431551246996)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 120, 2.50662827463100050241576528481104525333)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint64_t) denom[22] = { + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint64_t) denom[22] = { BOOST_MATH_INT_VALUE_SUFFIX(0, uLL), BOOST_MATH_INT_VALUE_SUFFIX(2432902008176640000, uLL), BOOST_MATH_INT_VALUE_SUFFIX(8752948036761600000, uLL), @@ -538,7 +538,7 @@ struct lanczos22 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 120, 0.1753839324538447655939518484052327068859e-6)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 120, 0.3765495513732730583386223384116545391759e-9)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint64_t) denom[22] = { + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint64_t) denom[22] = { BOOST_MATH_INT_VALUE_SUFFIX(0, uLL), BOOST_MATH_INT_VALUE_SUFFIX(2432902008176640000, uLL), BOOST_MATH_INT_VALUE_SUFFIX(8752948036761600000, uLL), @@ -645,7 +645,7 @@ struct lanczos22 : public boost::integral_constant // Max experimental error (with arbitrary precision arithmetic) 8.111667e-8 // Generated with compiler: Microsoft Visual C++ version 8.0 on Win32 at Mar 23 2006 // -struct lanczos6m24 : public boost::integral_constant +struct lanczos6m24 : public std::integral_constant { // // Use for float precision, when evaluated as a float: @@ -661,13 +661,13 @@ struct lanczos6m24 : public boost::integral_constant static_cast(27.5192015197455403062503721613097825345L), static_cast(2.50662858515256974113978724717473206342L) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint16_t) denom[6] = { - static_cast(0u), - static_cast(24u), - static_cast(50u), - static_cast(35u), - static_cast(10u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint16_t) denom[6] = { + static_cast(0u), + static_cast(24u), + static_cast(50u), + static_cast(35u), + static_cast(10u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -683,13 +683,13 @@ struct lanczos6m24 : public boost::integral_constant static_cast(6.595765571169314946316366571954421695196L), static_cast(0.6007854010515290065101128585795542383721L) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint16_t) denom[6] = { - static_cast(0u), - static_cast(24u), - static_cast(50u), - static_cast(35u), - static_cast(10u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint16_t) denom[6] = { + static_cast(0u), + static_cast(24u), + static_cast(50u), + static_cast(35u), + static_cast(10u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -740,7 +740,7 @@ struct lanczos6m24 : public boost::integral_constant // Max experimental error (with arbitrary precision arithmetic) 1.196214e-17 // Generated with compiler: Microsoft Visual C++ version 8.0 on Win32 at Mar 23 2006 // -struct lanczos13m53 : public boost::integral_constant +struct lanczos13m53 : public std::integral_constant { // // Use for double precision, when evaluated as a double: @@ -763,20 +763,20 @@ struct lanczos13m53 : public boost::integral_constant static_cast(210.8242777515793458725097339207133627117L), static_cast(2.506628274631000270164908177133837338626L) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint32_t) denom[13] = { - static_cast(0u), - static_cast(39916800u), - static_cast(120543840u), - static_cast(150917976u), - static_cast(105258076u), - static_cast(45995730u), - static_cast(13339535u), - static_cast(2637558u), - static_cast(357423u), - static_cast(32670u), - static_cast(1925u), - static_cast(66u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint32_t) denom[13] = { + static_cast(0u), + static_cast(39916800u), + static_cast(120543840u), + static_cast(150917976u), + static_cast(105258076u), + static_cast(45995730u), + static_cast(13339535u), + static_cast(2637558u), + static_cast(357423u), + static_cast(32670u), + static_cast(1925u), + static_cast(66u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -799,20 +799,20 @@ struct lanczos13m53 : public boost::integral_constant static_cast(0.5098416655656676188125178644804694509993L), static_cast(0.006061842346248906525783753964555936883222L) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint32_t) denom[13] = { - static_cast(0u), - static_cast(39916800u), - static_cast(120543840u), - static_cast(150917976u), - static_cast(105258076u), - static_cast(45995730u), - static_cast(13339535u), - static_cast(2637558u), - static_cast(357423u), - static_cast(32670u), - static_cast(1925u), - static_cast(66u), - static_cast(1u) + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint32_t) denom[13] = { + static_cast(0u), + static_cast(39916800u), + static_cast(120543840u), + static_cast(150917976u), + static_cast(105258076u), + static_cast(45995730u), + static_cast(13339535u), + static_cast(2637558u), + static_cast(357423u), + static_cast(32670u), + static_cast(1925u), + static_cast(66u), + static_cast(1u) }; return boost::math::tools::evaluate_rational(num, denom, z); } @@ -877,7 +877,7 @@ struct lanczos13m53 : public boost::integral_constant // Max experimental error (with arbitrary precision arithmetic) 2.7699e-26 // Generated with compiler: Microsoft Visual C++ version 8.0 on Win32 at Mar 23 2006 // -struct lanczos17m64 : public boost::integral_constant +struct lanczos17m64 : public std::integral_constant { // // Use for extended-double precision, when evaluated as an extended-double: @@ -905,7 +905,7 @@ struct lanczos17m64 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 64, 488.0063567520005730476791712814838113252)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 64, 2.50662827463100050241576877135758834683)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint64_t) denom[17] = { + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint64_t) denom[17] = { BOOST_MATH_INT_VALUE_SUFFIX(0, uLL), BOOST_MATH_INT_VALUE_SUFFIX(1307674368000, uLL), BOOST_MATH_INT_VALUE_SUFFIX(4339163001600, uLL), @@ -950,7 +950,7 @@ struct lanczos17m64 : public boost::integral_constant static_cast(BOOST_MATH_BIG_CONSTANT(T, 64, 0.002393749522058449186690627996063983095463)), static_cast(BOOST_MATH_BIG_CONSTANT(T, 64, 0.1229541408909435212800785616808830746135e-4)) }; - static const BOOST_MATH_INT_TABLE_TYPE(T, boost::uint64_t) denom[17] = { + static const BOOST_MATH_INT_TABLE_TYPE(T, std::uint64_t) denom[17] = { BOOST_MATH_INT_VALUE_SUFFIX(0, uLL), BOOST_MATH_INT_VALUE_SUFFIX(1307674368000, uLL), BOOST_MATH_INT_VALUE_SUFFIX(4339163001600, uLL), @@ -1042,7 +1042,7 @@ struct lanczos17m64 : public boost::integral_constant // Max experimental error (with arbitrary precision arithmetic) 1.0541e-38 // Generated with compiler: Microsoft Visual C++ version 8.0 on Win32 at Mar 23 2006 // -struct lanczos24m113 : public boost::integral_constant +struct lanczos24m113 : public std::integral_constant { // // Use for long-double precision, when evaluated as an long-double: @@ -1250,7 +1250,7 @@ struct lanczos24m113 : public boost::integral_constant // Generated with compiler: Microsoft Visual C++ version 14.2 on Win32 at Oct 14 2019 // Type precision was 134 bits or 43 max_digits10 // -struct lanczos32MP : public boost::integral_constant +struct lanczos32MP : public std::integral_constant { template static T lanczos_sum(const T& z) @@ -1499,7 +1499,7 @@ struct lanczos32MP : public boost::integral_constant // Generated with compiler: Microsoft Visual C++ version 14.2 on Win32 at Oct 14 2019 // Type precision was 168 bits or 53 max_digits10 // -struct lanczos35MP : public boost::integral_constant +struct lanczos35MP : public std::integral_constant { template static T lanczos_sum(const T& z) @@ -1766,7 +1766,7 @@ struct lanczos35MP : public boost::integral_constant // Generated with compiler: Microsoft Visual C++ version 14.2 on Win32 at Oct 14 2019 // Type precision was 201 bits or 63 max_digits10 // -struct lanczos48MP : public boost::integral_constant +struct lanczos48MP : public std::integral_constant { template static T lanczos_sum(const T& z) @@ -2110,7 +2110,7 @@ struct lanczos48MP : public boost::integral_constant // Generated with compiler: Microsoft Visual C++ version 14.2 on Win32 at Oct 14 2019 // Type precision was 234 bits or 73 max_digits10 // -struct lanczos49MP : public boost::integral_constant +struct lanczos49MP : public std::integral_constant { template static T lanczos_sum(const T& z) @@ -2460,7 +2460,7 @@ struct lanczos49MP : public boost::integral_constant // Generated with compiler: Microsoft Visual C++ version 14.2 on Win32 at Oct 14 2019 // Type precision was 267 bits or 83 max_digits10 // -struct lanczos49MP_2 : public boost::integral_constant +struct lanczos49MP_2 : public std::integral_constant { template static T lanczos_sum(const T& z) @@ -2810,7 +2810,7 @@ struct lanczos49MP_2 : public boost::integral_constant // Generated with compiler: Microsoft Visual C++ version 14.2 on Win32 at Oct 14 2019 // Type precision was 334 bits or 103 max_digits10 // -struct lanczos58MP : public boost::integral_constant +struct lanczos58MP : public std::integral_constant { template static T lanczos_sum(const T& z) @@ -3213,7 +3213,7 @@ struct lanczos58MP : public boost::integral_constant // // placeholder for no lanczos info available: // -struct undefined_lanczos : public boost::integral_constant { }; +struct undefined_lanczos : public std::integral_constant::max)() - 1> { }; #if 0 #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS @@ -3249,9 +3249,9 @@ struct lanczos typedef typename mpl::if_< typename mpl::less_equal< typename policies::precision::type, - boost::integral_constant + std::integral_constant >::type, - boost::integral_constant, + std::integral_constant::max)() - 2>, typename policies::precision::type >::type target_precision; From 0f991aa3b2bf8ef9e6b81cb80ed3125b23298dd3 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 12 Feb 2021 20:41:57 +0300 Subject: [PATCH 09/15] replace mpl with conditional --- .../boost/math/special_functions/lanczos.hpp | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/include/boost/math/special_functions/lanczos.hpp b/include/boost/math/special_functions/lanczos.hpp index 89317b5c6..ae3f8606a 100644 --- a/include/boost/math/special_functions/lanczos.hpp +++ b/include/boost/math/special_functions/lanczos.hpp @@ -12,10 +12,8 @@ #include #include -#include #include #include -#include #include #include #include @@ -3227,37 +3225,26 @@ struct undefined_lanczos : public std::integral_constant lanczos_list; - template struct lanczos { - typedef typename mpl::if_< - typename mpl::less_equal< - typename policies::precision::type, - std::integral_constant - >::type, - std::integral_constant::max)() - 2>, - typename policies::precision::type - >::type target_precision; + static constexpr auto target_precision = policies::precision::value; - typedef typename mpl::deref >::type>::type type; + using type = typename std::conditional<(target_precision == 24), lanczos6m24, + typename std::conditional<(target_precision == 53), lanczos13m53, + typename std::conditional<(target_precision == 60), lanczos11, + typename std::conditional<(target_precision == 64), lanczos17m64, + typename std::conditional<(target_precision == 72), lanczos13, + typename std::conditional<(target_precision == 113), lanczos24m113, + typename std::conditional<(target_precision == 120), lanczos22, + typename std::conditional<(target_precision == 134), lanczos32MP, + typename std::conditional<(target_precision == 168), lanczos35MP, + typename std::conditional<(target_precision == 201), lanczos48MP, + typename std::conditional<(target_precision == 234), lanczos49MP, + typename std::conditional<(target_precision == 267), lanczos49MP_2, + typename std::conditional<(target_precision == 334), lanczos58MP, undefined_lanczos>::type + >::type>::type>::type>::type>::type>::type>::type>::type>::type>::type>::type + >::type; }; } // namespace lanczos From bf23999c3cba42c98638dc289d22fa3bb29569a3 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 12 Feb 2021 21:33:14 +0300 Subject: [PATCH 10/15] Minor fixes --- include/boost/math/special_functions/lanczos.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boost/math/special_functions/lanczos.hpp b/include/boost/math/special_functions/lanczos.hpp index ae3f8606a..a2fb5d788 100644 --- a/include/boost/math/special_functions/lanczos.hpp +++ b/include/boost/math/special_functions/lanczos.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #if defined(__GNUC__) && defined(BOOST_MATH_USE_FLOAT128) @@ -3228,7 +3227,7 @@ struct undefined_lanczos : public std::integral_constant struct lanczos { - static constexpr auto target_precision = policies::precision::value; + static constexpr auto target_precision = policies::precision::type::value; using type = typename std::conditional<(target_precision == 24), lanczos6m24, typename std::conditional<(target_precision == 53), lanczos13m53, From 3779329ae8509a5f9ad05966cef4dba2859b84f4 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sat, 13 Feb 2021 10:31:24 +0300 Subject: [PATCH 11/15] Fix for non-convergence --- .../boost/math/special_functions/lanczos.hpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/boost/math/special_functions/lanczos.hpp b/include/boost/math/special_functions/lanczos.hpp index a2fb5d788..061c238ce 100644 --- a/include/boost/math/special_functions/lanczos.hpp +++ b/include/boost/math/special_functions/lanczos.hpp @@ -3227,22 +3227,22 @@ struct undefined_lanczos : public std::integral_constant struct lanczos { - static constexpr auto target_precision = policies::precision::type::value; + static constexpr auto target_precision = policies::precision::type::value <= 0 ? (std::numeric_limits::max)()-2 : + policies::precision::type::value; - using type = typename std::conditional<(target_precision == 24), lanczos6m24, - typename std::conditional<(target_precision == 53), lanczos13m53, - typename std::conditional<(target_precision == 60), lanczos11, - typename std::conditional<(target_precision == 64), lanczos17m64, - typename std::conditional<(target_precision == 72), lanczos13, - typename std::conditional<(target_precision == 113), lanczos24m113, - typename std::conditional<(target_precision == 120), lanczos22, - typename std::conditional<(target_precision == 134), lanczos32MP, - typename std::conditional<(target_precision == 168), lanczos35MP, - typename std::conditional<(target_precision == 201), lanczos48MP, - typename std::conditional<(target_precision == 234), lanczos49MP, - typename std::conditional<(target_precision == 267), lanczos49MP_2, - typename std::conditional<(target_precision == 334), lanczos58MP, undefined_lanczos>::type - >::type>::type>::type>::type>::type>::type>::type>::type>::type>::type>::type + using type = typename std::conditional<(target_precision <= 24), lanczos6m24, + typename std::conditional<(target_precision <= 53), lanczos13m53, + typename std::conditional<(target_precision <= 60), lanczos11, + typename std::conditional<(target_precision <= 64), lanczos17m64, + typename std::conditional<(target_precision <= 113), lanczos24m113, + typename std::conditional<(target_precision <= 120), lanczos22, + typename std::conditional<(target_precision <= 134), lanczos32MP, + typename std::conditional<(target_precision <= 168), lanczos35MP, + typename std::conditional<(target_precision <= 201), lanczos48MP, + typename std::conditional<(target_precision <= 234), lanczos49MP, + typename std::conditional<(target_precision <= 267), lanczos49MP_2, + typename std::conditional<(target_precision <= 334), lanczos58MP, undefined_lanczos>::type + >::type>::type>::type>::type>::type>::type>::type>::type>::type>::type >::type; }; From e01b1d20b887019c35dd48d9179098fefdb407fa Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sat, 13 Feb 2021 12:23:15 +0300 Subject: [PATCH 12/15] Bulk removal of unused MPL headers --- include/boost/math/distributions/geometric.hpp | 1 - .../math/distributions/negative_binomial.hpp | 1 - .../math/special_functions/detail/bessel_jy.hpp | 1 - .../math/special_functions/detail/polygamma.hpp | 2 -- .../detail/unchecked_bernoulli.hpp | 1 - include/boost/math/special_functions/digamma.hpp | 1 - include/boost/math/special_functions/expm1.hpp | 4 +--- include/boost/math/special_functions/gamma.hpp | 5 +---- include/boost/math/special_functions/trigamma.hpp | 1 - include/boost/math/tools/precision.hpp | 15 +++++++-------- include/boost/math/tools/rational.hpp | 1 - 11 files changed, 9 insertions(+), 24 deletions(-) diff --git a/include/boost/math/distributions/geometric.hpp b/include/boost/math/distributions/geometric.hpp index 717e6cc87..6b2781657 100644 --- a/include/boost/math/distributions/geometric.hpp +++ b/include/boost/math/distributions/geometric.hpp @@ -47,7 +47,6 @@ #include #include #include -#include #include // using std::numeric_limits; #include diff --git a/include/boost/math/distributions/negative_binomial.hpp b/include/boost/math/distributions/negative_binomial.hpp index de5a68281..6cb45e479 100644 --- a/include/boost/math/distributions/negative_binomial.hpp +++ b/include/boost/math/distributions/negative_binomial.hpp @@ -55,7 +55,6 @@ #include #include #include -#include #include // using std::numeric_limits; #include diff --git a/include/boost/math/special_functions/detail/bessel_jy.hpp b/include/boost/math/special_functions/detail/bessel_jy.hpp index 6ccf37cf5..d62e148c3 100644 --- a/include/boost/math/special_functions/detail/bessel_jy.hpp +++ b/include/boost/math/special_functions/detail/bessel_jy.hpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/include/boost/math/special_functions/detail/polygamma.hpp b/include/boost/math/special_functions/detail/polygamma.hpp index dd21d45a4..256df330a 100644 --- a/include/boost/math/special_functions/detail/polygamma.hpp +++ b/include/boost/math/special_functions/detail/polygamma.hpp @@ -22,8 +22,6 @@ #include #include #include - #include - #include #include #include diff --git a/include/boost/math/special_functions/detail/unchecked_bernoulli.hpp b/include/boost/math/special_functions/detail/unchecked_bernoulli.hpp index 4bb72d6cc..60f40075b 100644 --- a/include/boost/math/special_functions/detail/unchecked_bernoulli.hpp +++ b/include/boost/math/special_functions/detail/unchecked_bernoulli.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #ifdef BOOST_MATH_HAVE_CONSTEXPR_TABLES diff --git a/include/boost/math/special_functions/digamma.hpp b/include/boost/math/special_functions/digamma.hpp index 2cd752492..77f3782f5 100644 --- a/include/boost/math/special_functions/digamma.hpp +++ b/include/boost/math/special_functions/digamma.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #if defined(__GNUC__) && defined(BOOST_MATH_USE_FLOAT128) diff --git a/include/boost/math/special_functions/expm1.hpp b/include/boost/math/special_functions/expm1.hpp index 49e9460f1..8bf2530f3 100644 --- a/include/boost/math/special_functions/expm1.hpp +++ b/include/boost/math/special_functions/expm1.hpp @@ -10,8 +10,7 @@ #pragma once #endif -#include -#include // platform's ::expm1 +#include #include #include #include @@ -20,7 +19,6 @@ #include #include #include -#include #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS # include diff --git a/include/boost/math/special_functions/gamma.hpp b/include/boost/math/special_functions/gamma.hpp index 681a76190..a0d167df9 100644 --- a/include/boost/math/special_functions/gamma.hpp +++ b/include/boost/math/special_functions/gamma.hpp @@ -35,11 +35,8 @@ #include #include #include -#include -#include -#include -#include +#include #include #ifdef BOOST_MSVC diff --git a/include/boost/math/special_functions/trigamma.hpp b/include/boost/math/special_functions/trigamma.hpp index 943302dd5..f8fe67818 100644 --- a/include/boost/math/special_functions/trigamma.hpp +++ b/include/boost/math/special_functions/trigamma.hpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/include/boost/math/tools/precision.hpp b/include/boost/math/tools/precision.hpp index 73757295d..6aecc2036 100644 --- a/include/boost/math/tools/precision.hpp +++ b/include/boost/math/tools/precision.hpp @@ -13,14 +13,13 @@ #include #include #include -#include -#include -#include #include - -// These two are for LDBL_MAN_DIG: -#include -#include +#include +#include +#include +#include +#include +#include // LDBL_MANT_DIG namespace boost{ namespace math { @@ -188,7 +187,7 @@ inline T epsilon(const boost::false_type& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TY template struct log_limit_traits { - typedef typename mpl::if_c< + typedef typename std::conditional< (std::numeric_limits::radix == 2) && (std::numeric_limits::max_exponent == 128 || std::numeric_limits::max_exponent == 1024 diff --git a/include/boost/math/tools/rational.hpp b/include/boost/math/tools/rational.hpp index 940e8ca3c..b420eb69a 100644 --- a/include/boost/math/tools/rational.hpp +++ b/include/boost/math/tools/rational.hpp @@ -12,7 +12,6 @@ #include #include -#include #if BOOST_MATH_POLY_METHOD == 1 # define BOOST_HEADER() From ba914f375388fddf778dae4520629d03d0c855c8 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sat, 13 Feb 2021 14:29:32 +0300 Subject: [PATCH 13/15] Remove MPL and type_traits from promotion --- include/boost/math/tools/promotion.hpp | 104 +++++++++++-------------- 1 file changed, 47 insertions(+), 57 deletions(-) diff --git a/include/boost/math/tools/promotion.hpp b/include/boost/math/tools/promotion.hpp index 212bc3a6e..45b74ceef 100644 --- a/include/boost/math/tools/promotion.hpp +++ b/include/boost/math/tools/promotion.hpp @@ -22,18 +22,8 @@ #pragma once #endif -// Boost type traits: #include -#include // for boost::is_floating_point; -#include // for boost::is_integral -#include // for boost::is_convertible -#include // for boost::is_same -#include // for boost::remove_cv -// Boost Template meta programming: -#include // for boost::mpl::if_c. -#include // for boost::mpl::if_c. -#include // for boost::mpl::if_c. -#include // for boost::mpl::if_c. +#include #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS #include @@ -68,31 +58,31 @@ namespace boost template struct promote_arg { // If T is integral type, then promote to double. - typedef typename mpl::if_, double, T>::type type; + using type = typename std::conditional::value, double, T>::type; }; - // These full specialisations reduce mpl::if_ usage and speed up + // These full specialisations reduce std::conditional usage and speed up // compilation: - template <> struct promote_arg { typedef float type; }; - template <> struct promote_arg{ typedef double type; }; - template <> struct promote_arg { typedef long double type; }; - template <> struct promote_arg { typedef double type; }; + template <> struct promote_arg { using type = float; }; + template <> struct promote_arg{ using type = double; }; + template <> struct promote_arg { using type = long double; }; + template <> struct promote_arg { using type = double; }; template struct promote_args_2 { // Promote, if necessary, & pick the wider of the two floating-point types. // for both parameter types, if integral promote to double. - typedef typename promote_arg::type T1P; // T1 perhaps promoted. - typedef typename promote_arg::type T2P; // T2 perhaps promoted. + using T1P = typename promote_arg::type; // T1 perhaps promoted. + using T2P = typename promote_arg::type; // T2 perhaps promoted. - typedef typename mpl::if_c< - is_floating_point::value && is_floating_point::value, // both T1P and T2P are floating-point? + using type = typename std::conditional< + std::is_floating_point::value && std::is_floating_point::value, // both T1P and T2P are floating-point? #ifdef BOOST_MATH_USE_FLOAT128 - typename mpl::if_c::value || is_same<__float128, T2P>::value, // either long double? + typename std::conditional::value || std::is_same<__float128, T2P>::value, // either long double? __float128, #endif - typename mpl::if_c::value || is_same::value, // either long double? + typename std::conditional::value || std::is_same::value, // either long double? long double, // then result type is long double. - typename mpl::if_c::value || is_same::value, // either double? + typename std::conditional::value || std::is_same::value, // either double? double, // result type is double. float // else result type is float. >::type @@ -101,51 +91,51 @@ namespace boost #endif >::type, // else one or the other is a user-defined type: - typename mpl::if_c::value && ::boost::is_convertible::value, T2P, T1P>::type>::type type; + typename std::conditional::value && std::is_convertible::value, T2P, T1P>::type>::type; }; // promote_arg2 - // These full specialisations reduce mpl::if_ usage and speed up + // These full specialisations reduce std::conditional usage and speed up // compilation: - template <> struct promote_args_2 { typedef float type; }; - template <> struct promote_args_2{ typedef double type; }; - template <> struct promote_args_2 { typedef long double type; }; - template <> struct promote_args_2 { typedef double type; }; - template <> struct promote_args_2 { typedef double type; }; - template <> struct promote_args_2 { typedef double type; }; - template <> struct promote_args_2 { typedef double type; }; - template <> struct promote_args_2 { typedef double type; }; - template <> struct promote_args_2 { typedef long double type; }; - template <> struct promote_args_2 { typedef long double type; }; - template <> struct promote_args_2 { typedef double type; }; - template <> struct promote_args_2 { typedef double type; }; - template <> struct promote_args_2 { typedef long double type; }; - template <> struct promote_args_2 { typedef long double type; }; - template <> struct promote_args_2 { typedef long double type; }; - template <> struct promote_args_2 { typedef long double type; }; + template <> struct promote_args_2 { using type = float; }; + template <> struct promote_args_2{ using type = double; }; + template <> struct promote_args_2 { using type = long double; }; + template <> struct promote_args_2 { using type = double; }; + template <> struct promote_args_2 { using type = double; }; + template <> struct promote_args_2 { using type = double; }; + template <> struct promote_args_2 { using type = double; }; + template <> struct promote_args_2 { using type = double; }; + template <> struct promote_args_2 { using type = long double; }; + template <> struct promote_args_2 { using type = long double; }; + template <> struct promote_args_2 { using type = double; }; + template <> struct promote_args_2 { using type = double; }; + template <> struct promote_args_2 { using type = long double; }; + template <> struct promote_args_2 { using type = long double; }; + template <> struct promote_args_2 { using type = long double; }; + template <> struct promote_args_2 { using type = long double; }; template struct promote_args { - typedef typename promote_args_2< - typename remove_cv::type, + using type = typename promote_args_2< + typename std::remove_cv::type, typename promote_args_2< - typename remove_cv::type, + typename std::remove_cv::type, typename promote_args_2< - typename remove_cv::type, + typename std::remove_cv::type, typename promote_args_2< - typename remove_cv::type, + typename std::remove_cv::type, typename promote_args_2< - typename remove_cv::type, typename remove_cv::type + typename std::remove_cv::type, typename std::remove_cv::type >::type >::type >::type >::type - >::type type; + >::type; #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS // // Guard against use of long double if it's not supported: // - BOOST_STATIC_ASSERT_MSG((0 == ::boost::is_same::value), "Sorry, but this platform does not have sufficient long double support for the special functions to be reliably implemented."); + BOOST_STATIC_ASSERT_MSG((0 == std::is_same::value), "Sorry, but this platform does not have sufficient long double support for the special functions to be reliably implemented."); #endif }; @@ -157,21 +147,21 @@ namespace boost template struct promote_args_permissive { - typedef typename promote_args_2< - typename remove_cv::type, + using type = typename promote_args_2< + typename std::remove_cv::type, typename promote_args_2< - typename remove_cv::type, + typename std::remove_cv::type, typename promote_args_2< - typename remove_cv::type, + typename std::remove_cv::type, typename promote_args_2< - typename remove_cv::type, + typename std::remove_cv::type, typename promote_args_2< - typename remove_cv::type, typename remove_cv::type + typename std::remove_cv::type, typename std::remove_cv::type >::type >::type >::type >::type - >::type type; + >::type; }; } // namespace tools From 07144e2d16fdd649355aec3da0f0ea283d873de3 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sat, 13 Feb 2021 14:34:40 +0300 Subject: [PATCH 14/15] Replace magic target_precision values [CI SKIP] --- .../boost/math/special_functions/lanczos.hpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/boost/math/special_functions/lanczos.hpp b/include/boost/math/special_functions/lanczos.hpp index 061c238ce..4d4aed1ad 100644 --- a/include/boost/math/special_functions/lanczos.hpp +++ b/include/boost/math/special_functions/lanczos.hpp @@ -3230,18 +3230,18 @@ struct lanczos static constexpr auto target_precision = policies::precision::type::value <= 0 ? (std::numeric_limits::max)()-2 : policies::precision::type::value; - using type = typename std::conditional<(target_precision <= 24), lanczos6m24, - typename std::conditional<(target_precision <= 53), lanczos13m53, - typename std::conditional<(target_precision <= 60), lanczos11, - typename std::conditional<(target_precision <= 64), lanczos17m64, - typename std::conditional<(target_precision <= 113), lanczos24m113, - typename std::conditional<(target_precision <= 120), lanczos22, - typename std::conditional<(target_precision <= 134), lanczos32MP, - typename std::conditional<(target_precision <= 168), lanczos35MP, - typename std::conditional<(target_precision <= 201), lanczos48MP, - typename std::conditional<(target_precision <= 234), lanczos49MP, - typename std::conditional<(target_precision <= 267), lanczos49MP_2, - typename std::conditional<(target_precision <= 334), lanczos58MP, undefined_lanczos>::type + using type = typename std::conditional<(target_precision <= lanczos6m24::value), lanczos6m24, + typename std::conditional<(target_precision <= lanczos13m53::value), lanczos13m53, + typename std::conditional<(target_precision <= lanczos11::value), lanczos11, + typename std::conditional<(target_precision <= lanczos17m64::value), lanczos17m64, + typename std::conditional<(target_precision <= lanczos24m113::value), lanczos24m113, + typename std::conditional<(target_precision <= lanczos22::value), lanczos22, + typename std::conditional<(target_precision <= lanczos32MP::value), lanczos32MP, + typename std::conditional<(target_precision <= lanczos35MP::value), lanczos35MP, + typename std::conditional<(target_precision <= lanczos48MP::value), lanczos48MP, + typename std::conditional<(target_precision <= lanczos49MP::value), lanczos49MP, + typename std::conditional<(target_precision <= lanczos49MP_2::value), lanczos49MP_2, + typename std::conditional<(target_precision <= lanczos58MP::value), lanczos58MP, undefined_lanczos>::type >::type>::type>::type>::type>::type>::type>::type>::type>::type>::type >::type; }; From 93467954a9986317f9828760b7f0371105634236 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sat, 13 Feb 2021 19:40:50 +0000 Subject: [PATCH 15/15] Fix up Jamfiles for C++11 s a requirement. Fixes: https://github.com/boostorg/math/issues/531. --- build/Jamfile.v2 | 2 ++ example/Jamfile.v2 | 1 + test/Jamfile.v2 | 1 + 3 files changed, 4 insertions(+) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 3537e9f5d..fd840287e 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -5,6 +5,7 @@ import testing ; import pch ; +import ../../config/checks/config : requires ; project : requirements @@ -18,6 +19,7 @@ project intel-linux:-fvisibility=hidden #sun:-xldscope=hidden [ check-target-builds ../config//has_gcc_visibility "gcc visibility" : gcc:-fvisibility=hidden : ] + [ requires cxx11_noexcept cxx11_rvalue_references sfinae_expr cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_tuple cxx11_hdr_initializer_list cxx11_hdr_chrono cxx11_thread_local cxx11_constexpr cxx11_nullptr cxx11_numeric_limits cxx11_decltype cxx11_hdr_array cxx11_hdr_atomic cxx11_hdr_type_traits cxx11_allocator cxx11_explicit_conversion_operators ] ; cpp-pch pch : ../src/tr1/pch.hpp : ../src/tr1 shared:BOOST_MATH_TR1_DYN_LINK=1 ; diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index e7076a2f9..fb33e6cdf 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -39,6 +39,7 @@ project ../../.. ../include_private off:../test//no_eh + [ requires cxx11_noexcept cxx11_rvalue_references sfinae_expr cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_tuple cxx11_hdr_initializer_list cxx11_hdr_chrono cxx11_thread_local cxx11_constexpr cxx11_nullptr cxx11_numeric_limits cxx11_decltype cxx11_hdr_array cxx11_hdr_atomic cxx11_hdr_type_traits cxx11_allocator cxx11_explicit_conversion_operators ] ; test-suite examples : diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 624bd0b29..3b39e3bcb 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -74,6 +74,7 @@ project $(gmp_path) $(mpfr_path) $(mpfr_path)/build.vc10/lib/Win32/Debug + [ requires cxx11_noexcept cxx11_rvalue_references sfinae_expr cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_tuple cxx11_hdr_initializer_list cxx11_hdr_chrono cxx11_thread_local cxx11_constexpr cxx11_nullptr cxx11_numeric_limits cxx11_decltype cxx11_hdr_array cxx11_hdr_atomic cxx11_hdr_type_traits cxx11_allocator cxx11_explicit_conversion_operators ] ; if $(ntl-path)