add normal_distribution::stddev

This commit is contained in:
bolero-MURAKAMI 2012-11-16 13:40:19 +09:00
parent 225c11b505
commit f37e8a9088
19 changed files with 261 additions and 211 deletions

View file

@ -31,9 +31,9 @@
# include <sprout/config/compiler/codegear.hpp>
#elif defined(__BORLANDC__)
# include <sprout/config/compiler/borland.hpp>
#elif defined( __MWERKS__)
#elif defined(__MWERKS__)
# include <sprout/config/compiler/metrowerks.hpp>
#elif defined( __SUNPRO_CC)
#elif defined(__SUNPRO_CC)
# include <sprout/config/compiler/sunpro_cc.hpp>
#elif defined(__HP_aCC)
# include <sprout/config/compiler/hp_acc.hpp>

View file

@ -3,13 +3,14 @@
#include <sprout/config.hpp>
#include <sprout/random/linear_congruential.hpp>
#include <sprout/random/additive_combine.hpp>
#include <sprout/random/shuffle_order.hpp>
#include <sprout/random/linear_feedback_shift.hpp>
#include <sprout/random/xor_combine.hpp>
#include <sprout/random/taus88.hpp>
#include <sprout/random/inversive_congruential.hpp>
#include <sprout/random/mersenne_twister.hpp>
#include <sprout/random/linear_feedback_shift.hpp>
#include <sprout/random/shuffle_order.hpp>
#include <sprout/random/additive_combine.hpp>
#include <sprout/random/xor_combine.hpp>
#include <sprout/random/taus88.hpp>
#include <sprout/random/default_random_engine.hpp>
#include <sprout/random/uniform_smallint.hpp>
#include <sprout/random/uniform_int_distribution.hpp>
#include <sprout/random/uniform_01.hpp>
@ -18,7 +19,6 @@
#include <sprout/random/binomial_distribution.hpp>
#include <sprout/random/geometric_distribution.hpp>
#include <sprout/random/normal_distribution.hpp>
#include <sprout/random/default_random_engine.hpp>
#include <sprout/random/variate_generator.hpp>
#include <sprout/random/random_result.hpp>
#include <sprout/random/iterator.hpp>

View file

