OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
ExpressionRandom.h
Go to the documentation of this file.
1#ifndef OPALX_ExpressionRandom_HH
2#define OPALX_ExpressionRandom_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: ExpressionRandom.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// the random integers are generated in the range [0, MAXRAN)
27static const int maxran = 1000000000;
28
30// This generator is based on:
31// [center]
32// D. Knuth: The Art of Computer Programming, Vol. 2, 2nd edition.
33// [/center]
34
35class Random {
36public:
38 Random();
39
41 // The argument is the new seed, an integer in the range [0, 1000000000].
42 Random(int seed);
43
44 ~Random();
45
47 // The argument is the new seed, an integer in the range [0, 1000000000].
48 void reseed(int seed = 123456789);
49
51 // Return a real pseudo-random number in the range [0,1).
52 double uniform();
53
55 // Return two real Gaussian pseudo-random numbers with unit standard
56 // deviation. The values are placed in the two arguments.
57 void gauss(double& gr1, double& gr2);
58
60 // Return an integer pseudo-random number in the range [0,1000000000).
61 int integer();
62
64 void init55(int seed);
65
66private:
67 // generate next batch of random numbers
68 void irngen();
69
70 // a set of "NR" random integers
71 int irn[nr];
72
73 // the next item to be used in the random sequence
74 int next;
75};
76
77#endif // OPALX_ExpressionRandom_HH
const int nr
The OPALX expression random generator.
int integer()
Uniform distribution.
void reseed(int seed=123456789)
Set a new seed.
void gauss(double &gr1, double &gr2)
Gaussian distribution.
int irn[nr]
void init55(int seed)
Initialise random number generator.
double uniform()
Uniform distribution.
Random()
Constructor with default seed.