Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66986 - in trunk: boost/math/concepts boost/math/distributions libs/math/test libs/math/test/compile_test
From: john_at_[hidden]
Date: 2010-12-03 12:55:02


Author: johnmaddock
Date: 2010-12-03 12:55:00 EST (Fri, 03 Dec 2010)
New Revision: 66986
URL: http://svn.boost.org/trac/boost/changeset/66986

Log:
Add non-functional stub versions of the skewness and kurtosis to the non-central beta.
Update tests accordingly, and suppress some compiler warnings.
Text files modified:
   trunk/boost/math/concepts/distributions.hpp | 30 ++++++++++++++++++++++++++++++
   trunk/boost/math/distributions/non_central_beta.hpp | 26 +++++++++++++++++---------
   trunk/libs/math/test/Jamfile.v2 | 8 ++++----
   trunk/libs/math/test/compile_test/dist_nc_beta_incl_test.cpp | 34 ++++------------------------------
   trunk/libs/math/test/compile_test/instantiate.hpp | 15 ---------------
   trunk/libs/math/test/test_cbrt.cpp | 2 +-
   trunk/libs/math/test/test_nc_beta.cpp | 16 +++++++++++++---
   7 files changed, 69 insertions(+), 62 deletions(-)

Modified: trunk/boost/math/concepts/distributions.hpp
==============================================================================
--- trunk/boost/math/concepts/distributions.hpp (original)
+++ trunk/boost/math/concepts/distributions.hpp 2010-12-03 12:55:00 EST (Fri, 03 Dec 2010)
@@ -199,6 +199,7 @@
    static void test_extra_members(const boost::math::bernoulli_distribution<R, P>& d)
    {
       value_type r = d.success_fraction();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::beta_distribution<R, P>& d)
@@ -209,6 +210,8 @@
       r1 = boost::math::beta_distribution<R, P>::find_beta(r1, r2);
       r1 = boost::math::beta_distribution<R, P>::find_alpha(r1, r2, r1);
       r1 = boost::math::beta_distribution<R, P>::find_beta(r1, r2, r1);
+ (void)r1; // warning suppression
+ (void)r2; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::binomial_distribution<R, P>& d)
@@ -223,12 +226,14 @@
       r = Distribution::find_upper_bound_on_p(r, r, r, Distribution::jeffreys_prior_interval);
       r = Distribution::find_minimum_number_of_trials(r, r, r);
       r = Distribution::find_maximum_number_of_trials(r, r, r);
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::cauchy_distribution<R, P>& d)
    {
       value_type r = d.location();
       r = d.scale();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::chi_squared_distribution<R, P>& d)
@@ -236,41 +241,48 @@
       value_type r = d.degrees_of_freedom();
       r = Distribution::find_degrees_of_freedom(r, r, r, r);
       r = Distribution::find_degrees_of_freedom(r, r, r, r, r);
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::exponential_distribution<R, P>& d)
    {
       value_type r = d.lambda();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::extreme_value_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.location();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::fisher_f_distribution<R, P>& d)
    {
       value_type r = d.degrees_of_freedom1();
       r = d.degrees_of_freedom2();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::gamma_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.shape();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::inverse_chi_squared_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.degrees_of_freedom();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::inverse_gamma_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.shape();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::hypergeometric_distribution<R, P>& d)
@@ -278,24 +290,28 @@
       unsigned u = d.defective();
       u = d.sample_count();
       u = d.total();
+ (void)u; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::laplace_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.location();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::logistic_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.location();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::lognormal_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.location();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::negative_binomial_distribution<R, P>& d)
@@ -306,6 +322,7 @@
       r = Distribution::find_upper_bound_on_p(r, r, r);
       r = Distribution::find_minimum_number_of_trials(r, r, r);
       r = Distribution::find_maximum_number_of_trials(r, r, r);
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::non_central_beta_distribution<R, P>& d)
@@ -313,6 +330,8 @@
       value_type r1 = d.alpha();
       value_type r2 = d.beta();
       r1 = d.non_centrality();
+ (void)r1; // warning suppression
+ (void)r2; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::non_central_chi_squared_distribution<R, P>& d)
@@ -323,6 +342,7 @@
       r = Distribution::find_degrees_of_freedom(boost::math::complement(r, r, r));
       r = Distribution::find_non_centrality(r, r, r);
       r = Distribution::find_non_centrality(boost::math::complement(r, r, r));
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::non_central_f_distribution<R, P>& d)
@@ -330,12 +350,14 @@
       value_type r = d.degrees_of_freedom1();
       r = d.degrees_of_freedom2();
       r = d.non_centrality();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::non_central_t_distribution<R, P>& d)
    {
       value_type r = d.degrees_of_freedom();
       r = d.non_centrality();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::normal_distribution<R, P>& d)
@@ -344,22 +366,26 @@
       r = d.location();
       r = d.mean();
       r = d.standard_deviation();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::pareto_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.shape();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::poisson_distribution<R, P>& d)
    {
       value_type r = d.mean();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::rayleigh_distribution<R, P>& d)
    {
       value_type r = d.sigma();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::students_t_distribution<R, P>& d)
