Skip to content

Commit

Permalink
BOOST_ASSERT usage #112 (#113)
Browse files Browse the repository at this point in the history
* Replace assert with boost_assert in beta and hyperexponential

* Removed cassert header in the corresponding header

* added boost/assert header instead of cassert
  • Loading branch information
ygeunkim authored Oct 23, 2024
1 parent dcaee17 commit 5957c91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions include/boost/random/beta_distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#ifndef BOOST_RANDOM_BETA_DISTRIBUTION_HPP
#define BOOST_RANDOM_BETA_DISTRIBUTION_HPP

#include <cassert>
#include <istream>
#include <iosfwd>
#include <boost/assert.hpp>
#include <boost/random/detail/operators.hpp>
#include <boost/random/gamma_distribution.hpp>

Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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)
Expand Down
30 changes: 15 additions & 15 deletions include/boost/random/hyperexponential_distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define BOOST_RANDOM_HYPEREXPONENTIAL_DISTRIBUTION_HPP


#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/core/cmath.hpp>
#include <boost/random/detail/operators.hpp>
Expand All @@ -28,7 +29,6 @@
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
#include <boost/type_traits/has_pre_increment.hpp>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <iterator>
Expand Down Expand Up @@ -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_) );
}

/**
Expand Down Expand Up @@ -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_) );
}

/**
Expand Down Expand Up @@ -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());
}

/**
Expand All @@ -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
Expand All @@ -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_) );
}

/**
Expand All @@ -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

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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_) );
}

/**
Expand Down Expand Up @@ -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_) );
}

/**
Expand Down Expand Up @@ -648,7 +648,7 @@ class hyperexponential_distribution
: dd_(std::vector<RealT>(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_) );
}

/**
Expand All @@ -670,7 +670,7 @@ class hyperexponential_distribution
: dd_(std::vector<RealT>(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_) );
}

/**
Expand All @@ -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
Expand All @@ -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_) );
}

/**
Expand All @@ -733,7 +733,7 @@ class hyperexponential_distribution
: dd_(std::vector<RealT>(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

Expand Down

0 comments on commit 5957c91

Please sign in to comment.