mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Add class template argument deduction guides for distributions (#756)
* Demonstrate deduction guides for normal_distribution. * Add missing test case. * add class template argument deduction guides for distributions templated on real type - issue #754 * Remove no-arg tests in test_dist_deduction_guides.cpp - issue #754 GCC-8 and clang 6-8 were unhappy with the no-arg cases, which use the default template arg, not the deduction guide, anyway. * remove unused deduction guide for fisher_f - issue #754 Co-authored-by: jzmaddock <john@johnmaddock.co.uk>
This commit is contained in:
@@ -194,6 +194,12 @@ namespace boost
|
||||
// Convenient typedef to construct double version.
|
||||
typedef arcsine_distribution<double> arcsine;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
arcsine_distribution(RealType)->arcsine_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
arcsine_distribution(RealType, RealType)->arcsine_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const arcsine_distribution<RealType, Policy>& dist)
|
||||
|
||||
@@ -126,6 +126,11 @@ namespace boost
|
||||
|
||||
typedef bernoulli_distribution<double> bernoulli;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
bernoulli_distribution(RealType)->bernoulli_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const bernoulli_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable k = {0, 1}.
|
||||
|
||||
@@ -272,6 +272,13 @@ namespace boost
|
||||
RealType m_beta;
|
||||
}; // template <class RealType, class Policy> class beta_distribution
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
beta_distribution(RealType)->beta_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
beta_distribution(RealType, RealType)->beta_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const beta_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -414,6 +414,13 @@ namespace boost
|
||||
// IS now included since no longer a name clash with function binomial.
|
||||
//typedef binomial_distribution<double> binomial; // Reserved name of type double.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
binomial_distribution(RealType)->binomial_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
binomial_distribution(RealType,RealType)->binomial_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
const std::pair<RealType, RealType> range(const binomial_distribution<RealType, Policy>& dist)
|
||||
{ // Range of permissible values for random variable k.
|
||||
|
||||
@@ -176,6 +176,13 @@ private:
|
||||
|
||||
typedef cauchy_distribution<double> cauchy;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
cauchy_distribution(RealType)->cauchy_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
cauchy_distribution(RealType,RealType)->cauchy_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const cauchy_distribution<RealType, Policy>&)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -55,6 +55,11 @@ private:
|
||||
|
||||
typedef chi_squared_distribution<double> chi_squared;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
chi_squared_distribution(RealType)->chi_squared_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127)
|
||||
|
||||
@@ -78,6 +78,11 @@ private:
|
||||
|
||||
typedef exponential_distribution<double> exponential;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
exponential_distribution(RealType)->exponential_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const exponential_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -73,6 +73,13 @@ private:
|
||||
|
||||
typedef extreme_value_distribution<double> extreme_value;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
extreme_value_distribution(RealType)->extreme_value_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
extreme_value_distribution(RealType,RealType)->extreme_value_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const extreme_value_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -54,6 +54,11 @@ private:
|
||||
|
||||
typedef fisher_f_distribution<double> fisher_f;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
fisher_f_distribution(RealType,RealType)->fisher_f_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const fisher_f_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -100,6 +100,13 @@ private:
|
||||
|
||||
// NO typedef because of clash with name of gamma function.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
gamma_distribution(RealType)->gamma_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
gamma_distribution(RealType,RealType)->gamma_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const gamma_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -236,6 +236,11 @@ namespace boost
|
||||
|
||||
typedef geometric_distribution<double> geometric; // Reserved name of type double.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
geometric_distribution(RealType)->geometric_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const geometric_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable k.
|
||||
|
||||
@@ -97,6 +97,13 @@ private:
|
||||
|
||||
typedef inverse_chi_squared_distribution<double> inverse_chi_squared;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
inverse_chi_squared_distribution(RealType)->inverse_chi_squared_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
inverse_chi_squared_distribution(RealType,RealType)->inverse_chi_squared_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const inverse_chi_squared_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -122,6 +122,13 @@ typedef inverse_gamma_distribution<double> inverse_gamma;
|
||||
// but there is a typedef for gamma
|
||||
// typedef boost::math::gamma_distribution<Type, Policy> gamma;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
inverse_gamma_distribution(RealType)->inverse_gamma_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
inverse_gamma_distribution(RealType,RealType)->inverse_gamma_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
// Allow random variable x to be zero, treated as a special case (unlike some definitions).
|
||||
|
||||
template <class RealType, class Policy>
|
||||
|
||||
@@ -115,6 +115,13 @@ private:
|
||||
|
||||
typedef inverse_gaussian_distribution<double> inverse_gaussian;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
inverse_gaussian_distribution(RealType)->inverse_gaussian_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
inverse_gaussian_distribution(RealType,RealType)->inverse_gaussian_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const inverse_gaussian_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x, zero to max.
|
||||
|
||||
@@ -213,6 +213,11 @@ template <class RealType = double, class Policy = policies::policy<> >
|
||||
|
||||
typedef kolmogorov_smirnov_distribution<double> kolmogorov_k; // Convenience typedef for double version.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
kolmogorov_smirnov_distribution(RealType)->kolmogorov_smirnov_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
template <class RealType, class Policy>
|
||||
struct kolmogorov_smirnov_quantile_functor
|
||||
|
||||
@@ -80,6 +80,13 @@ private:
|
||||
// Convenient type synonym for double.
|
||||
typedef laplace_distribution<double> laplace;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
laplace_distribution(RealType)->laplace_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
laplace_distribution(RealType,RealType)->laplace_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Non-member functions.
|
||||
template <class RealType, class Policy>
|
||||
|
||||
@@ -51,7 +51,14 @@ namespace boost { namespace math {
|
||||
|
||||
|
||||
typedef logistic_distribution<double> logistic;
|
||||
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
logistic_distribution(RealType)->logistic_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
logistic_distribution(RealType,RealType)->logistic_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const logistic_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -75,6 +75,13 @@ private:
|
||||
|
||||
typedef lognormal_distribution<double> lognormal;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
lognormal_distribution(RealType)->lognormal_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
lognormal_distribution(RealType,RealType)->lognormal_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const lognormal_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x is >0 to +infinity.
|
||||
|
||||
@@ -251,6 +251,11 @@ namespace boost
|
||||
|
||||
typedef negative_binomial_distribution<double> negative_binomial; // Reserved name of type double.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
negative_binomial_distribution(RealType,RealType)->negative_binomial_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const negative_binomial_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable k.
|
||||
|
||||
@@ -707,6 +707,11 @@ namespace boost
|
||||
|
||||
typedef non_central_beta_distribution<double> non_central_beta; // Reserved name of type double.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
non_central_beta_distribution(RealType,RealType,RealType)->non_central_beta_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
// Non-member functions to give properties of the distribution.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
|
||||
@@ -783,6 +783,11 @@ namespace boost
|
||||
|
||||
typedef non_central_chi_squared_distribution<double> non_central_chi_squared; // Reserved name of type double.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
non_central_chi_squared_distribution(RealType,RealType)->non_central_chi_squared_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
// Non-member functions to give properties of the distribution.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
|
||||
@@ -63,6 +63,11 @@ namespace boost
|
||||
|
||||
typedef non_central_f_distribution<double> non_central_f; // Reserved name of type double.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
non_central_f_distribution(RealType,RealType,RealType)->non_central_f_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
// Non-member functions to give properties of the distribution.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
|
||||
@@ -838,6 +838,11 @@ namespace boost
|
||||
|
||||
typedef non_central_t_distribution<double> non_central_t; // Reserved name of type double.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
non_central_t_distribution(RealType,RealType)->non_central_t_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
// Non-member functions to give properties of the distribution.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
|
||||
@@ -71,6 +71,20 @@ private:
|
||||
|
||||
typedef normal_distribution<double> normal;
|
||||
|
||||
//
|
||||
// Deduction guides, note we don't check the
|
||||
// value of __cpp_deduction_guides, just assume
|
||||
// they work as advertised, even if this is pre-final C++17.
|
||||
//
|
||||
#ifdef __cpp_deduction_guides
|
||||
|
||||
template <class RealType>
|
||||
normal_distribution(RealType, RealType)->normal_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
normal_distribution(RealType)->normal_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127)
|
||||
|
||||
@@ -160,6 +160,14 @@ namespace boost
|
||||
|
||||
typedef pareto_distribution<double> pareto; // Convenience to allow pareto(2., 3.);
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
pareto_distribution(RealType)->pareto_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
pareto_distribution(RealType,RealType)->pareto_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const pareto_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -167,6 +167,11 @@ namespace boost
|
||||
|
||||
typedef poisson_distribution<double> poisson; // Reserved name of type double.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
poisson_distribution(RealType)->poisson_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
// Non-member functions to give properties of the distribution.
|
||||
|
||||
template <class RealType, class Policy>
|
||||
|
||||
@@ -77,6 +77,11 @@ private:
|
||||
|
||||
typedef rayleigh_distribution<double> rayleigh;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
rayleigh_distribution(RealType)->rayleigh_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const rayleigh_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -96,6 +96,15 @@ namespace boost{ namespace math{
|
||||
|
||||
typedef skew_normal_distribution<double> skew_normal;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
skew_normal_distribution(RealType)->skew_normal_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
skew_normal_distribution(RealType,RealType)->skew_normal_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
skew_normal_distribution(RealType,RealType,RealType)->skew_normal_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const skew_normal_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -62,6 +62,11 @@ private:
|
||||
|
||||
typedef students_t_distribution<double> students_t; // Convenience typedef for double version.
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
students_t_distribution(RealType)->students_t_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const students_t_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -184,6 +184,15 @@ namespace boost{ namespace math
|
||||
|
||||
typedef triangular_distribution<double> triangular;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
triangular_distribution(RealType)->triangular_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
triangular_distribution(RealType,RealType)->triangular_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
triangular_distribution(RealType,RealType,RealType)->triangular_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const triangular_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -140,6 +140,13 @@ namespace boost{ namespace math
|
||||
|
||||
typedef uniform_distribution<double> uniform;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
uniform_distribution(RealType)->uniform_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
uniform_distribution(RealType,RealType)->uniform_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const uniform_distribution<RealType, Policy>& /* dist */)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -99,6 +99,13 @@ private:
|
||||
|
||||
typedef weibull_distribution<double> weibull;
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
template <class RealType>
|
||||
weibull_distribution(RealType)->weibull_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
template <class RealType>
|
||||
weibull_distribution(RealType,RealType)->weibull_distribution<typename boost::math::tools::promote_args<RealType>::type>;
|
||||
#endif
|
||||
|
||||
template <class RealType, class Policy>
|
||||
inline const std::pair<RealType, RealType> range(const weibull_distribution<RealType, Policy>& /*dist*/)
|
||||
{ // Range of permissible values for random variable x.
|
||||
|
||||
@@ -877,6 +877,8 @@ test-suite distribution_tests :
|
||||
[ run test_signed_zero.cpp ../../test/build//boost_unit_test_framework ]
|
||||
[ run complex_test.cpp ../../test/build//boost_unit_test_framework ]
|
||||
|
||||
[ compile test_dist_deduction_guides.cpp : [ requires cpp_deduction_guides cpp_variadic_templates ] ]
|
||||
|
||||
;
|
||||
|
||||
test-suite mp :
|
||||
|
||||
144
test/test_dist_deduction_guides.cpp
Normal file
144
test/test_dist_deduction_guides.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
// (C) Copyright John Maddock 2022.
|
||||
// (C) Copyright James Folberth 2022.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Issue 754
|
||||
// Check that the class template argument deduction guides properly promote
|
||||
// integral ctor args to a real floating point type.
|
||||
|
||||
#include <boost/math/distributions/arcsine.hpp>
|
||||
#include <boost/math/distributions/bernoulli.hpp>
|
||||
#include <boost/math/distributions/beta.hpp>
|
||||
#include <boost/math/distributions/binomial.hpp>
|
||||
#include <boost/math/distributions/cauchy.hpp>
|
||||
#include <boost/math/distributions/chi_squared.hpp>
|
||||
//#include <boost/math/distributions/empirical_cumulative_distribution_function.hpp>
|
||||
#include <boost/math/distributions/exponential.hpp>
|
||||
#include <boost/math/distributions/extreme_value.hpp>
|
||||
#include <boost/math/distributions/fisher_f.hpp>
|
||||
#include <boost/math/distributions/gamma.hpp>
|
||||
#include <boost/math/distributions/geometric.hpp>
|
||||
//#include <boost/math/distributions/hyperexponential.hpp>
|
||||
//#include <boost/math/distributions/hypergeometric.hpp>
|
||||
#include <boost/math/distributions/inverse_chi_squared.hpp>
|
||||
#include <boost/math/distributions/inverse_gamma.hpp>
|
||||
#include <boost/math/distributions/inverse_gaussian.hpp>
|
||||
#include <boost/math/distributions/kolmogorov_smirnov.hpp>
|
||||
#include <boost/math/distributions/laplace.hpp>
|
||||
#include <boost/math/distributions/logistic.hpp>
|
||||
#include <boost/math/distributions/lognormal.hpp>
|
||||
#include <boost/math/distributions/negative_binomial.hpp>
|
||||
#include <boost/math/distributions/non_central_beta.hpp>
|
||||
#include <boost/math/distributions/non_central_chi_squared.hpp>
|
||||
#include <boost/math/distributions/non_central_f.hpp>
|
||||
#include <boost/math/distributions/non_central_t.hpp>
|
||||
#include <boost/math/distributions/normal.hpp>
|
||||
#include <boost/math/distributions/pareto.hpp>
|
||||
#include <boost/math/distributions/poisson.hpp>
|
||||
#include <boost/math/distributions/rayleigh.hpp>
|
||||
#include <boost/math/distributions/skew_normal.hpp>
|
||||
#include <boost/math/distributions/students_t.hpp>
|
||||
#include <boost/math/distributions/triangular.hpp>
|
||||
#include <boost/math/distributions/uniform.hpp>
|
||||
#include <boost/math/distributions/weibull.hpp>
|
||||
|
||||
// Instantiate a DistType object with the parameter pack given by Types.
|
||||
// Then verify that the `RealType` template parameter of DistType (stored in
|
||||
// in value_type) is promoted correctly according to the deduction guides.
|
||||
template <template<class, class> class DistType, class PromType = double, class... Types>
|
||||
void test_deduction_guide(Types... types)
|
||||
{
|
||||
DistType d(types...);
|
||||
static_assert(std::is_same<typename decltype(d)::value_type, PromType>::value);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::math;
|
||||
|
||||
test_deduction_guide<arcsine_distribution>(0);
|
||||
test_deduction_guide<arcsine_distribution>(0, 1);
|
||||
|
||||
test_deduction_guide<bernoulli_distribution>(0);
|
||||
|
||||
test_deduction_guide<beta_distribution>(1);
|
||||
test_deduction_guide<beta_distribution>(1, 1);
|
||||
|
||||
test_deduction_guide<binomial_distribution>(1);
|
||||
test_deduction_guide<binomial_distribution>(1, 0);
|
||||
|
||||
test_deduction_guide<cauchy_distribution>(0);
|
||||
test_deduction_guide<cauchy_distribution>(0, 1);
|
||||
|
||||
test_deduction_guide<chi_squared_distribution>(2);
|
||||
|
||||
test_deduction_guide<exponential_distribution>(1);
|
||||
|
||||
test_deduction_guide<extreme_value_distribution>(0);
|
||||
test_deduction_guide<extreme_value_distribution>(0, 1);
|
||||
|
||||
test_deduction_guide<fisher_f_distribution>(1, 2);
|
||||
|
||||
test_deduction_guide<gamma_distribution>(1);
|
||||
test_deduction_guide<gamma_distribution>(1, 1);
|
||||
|
||||
test_deduction_guide<geometric_distribution>(1);
|
||||
|
||||
test_deduction_guide<inverse_chi_squared_distribution>(1);
|
||||
test_deduction_guide<inverse_chi_squared_distribution>(1, 1);
|
||||
|
||||
test_deduction_guide<inverse_gamma_distribution>(1);
|
||||
test_deduction_guide<inverse_gamma_distribution>(1, 1);
|
||||
|
||||
test_deduction_guide<inverse_gaussian_distribution>(1);
|
||||
test_deduction_guide<inverse_gaussian_distribution>(1, 1);
|
||||
|
||||
test_deduction_guide<kolmogorov_smirnov_distribution>(1);
|
||||
|
||||
test_deduction_guide<laplace_distribution>(0);
|
||||
test_deduction_guide<laplace_distribution>(0, 1);
|
||||
|
||||
test_deduction_guide<logistic_distribution>(0);
|
||||
test_deduction_guide<logistic_distribution>(0, 1);
|
||||
|
||||
test_deduction_guide<lognormal_distribution>(0);
|
||||
test_deduction_guide<lognormal_distribution>(0, 1);
|
||||
|
||||
test_deduction_guide<negative_binomial_distribution>(1, 1);
|
||||
|
||||
test_deduction_guide<non_central_beta_distribution>(1, 1, 1);
|
||||
|
||||
test_deduction_guide<non_central_chi_squared_distribution>(1, 1);
|
||||
|
||||
test_deduction_guide<non_central_f_distribution>(1, 1, 1);
|
||||
|
||||
test_deduction_guide<non_central_t_distribution>(1, 1);
|
||||
|
||||
test_deduction_guide<normal_distribution>(2);
|
||||
test_deduction_guide<normal_distribution>(2, 3);
|
||||
|
||||
test_deduction_guide<pareto_distribution>(2);
|
||||
test_deduction_guide<pareto_distribution>(2, 3);
|
||||
|
||||
test_deduction_guide<poisson_distribution>(1);
|
||||
|
||||
test_deduction_guide<rayleigh_distribution>(1);
|
||||
|
||||
test_deduction_guide<skew_normal_distribution>(0);
|
||||
test_deduction_guide<skew_normal_distribution>(0, 1);
|
||||
test_deduction_guide<skew_normal_distribution>(0, 1, 0);
|
||||
|
||||
test_deduction_guide<students_t_distribution>(2);
|
||||
|
||||
test_deduction_guide<triangular_distribution>(-1);
|
||||
test_deduction_guide<triangular_distribution>(-1, 0);
|
||||
test_deduction_guide<triangular_distribution>(-1, 0, 1);
|
||||
|
||||
test_deduction_guide<uniform_distribution>(0);
|
||||
test_deduction_guide<uniform_distribution>(0, 1);
|
||||
|
||||
test_deduction_guide<weibull_distribution>(1);
|
||||
test_deduction_guide<weibull_distribution>(1, 1);
|
||||
}
|
||||
Reference in New Issue
Block a user