@@ -367,6 +393,7 @@
       value_type r = d.degrees_of_freedom();
       r = d.find_degrees_of_freedom(r, r, r, r);
       r = d.find_degrees_of_freedom(r, r, r, r, r);
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::triangular_distribution<R, P>& d)
@@ -374,18 +401,21 @@
       value_type r = d.lower();
       r = d.mode();
       r = d.upper();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::weibull_distribution<R, P>& d)
    {
       value_type r = d.scale();
       r = d.shape();
+ (void)r; // warning suppression
    }
    template <class R, class P>
    static void test_extra_members(const boost::math::uniform_distribution<R, P>& d)
    {
       value_type r = d.lower();
       r = d.upper();
+ (void)r; // warning suppression
    }
 private:
    static Distribution& get_object()

Modified: trunk/boost/math/distributions/non_central_beta.hpp
==============================================================================
--- trunk/boost/math/distributions/non_central_beta.hpp (original)
+++ trunk/boost/math/distributions/non_central_beta.hpp 2010-12-03 12:55:00 EST (Fri, 03 Dec 2010)
@@ -769,24 +769,32 @@
          return result;
       }
 
-#if 0
       // RealType standard_deviation(const non_central_beta_distribution<RealType, Policy>& dist)
       // standard_deviation provided by derived accessors.
-
       template <class RealType, class Policy>
- inline RealType skewness(const non_central_beta_distribution<RealType, Policy>& dist)
+ inline RealType skewness(const non_central_beta_distribution<RealType, Policy>& /*dist*/)
       { // skewness = sqrt(l).
          const char* function = "boost::math::non_central_beta_distribution<%1%>::skewness()";
- // TODO
- return 0;
+ typedef typename Policy::assert_undefined_type assert_type;
+ BOOST_STATIC_ASSERT(assert_type::value == 0);
+
+ return policies::raise_evaluation_error<RealType>(
+ function,
+ "This function is not yet implemented, the only sensible result is %1%.",
+ std::numeric_limits<RealType>::quiet_NaN(), Policy()); // infinity?
       }
 
       template <class RealType, class Policy>
- inline RealType kurtosis_excess(const non_central_beta_distribution<RealType, Policy>& dist)
+ inline RealType kurtosis_excess(const non_central_beta_distribution<RealType, Policy>& /*dist*/)
       {
          const char* function = "boost::math::non_central_beta_distribution<%1%>::kurtosis_excess()";
- // TODO
- return 0;
+ typedef typename Policy::assert_undefined_type assert_type;
+ BOOST_STATIC_ASSERT(assert_type::value == 0);
+
+ return policies::raise_evaluation_error<RealType>(
+ function,
+ "This function is not yet implemented, the only sensible result is %1%.",
+ std::numeric_limits<RealType>::quiet_NaN(), Policy()); // infinity?
       } // kurtosis_excess
 
       template <class RealType, class Policy>
@@ -794,7 +802,7 @@
       {
          return kurtosis_excess(dist) + 3;
       }
-#endif
+
       template <class RealType, class Policy>
       inline RealType pdf(const non_central_beta_distribution<RealType, Policy>& dist, const RealType& x)
       { // Probability Density/Mass Function.

Modified: trunk/libs/math/test/Jamfile.v2
==============================================================================
--- trunk/libs/math/test/Jamfile.v2 (original)
+++ trunk/libs/math/test/Jamfile.v2 2010-12-03 12:55:00 EST (Fri, 03 Dec 2010)
@@ -491,28 +491,28 @@
               <define>TEST_REAL_CONCEPT
               <toolset>intel:<pch>off
         : test_nc_chi_squared_real_concept ;
-run test_nc_beta.cpp pch ../../test/build//boost_test_exec_monitor
+run test_nc_beta.cpp ../../test/build//boost_test_exec_monitor
         : # command line
         : # input files
         : # requirements
               <define>TEST_FLOAT
               <toolset>intel:<pch>off
         : test_nc_beta_float ;
-run test_nc_beta.cpp pch ../../test/build//boost_test_exec_monitor
+run test_nc_beta.cpp ../../test/build//boost_test_exec_monitor
         : # command line
         : # input files
         : # requirements
               <define>TEST_DOUBLE
               <toolset>intel:<pch>off
         : test_nc_beta_double ;
-run test_nc_beta.cpp pch ../../test/build//boost_test_exec_monitor
+run test_nc_beta.cpp ../../test/build//boost_test_exec_monitor
         : # command line
         : # input files
         : # requirements
               <define>TEST_LDOUBLE
               <toolset>intel:<pch>off
         : test_nc_beta_long_double ;
-run test_nc_beta.cpp pch ../../test/build//boost_test_exec_monitor
+run test_nc_beta.cpp ../../test/build//boost_test_exec_monitor
         : # command line
         : # input files
         : # requirements

Modified: trunk/libs/math/test/compile_test/dist_nc_beta_incl_test.cpp
==============================================================================
--- trunk/libs/math/test/compile_test/dist_nc_beta_incl_test.cpp (original)
+++ trunk/libs/math/test/compile_test/dist_nc_beta_incl_test.cpp 2010-12-03 12:55:00 EST (Fri, 03 Dec 2010)
@@ -6,36 +6,10 @@
 // Basic sanity check that header <boost/math/distributions/non_central_beta.hpp>
 // #includes all the files that it needs to.
 //
-// In order to pass our conceptual tests, we need to forward declare
-// those functoins that the non-central beta (deliberately) doesn't
-// implement. These declarations have to appear *before* the
-// non central beta is defined, otherwise two-phase lookup
-// won't find them :-(
-//
-#include <boost/math/distributions/fwd.hpp>
-
-namespace boost{ namespace math{
-
-template <class T, class Policy>
-T skewness(const non_central_beta_distribution<T, Policy>&)
-{
- return 0;
-}
-
-template <class T, class Policy>
-T kurtosis(const non_central_beta_distribution<T, Policy>&)
-{
- return 0;
-}
-
-template <class T, class Policy>
-T kurtosis_excess(const non_central_beta_distribution<T, Policy>&)
-{
- return 0;
-}
-
-}}
-
+// This must appear *before* any #includes, and precludes pch usage:
+//
+#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
+//
 #include <boost/math/distributions/non_central_beta.hpp>
 //
 // Note this header includes no other headers, this is

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 2010-12-03 12:55:00 EST (Fri, 03 Dec 2010)
@@ -33,21 +33,6 @@
 }
 #endif
 
