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/tests/random.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/tests/random.cpp | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/tests/random.cpp b/src/tests/random.cpp index 3799803..e48c543 100644 --- a/src/tests/random.cpp +++ b/src/tests/random.cpp | |||
| @@ -9,41 +9,41 @@ using namespace Bu; | |||
| 9 | template<typename T> | 9 | template<typename T> |
| 10 | void coverage() | 10 | void coverage() |
| 11 | { | 11 | { |
| 12 | T rand; | 12 | T rand; |
| 13 | rand.seed( time( NULL ) ); | 13 | rand.seed( time( NULL ) ); |
| 14 | 14 | ||
| 15 | uint32_t uBucket[78]; | 15 | uint32_t uBucket[78]; |
| 16 | memset( uBucket, 0, sizeof(uint32_t)*78 ); | 16 | memset( uBucket, 0, sizeof(uint32_t)*78 ); |
| 17 | 17 | ||
| 18 | for( int j = 0; j < 1000000; j++ ) | 18 | for( int j = 0; j < 1000000; j++ ) |
| 19 | { | 19 | { |
| 20 | uBucket[(int)(((uint32_t)rand.rand())/(double)(0xfffffffful)*78+0.5)]++; | 20 | uBucket[(int)(((uint32_t)rand.rand())/(double)(0xfffffffful)*78+0.5)]++; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | uint32_t uMax = 0; | 23 | uint32_t uMax = 0; |
| 24 | for( int j = 0; j < 78; j++ ) | 24 | for( int j = 0; j < 78; j++ ) |
| 25 | { | 25 | { |
| 26 | if( uMax < uBucket[j] ) | 26 | if( uMax < uBucket[j] ) |
| 27 | uMax = uBucket[j]; | 27 | uMax = uBucket[j]; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | for( int y = 20; y >= 1; y-- ) | 30 | for( int y = 20; y >= 1; y-- ) |
| 31 | { | 31 | { |
| 32 | uint32_t iT = (uint32_t)((y/20.0)*uMax); | 32 | uint32_t iT = (uint32_t)((y/20.0)*uMax); |
| 33 | for( int x = 0; x < 78; x++ ) | 33 | for( int x = 0; x < 78; x++ ) |
| 34 | { | 34 | { |
| 35 | sio << ((iT<=uBucket[x])?"#":" "); | 35 | sio << ((iT<=uBucket[x])?"#":" "); |
| 36 | } | 36 | } |
| 37 | sio << sio.nl; | 37 | sio << sio.nl; |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | int main() | 41 | int main() |
| 42 | { | 42 | { |
| 43 | coverage<RandomBasic>(); | 43 | coverage<RandomBasic>(); |
| 44 | coverage<RandomCmwc>(); | 44 | coverage<RandomCmwc>(); |
| 45 | coverage<RandomSystem>(); | 45 | coverage<RandomSystem>(); |
| 46 | 46 | ||
| 47 | return 0; | 47 | return 0; |
| 48 | } | 48 | } |
| 49 | 49 | ||
