67 |
|
#include <time.h> |
68 |
|
#include <math.h> |
69 |
|
#include <vector> |
70 |
< |
namespace oopse { |
70 |
> |
namespace OpenMD { |
71 |
|
|
72 |
|
class MTRand { |
73 |
|
// Data |
135 |
|
uint32 loBits( const uint32& u ) const { return u & 0x7fffffffUL; } |
136 |
|
uint32 mixBits( const uint32& u, const uint32& v ) const |
137 |
|
{ return hiBit(u) | loBits(v); } |
138 |
+ |
#ifdef _MSC_VER |
139 |
+ |
#pragma warning( push ) // save current warning settings |
140 |
+ |
#pragma warning( disable : 4146 ) // warning C4146: unary minus operator applied to unsigned type, result still unsigned |
141 |
+ |
#endif |
142 |
|
uint32 twist( const uint32& m, const uint32& s0, const uint32& s1 ) const |
143 |
|
{ return m ^ (mixBits(s0,s1)>>1) ^ (-loBit(s1) & 0x9908b0dfUL); } |
144 |
+ |
#ifdef _MSC_VER |
145 |
+ |
#pragma warning( pop ) // return warning settings to what they were |
146 |
+ |
#endif |
147 |
+ |
|
148 |
|
static uint32 hash( time_t t, clock_t c ); |
149 |
|
}; |
150 |
|
|
206 |
|
* number in the stride sequence. |
207 |
|
*/ |
208 |
|
inline MTRand::uint32 MTRand::randInt() { |
209 |
< |
|
209 |
> |
|
210 |
|
std::vector<uint32> ranNums(nstrides_); |
211 |
|
|
212 |
|
for (int i = 0; i < nstrides_; ++i) { |
329 |
|
register int i = N; |
330 |
|
register bool success = true; |
331 |
|
while( success && i-- ) |
332 |
< |
success = fread( s++, sizeof(uint32), 1, urandom ); |
332 |
> |
success = (fread( s++, sizeof(uint32), 1, urandom ) == 0); |
333 |
|
fclose(urandom); |
334 |
|
if( success ) { return bigSeed; } |
335 |
|
} |