diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/stable/randomcmwc.cpp | |
parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip |
Converted tabs to spaces with tabconv.
Diffstat (limited to '')
-rw-r--r-- | src/stable/randomcmwc.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/stable/randomcmwc.cpp b/src/stable/randomcmwc.cpp index 9f68982..1d4a913 100644 --- a/src/stable/randomcmwc.cpp +++ b/src/stable/randomcmwc.cpp | |||
@@ -12,52 +12,52 @@ | |||
12 | #define PHI 0x9e3779b9 | 12 | #define PHI 0x9e3779b9 |
13 | 13 | ||
14 | Bu::RandomCmwc::RandomCmwc() : | 14 | Bu::RandomCmwc::RandomCmwc() : |
15 | q( 0 ), | 15 | q( 0 ), |
16 | c( 362436 ) | 16 | c( 362436 ) |
17 | { | 17 | { |
18 | q = new uint32_t[4096]; | 18 | q = new uint32_t[4096]; |
19 | } | 19 | } |
20 | 20 | ||
21 | Bu::RandomCmwc::~RandomCmwc() | 21 | Bu::RandomCmwc::~RandomCmwc() |
22 | { | 22 | { |
23 | delete[] q; | 23 | delete[] q; |
24 | } | 24 | } |
25 | 25 | ||
26 | void Bu::RandomCmwc::seed( int32_t iSeed ) | 26 | void Bu::RandomCmwc::seed( int32_t iSeed ) |
27 | { | 27 | { |
28 | i = 4095; | 28 | i = 4095; |
29 | c = 362436; | 29 | c = 362436; |
30 | 30 | ||
31 | Bu::RandomBasic rb; | 31 | Bu::RandomBasic rb; |
32 | rb.seed( iSeed ); | 32 | rb.seed( iSeed ); |
33 | 33 | ||
34 | for( int j = 0; j < 4096; j++ ) | 34 | for( int j = 0; j < 4096; j++ ) |
35 | q[j] = rb.rand(); | 35 | q[j] = rb.rand(); |
36 | 36 | ||
37 | c = rb.rand(); | 37 | c = rb.rand(); |
38 | 38 | ||
39 | return; | 39 | return; |
40 | q[0] = (uint32_t)rb.rand(); | 40 | q[0] = (uint32_t)rb.rand(); |
41 | q[1] = (uint32_t)rb.rand() + PHI; | 41 | q[1] = (uint32_t)rb.rand() + PHI; |
42 | q[2] = (uint32_t)rb.rand() + PHI + PHI; | 42 | q[2] = (uint32_t)rb.rand() + PHI + PHI; |
43 | 43 | ||
44 | for (int j = 3; j < 4096; j++) | 44 | for (int j = 3; j < 4096; j++) |
45 | q[j] = q[j - 3] ^ q[j - 2] ^ PHI ^ j; | 45 | q[j] = q[j - 3] ^ q[j - 2] ^ PHI ^ j; |
46 | } | 46 | } |
47 | 47 | ||
48 | int32_t Bu::RandomCmwc::rand() | 48 | int32_t Bu::RandomCmwc::rand() |
49 | { | 49 | { |
50 | uint64_t t, a = 18782LL; | 50 | uint64_t t, a = 18782LL; |
51 | uint32_t x, r = 0xfffffffe; | 51 | uint32_t x, r = 0xfffffffe; |
52 | i = (i + 1) & 4095; | 52 | i = (i + 1) & 4095; |
53 | t = a * q[i] + c; | 53 | t = a * q[i] + c; |
54 | c = (t >> 32); | 54 | c = (t >> 32); |
55 | x = t + c; | 55 | x = t + c; |
56 | if( x < c ) | 56 | if( x < c ) |
57 | { | 57 | { |
58 | x++; | 58 | x++; |
59 | c++; | 59 | c++; |
60 | } | 60 | } |
61 | return (q[i] = r - x); | 61 | return (q[i] = r - x); |
62 | } | 62 | } |
63 | 63 | ||