2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Reduce scope of changes

This commit is contained in:
Christopher Kormanyos
2024-02-16 06:10:17 +01:00
parent 7b0749cef6
commit 17f14ba3bf
9 changed files with 69 additions and 92 deletions

View File

@@ -343,7 +343,7 @@ struct DistributionConcept
template <class R, class P>
static void test_extra_members(const boost::math::hypergeometric_distribution<R, P>& d)
{
unsigned u = static_cast<unsigned>(d.defective());
unsigned u = d.defective();
u = d.sample_count();
u = d.total();
suppress_unused_variable_warning(u);

View File

@@ -17,9 +17,8 @@
#include <boost/math/constants/constants.hpp>
#include <boost/math/distributions/complement.hpp>
#include <boost/math/distributions/detail/common_error_handling.hpp>
#include <cmath>
#include <utility>
#include <cmath>
namespace boost{ namespace math
{
@@ -276,30 +275,29 @@ inline RealType quantile(const complemented2_type<cauchy_distribution<RealType,
template <class RealType, class Policy>
inline RealType mean(const cauchy_distribution<RealType, Policy>&)
{
// There is no mean:
return
policies::raise_domain_error<RealType>
(
"boost::math::mean(cauchy<%1%>&)",
"The Cauchy distribution does not have a mean: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy()
);
{ // There is no mean:
typedef typename Policy::assert_undefined_type assert_type;
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::mean(cauchy<%1%>&)",
"The Cauchy distribution does not have a mean: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy());
}
template <class RealType, class Policy>
inline RealType variance(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no variance:
return
policies::raise_domain_error<RealType>
(
"boost::math::variance(cauchy<%1%>&)",
"The Cauchy distribution does not have a variance: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy()
);
typedef typename Policy::assert_undefined_type assert_type;
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::variance(cauchy<%1%>&)",
"The Cauchy distribution does not have a variance: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy());
}
template <class RealType, class Policy>
@@ -317,47 +315,42 @@ template <class RealType, class Policy>
inline RealType skewness(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no skewness:
typedef typename Policy::assert_undefined_type assert_type;
static_assert(assert_type::value == 0, "assert type is undefined");
using assert_type = typename Policy::domain_error_type;
static_assert(!(assert_type::value), "Error Policy is undefined");
return
policies::raise_domain_error<RealType>
(
"boost::math::skewness(cauchy<%1%>&)",
"The Cauchy distribution does not have a skewness: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy()
);
return policies::raise_domain_error<RealType>(
"boost::math::skewness(cauchy<%1%>&)",
"The Cauchy distribution does not have a skewness: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy()); // infinity?
}
template <class RealType, class Policy>
inline RealType kurtosis(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no kurtosis:
return
policies::raise_domain_error<RealType>
(
"boost::math::kurtosis(cauchy<%1%>&)",
"The Cauchy distribution does not have a kurtosis: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy()
);
typedef typename Policy::assert_undefined_type assert_type;
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::kurtosis(cauchy<%1%>&)",
"The Cauchy distribution does not have a kurtosis: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy());
}
template <class RealType, class Policy>
inline RealType kurtosis_excess(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no kurtosis excess:
return
policies::raise_domain_error<RealType>
(
"boost::math::kurtosis_excess(cauchy<%1%>&)",
"The Cauchy distribution does not have a kurtosis: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy()
);
typedef typename Policy::assert_undefined_type assert_type;
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::kurtosis_excess(cauchy<%1%>&)",
"The Cauchy distribution does not have a kurtosis: "
"the only possible return value is %1%.",
std::numeric_limits<RealType>::quiet_NaN(), Policy());
}
template <class RealType, class Policy>

View File

@@ -321,8 +321,7 @@ T hypergeometric_pdf_prime_loop_imp(hypergeometric_pdf_prime_loop_data& data, hy
// to sidestep the issue:
//
hypergeometric_pdf_prime_loop_result_entry<T> t = { p, &result };
++data.prime_index;
data.current_prime = prime(static_cast<unsigned>(data.prime_index));
data.current_prime = prime(++data.prime_index);
return hypergeometric_pdf_prime_loop_imp<T>(data, t);
}
if((p < 1) && (tools::min_value<T>() / p > result.value))
@@ -332,14 +331,12 @@ T hypergeometric_pdf_prime_loop_imp(hypergeometric_pdf_prime_loop_data& data, hy
// to sidestep the issue:
//
hypergeometric_pdf_prime_loop_result_entry<T> t = { p, &result };
++data.prime_index;
data.current_prime = prime(static_cast<unsigned>(data.prime_index));
data.current_prime = prime(++data.prime_index);
return hypergeometric_pdf_prime_loop_imp<T>(data, t);
}
result.value *= p;
}
++data.prime_index;
data.current_prime = prime(static_cast<unsigned>(data.prime_index));
data.current_prime = prime(++data.prime_index);
}
//
// When we get to here we have run out of prime factors,
@@ -400,16 +397,16 @@ T hypergeometric_pdf_factorial_imp(std::uint64_t x, std::uint64_t r, std::uint64
BOOST_MATH_ASSERT(N <= boost::math::max_factorial<T>::value);
T result = boost::math::unchecked_factorial<T>(n);
T num[3] = {
boost::math::unchecked_factorial<T>(static_cast<unsigned>(r)),
boost::math::unchecked_factorial<T>(static_cast<unsigned>(N - n)),
boost::math::unchecked_factorial<T>(static_cast<unsigned>(N - r))
boost::math::unchecked_factorial<T>(r),
boost::math::unchecked_factorial<T>(N - n),
boost::math::unchecked_factorial<T>(N - r)
};
T denom[5] = {
boost::math::unchecked_factorial<T>(static_cast<unsigned>(N)),
boost::math::unchecked_factorial<T>(static_cast<unsigned>(x)),
boost::math::unchecked_factorial<T>(static_cast<unsigned>(n - x)),
boost::math::unchecked_factorial<T>(static_cast<unsigned>(r - x)),
boost::math::unchecked_factorial<T>(static_cast<unsigned>(N - n - r + x))
boost::math::unchecked_factorial<T>(N),
boost::math::unchecked_factorial<T>(x),
boost::math::unchecked_factorial<T>(n - x),
boost::math::unchecked_factorial<T>(r - x),
boost::math::unchecked_factorial<T>(N - n - r + x)
};
std::size_t i = 0;
std::size_t j = 0;

View File

@@ -806,34 +806,24 @@ namespace boost
// standard_deviation provided by derived accessors.
template <class RealType, class Policy>
inline RealType skewness(const non_central_beta_distribution<RealType, Policy>& /*dist*/)
{
// LCOV_EXCL_START
{ // skewness = sqrt(l).
const char* function = "boost::math::non_central_beta_distribution<%1%>::skewness()";
typedef typename Policy::assert_undefined_type assert_type;
static_assert(assert_type::value == 0, "Assert type is undefined.");
return
policies::raise_evaluation_error<RealType>
(
function,
"This function is not yet implemented, the only sensible result is %1%.", // LCOV_EXCL_LINE
std::numeric_limits<RealType>::quiet_NaN(), Policy()
);
// LCOV_EXCL_STOP
return policies::raise_evaluation_error<RealType>(function, "This function is not yet implemented, the only sensible result is %1%.", // LCOV_EXCL_LINE
std::numeric_limits<RealType>::quiet_NaN(), Policy()); // infinity? LCOV_EXCL_LINE
}
template <class RealType, class Policy>
inline RealType kurtosis_excess(const non_central_beta_distribution<RealType, Policy>& /*dist*/)
{
// LCOV_EXCL_START
const char* function = "boost::math::non_central_beta_distribution<%1%>::kurtosis_excess()";
typedef typename Policy::assert_undefined_type assert_type;
static_assert(assert_type::value == 0, "Assert type is undefined.");
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()
);
// LCOV_EXCL_STOP
return policies::raise_evaluation_error<RealType>(function, "This function is not yet implemented, the only sensible result is %1%.", // LCOV_EXCL_LINE
std::numeric_limits<RealType>::quiet_NaN(), Policy()); // infinity? LCOV_EXCL_LINE
} // kurtosis_excess
template <class RealType, class Policy>

View File

@@ -145,8 +145,6 @@ T bessel_y0(T x, const Policy&)
static const char* function = "boost::math::bessel_y0<%1%>(%1%,%1%)";
static_cast<void>(function[0U]);
BOOST_MATH_ASSERT(x > 0);
if (x <= 3) // x in (0, 3]

View File

@@ -226,7 +226,6 @@ test-suite special_fun :
[ run test_factorials.cpp pch ../../test/build//boost_unit_test_framework ]
[ run test_gamma.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run test_gamma_edge.cpp ]
[ run test_compile_test_and_run.cpp ]
[ run test_gamma_mp.cpp ../../test/build//boost_unit_test_framework : : : release <define>TEST=1 [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] : test_gamma_mp_1 ]
[ run test_gamma_mp.cpp ../../test/build//boost_unit_test_framework : : : release <define>TEST=2 [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] : test_gamma_mp_2 ]
[ run test_gamma_mp.cpp ../../test/build//boost_unit_test_framework : : : release <define>TEST=3 [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] : test_gamma_mp_3 ]
@@ -504,6 +503,7 @@ test-suite special_fun :
: test_igamma_inva_real_concept ]
[ run test_instantiate1.cpp test_instantiate2.cpp ]
[ run test_instantiate1.cpp test_instantiate2.cpp : : : <exception-handling>off : test_instantiate_no_eh ]
[ run test_instantiate3.cpp ]
[ run test_jacobi.cpp pch_light ../../test/build//boost_unit_test_framework ]
[ run test_laguerre.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]

View File

@@ -8,8 +8,8 @@
#ifndef BOOST_LIBS_MATH_TEST_INSTANTIATE_HPP
#define BOOST_LIBS_MATH_TEST_INSTANTIATE_HPP
#if !defined(BOOST_MATH_ASSERT_UNDEFINED_POLICY)
#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
#ifndef BOOST_MATH_ASSERT_UNDEFINED_POLICY
# define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
#endif
template <class RealType>

View File

@@ -11,11 +11,12 @@ extern void other_test();
int main(int argc, char* [])
{
instantiate(double(0));
if(argc > 10000)
{
instantiate(double(0));
instantiate_mixed(double(0));
other_test();
}
}

View File

@@ -35,7 +35,5 @@ auto main() -> int
{
local::instantiate_runner();
const auto result_is_ok = (boost::report_errors() == 0);
return (result_is_ok ? 0 : -1);
return boost::report_errors();
}