/usr/include/boost/random
NameSizeModeActions
detail/-0755rm
additive_combine.hpp88260644editdlrm
bernoulli_distribution.hpp56080644editdlrm
beta_distribution.hpp59000644editdlrm
binomial_distribution.hpp129850644editdlrm
cauchy_distribution.hpp65280644editdlrm
chi_squared_distribution.hpp63220644editdlrm
discard_block.hpp79910644editdlrm
discrete_distribution.hpp211370644editdlrm
exponential_distribution.hpp208950644editdlrm
extreme_value_distribution.hpp56110644editdlrm
faure.hpp114740644editdlrm
fisher_f_distribution.hpp59240644editdlrm
gamma_distribution.hpp91660644editdlrm
generate_canonical.hpp29540644editdlrm
geometric_distribution.hpp73390644editdlrm
hyperexponential_distribution.hpp369800644editdlrm
independent_bits.hpp91170644editdlrm
inversive_congruential.hpp95500644editdlrm
lagged_fibonacci.hpp182560644editdlrm
laplace_distribution.hpp57430644editdlrm
linear_congruential.hpp162140644editdlrm
linear_feedback_shift.hpp71620644editdlrm
lognormal_distribution.hpp80510644editdlrm
mersenne_twister.hpp240940644editdlrm
negative_binomial_distribution.hpp69110644editdlrm
niederreiter_base2.hpp117360644editdlrm
non_central_chi_squared_distribution.hpp77240644editdlrm
normal_distribution.hpp174410644editdlrm
piecewise_constant_distribution.hpp171860644editdlrm
piecewise_linear_distribution.hpp188020644editdlrm
poisson_distribution.hpp101450644editdlrm
random_device.hpp50320644editdlrm
random_number_generator.hpp19580644editdlrm
ranlux.hpp32920644editdlrm
seed_seq.hpp37920644editdlrm
shuffle_order.hpp91810644editdlrm
shuffle_output.hpp13520644editdlrm
sobol.hpp77040644editdlrm
student_t_distribution.hpp56330644editdlrm
subtract_with_carry.hpp215900644editdlrm
taus88.hpp11640644editdlrm
traits.hpp41650644editdlrm
triangle_distribution.hpp70330644editdlrm
uniform_01.hpp75380644editdlrm
uniform_int.hpp29090644editdlrm
uniform_int_distribution.hpp161990644editdlrm
uniform_on_sphere.hpp88120644editdlrm
uniform_real.hpp24490644editdlrm
uniform_real_distribution.hpp77260644editdlrm
uniform_smallint.hpp122300644editdlrm
variate_generator.hpp37080644editdlrm
weibull_distribution.hpp55240644editdlrm
xor_combine.hpp70490644editdlrm
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 #include #include #include #include #include #include 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 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 result_type operator()(Engine& eng); #ifndef BOOST_RANDOM_NO_STREAM_OPERATORS template friend std::basic_ostream& operator<<(std::basic_ostream& os, const new_uniform_01&) { return os; } template friend std::basic_istream& operator>>(std::basic_istream& is, new_uniform_01&) { return is; } #endif }; #else namespace detail { template 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 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::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 friend std::basic_ostream& operator<<(std::basic_ostream& os, const new_uniform_01&) { return os; } template friend std::basic_istream& operator>>(std::basic_istream& is, new_uniform_01&) { return is; } #endif }; template class backward_compatible_uniform_01 { typedef boost::random::detail::ptr_helper 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::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::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 friend std::basic_ostream& operator<<(std::basic_ostream& os, const backward_compatible_uniform_01& u) { os << u._rng; return os; } template friend std::basic_istream& operator>>(std::basic_istream& 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 const bool backward_compatible_uniform_01::has_fixed_range; #endif template::is_specialized> struct select_uniform_01 { template struct apply { typedef backward_compatible_uniform_01 type; }; }; template struct select_uniform_01 { template struct apply { typedef new_uniform_01 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 uniform_01 : public detail::select_uniform_01::BOOST_NESTED_TEMPLATE apply::type { typedef typename detail::select_uniform_01::BOOST_NESTED_TEMPLATE apply::type impl_type; typedef boost::random::detail::ptr_helper 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 friend std::basic_ostream& operator<<(std::basic_ostream& os, const uniform_01& u) { os << static_cast(u); return os; } template friend std::basic_istream& operator>>(std::basic_istream& is, uniform_01& u) { is >> static_cast(u); return is; } #endif }; #endif } // namespace random using random::uniform_01; } // namespace boost #include #endif // BOOST_RANDOM_UNIFORM_01_HPP