diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-06-27 11:11:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-27 11:11:13 (GMT) |
commit | e24393f41834f116038faf6c6d5012575a67136a (patch) | |
tree | a1e83679e55781bc92849a07c5acda7b5c09908c /contrib/src/boost/random/detail/uniform_int_float.hpp | |
parent | b3a2d91805feb81f79ee52c30a077521912b0bf9 (diff) | |
parent | 3a5692f40663282640775f8ff497c4860d265a2a (diff) | |
download | uscxml-e24393f41834f116038faf6c6d5012575a67136a.zip uscxml-e24393f41834f116038faf6c6d5012575a67136a.tar.gz uscxml-e24393f41834f116038faf6c6d5012575a67136a.tar.bz2 |
Merge pull request #149 from tklab-tud/sradomski
remerge
Diffstat (limited to 'contrib/src/boost/random/detail/uniform_int_float.hpp')
-rw-r--r-- | contrib/src/boost/random/detail/uniform_int_float.hpp | 152 |
1 files changed, 76 insertions, 76 deletions
diff --git a/contrib/src/boost/random/detail/uniform_int_float.hpp b/contrib/src/boost/random/detail/uniform_int_float.hpp index 893e471..393c455 100644 --- a/contrib/src/boost/random/detail/uniform_int_float.hpp +++ b/contrib/src/boost/random/detail/uniform_int_float.hpp @@ -1,76 +1,76 @@ -/* boost random/detail/uniform_int_float.hpp header file
- *
- * Copyright Jens Maurer 2000-2001
- * Copyright Steven Watanabe 2011
- * 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$
- *
- */
-
-#ifndef BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP
-#define BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP
-
-#include <boost/limits.hpp>
-#include <boost/config.hpp>
-#include <boost/integer.hpp>
-#include <boost/random/detail/config.hpp>
-#include <boost/random/detail/generator_bits.hpp>
-
-#include <boost/random/detail/disable_warnings.hpp>
-
-namespace boost {
-namespace random {
-namespace detail {
-
-template<class URNG>
-class uniform_int_float
-{
-public:
- typedef URNG base_type;
- typedef typename base_type::result_type base_result;
-
- typedef typename boost::uint_t<
- (std::numeric_limits<boost::uintmax_t>::digits <
- std::numeric_limits<base_result>::digits)?
- std::numeric_limits<boost::uintmax_t>::digits :
- std::numeric_limits<base_result>::digits
- >::fast result_type;
-
- uniform_int_float(base_type& rng)
- : _rng(rng) {}
-
- static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION ()
- { return 0; }
- static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION ()
- {
- std::size_t digits = std::numeric_limits<result_type>::digits;
- if(detail::generator_bits<URNG>::value() < digits) {
- digits = detail::generator_bits<URNG>::value();
- }
- return (result_type(2) << (digits - 1)) - 1;
- }
- base_type& base() { return _rng; }
- const base_type& base() const { return _rng; }
-
- result_type operator()()
- {
- base_result range = static_cast<base_result>((max)())+1;
- return static_cast<result_type>(_rng() * range);
- }
-
-private:
- base_type& _rng;
-};
-
-} // namespace detail
-} // namespace random
-} // namespace boost
-
-#include <boost/random/detail/enable_warnings.hpp>
-
-#endif // BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP
+/* boost random/detail/uniform_int_float.hpp header file + * + * Copyright Jens Maurer 2000-2001 + * Copyright Steven Watanabe 2011 + * 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$ + * + */ + +#ifndef BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP +#define BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP + +#include <boost/limits.hpp> +#include <boost/config.hpp> +#include <boost/integer.hpp> +#include <boost/random/detail/config.hpp> +#include <boost/random/detail/generator_bits.hpp> + +#include <boost/random/detail/disable_warnings.hpp> + +namespace boost { +namespace random { +namespace detail { + +template<class URNG> +class uniform_int_float +{ +public: + typedef URNG base_type; + typedef typename base_type::result_type base_result; + + typedef typename boost::uint_t< + (std::numeric_limits<boost::uintmax_t>::digits < + std::numeric_limits<base_result>::digits)? + std::numeric_limits<boost::uintmax_t>::digits : + std::numeric_limits<base_result>::digits + >::fast result_type; + + uniform_int_float(base_type& rng) + : _rng(rng) {} + + static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () + { return 0; } + static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () + { + std::size_t digits = std::numeric_limits<result_type>::digits; + if(detail::generator_bits<URNG>::value() < digits) { + digits = detail::generator_bits<URNG>::value(); + } + return (result_type(2) << (digits - 1)) - 1; + } + base_type& base() { return _rng; } + const base_type& base() const { return _rng; } + + result_type operator()() + { + base_result range = static_cast<base_result>((max)())+1; + return static_cast<result_type>(_rng() * range); + } + +private: + base_type& _rng; +}; + +} // namespace detail +} // namespace random +} // namespace boost + +#include <boost/random/detail/enable_warnings.hpp> + +#endif // BOOST_RANDOM_DETAIL_UNIFORM_INT_FLOAT_HPP |