Chris@16
|
1 /* boost random/uniform_real.hpp header file
|
Chris@16
|
2 *
|
Chris@16
|
3 * Copyright Jens Maurer 2000-2001
|
Chris@16
|
4 * Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
5 * accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 *
|
Chris@16
|
8 * See http://www.boost.org for most recent version including documentation.
|
Chris@16
|
9 *
|
Chris@101
|
10 * $Id$
|
Chris@16
|
11 *
|
Chris@16
|
12 * Revision history
|
Chris@16
|
13 * 2001-04-08 added min<max assertion (N. Becker)
|
Chris@16
|
14 * 2001-02-18 moved to individual header files
|
Chris@16
|
15 */
|
Chris@16
|
16
|
Chris@16
|
17 #ifndef BOOST_RANDOM_UNIFORM_REAL_HPP
|
Chris@16
|
18 #define BOOST_RANDOM_UNIFORM_REAL_HPP
|
Chris@16
|
19
|
Chris@16
|
20 #include <boost/assert.hpp>
|
Chris@16
|
21 #include <boost/config.hpp>
|
Chris@16
|
22 #include <boost/limits.hpp>
|
Chris@16
|
23 #include <boost/random/uniform_real_distribution.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost {
|
Chris@16
|
26
|
Chris@16
|
27 /**
|
Chris@16
|
28 * The distribution function uniform_real models a random distribution.
|
Chris@16
|
29 * On each invocation, it returns a random floating-point value uniformly
|
Chris@16
|
30 * distributed in the range [min..max).
|
Chris@16
|
31 *
|
Chris@16
|
32 * This class is deprecated. Please use @c uniform_real_distribution in
|
Chris@16
|
33 * new code.
|
Chris@16
|
34 */
|
Chris@16
|
35 template<class RealType = double>
|
Chris@16
|
36 class uniform_real : public random::uniform_real_distribution<RealType>
|
Chris@16
|
37 {
|
Chris@16
|
38 typedef random::uniform_real_distribution<RealType> base_type;
|
Chris@16
|
39 public:
|
Chris@16
|
40
|
Chris@16
|
41 class param_type : public base_type::param_type
|
Chris@16
|
42 {
|
Chris@16
|
43 public:
|
Chris@16
|
44 typedef uniform_real distribution_type;
|
Chris@16
|
45 /**
|
Chris@16
|
46 * Constructs the parameters of a uniform_real distribution.
|
Chris@16
|
47 *
|
Chris@16
|
48 * Requires: min <= max
|
Chris@16
|
49 */
|
Chris@16
|
50 explicit param_type(RealType min_arg = RealType(0.0),
|
Chris@16
|
51 RealType max_arg = RealType(1.0))
|
Chris@16
|
52 : base_type::param_type(min_arg, max_arg)
|
Chris@16
|
53 {}
|
Chris@16
|
54 };
|
Chris@16
|
55
|
Chris@16
|
56 /**
|
Chris@16
|
57 * Constructs a uniform_real object. @c min and @c max are the
|
Chris@16
|
58 * parameters of the distribution.
|
Chris@16
|
59 *
|
Chris@16
|
60 * Requires: min <= max
|
Chris@16
|
61 */
|
Chris@16
|
62 explicit uniform_real(RealType min_arg = RealType(0.0),
|
Chris@16
|
63 RealType max_arg = RealType(1.0))
|
Chris@16
|
64 : base_type(min_arg, max_arg)
|
Chris@16
|
65 {
|
Chris@101
|
66 BOOST_ASSERT(min_arg < max_arg);
|
Chris@16
|
67 }
|
Chris@16
|
68
|
Chris@16
|
69 /** Constructs a uniform_real distribution from its parameters. */
|
Chris@16
|
70 explicit uniform_real(const param_type& parm)
|
Chris@16
|
71 : base_type(parm)
|
Chris@16
|
72 {}
|
Chris@16
|
73
|
Chris@16
|
74 /** Returns the parameters of the distribution */
|
Chris@16
|
75 param_type param() const { return param_type(this->a(), this->b()); }
|
Chris@16
|
76 /** Sets the parameters of the distribution. */
|
Chris@16
|
77 void param(const param_type& parm) { this->base_type::param(parm); }
|
Chris@16
|
78 };
|
Chris@16
|
79
|
Chris@16
|
80 } // namespace boost
|
Chris@16
|
81
|
Chris@16
|
82 #endif // BOOST_RANDOM_UNIFORM_REAL_HPP
|