Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78711 - in trunk: boost/math boost/math/constants boost/math/distributions boost/math/policies boost/math/special_functions libs/math/test/compile_test
From: john_at_[hidden]
Date: 2012-05-28 07:05:45


Author: johnmaddock
Date: 2012-05-28 07:05:43 EDT (Mon, 28 May 2012)
New Revision: 78711
URL: http://svn.boost.org/trac/boost/changeset/78711

Log:
Update concept checks to unmask issues reported in #6934.
Add some distributions to the concept tests that were missing before.
Add skew_normal_distribution to distributions.hpp.
Fix some errors in calculating custom policies when the defaults have been changed.
Fix the errors and warnings that result from the above.
Refs #6934.
Text files modified:
   trunk/boost/math/constants/calculate_constants.hpp | 1
   trunk/boost/math/distributions.hpp | 1
   trunk/boost/math/distributions/skew_normal.hpp | 85 ++++++++++++++++++++-------------------
   trunk/boost/math/policies/policy.hpp | 8 +-
   trunk/boost/math/special_functions/expm1.hpp | 4
   trunk/libs/math/test/compile_test/distribution_concept_check.cpp | 54 ++++++++++++++++---------
   trunk/libs/math/test/compile_test/instantiate.hpp | 4 +
   7 files changed, 88 insertions(+), 69 deletions(-)

Modified: trunk/boost/math/constants/calculate_constants.hpp
==============================================================================
--- trunk/boost/math/constants/calculate_constants.hpp (original)
+++ trunk/boost/math/constants/calculate_constants.hpp 2012-05-28 07:05:43 EDT (Mon, 28 May 2012)
@@ -85,6 +85,7 @@
 template <int N>
 inline T constant_root_two_div_pi<T>::compute(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(mpl::int_<N>))
 {
+ BOOST_MATH_STD_USING
    return sqrt((2 / pi<T, policies::policy<policies::digits2<N> > >()));
 }
 

Modified: trunk/boost/math/distributions.hpp
==============================================================================
--- trunk/boost/math/distributions.hpp (original)
+++ trunk/boost/math/distributions.hpp 2012-05-28 07:05:43 EDT (Mon, 28 May 2012)
@@ -39,6 +39,7 @@
 #include <boost/math/distributions/pareto.hpp>
 #include <boost/math/distributions/poisson.hpp>
 #include <boost/math/distributions/rayleigh.hpp>
+#include <boost/math/distributions/skew_normal.hpp>
 #include <boost/math/distributions/students_t.hpp>
 #include <boost/math/distributions/triangular.hpp>
 #include <boost/math/distributions/uniform.hpp>

