OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
ClassicRandom.h
Go to the documentation of this file.
1#ifndef MAD_Random_HH
2#define MAD_Random_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: ClassicRandom.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Class: Random
13//
14// ------------------------------------------------------------------------
15// Class category: Utilities
16// ------------------------------------------------------------------------
17//
18// $Date: 2000/03/27 09:32:38 $
19// $Author: fci $
20//
21// ------------------------------------------------------------------------
22
23// the random numbers are generated in batches of 55
24const int nr = 55;
25
26
27// the random integers are generated in the range [0, MAXRAN)
28static const int maxran = 1000000000;
29
31// This generator is based on:
32// [center]
33// D. Knuth: The Art of Computer Programming, Vol. 2, 2nd edition.
34// [/center]
35
36class Random {
37
38public:
39
41 Random();
42
44 // The argument is the new seed, an integer in the range [0, 1000000000].
45 Random(int seed);
46
47 ~Random();
48
50 // The argument is the new seed, an integer in the range [0, 1000000000].
51 void reseed(int seed = 123456789);
52
54 // Return a real pseudo-random number in the range [0,1).
55 double uniform();
56
58 // Return two real Gaussian pseudo-random numbers with unit standard
59 // deviation. The values are placed in the two arguments.
60 void gauss(double &gr1, double &gr2);
61
63 // Return an integer pseudo-random number in the range [0,1000000000).
64 int integer();
65
67 void init55(int seed);
68
69private:
70
71 // generate next batch of random numbers
72 void irngen();
73
74 // a set of "NR" random integers
75 int irn[nr];
76
77 // the next item to be used in the random sequence
78 int next;
79};
80
81#endif // MAD_Random_HH
const int nr
Definition: ClassicRandom.h:24
int seed
The current random seed.
Definition: Options.cpp:37
The CLASSIC random generator.
Definition: ClassicRandom.h:36
int integer()
Uniform distribution.
void reseed(int seed=123456789)
Set a new seed.
void irngen()
void gauss(double &gr1, double &gr2)
Gaussian distribution.
int irn[nr]
Definition: ClassicRandom.h:75
void init55(int seed)
Initialise random number generator.
double uniform()
Uniform distribution.
Random()
Constructor with default seed.
int next
Definition: ClassicRandom.h:78