diff --git a/include/boost/math/concepts/distributions.hpp b/include/boost/math/concepts/distributions.hpp index d338053a8..5758e1429 100644 --- a/include/boost/math/concepts/distributions.hpp +++ b/include/boost/math/concepts/distributions.hpp @@ -199,6 +199,7 @@ struct DistributionConcept static void test_extra_members(const boost::math::bernoulli_distribution& d) { value_type r = d.success_fraction(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::beta_distribution& d) @@ -209,6 +210,8 @@ struct DistributionConcept r1 = boost::math::beta_distribution::find_beta(r1, r2); r1 = boost::math::beta_distribution::find_alpha(r1, r2, r1); r1 = boost::math::beta_distribution::find_beta(r1, r2, r1); + (void)r1; // warning suppression + (void)r2; // warning suppression } template static void test_extra_members(const boost::math::binomial_distribution& d) @@ -223,12 +226,14 @@ struct DistributionConcept 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 static void test_extra_members(const boost::math::cauchy_distribution& d) { value_type r = d.location(); r = d.scale(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::chi_squared_distribution& d) @@ -236,41 +241,48 @@ struct DistributionConcept 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 static void test_extra_members(const boost::math::exponential_distribution& d) { value_type r = d.lambda(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::extreme_value_distribution& d) { value_type r = d.scale(); r = d.location(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::fisher_f_distribution& d) { value_type r = d.degrees_of_freedom1(); r = d.degrees_of_freedom2(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::gamma_distribution& d) { value_type r = d.scale(); r = d.shape(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::inverse_chi_squared_distribution& d) { value_type r = d.scale(); r = d.degrees_of_freedom(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::inverse_gamma_distribution& d) { value_type r = d.scale(); r = d.shape(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::hypergeometric_distribution& d) @@ -278,24 +290,28 @@ struct DistributionConcept unsigned u = d.defective(); u = d.sample_count(); u = d.total(); + (void)u; // warning suppression } template static void test_extra_members(const boost::math::laplace_distribution& d) { value_type r = d.scale(); r = d.location(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::logistic_distribution& d) { value_type r = d.scale(); r = d.location(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::lognormal_distribution& d) { value_type r = d.scale(); r = d.location(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::negative_binomial_distribution& d) @@ -306,6 +322,7 @@ struct DistributionConcept 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 static void test_extra_members(const boost::math::non_central_beta_distribution& d) @@ -313,6 +330,8 @@ struct DistributionConcept value_type r1 = d.alpha(); value_type r2 = d.beta(); r1 = d.non_centrality(); + (void)r1; // warning suppression + (void)r2; // warning suppression } template static void test_extra_members(const boost::math::non_central_chi_squared_distribution& d) @@ -323,6 +342,7 @@ struct DistributionConcept 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 static void test_extra_members(const boost::math::non_central_f_distribution& d) @@ -330,12 +350,14 @@ struct DistributionConcept value_type r = d.degrees_of_freedom1(); r = d.degrees_of_freedom2(); r = d.non_centrality(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::non_central_t_distribution& d) { value_type r = d.degrees_of_freedom(); r = d.non_centrality(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::normal_distribution& d) @@ -344,22 +366,26 @@ struct DistributionConcept r = d.location(); r = d.mean(); r = d.standard_deviation(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::pareto_distribution& d) { value_type r = d.scale(); r = d.shape(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::poisson_distribution& d) { value_type r = d.mean(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::rayleigh_distribution& d) { value_type r = d.sigma(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::students_t_distribution& d) @@ -367,6 +393,7 @@ struct DistributionConcept 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 static void test_extra_members(const boost::math::triangular_distribution& d) @@ -374,18 +401,21 @@ struct DistributionConcept value_type r = d.lower(); r = d.mode(); r = d.upper(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::weibull_distribution& d) { value_type r = d.scale(); r = d.shape(); + (void)r; // warning suppression } template static void test_extra_members(const boost::math::uniform_distribution& d) { value_type r = d.lower(); r = d.upper(); + (void)r; // warning suppression } private: static Distribution& get_object() diff --git a/include/boost/math/distributions/non_central_beta.hpp b/include/boost/math/distributions/non_central_beta.hpp index 63e575553..bddc976d8 100644 --- a/include/boost/math/distributions/non_central_beta.hpp +++ b/include/boost/math/distributions/non_central_beta.hpp @@ -769,24 +769,32 @@ namespace boost return result; } -#if 0 // RealType standard_deviation(const non_central_beta_distribution& dist) // standard_deviation provided by derived accessors. - template - inline RealType skewness(const non_central_beta_distribution& dist) + inline RealType skewness(const non_central_beta_distribution& /*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( + function, + "This function is not yet implemented, the only sensible result is %1%.", + std::numeric_limits::quiet_NaN(), Policy()); // infinity? } template - inline RealType kurtosis_excess(const non_central_beta_distribution& dist) + inline RealType kurtosis_excess(const non_central_beta_distribution& /*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( + function, + "This function is not yet implemented, the only sensible result is %1%.", + std::numeric_limits::quiet_NaN(), Policy()); // infinity? } // kurtosis_excess template @@ -794,7 +802,7 @@ namespace boost { return kurtosis_excess(dist) + 3; } -#endif + template inline RealType pdf(const non_central_beta_distribution& dist, const RealType& x) { // Probability Density/Mass Function. diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c1ddcfa70..98349768b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -491,28 +491,28 @@ run test_nc_chi_squared.cpp pch ../../test/build//boost_test_exec_monitor TEST_REAL_CONCEPT intel: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 TEST_FLOAT intel: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 TEST_DOUBLE intel: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 TEST_LDOUBLE intel: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 diff --git a/test/compile_test/dist_nc_beta_incl_test.cpp b/test/compile_test/dist_nc_beta_incl_test.cpp index bbba36b77..12d6ef159 100644 --- a/test/compile_test/dist_nc_beta_incl_test.cpp +++ b/test/compile_test/dist_nc_beta_incl_test.cpp @@ -6,36 +6,10 @@ // Basic sanity check that header // #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 - -namespace boost{ namespace math{ - -template -T skewness(const non_central_beta_distribution&) -{ - return 0; -} - -template -T kurtosis(const non_central_beta_distribution&) -{ - return 0; -} - -template -T kurtosis_excess(const non_central_beta_distribution&) -{ - return 0; -} - -}} - +// This must appear *before* any #includes, and precludes pch usage: +// +#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false +// #include // // Note this header includes no other headers, this is diff --git a/test/compile_test/instantiate.hpp b/test/compile_test/instantiate.hpp index 97569667f..ab50f360c 100644 --- a/test/compile_test/instantiate.hpp +++ b/test/compile_test/instantiate.hpp @@ -33,21 +33,6 @@ BOOST_MATH_DECLARE_DISTRIBUTIONS(double, test_policy) } #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 -inline T skewness(const non_central_beta_distribution&){ return 0; } -template -inline T kurtosis_excess(const non_central_beta_distribution&){ return 0; } -template -inline T kurtosis(const non_central_beta_distribution&){ return 0; } - -}} // namespaces - template void instantiate(RealType) { diff --git a/test/test_cbrt.cpp b/test/test_cbrt.cpp index 7b4db617b..81a6a4b33 100644 --- a/test/test_cbrt.cpp +++ b/test/test_cbrt.cpp @@ -9,7 +9,7 @@ # pragma warning (disable : 4224) #endif -#include // include \libs\math\src\ +#include // include /libs/math/src/ #include #include diff --git a/test/test_nc_beta.cpp b/test/test_nc_beta.cpp index 9ff0ba823..f87eb658d 100644 --- a/test/test_nc_beta.cpp +++ b/test/test_nc_beta.cpp @@ -7,7 +7,10 @@ // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) -#include +// +// 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 @@ void test_spots(RealType) BOOST_MATH_STD_USING boost::math::non_central_beta_distribution 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(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(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 void test_spots(RealType) template