Modified: trunk/boost/math/distributions/skew_normal.hpp
==============================================================================
--- trunk/boost/math/distributions/skew_normal.hpp (original)
+++ trunk/boost/math/distributions/skew_normal.hpp 2012-05-28 07:05:43 EDT (Mon, 28 May 2012)
@@ -476,50 +476,51 @@
     // 21 elements
     static const RealType shapes[] = {
       0.0,
- 1.000000000000000e-004,
- 2.069138081114790e-004,
- 4.281332398719396e-004,
- 8.858667904100824e-004,
- 1.832980710832436e-003,
- 3.792690190732250e-003,
- 7.847599703514606e-003,
- 1.623776739188722e-002,
- 3.359818286283781e-002,
- 6.951927961775606e-002,
- 1.438449888287663e-001,
- 2.976351441631319e-001,
- 6.158482110660261e-001,
- 1.274274985703135e+000,
- 2.636650898730361e+000,
- 5.455594781168514e+000,
- 1.128837891684688e+001,
- 2.335721469090121e+001,
- 4.832930238571753e+001,
- 1.000000000000000e+002};
+ static_cast<RealType>(1.000000000000000e-004),
+ static_cast<RealType>(2.069138081114790e-004),
+ static_cast<RealType>(4.281332398719396e-004),
+ static_cast<RealType>(8.858667904100824e-004),
+ static_cast<RealType>(1.832980710832436e-003),
+ static_cast<RealType>(3.792690190732250e-003),
+ static_cast<RealType>(7.847599703514606e-003),
+ static_cast<RealType>(1.623776739188722e-002),
+ static_cast<RealType>(3.359818286283781e-002),
+ static_cast<RealType>(6.951927961775606e-002),
+ static_cast<RealType>(1.438449888287663e-001),
+ static_cast<RealType>(2.976351441631319e-001),
+ static_cast<RealType>(6.158482110660261e-001),
+ static_cast<RealType>(1.274274985703135e+000),
+ static_cast<RealType>(2.636650898730361e+000),
+ static_cast<RealType>(5.455594781168514e+000),
+ static_cast<RealType>(1.128837891684688e+001),
+ static_cast<RealType>(2.335721469090121e+001),
+ static_cast<RealType>(4.832930238571753e+001),
+ static_cast<RealType>(1.000000000000000e+002)
+ };
 
     // 21 elements
     static const RealType guess[] = {
       0.0,
- 5.000050000525391e-005,
- 1.500015000148736e-004,
- 3.500035000350010e-004,
- 7.500075000752560e-004,
- 1.450014500145258e-003,
- 3.050030500305390e-003,
- 6.250062500624765e-003,
- 1.295012950129504e-002,
- 2.675026750267495e-002,
- 5.525055250552491e-002,
- 1.132511325113255e-001,
- 2.249522495224952e-001,
- 3.992539925399257e-001,
- 5.353553535535358e-001,
- 4.954549545495457e-001,
- 3.524535245352451e-001,
- 2.182521825218249e-001,
- 1.256512565125654e-001,
- 6.945069450694508e-002,
- 3.735037350373460e-002
+ static_cast<RealType>(5.000050000525391e-005),
+ static_cast<RealType>(1.500015000148736e-004),
+ static_cast<RealType>(3.500035000350010e-004),
+ static_cast<RealType>(7.500075000752560e-004),
+ static_cast<RealType>(1.450014500145258e-003),
+ static_cast<RealType>(3.050030500305390e-003),
+ static_cast<RealType>(6.250062500624765e-003),
+ static_cast<RealType>(1.295012950129504e-002),
+ static_cast<RealType>(2.675026750267495e-002),
+ static_cast<RealType>(5.525055250552491e-002),
+ static_cast<RealType>(1.132511325113255e-001),
+ static_cast<RealType>(2.249522495224952e-001),
+ static_cast<RealType>(3.992539925399257e-001),
+ static_cast<RealType>(5.353553535535358e-001),
+ static_cast<RealType>(4.954549545495457e-001),
+ static_cast<RealType>(3.524535245352451e-001),
+ static_cast<RealType>(2.182521825218249e-001),
+ static_cast<RealType>(1.256512565125654e-001),
+ static_cast<RealType>(6.945069450694508e-002),
+ static_cast<RealType>(3.735037350373460e-002)
     };
 
     const RealType* result_ptr = std::lower_bound(shapes, shapes+21, shape);
@@ -532,7 +533,7 @@
 
     // TODO: make the search bounds smarter, depending on the shape parameter
     RealType search_min = 0; // below zero was caught above
- RealType search_max = 0.55; // will never go above 0.55
+ RealType search_max = 0.55f; // will never go above 0.55
 
     // refine
     if(d < static_cast<diff_type>(21)) // shape smaller 100
@@ -544,7 +545,7 @@
     }
     else // shape greater 100
     {
- result = 1e-4;
+ result = 1e-4f;
       search_max = guess[19]; // set 19 instead of 20 to have a safety margin because the table may not be exact @ shape=100
     }
     

Modified: trunk/boost/math/policies/policy.hpp
==============================================================================
--- trunk/boost/math/policies/policy.hpp (original)
+++ trunk/boost/math/policies/policy.hpp 2012-05-28 07:05:43 EDT (Mon, 28 May 2012)
@@ -431,7 +431,7 @@
    //
    // Mathematically undefined properties:
    //
