Skip to content

Commit

Permalink
Merge pull request #1092 from boostorg/cover_instantiate
Browse files Browse the repository at this point in the history
Run and cover compile-test instantiation
  • Loading branch information
ckormanyos authored Feb 14, 2024
2 parents bd518d9 + 287edb3 commit 593fea8
Show file tree
Hide file tree
Showing 9 changed files with 437 additions and 139 deletions.
2 changes: 1 addition & 1 deletion include/boost/math/concepts/distributions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = d.defective();
unsigned u = static_cast<unsigned>(d.defective());
u = d.sample_count();
u = d.total();
suppress_unused_variable_warning(u);
Expand Down
86 changes: 44 additions & 42 deletions include/boost/math/distributions/cauchy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
#include <boost/math/constants/constants.hpp>
#include <boost/math/distributions/complement.hpp>
#include <boost/math/distributions/detail/common_error_handling.hpp>
#include <utility>

#include <cmath>
#include <utility>

namespace boost{ namespace math
{
Expand Down Expand Up @@ -275,29 +276,30 @@ 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:
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());
{
// 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()
);
}

template <class RealType, class Policy>
inline RealType variance(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no variance:
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());
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>
Expand All @@ -315,42 +317,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");

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?
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()
);
}

template <class RealType, class Policy>
inline RealType kurtosis(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no kurtosis:
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());
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:
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());
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>
Expand Down
25 changes: 14 additions & 11 deletions include/boost/math/distributions/detail/hypergeometric_pdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ 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.current_prime = prime(++data.prime_index);
++data.prime_index;
data.current_prime = prime(static_cast<unsigned>(data.prime_index));
return hypergeometric_pdf_prime_loop_imp<T>(data, t);
}
if((p < 1) && (tools::min_value<T>() / p > result.value))
Expand All @@ -331,12 +332,14 @@ 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.current_prime = prime(++data.prime_index);
++data.prime_index;
data.current_prime = prime(static_cast<unsigned>(data.prime_index));
return hypergeometric_pdf_prime_loop_imp<T>(data, t);
}
result.value *= p;
}
data.current_prime = prime(++data.prime_index);
++data.prime_index;
data.current_prime = prime(static_cast<unsigned>(data.prime_index));
}
//
// When we get to here we have run out of prime factors,
Expand Down Expand Up @@ -397,16 +400,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>(r),
boost::math::unchecked_factorial<T>(N - n),
boost::math::unchecked_factorial<T>(N - r)
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))
};
T denom[5] = {
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)
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))
};
std::size_t i = 0;
std::size_t j = 0;
Expand Down
28 changes: 19 additions & 9 deletions include/boost/math/distributions/non_central_beta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,24 +806,34 @@ namespace boost
// standard_deviation provided by derived accessors.
template <class RealType, class Policy>
inline RealType skewness(const non_central_beta_distribution<RealType, Policy>& /*dist*/)
{ // skewness = sqrt(l).
{
// LCOV_EXCL_START
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()); // infinity? LCOV_EXCL_LINE
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
}

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%.", // LCOV_EXCL_LINE
std::numeric_limits<RealType>::quiet_NaN(), Policy()); // infinity? LCOV_EXCL_LINE
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
} // kurtosis_excess

template <class RealType, class Policy>
Expand Down
2 changes: 2 additions & 0 deletions include/boost/math/special_functions/detail/bessel_y0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ 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]
Expand Down
4 changes: 2 additions & 2 deletions include/boost/math/special_functions/lambert_w.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1822,12 +1822,12 @@ T lambert_wm1_imp(const T z, const Policy& pol)
"Argument z = %1% is too small (z < -std::numeric_limits<T>::min so denormalized) for Lambert W-1 branch!",
z, pol);
}
if (z == -boost::math::constants::exp_minus_one<T>()) // == singularity/branch point z = -exp(-1) = -3.6787944.
if (z == -boost::math::constants::exp_minus_one<T>()) // == singularity/branch point z = -exp(-1) = -0.36787944.
{ // At singularity, so return exactly -1.
return -static_cast<T>(1);
}
// z is too negative for the W-1 (or W0) branch.
if (z < -boost::math::constants::exp_minus_one<T>()) // > singularity/branch point z = -exp(-1) = -3.6787944.
if (z < -boost::math::constants::exp_minus_one<T>()) // > singularity/branch point z = -exp(-1) = -0.36787944.
{
return policies::raise_domain_error(function,
"Argument z = %1% is out of range (z < -exp(-1) = -3.6787944... <= 0) for Lambert W-1 (or W0) branch!",
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ 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 ]
Expand Down
Loading

0 comments on commit 593fea8

Please sign in to comment.