|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75983 - in sandbox/math_constants/boost/math: constants policies
From: john_at_[hidden]
Date: 2011-12-16 06:10:49
Author: johnmaddock
Date: 2011-12-16 06:10:48 EST (Fri, 16 Dec 2011)
New Revision: 75983
URL: http://svn.boost.org/trac/boost/changeset/75983
Log:
Change constant architecture to use a structure that can be partially specialised.
Fix min/max issues in error_handling.hpp.
Text files modified:
sandbox/math_constants/boost/math/constants/calculate_constants.hpp | 326 +++++++++++++++++++++++----------------
sandbox/math_constants/boost/math/constants/constants.hpp | 39 ++--
sandbox/math_constants/boost/math/constants/generate.hpp | 2
sandbox/math_constants/boost/math/policies/error_handling.hpp | 4
4 files changed, 218 insertions(+), 153 deletions(-)
Modified: sandbox/math_constants/boost/math/constants/calculate_constants.hpp
==============================================================================
--- sandbox/math_constants/boost/math/constants/calculate_constants.hpp (original)
+++ sandbox/math_constants/boost/math/constants/calculate_constants.hpp 2011-12-16 06:10:48 EST (Fri, 16 Dec 2011)
@@ -10,8 +10,9 @@
namespace boost{ namespace math{ namespace constants{ namespace detail{
-template <class T, int N>
-inline T calculate_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
@@ -64,48 +65,55 @@
*/
}
-template <class T, int N>
-inline T calculate_two_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_two_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return 2 * pi<T, policies::policy<policies::digits2<N> > >();
}
-template <class T, int N>
-inline T calculate_one_div_two_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_one_div_two_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return 1 / two_pi<T, policies::policy<policies::digits2<N> > >();
}
-template <class T, int N>
-inline T calculate_root_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_root_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sqrt(pi<T, policies::policy<policies::digits2<N> > >());
}
-template <class T, int N>
-inline T calculate_root_half_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_root_half_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sqrt(pi<T, policies::policy<policies::digits2<N> > >() / 2);
}
-template <class T, int N>
-inline T calculate_root_two_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_root_two_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sqrt(two_pi<T, policies::policy<policies::digits2<N> > >());
}
-template <class T, int N>
-inline T calculate_root_ln_four(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_root_ln_four<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sqrt(log(static_cast<T>(4)));
}
-template <class T, int N>
-inline T calculate_e(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_e<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
//
// Although we can clearly calculate this from first principles, this hooks into
@@ -116,14 +124,16 @@
return exp(static_cast<T>(1));
}
-template <class T, int N>
-inline T calculate_half(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_half<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return static_cast<T>(1) / static_cast<T>(2);
}
-template <class T, int N>
-inline T calculate_euler(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_euler<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
//
// This is the method described in:
@@ -154,30 +164,34 @@
return N / D;
}
-template <class T, int N>
-inline T calculate_root_two(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_root_two<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sqrt(static_cast<T>(2));
}
-template <class T, int N>
-inline T calculate_root_three(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_root_three<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sqrt(static_cast<T>(3));
}
-template <class T, int N>
-inline T calculate_half_root_two(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_half_root_two<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sqrt(static_cast<T>(2)) / 2;
}
-template <class T, int N>
-inline T calculate_ln_two(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_ln_two<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
//
// Although there are good ways to calculate this from scratch, this hooks into
@@ -188,153 +202,175 @@
return log(static_cast<T>(2));
}
-template <class T, int N>
-inline T calculate_ln_ln_two(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_ln_ln_two<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return log(log(static_cast<T>(2)));
}
-template <class T, int N>
-inline T calculate_third(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_third<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return static_cast<T>(1) / static_cast<T>(3);
}
-template <class T, int N>
-inline T calculate_twothirds(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_twothirds<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return static_cast<T>(2) / static_cast<T>(3);
}
-template <class T, int N>
-inline T calculate_two_thirds(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_two_thirds<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return static_cast<T>(2) / static_cast<T>(3);
}
-template <class T, int N>
-inline T calculate_three_quarters(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_three_quarters<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return static_cast<T>(3) / static_cast<T>(4);
}
-template <class T, int N>
-inline T calculate_pi_minus_three(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_pi_minus_three<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return pi<T, policies::policy<policies::digits2<N> > >() - static_cast<T>(3);
}
-template <class T, int N>
-inline T calculate_four_minus_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_four_minus_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return static_cast<T>(4) - pi<T, policies::policy<policies::digits2<N> > >();
}
-template <class T, int N>
-inline T calculate_pow23_four_minus_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_pow23_four_minus_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pow(four_minus_pi<T, policies::policy<policies::digits2<N> > >(), static_cast<T>(1.5));
}
-template <class T, int N>
-inline T calculate_exp_minus_half(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_exp_minus_half<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return exp(static_cast<T>(-0.5));
}
// Pi
-template <class T, int N>
-inline T calculate_one_div_root_two(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_one_div_root_two<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return static_cast<T>(1) / root_two<T, policies::policy<policies::digits2<N> > >();
}
-template <class T, int N>
-inline T calculate_one_div_root_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_one_div_root_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return static_cast<T>(1) / root_pi<T, policies::policy<policies::digits2<N> > >();
}
-template <class T, int N>
-inline T calculate_one_div_root_two_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_one_div_root_two_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return static_cast<T>(1) / root_two_pi<T, policies::policy<policies::digits2<N> > >();
}
-template <class T, int N>
-inline T calculate_root_one_div_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_root_one_div_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
return sqrt(static_cast<T>(1) / pi<T, policies::policy<policies::digits2<N> > >());
}
-template <class T, int N>
-inline T calculate_four_thirds_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_four_thirds_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >() * static_cast<T>(4) / static_cast<T>(3);
}
-template <class T, int N>
-inline T calculate_half_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_half_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >() / static_cast<T>(2);
}
-template <class T, int N>
-inline T calculate_third_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_third_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >() / static_cast<T>(3);
}
-template <class T, int N>
-inline T calculate_sixth_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_sixth_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >() / static_cast<T>(6);
}
-template <class T, int N>
-inline T calculate_two_thirds_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_two_thirds_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >() * static_cast<T>(2) / static_cast<T>(3);
}
-template <class T, int N>
-inline T calculate_three_quarters_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_three_quarters_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >() * static_cast<T>(3) / static_cast<T>(4);
}
-template <class T, int N>
-inline T calculate_pi_pow_e(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_pi_pow_e<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pow(pi<T, policies::policy<policies::digits2<N> > >(), e<T, policies::policy<policies::digits2<N> > >()); //
}
-template <class T, int N>
-inline T calculate_pi_sqr(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_pi_sqr<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >()
* pi<T, policies::policy<policies::digits2<N> > >() ; //
}
-template <class T, int N>
-inline T calculate_pi_sqr_div_six(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_pi_sqr_div_six<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >()
@@ -343,8 +379,9 @@
}
-template <class T, int N>
-inline T calculate_pi_cubed(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_pi_cubed<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >()
@@ -353,15 +390,17 @@
; //
}
-template <class T, int N>
-inline T calculate_cbrt_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_cbrt_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pow(pi<T, policies::policy<policies::digits2<N> > >(), static_cast<T>(-3));
}
-template <class T, int N>
-inline T calculate_one_div_cbrt_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_one_div_cbrt_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return static_cast<T>(1)
@@ -370,29 +409,33 @@
// Euler's e
-template <class T, int N>
-inline T calculate_e_pow_pi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_e_pow_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pow(e<T, policies::policy<policies::digits2<N> > >(), pi<T, policies::policy<policies::digits2<N> > >()); //
}
-template <class T, int N>
-inline T calculate_root_e(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_root_e<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sqrt(e<T, policies::policy<policies::digits2<N> > >());
}
-template <class T, int N>
-inline T calculate_log10_e(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_log10_e<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return log10(e<T, policies::policy<policies::digits2<N> > >());
}
-template <class T, int N>
-inline T calculate_one_div_log10_e(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_one_div_log10_e<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return static_cast<T>(1) /
@@ -401,8 +444,9 @@
// Trigonometric
-template <class T, int N>
-inline T calculate_degree(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_degree<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return pi<T, policies::policy<policies::digits2<N> > >()
@@ -410,8 +454,9 @@
; //
}
-template <class T, int N>
-inline T calculate_radian(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_radian<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return static_cast<T>(180)
@@ -419,50 +464,57 @@
; //
}
-template <class T, int N>
-inline T calculate_sin_one(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_sin_one<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sin(static_cast<T>(1)) ; //
}
-template <class T, int N>
-inline T calculate_cos_one(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_cos_one<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return cos(static_cast<T>(1)) ; //
}
-template <class T, int N>
-inline T calculate_sinh_one(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_sinh_one<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return sinh(static_cast<T>(1)) ; //
}
-template <class T, int N>
-inline T calculate_cosh_one(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_cosh_one<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return cosh(static_cast<T>(1)) ; //
}
-template <class T, int N>
-inline T calculate_phi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_phi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return (static_cast<T>(1) + sqrt(static_cast<T>(5)) )/static_cast<T>(2) ; //
}
-template <class T, int N>
-inline T calculate_log_phi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_log_phi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
//return log(phi<T, policies::policy<policies::digits2<N> > >()); // ???
return log((static_cast<T>(1) + sqrt(static_cast<T>(5)) )/static_cast<T>(2) );
}
-template <class T, int N>
-inline T calculate_one_div_log_phi(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_one_div_log_phi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
return static_cast<T>(1) /
@@ -475,8 +527,9 @@
//http://en.wikipedia.org/wiki/Gamma_function
-template <class T, int N>
-inline T calculate_gamma(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_gamma<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
// 1000 digits from http://www.wolframalpha.com
@@ -502,8 +555,9 @@
}
-template <class T, int N>
-inline T calculate_one_div_gamma(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_one_div_gamma<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
@@ -511,9 +565,9 @@
/ gamma<T, policies::policy<policies::digits2<N> > >();
}
-
-template <class T, int N>
-inline T calculate_gamma_sqr(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_gamma_sqr<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
@@ -522,8 +576,9 @@
}
// Continued fraction
-template <class T, int N>
-inline T calculate_cf10(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_cf10<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
// TODO calculate this.
BOOST_MATH_STD_USING
@@ -533,8 +588,9 @@
//Zeta
-template <class T, int N>
-inline T calculate_zeta_two(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_zeta_two<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
BOOST_MATH_STD_USING
@@ -543,8 +599,9 @@
/static_cast<T>(6);
}
-template <class T, int N>
-inline T calculate_zeta_three(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_zeta_three<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{
// http://mathworld.wolfram.com/AperysConstant.html
// http://en.wikipedia.org/wiki/Mathematical_constant
@@ -601,8 +658,9 @@
return sum / 64;
}
-template <class T, int N>
-inline T calculate_catalan(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_catalan<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{ // http://oeis.org/A006752/constant
//T c("0.915965594177219015054603514932384110774"
//"149374281672134266498119621763019776254769479356512926115106248574");
@@ -636,8 +694,9 @@
}
-template <class T, int N>
-inline T calculate_khinchin(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_khinchin<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{ // from e_float constants.cpp
// http://mathworld.wolfram.com/KhinchinsConstant.html
// TODO calculate this.
@@ -655,8 +714,9 @@
return k;
}
-template <class T, int N>
-inline T calculate_extreme_value_skewness(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_extreme_value_skewness<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{ // from e_float constants.cpp
// Mathematica: N[12 Sqrt[6] Zeta[3]/Pi^3, 1101]
// TODO Calculate this.
@@ -677,8 +737,9 @@
return ev;
}
-template <class T, int N>
-inline T calculate_glaisher(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_glaisher<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{ // from http://mpmath.googlecode.com/svn/data/glaisher.txt
// 20,000 digits of the Glaisher-Kinkelin constant A = exp(1/2 - zeta'(-1))
// Computed using A = exp((6 (-zeta(2))/pi^2 + log 2 pi + gamma)/12)
@@ -703,8 +764,9 @@
return g;
}
-template <class T, int N>
-inline T calculate_rayleigh_skewness(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_rayleigh_skewness<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{ // From e_float
// 1100 digits of the Rayleigh distribution skewness
// Mathematica: N[2 Sqrt[Pi] (Pi - 3)/((4 - Pi)^(3/2)), 1100]
@@ -725,8 +787,9 @@
return rs;
}
-template <class T, int N>
-inline T calculate_rayleigh_kurtosis_excess(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_rayleigh_kurtosis_excess<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{ // - (6 Pi^2 - 24 Pi + 16)/((Pi - 4)^2)
// TODO Calculate this using pi_minus_four etc.
return - (((static_cast<T>(6) * pi<T, policies::policy<policies::digits2<N> > >()
@@ -738,8 +801,9 @@
);
}
-template <class T, int N>
-inline T calculate_rayleigh_kurtosis(const mpl::int_<N>&BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+template <class T>
+template<int N>
+inline T constant_rayleigh_kurtosis<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
{ // 3 - (6 Pi^2 - 24 Pi + 16)/((Pi - 4)^2)
// TODO Calculate this using pi_minus_four etc.
return static_cast<T>(3) - (((static_cast<T>(6) * pi<T, policies::policy<policies::digits2<N> > >()
Modified: sandbox/math_constants/boost/math/constants/constants.hpp
==============================================================================
--- sandbox/math_constants/boost/math/constants/constants.hpp (original)
+++ sandbox/math_constants/boost/math/constants/constants.hpp 2011-12-16 06:10:48 EST (Fri, 16 Dec 2011)
@@ -160,43 +160,44 @@
#define BOOST_DEFINE_MATH_CONSTANT(name, x, y, exp)\
namespace detail{\
- /* Forward declaration of the calculation method, just in case it's not been provided yet */ \
- template <class T, int N> T BOOST_JOIN(calculate_, name)(const mpl::int_<N>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T)); \
- \
+ template <class T> struct BOOST_JOIN(constant_, name){\
+ private:\
/* The default implementations come next: */ \
- template <class T> inline T BOOST_JOIN(string_get_, name)(BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))\
+ static inline T get_from_string()\
{\
static const T result = detail::convert_from_string<T>(BOOST_STRINGIZE(BOOST_JOIN(BOOST_JOIN(x, y), BOOST_JOIN(e, exp))), boost::is_convertible<const char*, T>());\
return result;\
}\
- template <class T> inline T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_string>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(T))\
+ /* This one is for very high precision that is none the less known at compile time: */ \
+ template <int N> static T compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>));\
+ /* public getters come next */\
+ public:\
+ static inline T get(const mpl::int_<construct_from_string>&)\
{\
- constant_initializer<T, & BOOST_JOIN(string_get_, name)<T> >::do_nothing();\
- return BOOST_JOIN(string_get_, name)<T>();\
+ constant_initializer<T, & BOOST_JOIN(constant_, name)<T>::get_from_string >::do_nothing();\
+ return get_from_string();\
}\
- template <class T> inline BOOST_CONSTEXPR T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_float>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+ static inline BOOST_CONSTEXPR T get(const mpl::int_<construct_from_float>)\
{ return BOOST_JOIN(BOOST_JOIN(x, BOOST_JOIN(e, exp)), F); }\
- template <class T> inline BOOST_CONSTEXPR T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_double>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+ static inline BOOST_CONSTEXPR T get(const mpl::int_<construct_from_double>&)\
{ return BOOST_JOIN(x, BOOST_JOIN(e, exp)); }\
- template <class T> inline BOOST_CONSTEXPR T BOOST_JOIN(get_, name)(const mpl::int_<construct_from_long_double>& BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+ static inline BOOST_CONSTEXPR T get(const mpl::int_<construct_from_long_double>&)\
{ return BOOST_JOIN(BOOST_JOIN(x, BOOST_JOIN(e, exp)), L); }\
- /* This one is for very high precision that is none the less known at compile time: */ \
- template <class T, int N> inline T BOOST_JOIN(compute_get_, name)(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
- { static const T result = BOOST_JOIN(calculate_, name)<T>(mpl::int_<N>()); return result; }\
- template <class T, int N> inline T BOOST_JOIN(get_, name)(const mpl::int_<N>& n BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
+ template <int N> static inline T get(const mpl::int_<N>& n)\
{\
- constant_initializer2<T, N, & BOOST_JOIN(compute_get_, name)<T, N> >::do_nothing();\
- return BOOST_JOIN(compute_get_, name)<T, N>(); \
+ constant_initializer2<T, N, & BOOST_JOIN(constant_, name)<T>::template compute<N> >::do_nothing();\
+ return compute<N>(); \
}\
/* This one is for true arbitary precision, which may well vary at runtime: */ \
- template <class T> inline T BOOST_JOIN(get_, name)(const mpl::int_<0>& n BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
- { return tools::digits<T>() > max_string_digits ? BOOST_JOIN(calculate_, name)<T>(n) : BOOST_JOIN(get_, name)<T>(mpl::int_<construct_from_string>()); }\
+ static inline T get(const mpl::int_<0>&)\
+ { return tools::digits<T>() > max_string_digits ? compute<0>() : get(mpl::int_<construct_from_string>()); }\
+ }; /* end of struct */\
} /* namespace detail */ \
\
\
/* The actual forwarding function: */ \
template <class T, class Policy> inline BOOST_CONSTEXPR T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(Policy))\
- { return detail:: BOOST_JOIN(get_, name)<T>(typename construction_traits<T, Policy>::type()); }\
+ { return detail:: BOOST_JOIN(constant_, name)<T>::get(typename construction_traits<T, Policy>::type()); }\
template <class T> inline BOOST_CONSTEXPR T name(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T))\
{ return name<T, boost::math::policies::policy<> >(); }\
\
Modified: sandbox/math_constants/boost/math/constants/generate.hpp
==============================================================================
--- sandbox/math_constants/boost/math/constants/generate.hpp (original)
+++ sandbox/math_constants/boost/math/constants/generate.hpp 2011-12-16 06:10:48 EST (Fri, 16 Dec 2011)
@@ -68,7 +68,7 @@
#define BOOST_CONSTANTS_GENERATE(name) \
boost::math::constants::print_constant(#name, \
- & boost::math::constants::detail::BOOST_JOIN(calculate_, name)<boost::math::constants::generator_type>)
+ & boost::math::constants::detail::BOOST_JOIN(constant_, name)<boost::math::constants::generator_type>::get)
}}} // namespaces
Modified: sandbox/math_constants/boost/math/policies/error_handling.hpp
==============================================================================
--- sandbox/math_constants/boost/math/policies/error_handling.hpp (original)
+++ sandbox/math_constants/boost/math/policies/error_handling.hpp 2011-12-16 06:10:48 EST (Fri, 16 Dec 2011)
@@ -404,7 +404,7 @@
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
- return std::numeric_limits<T>::is_specialized ? (val > 0 ? std::numeric_limits<T>::max() : -std::numeric_limits<T>::max()): val;
+ return std::numeric_limits<T>::is_specialized ? (val > 0 ? (std::numeric_limits<T>::max)() : -(std::numeric_limits<T>::max)()): val;
}
template <class T, class TargetType>
@@ -418,7 +418,7 @@
errno = ERANGE;
// This may or may not do the right thing, but the user asked for the error
// to be silent so here we go anyway:
- return std::numeric_limits<T>::is_specialized ? (val > 0 ? std::numeric_limits<T>::max() : -std::numeric_limits<T>::max()): val;
+ return std::numeric_limits<T>::is_specialized ? (val > 0 ? (std::numeric_limits<T>::max)() : -(std::numeric_limits<T>::max)()): val;
}
template <class T, class TargetType>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk