aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/experimental/randomcmwc.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/experimental/randomcmwc.cpp b/src/experimental/randomcmwc.cpp
index 97f7262..a4e807e 100644
--- a/src/experimental/randomcmwc.cpp
+++ b/src/experimental/randomcmwc.cpp
@@ -9,37 +9,37 @@
9 9
10#define PHI 0x9e3779b9 10#define PHI 0x9e3779b9
11 11
12RandomCmwc::RandomCmwc() : 12Bu::RandomCmwc::RandomCmwc() :
13 q( NULL ), 13 q( 0 ),
14 c( 362436 ) 14 c( 362436 )
15{ 15{
16 q = new uint32_t[4096]; 16 q = new uint32_t[4096];
17} 17}
18 18
19RandomCmwc::~RandomCmwc() 19Bu::RandomCmwc::~RandomCmwc()
20{ 20{
21 delete[] q; 21 delete[] q;
22} 22}
23 23
24void RandomCmwc::seed( int32_t iSeed ) 24void Bu::RandomCmwc::seed( int32_t iSeed )
25{ 25{
26 int i; 26 int i;
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 (i = 3; i < 4096; i++)
33 Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; 33 q[i] = q[i - 3] ^ q[i - 2] ^ PHI ^ i;
34} 34}
35 35
36int32_t 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; 39 static uint32_t i = 4095;
40 uint32_t x, r = 0xfffffffe; 40 uint32_t x, r = 0xfffffffe;
41 i = (i + 1) & 4095; 41 i = (i + 1) & 4095;
42 t = a * Q[i] + c; 42 t = a * q[i] + c;
43 c = (t >> 32); 43 c = (t >> 32);
44 x = t + c; 44 x = t + c;
45 if( x < c ) 45 if( x < c )
@@ -47,6 +47,6 @@ int32_t RandomCmwc::rand()
47 x++; 47 x++;
48 c++; 48 c++;
49 } 49 }
50 return (Q[i] = r - x); 50 return (q[i] = r - x);
51} 51}
52 52