]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/random/random_number_generator.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
eaf32e534f284ab9335fd3a36ca63739672b96f5
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / random / random_number_generator.hpp
1 /* boost random/random_number_generator.hpp header file\r
2  *\r
3  * Copyright Jens Maurer 2000-2001\r
4  * Distributed under the Boost Software License, Version 1.0. (See\r
5  * accompanying file LICENSE_1_0.txt or copy at\r
6  * http://www.boost.org/LICENSE_1_0.txt)\r
7  *\r
8  * See http://www.boost.org for most recent version including documentation.\r
9  *\r
10  * $Id: random_number_generator.hpp 26164 2004-11-09 21:22:00Z jmaurer $\r
11  *\r
12  * Revision history\r
13  *  2001-02-18  moved to individual header files\r
14  */\r
15 \r
16 #ifndef BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP\r
17 #define BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP\r
18 \r
19 #include <boost/config.hpp>\r
20 #include <boost/limits.hpp>\r
21 #include <boost/static_assert.hpp>\r
22 #include <boost/random/uniform_int.hpp>\r
23 #include <boost/random/variate_generator.hpp>\r
24 \r
25 namespace boost {\r
26 \r
27 // a model for RandomNumberGenerator std:25.2.11 [lib.alg.random.shuffle]\r
28 template<class UniformRandomNumberGenerator, class IntType = long>\r
29 class random_number_generator\r
30 {\r
31 public:\r
32   typedef UniformRandomNumberGenerator base_type;\r
33   typedef IntType argument_type;\r
34   typedef IntType result_type;\r
35   random_number_generator(base_type& rng) : _rng(rng)\r
36   { \r
37 #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS\r
38     BOOST_STATIC_ASSERT(std::numeric_limits<result_type>::is_integer);\r
39 #endif\r
40   }\r
41   // compiler-generated copy ctor is fine\r
42   // assignment is disallowed because there is a reference member\r
43 \r
44   result_type operator()(argument_type n)\r
45   {\r
46     typedef uniform_int<IntType> dist_type;\r
47     return variate_generator<base_type&, dist_type>(_rng, dist_type(0, n-1))();\r
48   }\r
49 \r
50 private:\r
51   base_type& _rng;\r
52 };\r
53 \r
54 } // namespace boost\r
55 \r
56 #endif // BOOST_RANDOM_RANDOM_NUMBER_GENERATOR_HPP\r