diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/stable/randomcmwc.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/stable/randomcmwc.cpp b/src/stable/randomcmwc.cpp index ccfc4a9..9f68982 100644 --- a/src/stable/randomcmwc.cpp +++ b/src/stable/randomcmwc.cpp | |||
@@ -7,6 +7,8 @@ | |||
7 | 7 | ||
8 | #include "bu/randomcmwc.h" | 8 | #include "bu/randomcmwc.h" |
9 | 9 | ||
10 | #include "bu/randombasic.h" | ||
11 | |||
10 | #define PHI 0x9e3779b9 | 12 | #define PHI 0x9e3779b9 |
11 | 13 | ||
12 | Bu::RandomCmwc::RandomCmwc() : | 14 | Bu::RandomCmwc::RandomCmwc() : |
@@ -23,14 +25,24 @@ Bu::RandomCmwc::~RandomCmwc() | |||
23 | 25 | ||
24 | void Bu::RandomCmwc::seed( int32_t iSeed ) | 26 | void Bu::RandomCmwc::seed( int32_t iSeed ) |
25 | { | 27 | { |
26 | i = 4096; | 28 | i = 4095; |
29 | c = 362436; | ||
30 | |||
31 | Bu::RandomBasic rb; | ||
32 | rb.seed( iSeed ); | ||
33 | |||
34 | for( int j = 0; j < 4096; j++ ) | ||
35 | q[j] = rb.rand(); | ||
36 | |||
37 | c = rb.rand(); | ||
27 | 38 | ||
28 | q[0] = iSeed; | 39 | return; |
29 | q[1] = iSeed + PHI; | 40 | q[0] = (uint32_t)rb.rand(); |
30 | q[2] = iSeed + PHI + PHI; | 41 | q[1] = (uint32_t)rb.rand() + PHI; |
42 | q[2] = (uint32_t)rb.rand() + PHI + PHI; | ||
31 | 43 | ||
32 | for (int j = 3; j < 4096; j++) | 44 | for (int j = 3; j < 4096; j++) |
33 | q[j] = q[j - 3] ^ q[j - 2] ^ PHI ^ j; | 45 | q[j] = q[j - 3] ^ q[j - 2] ^ PHI ^ j; |
34 | } | 46 | } |
35 | 47 | ||
36 | int32_t Bu::RandomCmwc::rand() | 48 | int32_t Bu::RandomCmwc::rand() |