aboutsummaryrefslogtreecommitdiff
path: root/src/stable/randommersenne.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-09 19:10:54 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-09 19:10:54 +0000
commit21df391dc6055884e621181cbc3b51d9ec2b095c (patch)
treed92f3423c0585459fdfc0755ae415f0832d478b3 /src/stable/randommersenne.h
parent21e13f0b2c5242a2ee84b404a96d456e5b753056 (diff)
downloadlibbu++-21df391dc6055884e621181cbc3b51d9ec2b095c.tar.gz
libbu++-21df391dc6055884e621181cbc3b51d9ec2b095c.tar.bz2
libbu++-21df391dc6055884e621181cbc3b51d9ec2b095c.tar.xz
libbu++-21df391dc6055884e621181cbc3b51d9ec2b095c.zip
Added Mersenne Twister random number generator.
Diffstat (limited to 'src/stable/randommersenne.h')
-rw-r--r--src/stable/randommersenne.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/stable/randommersenne.h b/src/stable/randommersenne.h
new file mode 100644
index 0000000..27c100e
--- /dev/null
+++ b/src/stable/randommersenne.h
@@ -0,0 +1,31 @@
1#ifndef BU_RANDOM_MERSENNE_H
2#define BU_RANDOM_MERSENNE_H
3
4#include "bu/randombase.h"
5
6namespace Bu
7{
8 /**
9 * An implementation of Mersenne Twister (MT19937) algorithm. This as an
10 * algorithm with an excellent reputation for very good random number
11 * generation and a very large period. It is however, relatively slow and
12 * complex compared to, say the Complementary Multiply With Carry
13 * (Bu::RandomCmwc), and may not actually be a *better* random number
14 * generator.
15 */
16 class RandomMersenne : public Bu::RandomBase
17 {
18 public:
19 RandomMersenne( int32_t iSeed=0 );
20 virtual ~RandomMersenne();
21
22 virtual void seed( int32_t iSeed );
23 virtual int32_t rand();
24
25 private:
26 int32_t iIndex;
27 uint32_t iMt[624];
28 };
29};
30
31#endif