My Project
 All Classes Files Functions Variables Enumerations Pages
random.h
Go to the documentation of this file.
1 /**************************************************************************/
2 /* Copyright 2009 Tim Day */
3 /* */
4 /* This file is part of Fracplanet */
5 /* */
6 /* Fracplanet is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* Fracplanet is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
18 /**************************************************************************/
19 
24 #ifndef _random_h_
25 #define _random_h_
26 
28 class Random01
29 {
30 public:
31 
32  // Constructor. Argument is seed value.
33  Random01(uint s=0);
34 
36  ~Random01();
37 
38  // Return random number in 0-1 (don't think we care whether open interval or not).
39  double operator()()
40  {
41  return _gen();
42  }
43 
44  private:
45 
46  boost::mt19937 _rng;
47 
48  boost::uniform_real<> _dist;
49 
50  boost::variate_generator<boost::mt19937,boost::uniform_real<> > _gen;
51 };
52 
53 #endif
54 
55 
56 
57 
58 
59 
Generates random numbers in the range [0,1).
Definition: random.h:28
~Random01()
Destructor.
Definition: random.cpp:30