wavelength 1.0.0
Loading...
Searching...
No Matches
rand.h
Go to the documentation of this file.
1#pragma once
2
8class Rand {
9public:
11 static constexpr int kTableSize = 256;
12
20 explicit Rand(int nSeed);
21
29 void Seed(int nSeed);
30
40 int Int(int nLow, int nHigh);
41
51 float Float(float fLow, float fHigh);
52
60 float Float();
61
71 int Int();
72
73private:
74 int mIndex;
75 int mLagIndex;
76 int mTable[kTableSize];
77};
78
86void SeedRand(int nSeed);
87
96
106int RandomInt(int nLow, int nHigh);
107
116
126float RandomFloat(float fLow, float fHigh);
int Int()
Draw the next word.
Rand(int nSeed)
Construct a generator and seed it.
float Float(float fLow, float fHigh)
Draw a floating-point number.
int Int(int nLow, int nHigh)
Draw an integer.
static constexpr int kTableSize
Words of the state table.
Definition rand.h:11
float Float()
Draw a floating-point number in [0, 1).
void Seed(int nSeed)
Fill the state table from a linear congruential sequence and reset both indices.
float RandomFraction()
Draw a floating-point number in [0, 1) from the shared generator.
int RandomWord()
Draw a word from the shared generator.
int RandomInt(int nLow, int nHigh)
Draw an integer from the shared generator.
float RandomFloat(float fLow, float fHigh)
Draw a floating-point number from the shared generator.
void SeedRand(int nSeed)
Reseed the shared generator.