From a5239fa5675b99ccfd9d02de01c357abf2c4e438 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 2 May 2011 15:36:51 +0000 Subject: [PATCH] Suppress a whole bunch of new gcc-4.6 warnings. Add code to verify that the radix of the type is 2 wherever that assumption is made. Add some more instrumentation code. [SVN r71672] --- include/boost/math/concepts/distributions.hpp | 95 +++++++++++++++---- .../boost/math/concepts/real_type_concept.hpp | 12 +++ .../boost/math/distributions/bernoulli.hpp | 10 +- include/boost/math/distributions/beta.hpp | 18 ++-- include/boost/math/distributions/binomial.hpp | 16 ++-- include/boost/math/distributions/cauchy.hpp | 6 +- .../boost/math/distributions/exponential.hpp | 14 +-- .../math/distributions/extreme_value.hpp | 14 +-- include/boost/math/distributions/fisher_f.hpp | 20 ++-- include/boost/math/distributions/gamma.hpp | 20 ++-- .../boost/math/distributions/geometric.hpp | 18 ++-- .../math/distributions/hypergeometric.hpp | 10 +- .../math/distributions/inverse_gamma.hpp | 22 ++--- .../math/distributions/inverse_gaussian.hpp | 10 +- include/boost/math/distributions/laplace.hpp | 10 +- include/boost/math/distributions/logistic.hpp | 10 +- .../boost/math/distributions/lognormal.hpp | 22 ++--- .../math/distributions/negative_binomial.hpp | 18 ++-- include/boost/math/distributions/normal.hpp | 10 +- include/boost/math/distributions/pareto.hpp | 24 ++--- include/boost/math/distributions/poisson.hpp | 10 +- include/boost/math/distributions/rayleigh.hpp | 14 +-- .../boost/math/distributions/triangular.hpp | 24 ++--- include/boost/math/distributions/uniform.hpp | 22 ++--- include/boost/math/distributions/weibull.hpp | 22 ++--- .../boost/math/policies/error_handling.hpp | 2 +- include/boost/math/policies/policy.hpp | 6 +- include/boost/math/special_functions/beta.hpp | 8 +- include/boost/math/special_functions/cbrt.hpp | 2 + .../detail/t_distribution_inv.hpp | 5 +- .../boost/math/special_functions/gamma.hpp | 15 +++ include/boost/math/tools/config.hpp | 6 ++ include/boost/math/tools/precision.hpp | 6 +- 33 files changed, 312 insertions(+), 209 deletions(-) diff --git a/include/boost/math/concepts/distributions.hpp b/include/boost/math/concepts/distributions.hpp index 5758e1429..2e0037787 100644 --- a/include/boost/math/concepts/distributions.hpp +++ b/include/boost/math/concepts/distributions.hpp @@ -130,66 +130,118 @@ struct DistributionConcept // The result values are ignored in all these checks. value_type v = cdf(dist, x); v = cdf(complement(dist, x)); + suppress_unused_variable_warning(v); v = pdf(dist, x); + suppress_unused_variable_warning(v); v = quantile(dist, x); + suppress_unused_variable_warning(v); v = quantile(complement(dist, x)); + suppress_unused_variable_warning(v); v = mean(dist); + suppress_unused_variable_warning(v); v = mode(dist); + suppress_unused_variable_warning(v); v = standard_deviation(dist); + suppress_unused_variable_warning(v); v = variance(dist); + suppress_unused_variable_warning(v); v = hazard(dist, x); + suppress_unused_variable_warning(v); v = chf(dist, x); + suppress_unused_variable_warning(v); v = coefficient_of_variation(dist); + suppress_unused_variable_warning(v); v = skewness(dist); + suppress_unused_variable_warning(v); v = kurtosis(dist); + suppress_unused_variable_warning(v); v = kurtosis_excess(dist); + suppress_unused_variable_warning(v); v = median(dist); + suppress_unused_variable_warning(v); std::pair pv; pv = range(dist); + suppress_unused_variable_warning(pv); pv = support(dist); + suppress_unused_variable_warning(pv); float f = 1; v = cdf(dist, f); + suppress_unused_variable_warning(v); v = cdf(complement(dist, f)); + suppress_unused_variable_warning(v); v = pdf(dist, f); + suppress_unused_variable_warning(v); v = quantile(dist, f); + suppress_unused_variable_warning(v); v = quantile(complement(dist, f)); + suppress_unused_variable_warning(v); v = hazard(dist, f); + suppress_unused_variable_warning(v); v = chf(dist, f); + suppress_unused_variable_warning(v); double d = 1; v = cdf(dist, d); + suppress_unused_variable_warning(v); v = cdf(complement(dist, d)); + suppress_unused_variable_warning(v); v = pdf(dist, d); + suppress_unused_variable_warning(v); v = quantile(dist, d); + suppress_unused_variable_warning(v); v = quantile(complement(dist, d)); + suppress_unused_variable_warning(v); v = hazard(dist, d); + suppress_unused_variable_warning(v); v = chf(dist, d); + suppress_unused_variable_warning(v); #ifndef TEST_MPFR long double ld = 1; v = cdf(dist, ld); + suppress_unused_variable_warning(v); v = cdf(complement(dist, ld)); + suppress_unused_variable_warning(v); v = pdf(dist, ld); + suppress_unused_variable_warning(v); v = quantile(dist, ld); + suppress_unused_variable_warning(v); v = quantile(complement(dist, ld)); + suppress_unused_variable_warning(v); v = hazard(dist, ld); + suppress_unused_variable_warning(v); v = chf(dist, ld); + suppress_unused_variable_warning(v); #endif int i = 1; v = cdf(dist, i); + suppress_unused_variable_warning(v); v = cdf(complement(dist, i)); + suppress_unused_variable_warning(v); v = pdf(dist, i); + suppress_unused_variable_warning(v); v = quantile(dist, i); + suppress_unused_variable_warning(v); v = quantile(complement(dist, i)); + suppress_unused_variable_warning(v); v = hazard(dist, i); + suppress_unused_variable_warning(v); v = chf(dist, i); + suppress_unused_variable_warning(v); unsigned long li = 1; v = cdf(dist, li); + suppress_unused_variable_warning(v); v = cdf(complement(dist, li)); + suppress_unused_variable_warning(v); v = pdf(dist, li); + suppress_unused_variable_warning(v); v = quantile(dist, li); + suppress_unused_variable_warning(v); v = quantile(complement(dist, li)); + suppress_unused_variable_warning(v); v = hazard(dist, li); + suppress_unused_variable_warning(v); v = chf(dist, li); + suppress_unused_variable_warning(v); test_extra_members(dist); } template @@ -207,11 +259,13 @@ struct DistributionConcept value_type r1 = d.alpha(); value_type r2 = d.beta(); r1 = boost::math::beta_distribution::find_alpha(r1, r2); + suppress_unused_variable_warning(r1); r1 = boost::math::beta_distribution::find_beta(r1, r2); + suppress_unused_variable_warning(r1); r1 = boost::math::beta_distribution::find_alpha(r1, r2, r1); + suppress_unused_variable_warning(r1); r1 = boost::math::beta_distribution::find_beta(r1, r2, r1); - (void)r1; // warning suppression - (void)r2; // warning suppression + suppress_unused_variable_warning(r1); } template static void test_extra_members(const boost::math::binomial_distribution& d) @@ -226,14 +280,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 + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::cauchy_distribution& d) { value_type r = d.location(); r = d.scale(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::chi_squared_distribution& d) @@ -241,48 +295,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 + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::exponential_distribution& d) { value_type r = d.lambda(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } 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 + suppress_unused_variable_warning(r); } 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 + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::gamma_distribution& d) { value_type r = d.scale(); r = d.shape(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } 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 + suppress_unused_variable_warning(r); } 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 + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::hypergeometric_distribution& d) @@ -290,28 +344,28 @@ struct DistributionConcept unsigned u = d.defective(); u = d.sample_count(); u = d.total(); - (void)u; // warning suppression + suppress_unused_variable_warning(u); } template static void test_extra_members(const boost::math::laplace_distribution& d) { value_type r = d.scale(); r = d.location(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::logistic_distribution& d) { value_type r = d.scale(); r = d.location(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::lognormal_distribution& d) { value_type r = d.scale(); r = d.location(); - (void)r; // warning suppression + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::negative_binomial_distribution& d) @@ -322,7 +376,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 + suppress_unused_variable_warning(r); } template static void test_extra_members(const boost::math::non_central_beta_distribution& d) @@ -418,14 +472,17 @@ struct DistributionConcept (void)r; // warning suppression } private: + static Distribution* pd; static Distribution& get_object() { - // will never get called: - static char buf[sizeof(Distribution)]; - return * reinterpret_cast(buf); + // In reality this will never get called: + return *pd; } }; // struct DistributionConcept +template +Distribution* DistributionConcept::pd = 0; + } // namespace concepts } // namespace math } // namespace boost diff --git a/include/boost/math/concepts/real_type_concept.hpp b/include/boost/math/concepts/real_type_concept.hpp index 481c82774..f6ec01621 100644 --- a/include/boost/math/concepts/real_type_concept.hpp +++ b/include/boost/math/concepts/real_type_concept.hpp @@ -44,17 +44,29 @@ struct RealTypeConcept r = o / r; bool b; b = r == o; + suppress_unused_variable_warning(b); b = o == r; + suppress_unused_variable_warning(b); b = r != o; + suppress_unused_variable_warning(b); b = o != r; + suppress_unused_variable_warning(b); b = r <= o; + suppress_unused_variable_warning(b); b = o <= r; + suppress_unused_variable_warning(b); b = r >= o; + suppress_unused_variable_warning(b); b = o >= r; + suppress_unused_variable_warning(b); b = r < o; + suppress_unused_variable_warning(b); b = o < r; + suppress_unused_variable_warning(b); b = r > o; + suppress_unused_variable_warning(b); b = o > r; + suppress_unused_variable_warning(b); } void constraints() diff --git a/include/boost/math/distributions/bernoulli.hpp b/include/boost/math/distributions/bernoulli.hpp index 137ed0f20..cfa3ecf84 100644 --- a/include/boost/math/distributions/bernoulli.hpp +++ b/include/boost/math/distributions/bernoulli.hpp @@ -153,7 +153,7 @@ namespace boost { // Probability Density/Mass Function. BOOST_FPU_EXCEPTION_GUARD // Error check: - RealType result; // of checks. + RealType result = 0; // of checks. if(false == bernoulli_detail::check_dist_and_k( "boost::math::pdf(bernoulli_distribution<%1%>, %1%)", dist.success_fraction(), // 0 to 1 @@ -178,7 +178,7 @@ namespace boost { // Cumulative Distribution Function Bernoulli. RealType p = dist.success_fraction(); // Error check: - RealType result; + RealType result = 0; if(false == bernoulli_detail::check_dist_and_k( "boost::math::cdf(bernoulli_distribution<%1%>, %1%)", p, @@ -204,7 +204,7 @@ namespace boost bernoulli_distribution const& dist = c.dist; RealType p = dist.success_fraction(); // Error checks: - RealType result; + RealType result = 0; if(false == bernoulli_detail::check_dist_and_k( "boost::math::cdf(bernoulli_distribution<%1%>, %1%)", p, @@ -229,7 +229,7 @@ namespace boost // Return the number of expected successes k either 0 or 1. // for a given probability p. - RealType result; // of error checks: + RealType result = 0; // of error checks: if(false == bernoulli_detail::check_dist_and_prob( "boost::math::quantile(bernoulli_distribution<%1%>, %1%)", dist.success_fraction(), @@ -257,7 +257,7 @@ namespace boost // Error checks: RealType q = c.param; const bernoulli_distribution& dist = c.dist; - RealType result; + RealType result = 0; if(false == bernoulli_detail::check_dist_and_prob( "boost::math::quantile(bernoulli_distribution<%1%>, %1%)", dist.success_fraction(), diff --git a/include/boost/math/distributions/beta.hpp b/include/boost/math/distributions/beta.hpp index 0573d1d01..ef052599f 100644 --- a/include/boost/math/distributions/beta.hpp +++ b/include/boost/math/distributions/beta.hpp @@ -187,7 +187,7 @@ namespace boost RealType variance) // Expected value of variance. { static const char* function = "boost::math::beta_distribution<%1%>::find_alpha"; - RealType result; // of error checks. + RealType result = 0; // of error checks. if(false == beta_detail::check_mean( function, mean, &result, Policy()) @@ -206,7 +206,7 @@ namespace boost RealType variance) // Expected value of variance. { static const char* function = "boost::math::beta_distribution<%1%>::find_beta"; - RealType result; // of error checks. + RealType result = 0; // of error checks. if(false == beta_detail::check_mean( function, mean, &result, Policy()) @@ -229,7 +229,7 @@ namespace boost RealType probability) // cdf { static const char* function = "boost::math::beta_distribution<%1%>::find_alpha"; - RealType result; // of error checks. + RealType result = 0; // of error checks. if(false == beta_detail::check_prob( function, probability, &result, Policy()) @@ -253,7 +253,7 @@ namespace boost RealType probability) // probability cdf. { static const char* function = "boost::math::beta_distribution<%1%>::find_beta"; - RealType result; // of error checks. + RealType result = 0; // of error checks. if(false == beta_detail::check_prob( function, probability, &result, Policy()) @@ -376,7 +376,7 @@ namespace boost RealType b = dist.beta(); // Argument checks: - RealType result; + RealType result = 0; if(false == beta_detail::check_dist_and_x( function, a, b, x, @@ -399,7 +399,7 @@ namespace boost RealType b = dist.beta(); // Argument checks: - RealType result; + RealType result = 0; if(false == beta_detail::check_dist_and_x( function, a, b, x, @@ -433,7 +433,7 @@ namespace boost RealType b = dist.beta(); // Argument checks: - RealType result; + RealType result = 0; if(false == beta_detail::check_dist_and_x( function, a, b, x, @@ -468,7 +468,7 @@ namespace boost static const char* function = "boost::math::quantile(beta_distribution<%1%> const&, %1%)"; - RealType result; // of argument checks: + RealType result = 0; // of argument checks: RealType a = dist.alpha(); RealType b = dist.beta(); if(false == beta_detail::check_dist_and_prob( @@ -502,7 +502,7 @@ namespace boost // Error checks: RealType q = c.param; const beta_distribution& dist = c.dist; - RealType result; + RealType result = 0; RealType a = dist.alpha(); RealType b = dist.beta(); if(false == beta_detail::check_dist_and_prob( diff --git a/include/boost/math/distributions/binomial.hpp b/include/boost/math/distributions/binomial.hpp index ff70b819c..c73df929f 100644 --- a/include/boost/math/distributions/binomial.hpp +++ b/include/boost/math/distributions/binomial.hpp @@ -203,7 +203,7 @@ namespace boost // // Error checks: BOOST_MATH_STD_USING // ADL of std names - RealType result; + RealType result = 0; RealType trials = dist.trials(); RealType success_fraction = dist.success_fraction(); if(false == binomial_detail::check_dist_and_prob( @@ -317,7 +317,7 @@ namespace boost { static const char* function = "boost::math::binomial_distribution<%1%>::find_lower_bound_on_p"; // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( function, trials, RealType(0), successes, &result, Policy()) && @@ -342,7 +342,7 @@ namespace boost { static const char* function = "boost::math::binomial_distribution<%1%>::find_upper_bound_on_p"; // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( function, trials, RealType(0), successes, &result, Policy()) && @@ -369,7 +369,7 @@ namespace boost { static const char* function = "boost::math::binomial_distribution<%1%>::find_minimum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( function, k, p, k, &result, Policy()) && @@ -388,7 +388,7 @@ namespace boost { static const char* function = "boost::math::binomial_distribution<%1%>::find_maximum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( function, k, p, k, &result, Policy()) && @@ -446,7 +446,7 @@ namespace boost RealType n = dist.trials(); // Error check: - RealType result; + RealType result = 0; // initialization silences some compiler warnings if(false == binomial_detail::check_dist_and_k( "boost::math::pdf(binomial_distribution<%1%> const&, %1%)", n, @@ -524,7 +524,7 @@ namespace boost RealType p = dist.success_fraction(); // Error check: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( "boost::math::cdf(binomial_distribution<%1%> const&, %1%)", n, @@ -598,7 +598,7 @@ namespace boost RealType p = dist.success_fraction(); // Error checks: - RealType result; + RealType result = 0; if(false == binomial_detail::check_dist_and_k( "boost::math::cdf(binomial_distribution<%1%> const&, %1%)", n, diff --git a/include/boost/math/distributions/cauchy.hpp b/include/boost/math/distributions/cauchy.hpp index 0a818568c..0c93febaa 100644 --- a/include/boost/math/distributions/cauchy.hpp +++ b/include/boost/math/distributions/cauchy.hpp @@ -56,7 +56,7 @@ RealType cdf_imp(const cauchy_distribution& dist, const RealTy // BOOST_MATH_STD_USING // for ADL of std functions static const char* function = "boost::math::cdf(cauchy<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType location = dist.location(); RealType scale = dist.scale(); if(false == detail::check_location(function, location, &result, Policy())) @@ -105,7 +105,7 @@ RealType quantile_imp( static const char* function = "boost::math::quantile(cauchy<%1%>&, %1%)"; BOOST_MATH_STD_USING // for ADL of std functions - RealType result; + RealType result = 0; RealType location = dist.location(); RealType scale = dist.scale(); if(false == detail::check_location(function, location, &result, Policy())) @@ -197,7 +197,7 @@ inline RealType pdf(const cauchy_distribution& dist, const Rea BOOST_MATH_STD_USING // for ADL of std functions static const char* function = "boost::math::pdf(cauchy<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType location = dist.location(); RealType scale = dist.scale(); if(false == detail::check_scale("boost::math::pdf(cauchy<%1%>&, %1%)", scale, &result, Policy())) diff --git a/include/boost/math/distributions/exponential.hpp b/include/boost/math/distributions/exponential.hpp index 44bf04240..62b858c87 100644 --- a/include/boost/math/distributions/exponential.hpp +++ b/include/boost/math/distributions/exponential.hpp @@ -102,7 +102,7 @@ inline RealType pdf(const exponential_distribution& dist, cons static const char* function = "boost::math::pdf(const exponential_distribution<%1%>&, %1%)"; RealType lambda = dist.lambda(); - RealType result; + RealType result = 0; if(0 == detail::verify_lambda(function, lambda, &result, Policy())) return result; if(0 == detail::verify_exp_x(function, x, &result, Policy())) @@ -118,7 +118,7 @@ inline RealType cdf(const exponential_distribution& dist, cons static const char* function = "boost::math::cdf(const exponential_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType lambda = dist.lambda(); if(0 == detail::verify_lambda(function, lambda, &result, Policy())) return result; @@ -136,7 +136,7 @@ inline RealType quantile(const exponential_distribution& dist, static const char* function = "boost::math::quantile(const exponential_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType lambda = dist.lambda(); if(0 == detail::verify_lambda(function, lambda, &result, Policy())) return result; @@ -159,7 +159,7 @@ inline RealType cdf(const complemented2_type inline RealType mean(const exponential_distribution& dist) { - RealType result; + RealType result = 0; RealType lambda = dist.lambda(); if(0 == detail::verify_lambda("boost::math::mean(const exponential_distribution<%1%>&)", lambda, &result, Policy())) return result; @@ -208,7 +208,7 @@ inline RealType mean(const exponential_distribution& dist) template inline RealType standard_deviation(const exponential_distribution& dist) { - RealType result; + RealType result = 0; RealType lambda = dist.lambda(); if(0 == detail::verify_lambda("boost::math::standard_deviation(const exponential_distribution<%1%>&)", lambda, &result, Policy())) return result; diff --git a/include/boost/math/distributions/extreme_value.hpp b/include/boost/math/distributions/extreme_value.hpp index eeb94e750..3cf94d4b3 100644 --- a/include/boost/math/distributions/extreme_value.hpp +++ b/include/boost/math/distributions/extreme_value.hpp @@ -94,7 +94,7 @@ inline RealType pdf(const extreme_value_distribution& dist, co RealType a = dist.location(); RealType b = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::verify_scale_b("boost::math::pdf(const extreme_value_distribution<%1%>&, %1%)", b, &result, Policy())) return result; result = exp((a-x)/b) * exp(-exp((a-x)/b)) / b; @@ -108,7 +108,7 @@ inline RealType cdf(const extreme_value_distribution& dist, co RealType a = dist.location(); RealType b = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::verify_scale_b("boost::math::cdf(const extreme_value_distribution<%1%>&, %1%)", b, &result, Policy())) return result; @@ -126,7 +126,7 @@ RealType quantile(const extreme_value_distribution& dist, cons RealType a = dist.location(); RealType b = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::verify_scale_b(function, b, &result, Policy())) return result; if(0 == detail::check_probability(function, p, &result, Policy())) @@ -149,7 +149,7 @@ inline RealType cdf(const complemented2_type&, %1%)", b, &result, Policy())) return result; @@ -168,7 +168,7 @@ RealType quantile(const complemented2_type& dist) { RealType a = dist.location(); RealType b = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::verify_scale_b("boost::math::mean(const extreme_value_distribution<%1%>&)", b, &result, Policy())) return result; return a + constants::euler() * b; @@ -201,7 +201,7 @@ inline RealType standard_deviation(const extreme_value_distribution&)", b, &result, Policy())) return result; return constants::pi() * b / sqrt(static_cast(6)); diff --git a/include/boost/math/distributions/fisher_f.hpp b/include/boost/math/distributions/fisher_f.hpp index fe7fa06d2..07bcc81a6 100644 --- a/include/boost/math/distributions/fisher_f.hpp +++ b/include/boost/math/distributions/fisher_f.hpp @@ -76,7 +76,7 @@ RealType pdf(const fisher_f_distribution& dist, const RealType RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; static const char* function = "boost::math::pdf(fisher_f_distribution<%1%> const&, %1%)"; if(false == detail::check_df( function, df1, &error_result, Policy()) @@ -133,7 +133,7 @@ inline RealType cdf(const fisher_f_distribution& dist, const R RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -168,7 +168,7 @@ inline RealType quantile(const fisher_f_distribution& dist, co RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -194,7 +194,7 @@ inline RealType cdf(const complemented2_type& dist) RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -274,7 +274,7 @@ inline RealType variance(const fisher_f_distribution& dist) RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -295,7 +295,7 @@ inline RealType mode(const fisher_f_distribution& dist) RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -326,7 +326,7 @@ inline RealType skewness(const fisher_f_distribution& dist) RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( @@ -357,7 +357,7 @@ inline RealType kurtosis_excess(const fisher_f_distribution& d RealType df1 = dist.degrees_of_freedom1(); RealType df2 = dist.degrees_of_freedom2(); // Error check: - RealType error_result; + RealType error_result = 0; if(false == detail::check_df( function, df1, &error_result, Policy()) && detail::check_df( diff --git a/include/boost/math/distributions/gamma.hpp b/include/boost/math/distributions/gamma.hpp index 059c1466e..c15973bac 100644 --- a/include/boost/math/distributions/gamma.hpp +++ b/include/boost/math/distributions/gamma.hpp @@ -125,7 +125,7 @@ inline RealType pdf(const gamma_distribution& dist, const Real RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; if(false == detail::check_gamma_x(function, x, &result, Policy())) @@ -149,7 +149,7 @@ inline RealType cdf(const gamma_distribution& dist, const Real RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; if(false == detail::check_gamma_x(function, x, &result, Policy())) @@ -169,7 +169,7 @@ inline RealType quantile(const gamma_distribution& dist, const RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; if(false == detail::check_probability(function, p, &result, Policy())) @@ -193,7 +193,7 @@ inline RealType cdf(const complemented2_type& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; @@ -257,7 +257,7 @@ inline RealType variance(const gamma_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; @@ -275,7 +275,7 @@ inline RealType mode(const gamma_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; @@ -304,7 +304,7 @@ inline RealType skewness(const gamma_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; @@ -322,7 +322,7 @@ inline RealType kurtosis_excess(const gamma_distribution& dist RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_gamma(function, scale, shape, &result, Policy())) return result; diff --git a/include/boost/math/distributions/geometric.hpp b/include/boost/math/distributions/geometric.hpp index 5c6dbb6bb..51e55e69f 100644 --- a/include/boost/math/distributions/geometric.hpp +++ b/include/boost/math/distributions/geometric.hpp @@ -146,7 +146,7 @@ namespace boost RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test. { static const char* function = "boost::math::geometric<%1%>::find_lower_bound_on_p"; - RealType result; // of error checks. + RealType result = 0; // of error checks. RealType successes = 1; RealType failures = trials - successes; if(false == detail::check_probability(function, alpha, &result, Policy()) @@ -171,7 +171,7 @@ namespace boost RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test. { static const char* function = "boost::math::geometric<%1%>::find_upper_bound_on_p"; - RealType result; // of error checks. + RealType result = 0; // of error checks. RealType successes = 1; RealType failures = trials - successes; if(false == geometric_detail::check_dist_and_k( @@ -205,7 +205,7 @@ namespace boost { static const char* function = "boost::math::geometric<%1%>::find_minimum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) @@ -223,7 +223,7 @@ namespace boost { static const char* function = "boost::math::geometric<%1%>::find_maximum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) @@ -317,7 +317,7 @@ namespace boost static const char* function = "boost::math::pdf(const geometric_distribution<%1%>&, %1%)"; RealType p = dist.success_fraction(); - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, @@ -356,7 +356,7 @@ namespace boost // If necessary, it has already been promoted from an integral type. RealType p = dist.success_fraction(); // Error check: - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, @@ -389,7 +389,7 @@ namespace boost geometric_distribution const& dist = c.dist; RealType p = dist.success_fraction(); // Error check: - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_k( function, p, @@ -416,7 +416,7 @@ namespace boost RealType success_fraction = dist.success_fraction(); // Check dist and x. - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_prob (function, success_fraction, x, &result, Policy())) { @@ -465,7 +465,7 @@ namespace boost RealType x = c.param; const geometric_distribution& dist = c.dist; RealType success_fraction = dist.success_fraction(); - RealType result; + RealType result = 0; if(false == geometric_detail::check_dist_and_prob( function, success_fraction, diff --git a/include/boost/math/distributions/hypergeometric.hpp b/include/boost/math/distributions/hypergeometric.hpp index afbb5212d..63d1356a2 100644 --- a/include/boost/math/distributions/hypergeometric.hpp +++ b/include/boost/math/distributions/hypergeometric.hpp @@ -120,7 +120,7 @@ namespace boost { namespace math { inline RealType pdf(const hypergeometric_distribution& dist, const unsigned& x) { static const char* function = "boost::math::pdf(const hypergeometric_distribution<%1%>&, const %1%&)"; - RealType result; + RealType result = 0; if(!dist.check_params(function, &result)) return result; if(!dist.check_x(x, function, &result)) @@ -148,7 +148,7 @@ namespace boost { namespace math { inline RealType cdf(const hypergeometric_distribution& dist, const unsigned& x) { static const char* function = "boost::math::cdf(const hypergeometric_distribution<%1%>&, const %1%&)"; - RealType result; + RealType result = 0; if(!dist.check_params(function, &result)) return result; if(!dist.check_x(x, function, &result)) @@ -176,7 +176,7 @@ namespace boost { namespace math { inline RealType cdf(const complemented2_type, unsigned>& c) { static const char* function = "boost::math::cdf(const hypergeometric_distribution<%1%>&, const %1%&)"; - RealType result; + RealType result = 0; if(!c.dist.check_params(function, &result)) return result; if(!c.dist.check_x(c.param, function, &result)) @@ -206,7 +206,7 @@ namespace boost { namespace math { BOOST_MATH_STD_USING // for ADL of std functions // Checking function argument - RealType result; + RealType result = 0; const char* function = "boost::math::quantile(const hypergeometric_distribution<%1%>&, %1%)"; if (false == dist.check_params(function, &result)) return result; if(false == detail::check_probability(function, p, &result, Policy())) return result; @@ -220,7 +220,7 @@ namespace boost { namespace math { BOOST_MATH_STD_USING // for ADL of std functions // Checking function argument - RealType result; + RealType result = 0; const char* function = "quantile(const complemented2_type, %1%>&)"; if (false == c.dist.check_params(function, &result)) return result; if(false == detail::check_probability(function, c.param, &result, Policy())) return result; diff --git a/include/boost/math/distributions/inverse_gamma.hpp b/include/boost/math/distributions/inverse_gamma.hpp index 4a2c3eaaf..88083e084 100644 --- a/include/boost/math/distributions/inverse_gamma.hpp +++ b/include/boost/math/distributions/inverse_gamma.hpp @@ -150,7 +150,7 @@ inline RealType pdf(const inverse_gamma_distribution& dist, co RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_inverse_gamma(function, scale, shape, &result, Policy())) { // distribution parameters bad. return result; @@ -198,7 +198,7 @@ inline RealType cdf(const inverse_gamma_distribution& dist, co RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_inverse_gamma(function, scale, shape, &result, Policy())) { // distribution parameters bad. return result; @@ -227,7 +227,7 @@ inline RealType quantile(const inverse_gamma_distribution& dis RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_inverse_gamma(function, scale, shape, &result, Policy())) return result; if(false == detail::check_probability(function, p, &result, Policy())) @@ -253,7 +253,7 @@ inline RealType cdf(const complemented2_type& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { @@ -329,7 +329,7 @@ inline RealType variance(const inverse_gamma_distribution& dis RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { return result; @@ -355,7 +355,7 @@ inline RealType mode(const inverse_gamma_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_inverse_gamma(function, scale, shape, &result, Policy())) { return result; @@ -381,7 +381,7 @@ inline RealType skewness(const inverse_gamma_distribution& dis RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { @@ -408,7 +408,7 @@ inline RealType kurtosis_excess(const inverse_gamma_distribution& dis RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { diff --git a/include/boost/math/distributions/inverse_gaussian.hpp b/include/boost/math/distributions/inverse_gaussian.hpp index 6803273bc..67c1b4109 100644 --- a/include/boost/math/distributions/inverse_gaussian.hpp +++ b/include/boost/math/distributions/inverse_gaussian.hpp @@ -136,7 +136,7 @@ inline RealType pdf(const inverse_gaussian_distribution& dist, RealType scale = dist.scale(); RealType mean = dist.mean(); - RealType result; + RealType result = 0; static const char* function = "boost::math::pdf(const inverse_gaussian_distribution<%1%>&, %1%)"; if(false == detail::check_scale(function, scale, &result, Policy())) { @@ -170,7 +170,7 @@ inline RealType cdf(const inverse_gaussian_distribution& dist, RealType scale = dist.scale(); RealType mean = dist.mean(); static const char* function = "boost::math::cdf(const inverse_gaussian_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) { return result; @@ -317,7 +317,7 @@ inline RealType quantile(const inverse_gaussian_distribution& RealType scale = dist.scale(); static const char* function = "boost::math::quantile(const inverse_gaussian_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, scale, &result, Policy())) return result; if(false == detail::check_location(function, mean, &result, Policy())) @@ -375,7 +375,7 @@ inline RealType cdf(const complemented2_type& dist, const Re BOOST_MATH_STD_USING // for ADL of std functions // Checking function argument - RealType result; + RealType result = 0; const char* function = "boost::math::pdf(const laplace_distribution<%1%>&, %1%))"; if (false == dist.check_parameters(function, &result)) return result; if (false == detail::check_x(function, x, &result, Policy())) return result; @@ -126,7 +126,7 @@ inline RealType cdf(const laplace_distribution& dist, const Re BOOST_MATH_STD_USING // for ADL of std functions // Checking function argument - RealType result; + RealType result = 0; const char* function = "boost::math::cdf(const laplace_distribution<%1%>&, %1%)"; if (false == dist.check_parameters(function, &result)) return result; if (false == detail::check_x(function, x, &result, Policy())) return result; @@ -157,7 +157,7 @@ inline RealType quantile(const laplace_distribution& dist, con BOOST_MATH_STD_USING // for ADL of std functions. // Checking function argument - RealType result; + RealType result = 0; const char* function = "boost::math::quantile(const laplace_distribution<%1%>&, %1%)"; if (false == dist.check_parameters(function, &result)) return result; if(false == detail::check_probability(function, p, &result, Policy())) return result; @@ -199,7 +199,7 @@ inline RealType cdf(const complemented2_type& dist, const RealTyp static const char* function = "boost::math::pdf(const lognormal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(0 == detail::check_scale(function, sigma, &result, Policy())) return result; if(0 == detail::check_lognormal_x(function, x, &result, Policy())) @@ -125,7 +125,7 @@ inline RealType cdf(const lognormal_distribution& dist, const static const char* function = "boost::math::cdf(const lognormal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(0 == detail::check_lognormal_x(function, x, &result, Policy())) return result; @@ -143,7 +143,7 @@ inline RealType quantile(const lognormal_distribution& dist, c static const char* function = "boost::math::quantile(const lognormal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(0 == detail::check_probability(function, p, &result, Policy())) return result; @@ -163,7 +163,7 @@ inline RealType cdf(const complemented2_type& dist) RealType mu = dist.location(); RealType sigma = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::mean(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -217,7 +217,7 @@ inline RealType variance(const lognormal_distribution& dist) RealType mu = dist.location(); RealType sigma = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::variance(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -232,7 +232,7 @@ inline RealType mode(const lognormal_distribution& dist) RealType mu = dist.location(); RealType sigma = dist.scale(); - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::mode(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -258,7 +258,7 @@ inline RealType skewness(const lognormal_distribution& dist) RealType ss = sigma * sigma; RealType ess = exp(ss); - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::skewness(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -274,7 +274,7 @@ inline RealType kurtosis(const lognormal_distribution& dist) RealType sigma = dist.scale(); RealType ss = sigma * sigma; - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::kurtosis(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; @@ -290,7 +290,7 @@ inline RealType kurtosis_excess(const lognormal_distribution& RealType sigma = dist.scale(); RealType ss = sigma * sigma; - RealType result; + RealType result = 0; if(0 == detail::check_scale("boost::math::kurtosis_excess(const lognormal_distribution<%1%>&)", sigma, &result, Policy())) return result; diff --git a/include/boost/math/distributions/negative_binomial.hpp b/include/boost/math/distributions/negative_binomial.hpp index 521b52756..28ce4b996 100644 --- a/include/boost/math/distributions/negative_binomial.hpp +++ b/include/boost/math/distributions/negative_binomial.hpp @@ -165,7 +165,7 @@ namespace boost RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test. { static const char* function = "boost::math::negative_binomial<%1%>::find_lower_bound_on_p"; - RealType result; // of error checks. + RealType result = 0; // of error checks. RealType failures = trials - successes; if(false == detail::check_probability(function, alpha, &result, Policy()) && negative_binomial_detail::check_dist_and_k( @@ -190,7 +190,7 @@ namespace boost RealType alpha) // alpha 0.05 equivalent to 95% for one-sided test. { static const char* function = "boost::math::negative_binomial<%1%>::find_upper_bound_on_p"; - RealType result; // of error checks. + RealType result = 0; // of error checks. RealType failures = trials - successes; if(false == negative_binomial_detail::check_dist_and_k( function, successes, RealType(0), failures, &result, Policy()) @@ -222,7 +222,7 @@ namespace boost { static const char* function = "boost::math::negative_binomial<%1%>::find_minimum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, RealType(1), p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) @@ -239,7 +239,7 @@ namespace boost { static const char* function = "boost::math::negative_binomial<%1%>::find_maximum_number_of_trials"; // Error checks: - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, RealType(1), p, k, &result, Policy()) && detail::check_probability(function, alpha, &result, Policy())) @@ -343,7 +343,7 @@ namespace boost RealType r = dist.successes(); RealType p = dist.success_fraction(); - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, r, @@ -370,7 +370,7 @@ namespace boost RealType p = dist.success_fraction(); RealType r = dist.successes(); // Error check: - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, r, @@ -399,7 +399,7 @@ namespace boost RealType p = dist.success_fraction(); RealType r = dist.successes(); // Error check: - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_k( function, r, @@ -435,7 +435,7 @@ namespace boost RealType p = dist.success_fraction(); RealType r = dist.successes(); // Check dist and P. - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_prob (function, r, p, P, &result, Policy())) { @@ -509,7 +509,7 @@ namespace boost const negative_binomial_distribution& dist = c.dist; RealType p = dist.success_fraction(); RealType r = dist.successes(); - RealType result; + RealType result = 0; if(false == negative_binomial_detail::check_dist_and_prob( function, r, diff --git a/include/boost/math/distributions/normal.hpp b/include/boost/math/distributions/normal.hpp index 69da2dc38..baeecf634 100644 --- a/include/boost/math/distributions/normal.hpp +++ b/include/boost/math/distributions/normal.hpp @@ -106,7 +106,7 @@ inline RealType pdf(const normal_distribution& dist, const Rea // return 0; //} - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) { return result; @@ -138,7 +138,7 @@ inline RealType cdf(const normal_distribution& dist, const Rea RealType sd = dist.standard_deviation(); RealType mean = dist.mean(); static const char* function = "boost::math::cdf(const normal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) { return result; @@ -179,7 +179,7 @@ inline RealType quantile(const normal_distribution& dist, cons RealType mean = dist.mean(); static const char* function = "boost::math::quantile(const normal_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; if(false == detail::check_scale(function, sd, &result, Policy())) return result; if(false == detail::check_location(function, mean, &result, Policy())) @@ -218,7 +218,7 @@ inline RealType cdf(const complemented2_type::pareto_distribution", scale, shape, &result, Policy()); } @@ -182,7 +182,7 @@ namespace boost static const char* function = "boost::math::pdf(const pareto_distribution<%1%>&, %1%)"; RealType scale = dist.scale(); RealType shape = dist.shape(); - RealType result; + RealType result = 0; if(false == (detail::check_pareto_x(function, x, &result, Policy()) && detail::check_pareto(function, scale, shape, &result, Policy()))) return result; @@ -201,7 +201,7 @@ namespace boost static const char* function = "boost::math::cdf(const pareto_distribution<%1%>&, %1%)"; RealType scale = dist.scale(); RealType shape = dist.shape(); - RealType result; + RealType result = 0; if(false == (detail::check_pareto_x(function, x, &result, Policy()) && detail::check_pareto(function, scale, shape, &result, Policy()))) @@ -222,7 +222,7 @@ namespace boost { BOOST_MATH_STD_USING // for ADL of std function pow. static const char* function = "boost::math::quantile(const pareto_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType scale = dist.scale(); RealType shape = dist.shape(); if(false == (detail::check_probability(function, p, &result, Policy()) @@ -249,7 +249,7 @@ namespace boost { BOOST_MATH_STD_USING // for ADL of std function pow. static const char* function = "boost::math::cdf(const pareto_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType x = c.param; RealType scale = c.dist.scale(); RealType shape = c.dist.shape(); @@ -271,7 +271,7 @@ namespace boost { BOOST_MATH_STD_USING // for ADL of std function pow. static const char* function = "boost::math::quantile(const pareto_distribution<%1%>&, %1%)"; - RealType result; + RealType result = 0; RealType q = c.param; RealType scale = c.dist.scale(); RealType shape = c.dist.shape(); @@ -296,7 +296,7 @@ namespace boost template inline RealType mean(const pareto_distribution& dist) { - RealType result; + RealType result = 0; static const char* function = "boost::math::mean(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), dist.shape(), &result, Policy())) { @@ -322,7 +322,7 @@ namespace boost template inline RealType median(const pareto_distribution& dist) { - RealType result; + RealType result = 0; static const char* function = "boost::math::median(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), dist.shape(), &result, Policy())) { @@ -335,7 +335,7 @@ namespace boost template inline RealType variance(const pareto_distribution& dist) { - RealType result; + RealType result = 0; RealType scale = dist.scale(); RealType shape = dist.shape(); static const char* function = "boost::math::variance(const pareto_distribution<%1%>&, %1%)"; @@ -361,7 +361,7 @@ namespace boost inline RealType skewness(const pareto_distribution& dist) { BOOST_MATH_STD_USING - RealType result; + RealType result = 0; RealType shape = dist.shape(); static const char* function = "boost::math::pdf(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), shape, &result, Policy())) @@ -386,7 +386,7 @@ namespace boost template inline RealType kurtosis(const pareto_distribution& dist) { - RealType result; + RealType result = 0; RealType shape = dist.shape(); static const char* function = "boost::math::pdf(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), shape, &result, Policy())) @@ -410,7 +410,7 @@ namespace boost template inline RealType kurtosis_excess(const pareto_distribution& dist) { - RealType result; + RealType result = 0; RealType shape = dist.shape(); static const char* function = "boost::math::pdf(const pareto_distribution<%1%>&, %1%)"; if(false == detail::check_pareto(function, dist.scale(), shape, &result, Policy())) diff --git a/include/boost/math/distributions/poisson.hpp b/include/boost/math/distributions/poisson.hpp index 3cb06e0f4..3dd58f80c 100644 --- a/include/boost/math/distributions/poisson.hpp +++ b/include/boost/math/distributions/poisson.hpp @@ -316,7 +316,7 @@ namespace boost RealType mean = dist.mean(); // Error check: - RealType result; + RealType result = 0; if(false == poisson_detail::check_dist_and_k( "boost::math::pdf(const poisson_distribution<%1%>&, %1%)", mean, @@ -362,7 +362,7 @@ namespace boost RealType mean = dist.mean(); // Error checks: - RealType result; + RealType result = 0; if(false == poisson_detail::check_dist_and_k( "boost::math::cdf(const poisson_distribution<%1%>&, %1%)", mean, @@ -414,7 +414,7 @@ namespace boost RealType mean = dist.mean(); // Error checks: - RealType result; + RealType result = 0; if(false == poisson_detail::check_dist_and_k( "boost::math::cdf(const poisson_distribution<%1%>&, %1%)", mean, @@ -443,7 +443,7 @@ namespace boost inline RealType quantile(const poisson_distribution& dist, const RealType& p) { // Quantile (or Percent Point) Poisson function. // Return the number of expected events k for a given probability p. - RealType result; // of Argument checks: + RealType result = 0; // of Argument checks: if(false == poisson_detail::check_prob( "boost::math::quantile(const poisson_distribution<%1%>&, %1%)", p, @@ -514,7 +514,7 @@ namespace boost // Error checks: RealType q = c.param; const poisson_distribution& dist = c.dist; - RealType result; // of argument checks. + RealType result = 0; // of argument checks. if(false == poisson_detail::check_prob( "boost::math::quantile(const poisson_distribution<%1%>&, %1%)", q, diff --git a/include/boost/math/distributions/rayleigh.hpp b/include/boost/math/distributions/rayleigh.hpp index 2aeef4d64..1ffb9dc0a 100644 --- a/include/boost/math/distributions/rayleigh.hpp +++ b/include/boost/math/distributions/rayleigh.hpp @@ -98,7 +98,7 @@ inline RealType pdf(const rayleigh_distribution& dist, const R BOOST_MATH_STD_USING // for ADL of std function exp. RealType sigma = dist.sigma(); - RealType result; + RealType result = 0; static const char* function = "boost::math::pdf(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) { @@ -118,7 +118,7 @@ inline RealType cdf(const rayleigh_distribution& dist, const R { BOOST_MATH_STD_USING // for ADL of std functions - RealType result; + RealType result = 0; RealType sigma = dist.sigma(); static const char* function = "boost::math::cdf(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) @@ -138,7 +138,7 @@ inline RealType quantile(const rayleigh_distribution& dist, co { BOOST_MATH_STD_USING // for ADL of std functions - RealType result; + RealType result = 0; RealType sigma = dist.sigma(); static const char* function = "boost::math::quantile(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) @@ -163,7 +163,7 @@ inline RealType cdf(const complemented2_type inline RealType mean(const rayleigh_distribution& dist) { - RealType result; + RealType result = 0; RealType sigma = dist.sigma(); static const char* function = "boost::math::mean(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) @@ -225,7 +225,7 @@ inline RealType mean(const rayleigh_distribution& dist) template inline RealType variance(const rayleigh_distribution& dist) { - RealType result; + RealType result = 0; RealType sigma = dist.sigma(); static const char* function = "boost::math::variance(const rayleigh_distribution<%1%>&, %1%)"; if(false == detail::verify_sigma(function, sigma, &result, Policy())) diff --git a/include/boost/math/distributions/triangular.hpp b/include/boost/math/distributions/triangular.hpp index 5030081db..ee607e177 100644 --- a/include/boost/math/distributions/triangular.hpp +++ b/include/boost/math/distributions/triangular.hpp @@ -199,7 +199,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -237,7 +237,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -273,7 +273,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks + RealType result = 0; // of checks if(false == detail::check_triangular(function,lower, mode, upper, &result, Policy())) { return result; @@ -316,7 +316,7 @@ namespace boost{ namespace math RealType mode = c.dist.mode(); RealType upper = c.dist.upper(); RealType x = c.param; - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -352,7 +352,7 @@ namespace boost{ namespace math RealType m = c.dist.mode(); RealType u = c.dist.upper(); RealType q = c.param; // probability 0 to 1. - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, l, m, u, &result, Policy())) { return result; @@ -399,7 +399,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -415,7 +415,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function, lower, mode, upper, &result, Policy())) { return result; @@ -428,7 +428,7 @@ namespace boost{ namespace math { static const char* function = "boost::math::mode(const triangular_distribution<%1%>&)"; RealType mode = dist.mode(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular_mode(function, mode, &result, Policy())) { // This should never happen! return result; @@ -442,7 +442,7 @@ namespace boost{ namespace math BOOST_MATH_STD_USING // ADL of std functions. static const char* function = "boost::math::median(const triangular_distribution<%1%>&)"; RealType mode = dist.mode(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular_mode(function, mode, &result, Policy())) { // This should never happen! return result; @@ -469,7 +469,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType mode = dist.mode(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function,lower, mode, upper, &result, Policy())) { return result; @@ -485,7 +485,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType upper = dist.upper(); RealType mode = dist.mode(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function,lower, mode, upper, &result, Policy())) { return result; @@ -500,7 +500,7 @@ namespace boost{ namespace math RealType lower = dist.lower(); RealType upper = dist.upper(); RealType mode = dist.mode(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_triangular(function,lower, mode, upper, &result, Policy())) { return result; diff --git a/include/boost/math/distributions/uniform.hpp b/include/boost/math/distributions/uniform.hpp index 2e17e18e7..5d967a17f 100644 --- a/include/boost/math/distributions/uniform.hpp +++ b/include/boost/math/distributions/uniform.hpp @@ -161,7 +161,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::pdf(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy())) { return result; @@ -186,7 +186,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::cdf(const uniform_distribution<%1%>&, %1%)",lower, upper, &result, Policy())) { return result; @@ -211,7 +211,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks + RealType result = 0; // of checks if(false == detail::check_uniform("boost::math::quantile(const uniform_distribution<%1%>&, %1%)",lower, upper, &result, Policy())) { return result; @@ -237,7 +237,7 @@ namespace boost{ namespace math RealType lower = c.dist.lower(); RealType upper = c.dist.upper(); RealType x = c.param; - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::cdf(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy())) { return result; @@ -263,7 +263,7 @@ namespace boost{ namespace math RealType lower = c.dist.lower(); RealType upper = c.dist.upper(); RealType q = c.param; - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::quantile(const uniform_distribution<%1%>&, %1%)", lower, upper, &result, Policy())) { return result; @@ -285,7 +285,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::mean(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; @@ -298,7 +298,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::variance(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; @@ -312,7 +312,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::mode(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; @@ -326,7 +326,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::median(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; @@ -338,7 +338,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::skewness(const uniform_distribution<%1%>&)",lower, upper, &result, Policy())) { return result; @@ -351,7 +351,7 @@ namespace boost{ namespace math { RealType lower = dist.lower(); RealType upper = dist.upper(); - RealType result; // of checks. + RealType result = 0; // of checks. if(false == detail::check_uniform("boost::math::kurtosis_execess(const uniform_distribution<%1%>&)", lower, upper, &result, Policy())) { return result; diff --git a/include/boost/math/distributions/weibull.hpp b/include/boost/math/distributions/weibull.hpp index e47437ff3..6b5c7db34 100644 --- a/include/boost/math/distributions/weibull.hpp +++ b/include/boost/math/distributions/weibull.hpp @@ -126,7 +126,7 @@ inline RealType pdf(const weibull_distribution& dist, const Re RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; if(false == detail::check_weibull_x(function, x, &result, Policy())) @@ -152,7 +152,7 @@ inline RealType cdf(const weibull_distribution& dist, const Re RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; if(false == detail::check_weibull_x(function, x, &result, Policy())) @@ -173,7 +173,7 @@ inline RealType quantile(const weibull_distribution& dist, con RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; if(false == detail::check_probability(function, p, &result, Policy())) @@ -197,7 +197,7 @@ inline RealType cdf(const complemented2_type& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; @@ -259,7 +259,7 @@ inline RealType variance(const weibull_distribution& dist) static const char* function = "boost::math::variance(const weibull_distribution<%1%>)"; - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) { return result; @@ -281,7 +281,7 @@ inline RealType mode(const weibull_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) { return result; @@ -302,7 +302,7 @@ inline RealType median(const weibull_distribution& dist) RealType shape = dist.shape(); // Wikipedia k RealType scale = dist.scale(); // Wikipedia lambda - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) { return result; @@ -322,7 +322,7 @@ inline RealType skewness(const weibull_distribution& dist) RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) { return result; @@ -348,7 +348,7 @@ inline RealType kurtosis_excess(const weibull_distribution& di RealType shape = dist.shape(); RealType scale = dist.scale(); - RealType result; + RealType result = 0; if(false == detail::check_weibull(function, scale, shape, &result, Policy())) return result; diff --git a/include/boost/math/policies/error_handling.hpp b/include/boost/math/policies/error_handling.hpp index 198cd020b..833ae4901 100644 --- a/include/boost/math/policies/error_handling.hpp +++ b/include/boost/math/policies/error_handling.hpp @@ -616,7 +616,7 @@ inline R checked_narrowing_cast(T val, const char* function) // // Most of what follows will evaluate to a no-op: // - R result; + R result = 0; if(detail::check_overflow(val, &result, function, overflow_type())) return result; if(detail::check_underflow(val, &result, function, underflow_type())) diff --git a/include/boost/math/policies/policy.hpp b/include/boost/math/policies/policy.hpp index b66cd7f92..355bf18fd 100644 --- a/include/boost/math/policies/policy.hpp +++ b/include/boost/math/policies/policy.hpp @@ -738,6 +738,7 @@ struct basic_digits : public mpl::int_{ }; template struct precision { + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); typedef typename Policy::precision_type precision_type; typedef basic_digits digits_t; typedef typename mpl::if_< @@ -775,6 +776,7 @@ struct precision template struct precision { + BOOST_STATIC_ASSERT((::std::numeric_limits::radix == 2) || ((::std::numeric_limits::is_specialized == 0) || (::std::numeric_limits::digits == 0))); #ifndef __BORLANDC__ typedef typename Policy::precision_type precision_type; typedef typename mpl::if_c< @@ -896,8 +898,10 @@ inline T get_epsilon_imp(mpl::true_ const&) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); #else BOOST_ASSERT(::std::numeric_limits::is_specialized); + BOOST_ASSERT(::std::numeric_limits::radix == 2); #endif typedef typename boost::math::policies::precision::type p_t; typedef mpl::bool_::digits> is_small_int; @@ -916,7 +920,7 @@ inline T get_epsilon_imp(mpl::false_ const&) template inline T get_epsilon(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) { - typedef mpl::bool_< std::numeric_limits::is_specialized > tag_type; + typedef mpl::bool_< (std::numeric_limits::is_specialized && (std::numeric_limits::radix == 2)) > tag_type; return detail::get_epsilon_imp(tag_type()); } diff --git a/include/boost/math/special_functions/beta.hpp b/include/boost/math/special_functions/beta.hpp index 0e17af242..b68834c75 100644 --- a/include/boost/math/special_functions/beta.hpp +++ b/include/boost/math/special_functions/beta.hpp @@ -326,6 +326,10 @@ T ibeta_power_terms(T a, T b2 = (y * cgh) / bgh; l1 = a * log(b1); l2 = b * log(b2); + BOOST_MATH_INSTRUMENT_VARIABLE(b1); + BOOST_MATH_INSTRUMENT_VARIABLE(b2); + BOOST_MATH_INSTRUMENT_VARIABLE(l1); + BOOST_MATH_INSTRUMENT_VARIABLE(l2); if((l1 >= tools::log_max_value()) || (l1 <= tools::log_min_value()) || (l2 >= tools::log_max_value()) @@ -384,9 +388,8 @@ T ibeta_power_terms(T a, return pow(x, a) * pow(y, b); } - T result; + T result= 0; // assignment here silences warnings later - T prefix = 1; T c = a + b; // integration limits for the gamma functions: @@ -519,7 +522,6 @@ T ibeta_series(T a, T b, T x, T s0, const boost::math::lanczos::undefined_lanczo if(normalised) { - T prefix = 1; T c = a + b; // figure out integration limits for the gamma function: diff --git a/include/boost/math/special_functions/cbrt.hpp b/include/boost/math/special_functions/cbrt.hpp index c5421344f..0fc6e0742 100644 --- a/include/boost/math/special_functions/cbrt.hpp +++ b/include/boost/math/special_functions/cbrt.hpp @@ -90,6 +90,8 @@ T cbrt_imp(T z, const Policy& pol) typedef typename largest_cbrt_int_type::type shift_type; + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); + if(abs(i_exp3) < std::numeric_limits::digits) { if(i_exp3 > 0) diff --git a/include/boost/math/special_functions/detail/t_distribution_inv.hpp b/include/boost/math/special_functions/detail/t_distribution_inv.hpp index 8f7f0e6fd..bb6bc848a 100644 --- a/include/boost/math/special_functions/detail/t_distribution_inv.hpp +++ b/include/boost/math/special_functions/detail/t_distribution_inv.hpp @@ -529,7 +529,10 @@ inline T fast_students_t_quantile(T df, T p, const Policy& pol) typedef mpl::bool_< (std::numeric_limits::digits <= 53) && - (std::numeric_limits::is_specialized)> tag_type; + (std::numeric_limits::is_specialized) + && + (std::numeric_limits::radix == 2) + > tag_type; return policies::checked_narrowing_cast(fast_students_t_quantile_imp(static_cast(df), static_cast(p), pol, static_cast(0)), "boost::math::students_t_quantile<%1%>(%1%,%1%,%1%)"); } diff --git a/include/boost/math/special_functions/gamma.hpp b/include/boost/math/special_functions/gamma.hpp index 5d414259b..461adf397 100644 --- a/include/boost/math/special_functions/gamma.hpp +++ b/include/boost/math/special_functions/gamma.hpp @@ -1,3 +1,4 @@ + // Copyright John Maddock 2006-7. // Copyright Paul A. Bristow 2007. @@ -150,6 +151,7 @@ T gamma_imp(T z, const Policy& pol, const L& l) if(z <= -20) { result = gamma_imp(T(-z), pol, l) * sinpx(z); + BOOST_MATH_INSTRUMENT_VARIABLE(result); if((fabs(result) < 1) && (tools::max_value() * fabs(result) < boost::math::constants::pi())) return policies::raise_overflow_error(function, "Result of tgamma is too large to represent.", pol); result = -boost::math::constants::pi() / result; @@ -157,6 +159,7 @@ T gamma_imp(T z, const Policy& pol, const L& l) return policies::raise_underflow_error(function, "Result of tgamma is too small to represent.", pol); if((boost::math::fpclassify)(result) == (int)FP_SUBNORMAL) return policies::raise_denorm_error(function, "Result of tgamma is denormalized.", result, pol); + BOOST_MATH_INSTRUMENT_VARIABLE(result); return result; } @@ -167,29 +170,41 @@ T gamma_imp(T z, const Policy& pol, const L& l) z += 1; } } + BOOST_MATH_INSTRUMENT_VARIABLE(result); if((floor(z) == z) && (z < max_factorial::value)) { result *= unchecked_factorial(itrunc(z, pol) - 1); + BOOST_MATH_INSTRUMENT_VARIABLE(result); } else { result *= L::lanczos_sum(z); + BOOST_MATH_INSTRUMENT_VARIABLE(result); + BOOST_MATH_INSTRUMENT_VARIABLE(tools::log_max_value()); if(z * log(z) > tools::log_max_value()) { // we're going to overflow unless this is done with care: T zgh = (z + static_cast(L::g()) - boost::math::constants::half()); + BOOST_MATH_INSTRUMENT_VARIABLE(zgh); if(log(zgh) * z / 2 > tools::log_max_value()) return policies::raise_overflow_error(function, "Result of tgamma is too large to represent.", pol); T hp = pow(zgh, (z / 2) - T(0.25)); + BOOST_MATH_INSTRUMENT_VARIABLE(hp); result *= hp / exp(zgh); + BOOST_MATH_INSTRUMENT_VARIABLE(result); if(tools::max_value() / hp < result) return policies::raise_overflow_error(function, "Result of tgamma is too large to represent.", pol); result *= hp; + BOOST_MATH_INSTRUMENT_VARIABLE(result); } else { T zgh = (z + static_cast(L::g()) - boost::math::constants::half()); + BOOST_MATH_INSTRUMENT_VARIABLE(zgh); + BOOST_MATH_INSTRUMENT_VARIABLE(pow(zgh, z - boost::math::constants::half())); + BOOST_MATH_INSTRUMENT_VARIABLE(exp(zgh)); result *= pow(zgh, z - boost::math::constants::half()) / exp(zgh); + BOOST_MATH_INSTRUMENT_VARIABLE(result); } } return result; diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index 140733205..736fedee5 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -253,6 +253,12 @@ inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) return (std::max)((std::max)(a, b), (std::max)(c, d)); } } // namespace tools + +template +void suppress_unused_variable_warning(const T&) +{ +} + }} // namespace boost namespace math #if ((defined(__linux__) && !defined(__UCLIBC__)) || defined(__QNX__) || defined(__IBMCPP__)) && !defined(BOOST_NO_FENV_H) diff --git a/include/boost/math/tools/precision.hpp b/include/boost/math/tools/precision.hpp index e7695e92a..54cadcc96 100644 --- a/include/boost/math/tools/precision.hpp +++ b/include/boost/math/tools/precision.hpp @@ -45,8 +45,10 @@ inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT( ::std::numeric_limits::is_specialized); + BOOST_STATIC_ASSERT( ::std::numeric_limits::radix == 2); #else BOOST_ASSERT(::std::numeric_limits::is_specialized); + BOOST_ASSERT(::std::numeric_limits::radix == 2); #endif return std::numeric_limits::digits; } @@ -303,14 +305,14 @@ inline T forth_root_epsilon_imp(const T*, const Tag&) template inline T root_epsilon() { - typedef mpl::int_::digits> tag_type; + typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; return detail::root_epsilon_imp(static_cast(0), tag_type()); } template inline T forth_root_epsilon() { - typedef mpl::int_::digits> tag_type; + typedef mpl::int_< (::std::numeric_limits::radix == 2) ? std::numeric_limits::digits : 0> tag_type; return detail::forth_root_epsilon_imp(static_cast(0), tag_type()); }