From 5957c91dc41d5d2214f2a0fc24da83417c17a9d0 Mon Sep 17 00:00:00 2001 From: Young Geun Kim Date: Thu, 24 Oct 2024 03:46:17 +0900 Subject: [PATCH] BOOST_ASSERT usage #112 (#113) * Replace assert with boost_assert in beta and hyperexponential * Removed cassert header in the corresponding header * added boost/assert header instead of cassert --- include/boost/random/beta_distribution.hpp | 10 +++---- .../random/hyperexponential_distribution.hpp | 30 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/boost/random/beta_distribution.hpp b/include/boost/random/beta_distribution.hpp index dabb72bfe2..145bf9750e 100644 --- a/include/boost/random/beta_distribution.hpp +++ b/include/boost/random/beta_distribution.hpp @@ -13,9 +13,9 @@ #ifndef BOOST_RANDOM_BETA_DISTRIBUTION_HPP #define BOOST_RANDOM_BETA_DISTRIBUTION_HPP -#include #include #include +#include #include #include @@ -48,8 +48,8 @@ class beta_distribution { RealType beta_arg = RealType(1.0)) : _alpha(alpha_arg), _beta(beta_arg) { - assert(alpha_arg > 0); - assert(beta_arg > 0); + BOOST_ASSERT(alpha_arg > 0); + BOOST_ASSERT(beta_arg > 0); } /** Returns the "alpha" parameter of the distribtuion. */ @@ -86,8 +86,8 @@ class beta_distribution { RealType beta_arg = RealType(1.0)) : _alpha(alpha_arg), _beta(beta_arg) { - assert(alpha_arg > 0); - assert(beta_arg > 0); + BOOST_ASSERT(alpha_arg > 0); + BOOST_ASSERT(beta_arg > 0); } /** Constructs an @c beta_distribution from its parameters. */ explicit beta_distribution(const param_type& parm) diff --git a/include/boost/random/hyperexponential_distribution.hpp b/include/boost/random/hyperexponential_distribution.hpp index 9ce9e4c402..3a71c9e3e0 100644 --- a/include/boost/random/hyperexponential_distribution.hpp +++ b/include/boost/random/hyperexponential_distribution.hpp @@ -18,6 +18,7 @@ #define BOOST_RANDOM_HYPEREXPONENTIAL_DISTRIBUTION_HPP +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -266,7 +266,7 @@ class hyperexponential_distribution { hyperexp_detail::normalize(probs_); - assert( hyperexp_detail::check_params(probs_, rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(probs_, rates_) ); } /** @@ -299,7 +299,7 @@ class hyperexponential_distribution { hyperexp_detail::normalize(probs_); - assert( hyperexp_detail::check_params(probs_, rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(probs_, rates_) ); } /** @@ -336,7 +336,7 @@ class hyperexponential_distribution : probs_(std::distance(rate_first, rate_last), 1), // will be normalized below rates_(rate_first, rate_last) { - assert(probs_.size() == rates_.size()); + BOOST_ASSERT(probs_.size() == rates_.size()); } /** @@ -360,7 +360,7 @@ class hyperexponential_distribution { hyperexp_detail::normalize(probs_); - assert( hyperexp_detail::check_params(probs_, rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(probs_, rates_) ); } #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST @@ -387,7 +387,7 @@ class hyperexponential_distribution { hyperexp_detail::normalize(probs_); - assert( hyperexp_detail::check_params(probs_, rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(probs_, rates_) ); } /** @@ -413,7 +413,7 @@ class hyperexponential_distribution { hyperexp_detail::normalize(probs_); - assert( hyperexp_detail::check_params(probs_, rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(probs_, rates_) ); } #endif // BOOST_NO_CXX11_HDR_INITIALIZER_LIST @@ -518,7 +518,7 @@ class hyperexponential_distribution hyperexp_detail::normalize(param.probs_); //post: vector size conformance - assert(param.probs_.size() == param.rates_.size()); + BOOST_ASSERT(param.probs_.size() == param.rates_.size()); return is; } @@ -578,7 +578,7 @@ class hyperexponential_distribution : dd_(prob_first, prob_last), rates_(rate_first, rate_last) { - assert( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); } /** @@ -610,7 +610,7 @@ class hyperexponential_distribution : dd_(prob_range), rates_(boost::begin(rate_range), boost::end(rate_range)) { - assert( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); } /** @@ -648,7 +648,7 @@ class hyperexponential_distribution : dd_(std::vector(std::distance(rate_first, rate_last), 1)), rates_(rate_first, rate_last) { - assert( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); } /** @@ -670,7 +670,7 @@ class hyperexponential_distribution : dd_(std::vector(boost::size(rate_range), 1)), rates_(boost::begin(rate_range), boost::end(rate_range)) { - assert( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); } /** @@ -682,7 +682,7 @@ class hyperexponential_distribution : dd_(param.probabilities()), rates_(param.rates()) { - assert( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); } #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST @@ -708,7 +708,7 @@ class hyperexponential_distribution : dd_(l1.begin(), l1.end()), rates_(l2.begin(), l2.end()) { - assert( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); } /** @@ -733,7 +733,7 @@ class hyperexponential_distribution : dd_(std::vector(std::distance(l1.begin(), l1.end()), 1)), rates_(l1.begin(), l1.end()) { - assert( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); + BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) ); } #endif