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