Commit 9b0ded25 authored by Manuel Günther's avatar Manuel Günther
Browse files

Renamed functions to support old boost versions

parent 0fb8f966
......@@ -20,7 +20,7 @@
#include <iterator>
#include <boost/assert.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/vector_io.hpp>
......@@ -102,7 +102,7 @@ struct integer_alias_table {
template<class URNG>
WeightType test(URNG &urng) const
{
return boost::random::uniform_int_distribution<WeightType>(0, _average)(urng);
return boost::uniform_int<WeightType>(0, _average)(urng);
}
bool accept(IntType result, WeightType val) const
{
......@@ -125,7 +125,7 @@ struct integer_alias_table {
template<class URNG>
static WeightType generate_in_range(URNG &urng, WeightType max)
{
return boost::random::uniform_int_distribution<WeightType>(
return boost::uniform_int<WeightType>(
static_cast<WeightType>(0), max-1)(urng);
}
typedef std::vector<std::pair<WeightType, IntType> > alias_table_t;
......@@ -179,7 +179,7 @@ struct real_alias_table {
template<class URNG>
WeightType test(URNG &urng) const
{
return boost::random::uniform_01<WeightType>()(urng);
return boost::uniform_01<WeightType>()(urng);
}
bool accept(IntType, WeightType) const
{
......@@ -192,7 +192,7 @@ struct real_alias_table {
template<class URNG>
static WeightType generate_in_range(URNG &urng, WeightType)
{
return boost::random::uniform_01<WeightType>()(urng);
return boost::uniform_01<WeightType>()(urng);
}
typedef std::vector<std::pair<WeightType, IntType> > alias_table_t;
alias_table_t _alias_table;
......@@ -433,7 +433,7 @@ public:
IntType result;
WeightType test;
do {
result = boost::random::uniform_int_distribution<IntType>((min)(), (max)())(urng);
result = boost::uniform_int<IntType>((min)(), (max)())(urng);
test = _impl.test(urng);
} while(!_impl.accept(result, test));
if(test < _impl._alias_table[result].first) {
......
......@@ -29,7 +29,7 @@
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/exponential_distribution.hpp>
#include <bob.core/boost/operators.hpp>
......@@ -192,8 +192,8 @@ std::pair<RealType, int> generate_int_float_pair(Engine& eng, boost::mpl::true_)
template<class RealType, std::size_t w, class Engine>
inline std::pair<RealType, int> generate_int_float_pair(Engine& eng, boost::mpl::false_)
{
int bucket = boost::random::uniform_int_distribution<>(0, (1 << w) - 1)(eng);
RealType r = boost::random::uniform_01<RealType>()(eng);
int bucket = boost::uniform_int<>(0, (1 << w) - 1)(eng);
RealType r = boost::uniform_01<RealType>()(eng);
return std::make_pair(r, bucket);
}
......@@ -220,7 +220,7 @@ struct unit_normal_distribution
RealType x = vals.first * RealType(table_x[i]);
if(x < table_x[i + 1]) return x * sign;
if(i == 0) return generate_tail(eng) * sign;
RealType y = RealType(table_y[i]) + boost::random::uniform_01<RealType>()(eng) * RealType(table_y[i + 1] - table_y[i]);
RealType y = RealType(table_y[i]) + boost::uniform_01<RealType>()(eng) * RealType(table_y[i + 1] - table_y[i]);
if (y < f(x)) return x * sign;
}
}
......
......@@ -21,10 +21,10 @@ namespace bob { namespace core { namespace random {
using uniform_smallint_distribution = boost::random::uniform_smallint<IntType>;
template <class IntType=int>
using uniform_int_distribution = boost::random::uniform_int_distribution<IntType>;
using uniform_int_distribution = boost::uniform_int<IntType>;
template <class RealType=double>
using uniform_real_distribution = boost::random::uniform_real_distribution<RealType>;
using uniform_real_distribution = boost::uniform_real<RealType>;
template <class RealType=double>
using gamma_distribution = boost::random::gamma_distribution<RealType>;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment