aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable')
-rw-r--r--src/stable/randomcmwc.cpp7
-rw-r--r--src/stable/randomcmwc.h2
2 files changed, 4 insertions, 5 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;
diff --git a/src/stable/randomcmwc.h b/src/stable/randomcmwc.h
index 747eb6a..fff891b 100644
--- a/src/stable/randomcmwc.h
+++ b/src/stable/randomcmwc.h
@@ -22,7 +22,7 @@ namespace Bu
22 virtual int32_t rand(); 22 virtual int32_t rand();
23 23
24 private: 24 private:
25 uint32_t *q, c; 25 uint32_t *q, c, i;
26 }; 26 };
27}; 27};
28 28