@ -16,18 +16,27 @@ namespace sprout {
template<typename MLCG1, typename MLCG2>
class additive_combine_engine {
public:
typedef MLCG1 first_base;
typedef MLCG2 second_base;
typedef typename first_base::result_type result_type;
typedef MLCG1 base1_type;
typedef MLCG2 base2_type;
typedef base1_type first_base;
typedef base2_type second_base;
typedef typename base1_type::result_type result_type;
private:
static SPROUT_CONSTEXPR result_type static_min() SPROUT_NOEXCEPT {
return 1;
}
static SPROUT_CONSTEXPR result_type static_max() SPROUT_NOEXCEPT {
return base1_type::modulus - 1;
}
public:
struct private_constructor_tag {};
private:
first_base mlcg1_;
second_base mlcg2_;
base1_type mlcg1_;
base2_type mlcg2_;
private:
SPROUT_CONSTEXPR additive_combine_engine(
first_base const& mlcg1,
second_base const& mlcg2,
base1_type const& mlcg1,
base2_type const& mlcg2,
private_constructor_tag
)
: mlcg1_(mlcg1)
@ -38,7 +47,7 @@ namespace sprout {
return sprout::random::random_result<additive_combine_engine>(
rnd2.result() < rnd1.result()
? rnd1.result() - rnd2.result()
: rnd1.result() - rnd2.result() + first_base::modulus - 1
: rnd1.result() - rnd2.result() + base1_type::modulus - 1
,
additive_combine_engine(
rnd1.engine(),
@ -60,19 +69,25 @@ namespace sprout {
: mlcg1_(seed1)
, mlcg2_(seed2)
{}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return 1;
}
SPROUT_CONSTEXPR result_type max() const {
return first_base::modulus - 1;
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return base1_type::modulus - 1;
}
SPROUT_CONSTEXPR sprout::random::random_result<additive_combine_engine> operator()() const {
return generate(mlcg1_(), mlcg2_());
}
friend SPROUT_CONSTEXPR bool operator==(additive_combine_engine const& lhs, additive_combine_engine const& rhs) {
SPROUT_CONSTEXPR base1_type const& base1() const SPROUT_NOEXCEPT {
return mlcg1_;
}
SPROUT_CONSTEXPR base2_type const& base2() const SPROUT_NOEXCEPT {
return mlcg2_;
}
friend SPROUT_CONSTEXPR bool operator==(additive_combine_engine const& lhs, additive_combine_engine const& rhs) SPROUT_NOEXCEPT {
return lhs.mlcg1_ == rhs.mlcg1_ && lhs.mlcg2_ == rhs.mlcg2_;
}
friend SPROUT_CONSTEXPR bool operator!=(additive_combine_engine const& lhs, additive_combine_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(additive_combine_engine const& lhs, additive_combine_engine const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename Elem, typename Traits>

View file

@ -46,7 +46,7 @@ namespace sprout {
explicit SPROUT_CONSTEXPR param_type(RealType p_arg)
: p_(arg_check(p_arg))
{}
SPROUT_CONSTEXPR RealType p() const {
SPROUT_CONSTEXPR RealType p() const SPROUT_NOEXCEPT {
return p_;
}
template<typename Elem, typename Traits>
@ -73,10 +73,10 @@ namespace sprout {
{
return lhs << rhs.p_;
}
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return lhs.p_ == rhs.p_;
}
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};
@ -104,16 +104,16 @@ namespace sprout {
explicit SPROUT_CONSTEXPR bernoulli_distribution(param_type const& parm)
: p_(parm.p())
{}
SPROUT_CONSTEXPR RealType p() const {
SPROUT_CONSTEXPR RealType p() const SPROUT_NOEXCEPT {
return p_;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return false;
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return true;
}
SPROUT_CONSTEXPR param_type param() const {
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
return param_type(p_);
}
void param(param_type const& parm) {
@ -146,10 +146,10 @@ namespace sprout {
{
return lhs << rhs.param();
}
friend SPROUT_CONSTEXPR bool operator==(bernoulli_distribution const& lhs, bernoulli_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(bernoulli_distribution const& lhs, bernoulli_distribution const& rhs) SPROUT_NOEXCEPT {
return lhs.param() == rhs.param();
}
friend SPROUT_CONSTEXPR bool operator!=(bernoulli_distribution const& lhs, bernoulli_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(bernoulli_distribution const& lhs, bernoulli_distribution const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};

View file

@ -102,10 +102,10 @@ namespace sprout {
: t_(arg_check(t_arg, p_arg))
, p_(p_arg)
{}
SPROUT_CONSTEXPR IntType t() const {
SPROUT_CONSTEXPR IntType t() const SPROUT_NOEXCEPT {
return t_;
}
SPROUT_CONSTEXPR RealType p() const {
SPROUT_CONSTEXPR RealType p() const SPROUT_NOEXCEPT {
return p_;
}
template<typename Elem, typename Traits>
@ -134,10 +134,10 @@ namespace sprout {
{
return lhs << rhs.t_ << " " << rhs.p_;
}
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return lhs.t_ == rhs.t_ && lhs.p_ == rhs.p_;
}
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};
@ -635,19 +635,19 @@ namespace sprout {
, btrd_(!init_use_inversion(parm.t(), parm.p()) ? init_btrd(parm.t(), parm.p()) : btrd_type())
, q_n_(init_use_inversion(parm.t(), parm.p()) ? init_q_n(parm.t(), parm.p()) : RealType())
{}
SPROUT_CONSTEXPR result_type t() const {
SPROUT_CONSTEXPR result_type t() const SPROUT_NOEXCEPT {
return t_;
}
SPROUT_CONSTEXPR result_type p() const {
SPROUT_CONSTEXPR result_type p() const SPROUT_NOEXCEPT {
return p_;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return 0;
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return t_;
}
SPROUT_CONSTEXPR param_type param() const {
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
return param_type(t_, p_);
}
void param(param_type const& parm) {
@ -685,10 +685,10 @@ namespace sprout {
{
return lhs << rhs.param();
}
friend SPROUT_CONSTEXPR bool operator==(binomial_distribution const& lhs, binomial_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(binomial_distribution const& lhs, binomial_distribution const& rhs) SPROUT_NOEXCEPT {
return lhs.param() == rhs.param();
}
friend SPROUT_CONSTEXPR bool operator!=(binomial_distribution const& lhs, binomial_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(binomial_distribution const& lhs, binomial_distribution const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};

View file

@ -50,7 +50,7 @@ namespace sprout {
explicit SPROUT_CONSTEXPR param_type(RealType p_arg)
: p_(arg_check(p_arg))
{}
SPROUT_CONSTEXPR RealType p() const {
SPROUT_CONSTEXPR RealType p() const SPROUT_NOEXCEPT {
return p_;
}
template<typename Elem, typename Traits>
@ -77,10 +77,10 @@ namespace sprout {
{
return lhs << rhs.p_;
}
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return lhs.p_ == rhs.p_;
}
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};
@ -119,16 +119,16 @@ namespace sprout {
: p_(parm.p())
, log_1mp_(init_log_1mp(parm.p()))
{}
SPROUT_CONSTEXPR result_type p() const {
SPROUT_CONSTEXPR result_type p() const SPROUT_NOEXCEPT {
return p_;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return 0;
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return std::numeric_limits<result_type>::max();
}
SPROUT_CONSTEXPR param_type param() const {
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
return param_type(p_);
}
void param(param_type const& parm) {
@ -159,10 +159,10 @@ namespace sprout {
{
return lhs << rhs.param();
}
friend SPROUT_CONSTEXPR bool operator==(geometric_distribution const& lhs, geometric_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(geometric_distribution const& lhs, geometric_distribution const& rhs) SPROUT_NOEXCEPT {
return lhs.param() == rhs.param();
}
friend SPROUT_CONSTEXPR bool operator!=(geometric_distribution const& lhs, geometric_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(geometric_distribution const& lhs, geometric_distribution const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};

View file

@ -26,13 +26,14 @@ namespace sprout {
SPROUT_STATIC_CONSTEXPR IntType increment = b;
SPROUT_STATIC_CONSTEXPR IntType modulus = p;
SPROUT_STATIC_CONSTEXPR IntType default_seed = 1;
private:
static SPROUT_CONSTEXPR result_type static_min() {
public:
static SPROUT_CONSTEXPR result_type static_min() SPROUT_NOEXCEPT {
return b == 0 ? 1 : 0;
}
static SPROUT_CONSTEXPR result_type static_max() {
static SPROUT_CONSTEXPR result_type static_max() SPROUT_NOEXCEPT {
return modulus - 1;
}
private:
template<typename T>
static SPROUT_CONSTEXPR typename std::enable_if<!(b == 0) && std::is_unsigned<T>::value, bool>::type
arg_check_nothrow(T const& x0) {
@ -80,20 +81,20 @@ namespace sprout {
explicit SPROUT_CONSTEXPR inversive_congruential_engine(IntType const& x0)
: x_(init_seed(x0))
{}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return static_min();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return static_max();
}
SPROUT_CONSTEXPR sprout::random::random_result<inversive_congruential_engine> operator()() const {
typedef sprout::random::detail::const_mod<IntType, p> do_mod;
return generate(do_mod::mult_add(a, do_mod::invert(x_), b));
}
friend SPROUT_CONSTEXPR bool operator==(inversive_congruential_engine const& lhs, inversive_congruential_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(inversive_congruential_engine const& lhs, inversive_congruential_engine const& rhs) SPROUT_NOEXCEPT {
return lhs.x_ == rhs.x_;
}
friend SPROUT_CONSTEXPR bool operator!=(inversive_congruential_engine const& lhs, inversive_congruential_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(inversive_congruential_engine const& lhs, inversive_congruential_engine const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename Elem, typename Traits>

View file

@ -15,28 +15,28 @@ namespace sprout {
//
// linear_congruential_engine
//
template<typename IntType, IntType a, IntType c, IntType m>
template<typename UIntType, UIntType a, UIntType c, UIntType m>
class linear_congruential_engine {
static_assert(std::numeric_limits<UIntType>::is_integer, "std::numeric_limits<UIntType>::is_integer");
static_assert(m == 0 || a < m, "m == 0 || a < m");
static_assert(m == 0 || c < m, "m == 0 || c < m");
public:
typedef IntType result_type;
typedef UIntType result_type;
private:
struct private_constructor_tag {};
public:
SPROUT_STATIC_CONSTEXPR IntType multiplier = a;
SPROUT_STATIC_CONSTEXPR IntType increment = c;
SPROUT_STATIC_CONSTEXPR IntType modulus = m;
SPROUT_STATIC_CONSTEXPR IntType default_seed = 1;
SPROUT_STATIC_CONSTEXPR UIntType multiplier = a;
SPROUT_STATIC_CONSTEXPR UIntType increment = c;
SPROUT_STATIC_CONSTEXPR UIntType modulus = m;
SPROUT_STATIC_CONSTEXPR UIntType default_seed = 1;
public:
static_assert(std::numeric_limits<IntType>::is_integer, "std::numeric_limits<IntType>::is_integer");
static_assert(m == 0 || a < m, "m == 0 || a < m");
static_assert(m == 0 || c < m, "m == 0 || c < m");
private:
static SPROUT_CONSTEXPR result_type static_min() {
static SPROUT_CONSTEXPR result_type static_min() SPROUT_NOEXCEPT {
return c == 0 ? 1 : 0;
}
static SPROUT_CONSTEXPR result_type static_max() {
return modulus - 1;
static SPROUT_CONSTEXPR result_type static_max() SPROUT_NOEXCEPT {
return m - 1;
}
private:
template<typename T>
static SPROUT_CONSTEXPR typename std::enable_if<!(c == 0) && std::is_unsigned<T>::value, bool>::type
arg_check_nothrow(T const& x0) {
@ -47,24 +47,24 @@ namespace sprout {
arg_check_nothrow(T const& x0) {
return x0 >= static_min() && x0 <= static_max();
}
static SPROUT_CONSTEXPR IntType arg_check(IntType const& x0) {
static SPROUT_CONSTEXPR UIntType arg_check(UIntType const& x0) {
return arg_check_nothrow(x0) ? x0
: throw std::invalid_argument("linear_congruential_engine<>: invalid argument (x0 >= static_min() && x0 <= static_max())")
;
}
static SPROUT_CONSTEXPR IntType init_seed_2(IntType const& x0) {
static SPROUT_CONSTEXPR UIntType init_seed_2(UIntType const& x0) {
return arg_check(increment == 0 && x0 == 0 ? 1 : x0);
}
static SPROUT_CONSTEXPR IntType init_seed_1(IntType const& x0) {
static SPROUT_CONSTEXPR UIntType init_seed_1(UIntType const& x0) {
return init_seed_2(x0 <= 0 && x0 != 0 ? x0 + modulus : x0);
}
static SPROUT_CONSTEXPR IntType init_seed(IntType const& x0) {
static SPROUT_CONSTEXPR UIntType init_seed(UIntType const& x0) {
return init_seed_1(modulus == 0 ? x0 : x0 % modulus);
}
private:
IntType x_;
UIntType x_;
private:
SPROUT_CONSTEXPR linear_congruential_engine(IntType const& x, private_constructor_tag)
SPROUT_CONSTEXPR linear_congruential_engine(UIntType const& x, private_constructor_tag)
: x_(x)
{}
SPROUT_CONSTEXPR sprout::random::random_result<linear_congruential_engine> generate(result_type result) const {
@ -77,22 +77,22 @@ namespace sprout {
SPROUT_CONSTEXPR linear_congruential_engine()
: x_(init_seed(default_seed))
{}
explicit SPROUT_CONSTEXPR linear_congruential_engine(IntType const& x0)
explicit SPROUT_CONSTEXPR linear_congruential_engine(UIntType const& x0)
: x_(init_seed(x0))
{}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return static_min();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return static_max();
}
SPROUT_CONSTEXPR sprout::random::random_result<linear_congruential_engine> operator()() const {
return generate(sprout::random::detail::const_mod<IntType, m>::mult_add(a, x_, c));
return generate(sprout::random::detail::const_mod<UIntType, m>::mult_add(a, x_, c));
}
friend SPROUT_CONSTEXPR bool operator==(linear_congruential_engine const& lhs, linear_congruential_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(linear_congruential_engine const& lhs, linear_congruential_engine const& rhs) SPROUT_NOEXCEPT {
return lhs.x_ == rhs.x_;
}
friend SPROUT_CONSTEXPR bool operator!=(linear_congruential_engine const& lhs, linear_congruential_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(linear_congruential_engine const& lhs, linear_congruential_engine const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename Elem, typename Traits>
@ -101,7 +101,7 @@ namespace sprout {
linear_congruential_engine& rhs
)
{
IntType x;
UIntType x;
if (lhs >> x) {
if(arg_check_nothrow(x)) {
rhs.x_ = x;
@ -120,14 +120,14 @@ namespace sprout {
return lhs << rhs.x_;
}
};
template<typename IntType, IntType a, IntType c, IntType m>
SPROUT_CONSTEXPR_OR_CONST IntType sprout::random::linear_congruential_engine<IntType, a, c, m>::multiplier;
template<typename IntType, IntType a, IntType c, IntType m>
SPROUT_CONSTEXPR_OR_CONST IntType sprout::random::linear_congruential_engine<IntType, a, c, m>::increment;
template<typename IntType, IntType a, IntType c, IntType m>
SPROUT_CONSTEXPR_OR_CONST IntType sprout::random::linear_congruential_engine<IntType, a, c, m>::modulus;
template<typename IntType, IntType a, IntType c, IntType m>
SPROUT_CONSTEXPR_OR_CONST IntType sprout::random::linear_congruential_engine<IntType, a, c, m>::default_seed;
template<typename UIntType, UIntType a, UIntType c, UIntType m>
SPROUT_CONSTEXPR_OR_CONST UIntType sprout::random::linear_congruential_engine<UIntType, a, c, m>::multiplier;
template<typename UIntType, UIntType a, UIntType c, UIntType m>
SPROUT_CONSTEXPR_OR_CONST UIntType sprout::random::linear_congruential_engine<UIntType, a, c, m>::increment;
template<typename UIntType, UIntType a, UIntType c, UIntType m>
SPROUT_CONSTEXPR_OR_CONST UIntType sprout::random::linear_congruential_engine<UIntType, a, c, m>::modulus;
template<typename UIntType, UIntType a, UIntType c, UIntType m>
SPROUT_CONSTEXPR_OR_CONST UIntType sprout::random::linear_congruential_engine<UIntType, a, c, m>::default_seed;
//
// minstd_rand0

View file

@ -29,16 +29,17 @@ namespace sprout {
static_assert(k < w, "k < w");
static_assert(0 < 2 * q && 2 * q < k, "0 < 2 * q && 2 * q < k");
static_assert(0 < s && s <= k - q, "0 < s && s <= k - q");
public:
static SPROUT_CONSTEXPR result_type static_min() SPROUT_NOEXCEPT {
return 0;
}
static SPROUT_CONSTEXPR result_type static_max() SPROUT_NOEXCEPT {
return wordmask();
}
private:
static SPROUT_CONSTEXPR UIntType wordmask() {
return sprout::detail::low_bits_mask_t<w>::sig_bits;
}
static SPROUT_CONSTEXPR result_type static_min() {
return 0;
}
static SPROUT_CONSTEXPR result_type static_max() {
return wordmask();
}
static SPROUT_CONSTEXPR UIntType init_seed_1(UIntType const& x0) {
return x0 < (1 << (w - k)) ? x0 + (1 << (w - k)) : x0;
}
@ -64,19 +65,19 @@ namespace sprout {
explicit SPROUT_CONSTEXPR linear_feedback_shift_engine(UIntType const& x0)
: x_(init_seed(x0))
{}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return static_min();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return static_max();
}
SPROUT_CONSTEXPR sprout::random::random_result<linear_feedback_shift_engine> operator()() const {
return generate(((x_ & ((wordmask() << (w - k)) & wordmask())) << s) ^ ((((x_ << q) ^ x_) & wordmask()) >> (k - s)));
}
friend SPROUT_CONSTEXPR bool operator==(linear_feedback_shift_engine const& lhs, linear_feedback_shift_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(linear_feedback_shift_engine const& lhs, linear_feedback_shift_engine const& rhs) SPROUT_NOEXCEPT {
return lhs.x_ == rhs.x_;
}
friend SPROUT_CONSTEXPR bool operator!=(linear_feedback_shift_engine const& lhs, linear_feedback_shift_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(linear_feedback_shift_engine const& lhs, linear_feedback_shift_engine const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename Elem, typename Traits>

View file

@ -46,6 +46,13 @@ namespace sprout {
SPROUT_STATIC_CONSTEXPR std::size_t unroll_factor = 6;
SPROUT_STATIC_CONSTEXPR std::size_t unroll_extra1 = (n - m) % unroll_factor;
SPROUT_STATIC_CONSTEXPR std::size_t unroll_extra2 = (m - 1) % unroll_factor;
public:
static SPROUT_CONSTEXPR result_type static_min() SPROUT_NOEXCEPT {
return 0;
}
static SPROUT_CONSTEXPR result_type static_max() SPROUT_NOEXCEPT {
return sprout::detail::low_bits_mask_t<w>::sig_bits;
}
private:
template<typename... Args>
static SPROUT_CONSTEXPR typename std::enable_if<
@ -68,13 +75,6 @@ namespace sprout {
static SPROUT_CONSTEXPR sprout::array<UIntType, n> init_seed(UIntType const& value) {
return init_seed_1(value & static_max());
}
public:
static SPROUT_CONSTEXPR result_type static_min() {
return 0;
}
static SPROUT_CONSTEXPR result_type static_max() {
return sprout::detail::low_bits_mask_t<w>::sig_bits;
}
private:
sprout::array<UIntType, n> x_;
std::size_t i_;
@ -373,10 +373,10 @@ namespace sprout {
: x_(init_seed(value))
, i_(n)
{}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return static_min();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return static_max();
}
SPROUT_CONSTEXPR sprout::random::random_result<mersenne_twister_engine> operator()() const {
@ -385,13 +385,13 @@ namespace sprout {
: generate()
;
}
friend SPROUT_CONSTEXPR bool operator==(mersenne_twister_engine const& lhs, mersenne_twister_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(mersenne_twister_engine const& lhs, mersenne_twister_engine const& rhs) SPROUT_NOEXCEPT {
return lhs.i_ < rhs.i_
? lhs.equal_impl(rhs)
: rhs.equal_impl(lhs)
;
}
friend SPROUT_CONSTEXPR bool operator!=(mersenne_twister_engine const& lhs, mersenne_twister_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(mersenne_twister_engine const& lhs, mersenne_twister_engine const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename Elem, typename Traits>

View file

@ -59,10 +59,13 @@ namespace sprout {
: mean_(arg_check(mean_arg, sigma_arg))
, sigma_(sigma_arg)
{}
SPROUT_CONSTEXPR RealType mean() const {
SPROUT_CONSTEXPR RealType mean() const SPROUT_NOEXCEPT {
return mean_;
}
SPROUT_CONSTEXPR RealType sigma() const {
SPROUT_CONSTEXPR RealType sigma() const SPROUT_NOEXCEPT {
return sigma_;
}
SPROUT_CONSTEXPR RealType stddev() const SPROUT_NOEXCEPT {
return sigma_;
}
template<typename Elem, typename Traits>
@ -91,10 +94,10 @@ namespace sprout {
{
return lhs << rhs.mean_ << " " << rhs.sigma_;
}
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return lhs.mean_ == rhs.mean_ && lhs.sigma_ == rhs.sigma_;
}
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};
@ -186,19 +189,22 @@ namespace sprout {
, cached_rho_(0)
, valid_(false)
{}
SPROUT_CONSTEXPR result_type mean() const {
SPROUT_CONSTEXPR result_type mean() const SPROUT_NOEXCEPT {
return mean_;
}
SPROUT_CONSTEXPR result_type sigma() const {
SPROUT_CONSTEXPR result_type sigma() const SPROUT_NOEXCEPT {
return sigma_;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type stddev() const SPROUT_NOEXCEPT {
return sigma_;
}
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return -std::numeric_limits<RealType>::infinity();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return std::numeric_limits<RealType>::infinity();
}
SPROUT_CONSTEXPR param_type param() const {
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
return param_type(mean_, sigma_);
}
void param(param_type const& parm) {
@ -238,14 +244,14 @@ namespace sprout {
{
return lhs << rhs.param() << " " << rhs.valid_ << " " << rhs.cached_rho_ << " " << rhs.r1_ << " " << rhs.r2_;
}
friend SPROUT_CONSTEXPR bool operator==(normal_distribution const& lhs, normal_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(normal_distribution const& lhs, normal_distribution const& rhs) SPROUT_NOEXCEPT {
return lhs.param() == rhs.param()
&& lhs.valid_ == rhs.valid_
&& lhs.cached_rho_ == rhs.cached_rho_
&& lhs.r1_ == rhs.r1_ && lhs.r2_ == rhs.r2_
;
}
friend SPROUT_CONSTEXPR bool operator!=(normal_distribution const& lhs, normal_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(normal_distribution const& lhs, normal_distribution const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};

View file

@ -68,46 +68,46 @@ namespace sprout {
, engine_(engine)
, distribution_(distribution)
{}
SPROUT_CONSTEXPR operator result_type() const {
SPROUT_CONSTEXPR operator result_type() const SPROUT_NOEXCEPT {
return result_;
}
SPROUT_CONSTEXPR random_result operator()() const {
return distribution_(engine_);
}
result_type& result() {
result_type& result() SPROUT_NOEXCEPT {
return result_;
}
SPROUT_CONSTEXPR result_type const& result() const {
SPROUT_CONSTEXPR result_type const& result() const SPROUT_NOEXCEPT {
return result_;
}
result_type& generated_value() {
result_type& generated_value() SPROUT_NOEXCEPT {
return result_;
}
SPROUT_CONSTEXPR result_type const& generated_value() const {
SPROUT_CONSTEXPR result_type const& generated_value() const SPROUT_NOEXCEPT {
return result_;
}
engine_type& engine() {
engine_type& engine() SPROUT_NOEXCEPT {
return engine_;
}
SPROUT_CONSTEXPR engine_type const& engine() const {
SPROUT_CONSTEXPR engine_type const& engine() const SPROUT_NOEXCEPT {
return engine_;
}
random_result& next_generator() {
random_result& next_generator() SPROUT_NOEXCEPT {
return *this;
}
SPROUT_CONSTEXPR random_result const& next_generator() const {
SPROUT_CONSTEXPR random_result const& next_generator() const SPROUT_NOEXCEPT {
return *this;
}
distribution_type& distribution() {
distribution_type& distribution() SPROUT_NOEXCEPT {
return distribution_;
}
SPROUT_CONSTEXPR distribution_type const& distribution() const {
SPROUT_CONSTEXPR distribution_type const& distribution() const SPROUT_NOEXCEPT {
return distribution_;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return distribution_.min();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return distribution_.max();
}
void swap(random_result& other)
@ -121,19 +121,19 @@ namespace sprout {
sprout::swap(engine_, other.engine_);
sprout::swap(distribution_, other.distribution_);
}
friend SPROUT_CONSTEXPR bool operator==(random_result const& lhs, random_result const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(random_result const& lhs, random_result const& rhs) SPROUT_NOEXCEPT {
return lhs.result_ == rhs.result_
&& lhs.engine_ == rhs.engine_
&& lhs.distribution_ == rhs.distribution_
;
}
friend SPROUT_CONSTEXPR bool operator!=(random_result const& lhs, random_result const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(random_result const& lhs, random_result const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
SPROUT_CONSTEXPR reference operator*() const {
SPROUT_CONSTEXPR reference operator*() const SPROUT_NOEXCEPT {
return result_;
}
SPROUT_CONSTEXPR pointer operator->() const {
SPROUT_CONSTEXPR pointer operator->() const SPROUT_NOEXCEPT {
return &result_;
}
random_result& operator++() {
@ -193,48 +193,48 @@ namespace sprout {
: result_(result)
, engine_(engine)
{}
SPROUT_CONSTEXPR operator result_type() const {
SPROUT_CONSTEXPR operator result_type() const SPROUT_NOEXCEPT {
return result_;
}
SPROUT_CONSTEXPR random_result operator()() const {
return engine_();
}
result_type& result() {
result_type& result() SPROUT_NOEXCEPT {
return result_;
}
SPROUT_CONSTEXPR result_type const& result() const {
SPROUT_CONSTEXPR result_type const& result() const SPROUT_NOEXCEPT {
return result_;
}
result_type& generated_value() {
result_type& generated_value() SPROUT_NOEXCEPT {
return result_;
}
SPROUT_CONSTEXPR result_type const& generated_value() const {
SPROUT_CONSTEXPR result_type const& generated_value() const SPROUT_NOEXCEPT {
return result_;
}
engine_type& engine() {
engine_type& engine() SPROUT_NOEXCEPT {
return engine_;
}
SPROUT_CONSTEXPR engine_type const& engine() const {
SPROUT_CONSTEXPR engine_type const& engine() const SPROUT_NOEXCEPT {
return engine_;
}
random_result& next_generator() {
random_result& next_generator() SPROUT_NOEXCEPT {
return *this;
}
SPROUT_CONSTEXPR random_result const& next_generator() const {
SPROUT_CONSTEXPR random_result const& next_generator() const SPROUT_NOEXCEPT {
return *this;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return engine_.min();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return engine_.max();
}
friend SPROUT_CONSTEXPR bool operator==(random_result const& lhs, random_result const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(random_result const& lhs, random_result const& rhs) SPROUT_NOEXCEPT {
return lhs.result_ == rhs.result_
&& lhs.engine_ == rhs.engine_
;
}
friend SPROUT_CONSTEXPR bool operator!=(random_result const& lhs, random_result const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(random_result const& lhs, random_result const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
void swap(random_result& other)
@ -246,10 +246,10 @@ namespace sprout {
sprout::swap(result_, other.result_);
sprout::swap(engine_, other.engine_);
}
SPROUT_CONSTEXPR reference operator*() const {
SPROUT_CONSTEXPR reference operator*() const SPROUT_NOEXCEPT {
return result_;
}
SPROUT_CONSTEXPR pointer operator->() const {
SPROUT_CONSTEXPR pointer operator->() const SPROUT_NOEXCEPT {
return &result_;
}
random_result& operator++() {

View file

@ -36,6 +36,11 @@ namespace sprout {
class shuffle_order_engine
: private sprout::random::detail::shuffle_order_engine_member<UniformRandomNumberGenerator, k>
{
static_assert(
std::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer,
"std::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer"
);
static_assert(k > 0, "k > 0");
private:
typedef sprout::random::detail::shuffle_order_engine_member<UniformRandomNumberGenerator, k> member_type;
public:
@ -47,8 +52,12 @@ namespace sprout {
SPROUT_STATIC_CONSTEXPR std::size_t buffer_size = k;
SPROUT_STATIC_CONSTEXPR std::size_t table_size = k;
public:
static_assert(std::numeric_limits<result_type>::is_integer, "std::numeric_limits<result_type>::is_integer");
static_assert(k > 0, "k > 0");
static SPROUT_CONSTEXPR result_type static_min() SPROUT_NOEXCEPT {
return base_type::static_min();
}
static SPROUT_CONSTEXPR result_type static_max() SPROUT_NOEXCEPT {
return base_type::static_max();
}
private:
template<typename Random, typename... Args>
static SPROUT_CONSTEXPR typename std::enable_if<
@ -120,10 +129,10 @@ namespace sprout {
explicit SPROUT_CONSTEXPR shuffle_order_engine(base_type const& rng)
: member_type(init_member(rng))
{}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return rng_.min();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return rng_.max();
}
SPROUT_CONSTEXPR sprout::random::random_result<shuffle_order_engine> operator()() const {
@ -133,10 +142,13 @@ namespace sprout {
base_unsigned(sprout::random::detail::subtract<result_type>()(y_, min()))
);
}
friend SPROUT_CONSTEXPR bool operator==(shuffle_order_engine const& lhs, shuffle_order_engine const& rhs) {
SPROUT_CONSTEXPR base_type const& base() const SPROUT_NOEXCEPT {
return rng_;
}
friend SPROUT_CONSTEXPR bool operator==(shuffle_order_engine const& lhs, shuffle_order_engine const& rhs) SPROUT_NOEXCEPT {
return lhs.rng_ == rhs.rng_ && lhs.y_ == rhs.y_ && lhs.v_ == rhs.v_;
}
friend SPROUT_CONSTEXPR bool operator!=(shuffle_order_engine const& lhs, shuffle_order_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(shuffle_order_engine const& lhs, shuffle_order_engine const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename Elem, typename Traits>

View file

@ -44,10 +44,10 @@ namespace sprout {
{
return lhs;
}
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return true;
}
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};
@ -118,13 +118,13 @@ namespace sprout {
{}
explicit SPROUT_CONSTEXPR uniform_01(param_type const& parm)
{}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return result_type(0);
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return result_type(1);
}
SPROUT_CONSTEXPR param_type param() const {
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
return param_type();
}
void param(param_type const& parm) {
@ -149,10 +149,10 @@ namespace sprout {
{
return lhs;
}
friend SPROUT_CONSTEXPR bool operator==(uniform_01 const& lhs, uniform_01 const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(uniform_01 const& lhs, uniform_01 const& rhs) SPROUT_NOEXCEPT {
return true;
}
friend SPROUT_CONSTEXPR bool operator!=(uniform_01 const& lhs, uniform_01 const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(uniform_01 const& lhs, uniform_01 const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};

View file

@ -320,10 +320,10 @@ namespace sprout {
: min_(arg_check(min_arg, max_arg))
, max_(max_arg)
{}
SPROUT_CONSTEXPR IntType a() const {
SPROUT_CONSTEXPR IntType a() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR IntType b() const {
SPROUT_CONSTEXPR IntType b() const SPROUT_NOEXCEPT {
return max_;
}
template<typename Elem, typename Traits>
@ -352,10 +352,10 @@ namespace sprout {
{
return lhs << rhs.min_ << " " << rhs.max_;
}
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return lhs.min_ == rhs.min_ && lhs.max_ == rhs.max_;
}
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};
@ -384,19 +384,19 @@ namespace sprout {
: min_(parm.a())
, max_(parm.b())
{}
SPROUT_CONSTEXPR result_type a() const {
SPROUT_CONSTEXPR result_type a() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR result_type b() const {
SPROUT_CONSTEXPR result_type b() const SPROUT_NOEXCEPT {
return max_;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return max_;
}
SPROUT_CONSTEXPR param_type param() const {
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
return param_type(min_, max_);
}
void param(param_type const& parm) {
@ -427,10 +427,10 @@ namespace sprout {
{
return lhs << rhs.param();
}
friend SPROUT_CONSTEXPR bool operator==(uniform_int_distribution const& lhs, uniform_int_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(uniform_int_distribution const& lhs, uniform_int_distribution const& rhs) SPROUT_NOEXCEPT {
return lhs.param() == rhs.param();
}
friend SPROUT_CONSTEXPR bool operator!=(uniform_int_distribution const& lhs, uniform_int_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(uniform_int_distribution const& lhs, uniform_int_distribution const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};

View file

@ -215,10 +215,10 @@ namespace sprout {
: min_(arg_check(min_arg, max_arg))
, max_(max_arg)
{}
SPROUT_CONSTEXPR RealType a() const {
SPROUT_CONSTEXPR RealType a() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR RealType b() const {
SPROUT_CONSTEXPR RealType b() const SPROUT_NOEXCEPT {
return max_;
}
template<typename Elem, typename Traits>
@ -247,10 +247,10 @@ namespace sprout {
{
return lhs << rhs.min_ << " " << rhs.max_;
}
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return lhs.min_ == rhs.min_ && lhs.max_ == rhs.max_;
}
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};
@ -279,19 +279,19 @@ namespace sprout {
: min_(parm.a())
, max_(parm.b())
{}
SPROUT_CONSTEXPR result_type a() const {
SPROUT_CONSTEXPR result_type a() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR result_type b() const {
SPROUT_CONSTEXPR result_type b() const SPROUT_NOEXCEPT {
return max_;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return max_;
}
SPROUT_CONSTEXPR param_type param() const {
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
return param_type(min_, max_);
}
void param(param_type const& parm) {
@ -322,10 +322,10 @@ namespace sprout {
{
return lhs << rhs.param();
}
friend SPROUT_CONSTEXPR bool operator==(uniform_real_distribution const& lhs, uniform_real_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(uniform_real_distribution const& lhs, uniform_real_distribution const& rhs) SPROUT_NOEXCEPT {
return lhs.param() == rhs.param();
}
friend SPROUT_CONSTEXPR bool operator!=(uniform_real_distribution const& lhs, uniform_real_distribution const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(uniform_real_distribution const& lhs, uniform_real_distribution const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};

View file

@ -53,10 +53,10 @@ namespace sprout {
: min_(arg_check(min_arg, max_arg))
, max_(max_arg)
{}
SPROUT_CONSTEXPR IntType a() const {
SPROUT_CONSTEXPR IntType a() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR IntType b() const {
SPROUT_CONSTEXPR IntType b() const SPROUT_NOEXCEPT {
return max_;
}
template<typename Elem, typename Traits>
@ -85,10 +85,10 @@ namespace sprout {
{
return lhs << rhs.min_ << " " << rhs.max_;
}
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return lhs.min_ == rhs.min_ && lhs.max_ == rhs.max_;
}
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(param_type const& lhs, param_type const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};
@ -214,19 +214,19 @@ namespace sprout {
: min_(parm.a())
, max_(parm.b())
{}
SPROUT_CONSTEXPR result_type a() const {
SPROUT_CONSTEXPR result_type a() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR result_type b() const {
SPROUT_CONSTEXPR result_type b() const SPROUT_NOEXCEPT {
return max_;
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return min_;
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return max_;
}
SPROUT_CONSTEXPR param_type param() const {
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
return param_type(min_, max_);
}
void param(param_type const& parm) {
@ -258,10 +258,10 @@ namespace sprout {
{
return lhs << rhs.param();
}
friend SPROUT_CONSTEXPR bool operator==(uniform_smallint const& lhs, uniform_smallint const& rhs) {
friend SPROUT_CONSTEXPR bool operator==(uniform_smallint const& lhs, uniform_smallint const& rhs) SPROUT_NOEXCEPT {
return lhs.param() == rhs.param();
}
friend SPROUT_CONSTEXPR bool operator!=(uniform_smallint const& lhs, uniform_smallint const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(uniform_smallint const& lhs, uniform_smallint const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
};

View file

@ -44,22 +44,22 @@ namespace sprout {
SPROUT_CONSTEXPR random_result_type operator()() const {
return distribution_(engine_);
}
engine_reference_type engine() {
engine_reference_type engine() SPROUT_NOEXCEPT {
return engine_helper_type::ref(engine_);
}
SPROUT_CONSTEXPR engine_const_reference_type engine() const {
SPROUT_CONSTEXPR engine_const_reference_type engine() const SPROUT_NOEXCEPT {
return engine_helper_type::ref(engine_);
}
distribution_reference_type distribution() {
distribution_reference_type distribution() SPROUT_NOEXCEPT {
return distribution_helper_type::ref(distribution_);
}
SPROUT_CONSTEXPR distribution_const_reference_type distribution() const {
SPROUT_CONSTEXPR distribution_const_reference_type distribution() const SPROUT_NOEXCEPT {
return distribution_helper_type::ref(distribution_);
}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return distribution_.min();
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return distribution_.max();
}
};

View file

@ -17,10 +17,19 @@ namespace sprout {
public:
typedef URNG1 base1_type;
typedef URNG2 base2_type;
typedef base1_type first_base;
typedef base2_type second_base;
typedef typename base1_type::result_type result_type;
public:
SPROUT_STATIC_CONSTEXPR int shift1 = s1;
SPROUT_STATIC_CONSTEXPR int shift2 = s2;
public:
static SPROUT_CONSTEXPR result_type static_min() SPROUT_NOEXCEPT {
return NS_SSCRISK_CEL_OR_SPROUT::min(base1_type::static_min(), base2_type::static_min());
}
static SPROUT_CONSTEXPR result_type static_max() SPROUT_NOEXCEPT {
return NS_SSCRISK_CEL_OR_SPROUT::max(base1_type::static_max(), base2_type::static_max());
}
private:
base1_type rng1_;
base2_type rng2_;
@ -48,19 +57,25 @@ namespace sprout {
: rng1_(rng1)
, rng2_(rng2)
{}
SPROUT_CONSTEXPR result_type min() const {
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
return NS_SSCRISK_CEL_OR_SPROUT::min(rng1_.min(), rng2_.min());
}
SPROUT_CONSTEXPR result_type max() const {
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
return NS_SSCRISK_CEL_OR_SPROUT::max(rng1_.max(), rng2_.max());
}
SPROUT_CONSTEXPR sprout::random::random_result<xor_combine_engine> operator()() const {
return generate(rng1_(), rng2_());
}
friend SPROUT_CONSTEXPR bool operator==(xor_combine_engine const& lhs, xor_combine_engine const& rhs) {
SPROUT_CONSTEXPR base1_type const& base1() const SPROUT_NOEXCEPT {
return rng1_;
}
SPROUT_CONSTEXPR base2_type const& base2() const SPROUT_NOEXCEPT {
return rng2_;
}
friend SPROUT_CONSTEXPR bool operator==(xor_combine_engine const& lhs, xor_combine_engine const& rhs) SPROUT_NOEXCEPT {
return lhs.rng1_ == rhs.rng1_ && lhs.rng2_ == rhs.rng2_;
}
friend SPROUT_CONSTEXPR bool operator!=(xor_combine_engine const& lhs, xor_combine_engine const& rhs) {
friend SPROUT_CONSTEXPR bool operator!=(xor_combine_engine const& lhs, xor_combine_engine const& rhs) SPROUT_NOEXCEPT {
return !(lhs == rhs);
}
template<typename Elem, typename Traits>