diff --git a/include/boost/math/constants/calculate_constants.hpp b/include/boost/math/constants/calculate_constants.hpp index 2dcdb9a02..71487885b 100644 --- a/include/boost/math/constants/calculate_constants.hpp +++ b/include/boost/math/constants/calculate_constants.hpp @@ -296,6 +296,15 @@ inline T constant_three_quarters::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S return static_cast(3) / static_cast(4); } +template +template +inline T constant_sixth::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_)) +{ + BOOST_MATH_STD_USING + return static_cast(1) / static_cast(6); +} + +// Pi and related constants. template template inline T constant_pi_minus_three::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_)) @@ -326,7 +335,14 @@ inline T constant_exp_minus_half::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S return exp(static_cast(-0.5)); } -// Pi +template +template +inline T constant_exp_minus_one::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_)) +{ + BOOST_MATH_STD_USING + return exp(static_cast(-1.)); +} + template template inline T constant_one_div_root_two::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_)) @@ -356,7 +372,6 @@ inline T constant_root_one_div_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_ return sqrt(static_cast(1) / pi > >()); } - template template inline T constant_four_thirds_pi::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_)) diff --git a/include/boost/math/constants/constants.hpp b/include/boost/math/constants/constants.hpp index b5db9cedf..d35aa0271 100644 --- a/include/boost/math/constants/constants.hpp +++ b/include/boost/math/constants/constants.hpp @@ -65,8 +65,7 @@ namespace boost{ namespace math struct dummy_size{}; // - // Max number of binary digits in the string representations - // of our constants: + // Max number of binary digits in the string representations of our constants: // BOOST_STATIC_CONSTANT(int, max_string_digits = (101 * 1000L) / 301L); @@ -266,6 +265,7 @@ namespace boost{ namespace math BOOST_DEFINE_MATH_CONSTANT(third, 3.333333333333333333333333333333333333e-01, "3.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333e-01") BOOST_DEFINE_MATH_CONSTANT(twothirds, 6.666666666666666666666666666666666666e-01, "6.66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667e-01") BOOST_DEFINE_MATH_CONSTANT(two_thirds, 6.666666666666666666666666666666666666e-01, "6.66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667e-01") + BOOST_DEFINE_MATH_CONSTANT(sixth, 1.666666666666666666666666666666666666e-01, "1.66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667e-01"); BOOST_DEFINE_MATH_CONSTANT(three_quarters, 7.500000000000000000000000000000000000e-01, "7.50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e-01") BOOST_DEFINE_MATH_CONSTANT(root_two, 1.414213562373095048801688724209698078e+00, "1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157273501384623e+00") BOOST_DEFINE_MATH_CONSTANT(root_three, 1.732050807568877293527446341505872366e+00, "1.73205080756887729352744634150587236694280525381038062805580697945193301690880003708114618675724857567562614142e+00") @@ -301,6 +301,7 @@ namespace boost{ namespace math BOOST_DEFINE_MATH_CONSTANT(one_div_cbrt_pi, 6.827840632552956814670208331581645981e-01, "6.82784063255295681467020833158164598108367515632448804042681583118899226433403918237673501922595519865685577274e-01") BOOST_DEFINE_MATH_CONSTANT(e, 2.718281828459045235360287471352662497e+00, "2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193e+00") BOOST_DEFINE_MATH_CONSTANT(exp_minus_half, 6.065306597126334236037995349911804534e-01, "6.06530659712633423603799534991180453441918135487186955682892158735056519413748423998647611507989456026423789794e-01") + BOOST_DEFINE_MATH_CONSTANT(exp_minus_one, 3.678794411714423215955237701614608674e-01, "3.67879441171442321595523770161460867445811131031767834507836801697461495744899803357147274345919643746627325277e-01"); BOOST_DEFINE_MATH_CONSTANT(e_pow_pi, 2.314069263277926900572908636794854738e+01, "2.31406926327792690057290863679485473802661062426002119934450464095243423506904527835169719970675492196759527048e+01") BOOST_DEFINE_MATH_CONSTANT(root_e, 1.648721270700128146848650787814163571e+00, "1.64872127070012814684865078781416357165377610071014801157507931164066102119421560863277652005636664300286663776e+00") BOOST_DEFINE_MATH_CONSTANT(log10_e, 4.342944819032518276511289189166050822e-01, "4.34294481903251827651128918916605082294397005803666566114453783165864649208870774729224949338431748318706106745e-01") diff --git a/test/test_constant_generate.cpp b/test/test_constant_generate.cpp index 937f26750..53f1c6a73 100644 --- a/test/test_constant_generate.cpp +++ b/test/test_constant_generate.cpp @@ -14,8 +14,9 @@ // To add new constants, add a function that calculates the value of the constant to // boost/math/constants/calculate_constants.hpp +// See http://www.boost.org/doc/libs/release/libs/math/doc/html/math_toolkit/new_const.html -#include +#include // Requires /modular-boost/libs/math/include_private in search path. #include int main() @@ -26,6 +27,7 @@ int main() BOOST_CONSTANTS_GENERATE(twothirds); BOOST_CONSTANTS_GENERATE(two_thirds); BOOST_CONSTANTS_GENERATE(three_quarters); + BOOST_CONSTANTS_GENERATE(sixth); // two and related. BOOST_CONSTANTS_GENERATE(root_two); BOOST_CONSTANTS_GENERATE(root_three); @@ -69,6 +71,7 @@ int main() // Euler's e and related. BOOST_CONSTANTS_GENERATE(e); BOOST_CONSTANTS_GENERATE(exp_minus_half); + BOOST_CONSTANTS_GENERATE(exp_minus_one); BOOST_CONSTANTS_GENERATE(e_pow_pi); BOOST_CONSTANTS_GENERATE(root_e); diff --git a/test/test_constants.cpp b/test/test_constants.cpp index 85e5a893f..3eb2fc1fc 100644 --- a/test/test_constants.cpp +++ b/test/test_constants.cpp @@ -157,6 +157,8 @@ void test_spots(RealType) BOOST_CHECK_CLOSE_FRACTION(0.333333333333333333333333333333333333333L, third(), tolerance); BOOST_CHECK_CLOSE_FRACTION(0.666666666666666666666666666666666666667L, two_thirds(), tolerance); BOOST_CHECK_CLOSE_FRACTION(0.75L, three_quarters(), tolerance); + BOOST_CHECK_CLOSE_FRACTION(0.1666666666666666666666666666666666666667L, sixth(), tolerance); + // Two and related. BOOST_CHECK_CLOSE_FRACTION(sqrt(2.L), root_two(), tolerance); BOOST_CHECK_CLOSE_FRACTION(sqrt(3.L), root_three(), tolerance); @@ -195,8 +197,8 @@ void test_spots(RealType) // Euler BOOST_CHECK_CLOSE_FRACTION(2.71828182845904523536028747135266249775724709369995L, e(), tolerance); - //BOOST_CHECK_CLOSE_FRACTION(exp(-0.5L), exp_minus_half(), tolerance); // See above. + BOOST_CHECK_CLOSE_FRACTION(exp(-1.L), exp_minus_one(), tolerance); BOOST_CHECK_CLOSE_FRACTION(pow(e(), pi()), e_pow_pi(), tolerance); // See also above. BOOST_CHECK_CLOSE_FRACTION(sqrt(e()), root_e(), tolerance); BOOST_CHECK_CLOSE_FRACTION(log10(e()), log10_e(), tolerance);