mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Added new constants expminusone and sixth
This commit is contained in:
@@ -296,6 +296,15 @@ inline T constant_three_quarters<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S
|
||||
return static_cast<T>(3) / static_cast<T>(4);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template<int N>
|
||||
inline T constant_sixth<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
return static_cast<T>(1) / static_cast<T>(6);
|
||||
}
|
||||
|
||||
// Pi and related constants.
|
||||
template <class T>
|
||||
template<int N>
|
||||
inline T constant_pi_minus_three<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
|
||||
@@ -326,7 +335,14 @@ inline T constant_exp_minus_half<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_S
|
||||
return exp(static_cast<T>(-0.5));
|
||||
}
|
||||
|
||||
// Pi
|
||||
template <class T>
|
||||
template<int N>
|
||||
inline T constant_exp_minus_one<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
|
||||
{
|
||||
BOOST_MATH_STD_USING
|
||||
return exp(static_cast<T>(-1.));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
template<int N>
|
||||
inline T constant_one_div_root_two<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
|
||||
@@ -356,7 +372,6 @@ inline T constant_root_one_div_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_
|
||||
return sqrt(static_cast<T>(1) / pi<T, policies::policy<policies::digits2<N> > >());
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
template<int N>
|
||||
inline T constant_four_thirds_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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 <boost/math/constants/generate.hpp>
|
||||
#include <boost/math/constants/generate.hpp> // Requires /modular-boost/libs/math/include_private in search path.
|
||||
#include <boost/math/constants/calculate_constants.hpp>
|
||||
|
||||
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);
|
||||
|
||||
@@ -157,6 +157,8 @@ void test_spots(RealType)
|
||||
BOOST_CHECK_CLOSE_FRACTION(0.333333333333333333333333333333333333333L, third<RealType>(), tolerance);
|
||||
BOOST_CHECK_CLOSE_FRACTION(0.666666666666666666666666666666666666667L, two_thirds<RealType>(), tolerance);
|
||||
BOOST_CHECK_CLOSE_FRACTION(0.75L, three_quarters<RealType>(), tolerance);
|
||||
BOOST_CHECK_CLOSE_FRACTION(0.1666666666666666666666666666666666666667L, sixth<RealType>(), tolerance);
|
||||
|
||||
// Two and related.
|
||||
BOOST_CHECK_CLOSE_FRACTION(sqrt(2.L), root_two<RealType>(), tolerance);
|
||||
BOOST_CHECK_CLOSE_FRACTION(sqrt(3.L), root_three<RealType>(), tolerance);
|
||||
@@ -195,8 +197,8 @@ void test_spots(RealType)
|
||||
|
||||
// Euler
|
||||
BOOST_CHECK_CLOSE_FRACTION(2.71828182845904523536028747135266249775724709369995L, e<RealType>(), tolerance);
|
||||
|
||||
//BOOST_CHECK_CLOSE_FRACTION(exp(-0.5L), exp_minus_half<RealType>(), tolerance); // See above.
|
||||
BOOST_CHECK_CLOSE_FRACTION(exp(-1.L), exp_minus_one<RealType>(), tolerance);
|
||||
BOOST_CHECK_CLOSE_FRACTION(pow(e<RealType>(), pi<RealType>()), e_pow_pi<RealType>(), tolerance); // See also above.
|
||||
BOOST_CHECK_CLOSE_FRACTION(sqrt(e<RealType>()), root_e<RealType>(), tolerance);
|
||||
BOOST_CHECK_CLOSE_FRACTION(log10(e<RealType>()), log10_e<RealType>(), tolerance);
|
||||
|
||||
Reference in New Issue
Block a user