- typedef typename detail::find_arg<arg_list, is_assert_undefined<mpl::_1>, discrete_quantile<> >::type assert_undefined_type;
+ typedef typename detail::find_arg<arg_list, is_assert_undefined<mpl::_1>, assert_undefined<> >::type assert_undefined_type;
    //
    // Max iterations:
    //
@@ -537,12 +537,12 @@
    //
    // Mathematically undefined properties:
    //
- typedef typename detail::find_arg<arg_list, is_assert_undefined<mpl::_1>, discrete_quantile<> >::type assert_undefined_type;
+ typedef typename detail::find_arg<arg_list, is_assert_undefined<mpl::_1>, typename Policy::assert_undefined_type >::type assert_undefined_type;
    //
    // Max iterations:
    //
- typedef typename detail::find_arg<arg_list, is_max_series_iterations<mpl::_1>, max_series_iterations<> >::type max_series_iterations_type;
- typedef typename detail::find_arg<arg_list, is_max_root_iterations<mpl::_1>, max_root_iterations<> >::type max_root_iterations_type;
+ typedef typename detail::find_arg<arg_list, is_max_series_iterations<mpl::_1>, typename Policy::max_series_iterations_type>::type max_series_iterations_type;
+ typedef typename detail::find_arg<arg_list, is_max_root_iterations<mpl::_1>, typename Policy::max_root_iterations_type>::type max_root_iterations_type;
    //
    // Define a typelist of the policies:
    //

Modified: trunk/boost/math/special_functions/expm1.hpp
==============================================================================
--- trunk/boost/math/special_functions/expm1.hpp (original)
+++ trunk/boost/math/special_functions/expm1.hpp 2012-05-28 07:05:43 EDT (Mon, 28 May 2012)
@@ -151,8 +151,8 @@
       return x;
 
    static const float Y = 0.10281276702880859e1f;
- static const T n[] = { -0.28127670288085937e-1, 0.51278186299064534e0, -0.6310029069350198e-1, 0.11638457975729296e-1, -0.52143390687521003e-3, 0.21491399776965688e-4 };
- static const T d[] = { 1, -0.45442309511354755e0, 0.90850389570911714e-1, -0.10088963629815502e-1, 0.63003407478692265e-3, -0.17976570003654402e-4 };
+ static const T n[] = { static_cast<T>(-0.28127670288085937e-1), static_cast<T>(0.51278186299064534e0), static_cast<T>(-0.6310029069350198e-1), static_cast<T>(0.11638457975729296e-1), static_cast<T>(-0.52143390687521003e-3), static_cast<T>(0.21491399776965688e-4) };
+ static const T d[] = { 1, static_cast<T>(-0.45442309511354755e0), static_cast<T>(0.90850389570911714e-1), static_cast<T>(-0.10088963629815502e-1), static_cast<T>(0.63003407478692265e-3), static_cast<T>(-0.17976570003654402e-4) };
 
    T result = x * Y + x * tools::evaluate_polynomial(n, x) / tools::evaluate_polynomial(d, x);
    return result;

Modified: trunk/libs/math/test/compile_test/distribution_concept_check.cpp
==============================================================================
--- trunk/libs/math/test/compile_test/distribution_concept_check.cpp (original)
+++ trunk/libs/math/test/compile_test/distribution_concept_check.cpp 2012-05-28 07:05:43 EDT (Mon, 28 May 2012)
@@ -16,26 +16,40 @@
    using namespace boost::math;
    using namespace boost::math::concepts;
 
