66 |
|
#include <stdio.h> |
67 |
|
#include <time.h> |
68 |
|
#include <math.h> |
69 |
+ |
#include <vector> |
70 |
+ |
namespace oopse { |
71 |
|
|
72 |
|
class MTRand { |
73 |
|
// Data |
118 |
|
void seed( const uint32 oneSeed ); |
119 |
|
void seed( uint32 *const bigSeed, const uint32 seedLength = N ); |
120 |
|
void seed(); |
121 |
< |
|
121 |
> |
|
122 |
> |
std::vector<uint32>generateSeeds(); |
123 |
> |
|
124 |
|
// Saving and loading generator state |
125 |
|
void save( uint32* saveArray ) const; // to array of size SAVE |
126 |
|
void load( uint32 *const loadArray ); // from such array |
293 |
|
|
294 |
|
inline void MTRand::seed() |
295 |
|
{ |
296 |
< |
vector<uint32> seeds; |
296 |
> |
std::vector<uint32> seeds; |
297 |
|
|
298 |
|
seeds = generateSeeds(); |
299 |
|
|
305 |
|
} |
306 |
|
|
307 |
|
|
308 |
< |
inline vector<uint32> MTRand::generateSeeds() { |
308 |
> |
inline std::vector<MTRand::uint32> MTRand::generateSeeds() { |
309 |
|
// Seed the generator with an array from /dev/urandom if available |
310 |
|
// Otherwise use a hash of time() and clock() values |
311 |
|
|
312 |
< |
vector<uint32> bigSeed; |
312 |
> |
std::vector<uint32> bigSeed; |
313 |
|
|
314 |
|
// First try getting an array from /dev/urandom |
315 |
|
FILE* urandom = fopen( "/dev/urandom", "rb" ); |
432 |
|
return is; |
433 |
|
} |
434 |
|
|
435 |
+ |
} |
436 |
|
#endif // MERSENNETWISTER_H |
437 |
|
|
438 |
|
// Change log: |