aboutsummaryrefslogtreecommitdiff
path: root/src/stable/randomcmwc.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/stable/randomcmwc.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/stable/randomcmwc.cpp b/src/stable/randomcmwc.cpp
index a4e807e..ccfc4a9 100644
--- a/src/stable/randomcmwc.cpp
+++ b/src/stable/randomcmwc.cpp
@@ -23,20 +23,19 @@ Bu::RandomCmwc::~RandomCmwc()
23 23
24void Bu::RandomCmwc::seed( int32_t iSeed ) 24void Bu::RandomCmwc::seed( int32_t iSeed )
25{ 25{
26 int i; 26 i = 4096;
27 27
28 q[0] = iSeed; 28 q[0] = iSeed;
29 q[1] = iSeed + PHI; 29 q[1] = iSeed + PHI;
30 q[2] = iSeed + PHI + PHI; 30 q[2] = iSeed + PHI + PHI;
31 31
32 for (i = 3; i < 4096; i++) 32 for (int j = 3; j < 4096; j++)
33 q[i] = q[i - 3] ^ q[i - 2] ^ PHI ^ i; 33 q[j] = q[j - 3] ^ q[j - 2] ^ PHI ^ j;
34} 34}
35 35
36int32_t Bu::RandomCmwc::rand() 36int32_t Bu::RandomCmwc::rand()
37{ 37{
38 uint64_t t, a = 18782LL; 38 uint64_t t, a = 18782LL;
39 static uint32_t i = 4095;
40 uint32_t x, r = 0xfffffffe; 39 uint32_t x, r = 0xfffffffe;
41 i = (i + 1) & 4095; 40 i = (i + 1) & 4095;
42 t = a * q[i] + c; 41 t = a * q[i] + c;