Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXRandom.h
1 /********************************************************************************
2 * *
3 * R a n d o m N u m b e r G e n e r a t o r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2007,2018 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXRANDOM_H
22 #define FXRANDOM_H
23 
24 namespace FX {
25 
26 
31 class FXRandom {
32 private:
33  FXulong state;
34 public:
35 
39  FXRandom();
40 
45  FXRandom(FXulong s);
46 
50  FXRandom(const FXRandom& s):state(s.state){}
51 
55  FXRandom& operator=(const FXRandom& s){ state=s.state; return *this; }
56 
60  FXulong next();
61 
65  void seed(FXulong s);
66 
70  FXulong getState() const { return state; }
71 
75  void setState(FXulong s){ state=s; }
76 
80  FXulong randLong();
81 
85  FXfloat randFloat();
86 
90  FXdouble randDouble();
91  };
92 
93 }
94 
95 
96 #endif
FXulong getState() const
Get state of random generator.
Definition: FXRandom.h:70
FXRandom provides a thread-safe random number generator with a period of around 1.84E19.
Definition: FXRandom.h:31
FXulong next()
Generate next state of the random generator.
void seed(FXulong s)
Change state of random generator with new seed s.
FXRandom()
Construct random generator with default seed value.
FXulong randLong()
Draw random unsigned long, uniformly distributed.
FXdouble randDouble()
Draw random double, uniformly distributed between 0 and 1.
Definition: FX4Splitter.h:28
FXRandom & operator=(const FXRandom &s)
Assignment state from another random generator.
Definition: FXRandom.h:55
FXRandom(const FXRandom &s)
Initialize this random generator with the state of another.
Definition: FXRandom.h:50
FXfloat randFloat()
Draw random float, uniformly distributed between 0 and 1.
void setState(FXulong s)
Set state of random generator.
Definition: FXRandom.h:75

Copyright © 1997-2018 Jeroen van der Zijp