- function_requires<DistributionConcept<normal_distribution<RealType> > >();
- function_requires<DistributionConcept<beta_distribution<RealType> > >();
- function_requires<DistributionConcept<binomial_distribution<RealType> > >();
- function_requires<DistributionConcept<cauchy_distribution<RealType> > >();
- function_requires<DistributionConcept<bernoulli_distribution<RealType> > >();
- function_requires<DistributionConcept<chi_squared_distribution<RealType> > >();
- function_requires<DistributionConcept<exponential_distribution<RealType> > >();
- function_requires<DistributionConcept<extreme_value_distribution<RealType> > >();
- function_requires<DistributionConcept<fisher_f_distribution<RealType> > >();
- function_requires<DistributionConcept<gamma_distribution<RealType> > >();
- function_requires<DistributionConcept<students_t_distribution<RealType> > >();
- function_requires<DistributionConcept<pareto_distribution<RealType> > >();
- function_requires<DistributionConcept<poisson_distribution<RealType> > >();
- function_requires<DistributionConcept<rayleigh_distribution<RealType> > >();
- function_requires<DistributionConcept<weibull_distribution<RealType> > >();
- function_requires<DistributionConcept<lognormal_distribution<RealType> > >();
- function_requires<DistributionConcept<triangular_distribution<RealType> > >();
- function_requires<DistributionConcept<uniform_distribution<RealType> > >();
- function_requires<DistributionConcept<negative_binomial_distribution<RealType> > >();
- function_requires<DistributionConcept<non_central_chi_squared_distribution<RealType> > >();
+ typedef policies::policy<policies::digits2<std::numeric_limits<RealType>::digits - 2> > custom_policy;
+
+ function_requires<DistributionConcept<bernoulli_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<beta_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<binomial_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<cauchy_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<chi_squared_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<exponential_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<extreme_value_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<fisher_f_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<gamma_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<geometric_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<hypergeometric_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<hypergeometric_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<inverse_chi_squared_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<inverse_gamma_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<inverse_gaussian_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<laplace_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<logistic_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<lognormal_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<negative_binomial_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<non_central_beta_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<non_central_chi_squared_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<non_central_f_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<non_central_t_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<normal_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<pareto_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<poisson_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<rayleigh_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<skew_normal_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<students_t_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<triangular_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<uniform_distribution<RealType, custom_policy> > >();
+ function_requires<DistributionConcept<weibull_distribution<RealType, custom_policy> > >();
 }
 
 

Modified: trunk/libs/math/test/compile_test/instantiate.hpp
==============================================================================
--- trunk/libs/math/test/compile_test/instantiate.hpp (original)
+++ trunk/libs/math/test/compile_test/instantiate.hpp 2012-05-28 07:05:43 EDT (Mon, 28 May 2012)
@@ -18,7 +18,7 @@
 
 #ifndef BOOST_MATH_INSTANTIATE_MINIMUM
 
-typedef boost::math::policies::policy<> test_policy;
+typedef boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false> > test_policy;
 
 namespace test{
 
@@ -67,6 +67,7 @@
    function_requires<DistributionConcept<poisson_distribution<RealType> > >();
    function_requires<DistributionConcept<rayleigh_distribution<RealType> > >();
    function_requires<DistributionConcept<students_t_distribution<RealType> > >();
+ function_requires<DistributionConcept<skew_normal_distribution<RealType> > >();
    function_requires<DistributionConcept<triangular_distribution<RealType> > >();
    function_requires<DistributionConcept<uniform_distribution<RealType> > >();
    function_requires<DistributionConcept<weibull_distribution<RealType> > >();
@@ -97,6 +98,7 @@
    function_requires<DistributionConcept<pareto_distribution<RealType, test_policy> > >();
    function_requires<DistributionConcept<poisson_distribution<RealType, test_policy> > >();
    function_requires<DistributionConcept<rayleigh_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<skew_normal_distribution<RealType, test_policy> > >();
    function_requires<DistributionConcept<students_t_distribution<RealType, test_policy> > >();
    function_requires<DistributionConcept<triangular_distribution<RealType, test_policy> > >();
    function_requires<DistributionConcept<uniform_distribution<RealType, test_policy> > >();


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