-namespace boost{ namespace math{
-//
-// The non central beta doesn't define some properties,
-// define some stub methods here so that we can concept
-// check everything else:
-//
-template <class T, class Policy>
-inline T skewness(const non_central_beta_distribution<T, Policy>&){ return 0; }
-template <class T, class Policy>
-inline T kurtosis_excess(const non_central_beta_distribution<T, Policy>&){ return 0; }
-template <class T, class Policy>
-inline T kurtosis(const non_central_beta_distribution<T, Policy>&){ return 0; }
-
-}} // namespaces
-
 template <class RealType>
 void instantiate(RealType)
 {

Modified: trunk/libs/math/test/test_cbrt.cpp
==============================================================================
--- trunk/libs/math/test/test_cbrt.cpp (original)
+++ trunk/libs/math/test/test_cbrt.cpp 2010-12-03 12:55:00 EST (Fri, 03 Dec 2010)
@@ -9,7 +9,7 @@
 # pragma warning (disable : 4224)
 #endif
 
-#include <pch.hpp> // include \libs\math\src\
+#include <pch.hpp> // include /libs/math/src/
 
 #include <boost/math/concepts/real_concept.hpp>
 #include <boost/test/test_exec_monitor.hpp>

Modified: trunk/libs/math/test/test_nc_beta.cpp
==============================================================================
--- trunk/libs/math/test/test_nc_beta.cpp (original)
+++ trunk/libs/math/test/test_nc_beta.cpp 2010-12-03 12:55:00 EST (Fri, 03 Dec 2010)
@@ -7,7 +7,10 @@
 // (See accompanying file LICENSE_1_0.txt
 // or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#include <pch.hpp>
+//
+// This must appear *before* any #includes, and precludes pch usage:
+//
+#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
 
 #ifdef _MSC_VER
 #pragma warning (disable:4127 4512)
@@ -263,9 +266,16 @@
 
    BOOST_MATH_STD_USING
    boost::math::non_central_beta_distribution<RealType> dist(100, 3, 63);
- BOOST_CHECK_CLOSE(mean(dist), 4.82280451915522329944315287538684030781836554279474240490936e13 * exp(-RealType(31.5)) * 100 / 103, tolerance);
+ BOOST_CHECK_CLOSE(mean(dist), RealType(4.82280451915522329944315287538684030781836554279474240490936e13L) * exp(-RealType(31.5)) * 100 / 103, tolerance);
    // Variance only guarentees small absolute error:
- BOOST_CHECK_SMALL(variance(dist) - static_cast<RealType>(4.85592267707818899235900237275021938334418424134218087127572e13 * exp(RealType(-31.5)) * 100 * 101 / (103 * 104) - 4.82280451915522329944315287538684030781836554279474240490936e13 * 4.82280451915522329944315287538684030781836554279474240490936e13 * exp(RealType(-63)) * 10000 / (103 * 103)), abs_tolerance);
+ BOOST_CHECK_SMALL(variance(dist)
+ - static_cast<RealType>(RealType(4.85592267707818899235900237275021938334418424134218087127572e13L)
+ * exp(RealType(-31.5)) * 100 * 101 / (103 * 104) -
+ RealType(4.82280451915522329944315287538684030781836554279474240490936e13L) * RealType(4.82280451915522329944315287538684030781836554279474240490936e13L)
+ * exp(RealType(-63)) * 10000 / (103 * 103)), abs_tolerance);
+ BOOST_CHECK_THROW(skewness(dist), boost::math::evaluation_error);
+ BOOST_CHECK_THROW(kurtosis(dist), boost::math::evaluation_error);
+ BOOST_CHECK_THROW(kurtosis_excess(dist), boost::math::evaluation_error);
 } // template <class RealType>void test_spots(RealType)
 
 template <class T>


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