/
usr
/
include
/
boost
/
random
/
/usr/include/boost/random
mkdir
upload
Name
Size
Mode
Actions
detail/
-
0755
rm
additive_combine.hpp
8826
0644
edit
dl
rm
bernoulli_distribution.hpp
5608
0644
edit
dl
rm
beta_distribution.hpp
5900
0644
edit
dl
rm
binomial_distribution.hpp
12985
0644
edit
dl
rm
cauchy_distribution.hpp
6528
0644
edit
dl
rm
chi_squared_distribution.hpp
6322
0644
edit
dl
rm
discard_block.hpp
7991
0644
edit
dl
rm
discrete_distribution.hpp
21137
0644
edit
dl
rm
exponential_distribution.hpp
20895
0644
edit
dl
rm
extreme_value_distribution.hpp
5611
0644
edit
dl
rm
faure.hpp
11474
0644
edit
dl
rm
fisher_f_distribution.hpp
5924
0644
edit
dl
rm
gamma_distribution.hpp
9166
0644
edit
dl
rm
generate_canonical.hpp
2954
0644
edit
dl
rm
geometric_distribution.hpp
7339
0644
edit
dl
rm
hyperexponential_distribution.hpp
36980
0644
edit
dl
rm
independent_bits.hpp
9117
0644
edit
dl
rm
inversive_congruential.hpp
9550
0644
edit
dl
rm
lagged_fibonacci.hpp
18256
0644
edit
dl
rm
laplace_distribution.hpp
5743
0644
edit
dl
rm
linear_congruential.hpp
16214
0644
edit
dl
rm
linear_feedback_shift.hpp
7162
0644
edit
dl
rm
lognormal_distribution.hpp
8051
0644
edit
dl
rm
mersenne_twister.hpp
24094
0644
edit
dl
rm
negative_binomial_distribution.hpp
6911
0644
edit
dl
rm
niederreiter_base2.hpp
11736
0644
edit
dl
rm
non_central_chi_squared_distribution.hpp
7724
0644
edit
dl
rm
normal_distribution.hpp
17441
0644
edit
dl
rm
piecewise_constant_distribution.hpp
17186
0644
edit
dl
rm
piecewise_linear_distribution.hpp
18802
0644
edit
dl
rm
poisson_distribution.hpp
10145
0644
edit
dl
rm
random_device.hpp
5032
0644
edit
dl
rm
random_number_generator.hpp
1958
0644
edit
dl
rm
ranlux.hpp
3292
0644
edit
dl
rm
seed_seq.hpp
3792
0644
edit
dl
rm
shuffle_order.hpp
9181
0644
edit
dl
rm
shuffle_output.hpp
1352
0644
edit
dl
rm
sobol.hpp
7704
0644
edit
dl
rm
student_t_distribution.hpp
5633
0644
edit
dl
rm
subtract_with_carry.hpp
21590
0644
edit
dl
rm
taus88.hpp
1164
0644
edit
dl
rm
traits.hpp
4165
0644
edit
dl
rm
triangle_distribution.hpp
7033
0644
edit
dl
rm
uniform_01.hpp
7538
0644
edit
dl
rm
uniform_int.hpp
2909
0644
edit
dl
rm
uniform_int_distribution.hpp
16199
0644
edit
dl
rm
uniform_on_sphere.hpp
8812
0644
edit
dl
rm
uniform_real.hpp
2449
0644
edit
dl
rm
uniform_real_distribution.hpp
7726
0644
edit
dl
rm
uniform_smallint.hpp
12230
0644
edit
dl
rm
variate_generator.hpp
3708
0644
edit
dl
rm
weibull_distribution.hpp
5524
0644
edit
dl
rm
xor_combine.hpp
7049
0644
edit
dl
rm
Edit:
/usr/include/boost/random/uniform_01.hpp
(7538B)
/* boost random/uniform_01.hpp header file * * Copyright Jens Maurer 2000-2001 * Distributed under the Boost Software License, Version 1.0. (See * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * See http://www.boost.org for most recent version including documentation. * * $Id$ * * Revision history * 2001-02-18 moved to individual header files */ #ifndef BOOST_RANDOM_UNIFORM_01_HPP #define BOOST_RANDOM_UNIFORM_01_HPP #include <iostream> #include <boost/config.hpp> #include <boost/limits.hpp> #include <boost/static_assert.hpp> #include <boost/random/detail/config.hpp> #include <boost/random/detail/ptr_helper.hpp> #include <boost/random/detail/disable_warnings.hpp> namespace boost { namespace random { #ifdef BOOST_RANDOM_DOXYGEN /** * The distribution function uniform_01 models a \random_distribution. * On each invocation, it returns a random floating-point value * uniformly distributed in the range [0..1). * * The template parameter RealType shall denote a float-like value type * with support for binary operators +, -, and /. * * Note: The current implementation is buggy, because it may not fill * all of the mantissa with random bits. I'm unsure how to fill a * (to-be-invented) @c boost::bigfloat class with random bits efficiently. * It's probably time for a traits class. */ template<class RealType = double> class uniform_01 { public: typedef RealType input_type; typedef RealType result_type; result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const; result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const; void reset(); template<class Engine> result_type operator()(Engine& eng); #ifndef BOOST_RANDOM_NO_STREAM_OPERATORS template<class CharT, class Traits> friend std::basic_ostream<CharT,Traits>& operator<<(std::basic_ostream<CharT,Traits>& os, const new_uniform_01&) { return os; } template<class CharT, class Traits> friend std::basic_istream<CharT,Traits>& operator>>(std::basic_istream<CharT,Traits>& is, new_uniform_01&) { return is; } #endif }; #else namespace detail { template<class RealType> class new_uniform_01 { public: typedef RealType input_type; typedef RealType result_type; // compiler-generated copy ctor and copy assignment are fine result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(0); } result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(1); } void reset() { } template<class Engine> result_type operator()(Engine& eng) { for (;;) { typedef typename Engine::result_type base_result; result_type factor = result_type(1) / (result_type(base_result((eng.max)()-(eng.min)())) + result_type(std::numeric_limits<base_result>::is_integer ? 1 : 0)); result_type result = result_type(base_result(eng() - (eng.min)())) * factor; if (result < result_type(1)) return result; } } #ifndef BOOST_RANDOM_NO_STREAM_OPERATORS template<class CharT, class Traits> friend std::basic_ostream<CharT,Traits>& operator<<(std::basic_ostream<CharT,Traits>& os, const new_uniform_01&) { return os; } template<class CharT, class Traits> friend std::basic_istream<CharT,Traits>& operator>>(std::basic_istream<CharT,Traits>& is, new_uniform_01&) { return is; } #endif }; template<class UniformRandomNumberGenerator, class RealType> class backward_compatible_uniform_01 { typedef boost::random::detail::ptr_helper<UniformRandomNumberGenerator> traits; public: typedef UniformRandomNumberGenerator base_type; typedef RealType result_type; BOOST_STATIC_CONSTANT(bool, has_fixed_range = false); #if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) BOOST_STATIC_ASSERT(!std::numeric_limits<RealType>::is_integer); #endif explicit backward_compatible_uniform_01(typename traits::rvalue_type rng) : _rng(rng), _factor(result_type(1) / (result_type((base().max)()-(base().min)()) + result_type(std::numeric_limits<base_result>::is_integer ? 1 : 0))) { } // compiler-generated copy ctor and copy assignment are fine result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(0); } result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(1); } typename traits::value_type& base() { return traits::ref(_rng); } const typename traits::value_type& base() const { return traits::ref(_rng); } void reset() { } result_type operator()() { for (;;) { result_type result = result_type(base()() - (base().min)()) * _factor; if (result < result_type(1)) return result; } } #if !defined(BOOST_NO_OPERATORS_IN_NAMESPACE) && !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) template<class CharT, class Traits> friend std::basic_ostream<CharT,Traits>& operator<<(std::basic_ostream<CharT,Traits>& os, const backward_compatible_uniform_01& u) { os << u._rng; return os; } template<class CharT, class Traits> friend std::basic_istream<CharT,Traits>& operator>>(std::basic_istream<CharT,Traits>& is, backward_compatible_uniform_01& u) { is >> u._rng; return is; } #endif private: typedef typename traits::value_type::result_type base_result; UniformRandomNumberGenerator _rng; result_type _factor; }; #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION // A definition is required even for integral static constants template<class UniformRandomNumberGenerator, class RealType> const bool backward_compatible_uniform_01<UniformRandomNumberGenerator, RealType>::has_fixed_range; #endif template<class UniformRandomNumberGenerator, bool is_number = std::numeric_limits<UniformRandomNumberGenerator>::is_specialized> struct select_uniform_01 { template<class RealType> struct apply { typedef backward_compatible_uniform_01<UniformRandomNumberGenerator, RealType> type; }; }; template<class Num> struct select_uniform_01<Num, true> { template<class RealType> struct apply { typedef new_uniform_01<Num> type; }; }; } // Because it is so commonly used: uniform distribution on the real [0..1) // range. This allows for specializations to avoid a costly int -> float // conversion plus float multiplication template<class UniformRandomNumberGenerator = double, class RealType = double> class uniform_01 : public detail::select_uniform_01<UniformRandomNumberGenerator>::BOOST_NESTED_TEMPLATE apply<RealType>::type { typedef typename detail::select_uniform_01<UniformRandomNumberGenerator>::BOOST_NESTED_TEMPLATE apply<RealType>::type impl_type; typedef boost::random::detail::ptr_helper<UniformRandomNumberGenerator> traits; public: uniform_01() {} explicit uniform_01(typename traits::rvalue_type rng) : impl_type(rng) { } #if !defined(BOOST_NO_OPERATORS_IN_NAMESPACE) && !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) template<class CharT, class Traits> friend std::basic_ostream<CharT,Traits>& operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_01& u) { os << static_cast<const impl_type&>(u); return os; } template<class CharT, class Traits> friend std::basic_istream<CharT,Traits>& operator>>(std::basic_istream<CharT,Traits>& is, uniform_01& u) { is >> static_cast<impl_type&>(u); return is; } #endif }; #endif } // namespace random using random::uniform_01; } // namespace boost #include <boost/random/detail/enable_warnings.hpp> #endif // BOOST_RANDOM_UNIFORM_01_HPP
Save
cmd:
run