mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
add normal_distribution::stddev
This commit is contained in:
parent
225c11b505
commit
f37e8a9088
19 changed files with 261 additions and 211 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue