1
- /*
1
+ /*
2
2
* The Mersenne Twister pseudo-random number generator (PRNG)
3
3
*
4
4
* This is an implementation of fast PRNG called MT19937,
14
14
*
15
15
* Written by Christian Stigen Larsen
16
16
* http://csl.sublevel3.org
17
- *
17
+ *
18
18
* Distributed under the modified BSD license.
19
19
*
20
20
* 2012-01-11
@@ -40,7 +40,7 @@ static unsigned index = 0;
40
40
#define L31 (x ) (0x7FFFFFFF & x) // 31 Least Significant Bits
41
41
#define ODD (x ) (x & 1 ) // Check if number is odd
42
42
43
- #define UINT32_MAX std::numeric_limits<uint32_t >::max()
43
+ #define MD_UINT32_MAX std::numeric_limits<uint32_t >::max()
44
44
45
45
static inline void generate_numbers ()
46
46
{
@@ -170,10 +170,10 @@ extern "C" int mt_rand()
170
170
* PORTABILITY WARNING:
171
171
*
172
172
* rand_u32() uses all 32-bits for the pseudo-random number,
173
- * but rand() must return a number from 0 ... RAND_MAX .
173
+ * but rand() must return a number from 0 ... MD_RAND_MAX .
174
174
*
175
175
* We'll just assume that rand() only uses 31 bits worth of
176
- * data, and that we're on a two's complement system.
176
+ * data, and that we're on a two's complement system.
177
177
*
178
178
* So, to output an integer compatible with rand(), we have
179
179
* two options: Either mask off the highest (32nd) bit, or
@@ -191,32 +191,32 @@ extern "C" void mt_srand(unsigned value)
191
191
192
192
extern " C" float randf_cc ()
193
193
{
194
- return static_cast <float >(rand_u32 ())/UINT32_MAX ;
194
+ return static_cast <float >(rand_u32 ())/MD_UINT32_MAX ;
195
195
}
196
196
197
197
extern " C" float randf_co ()
198
198
{
199
- return static_cast <float >(rand_u32 ())/(UINT32_MAX +1 .0f );
199
+ return static_cast <float >(rand_u32 ())/(MD_UINT32_MAX +1 .0f );
200
200
}
201
201
202
202
extern " C" float randf_oo ()
203
203
{
204
- return (static_cast <float >(rand_u32 ())+0 .5f )/(UINT32_MAX +1 .0f );
204
+ return (static_cast <float >(rand_u32 ())+0 .5f )/(MD_UINT32_MAX +1 .0f );
205
205
}
206
206
207
207
extern " C" double randd_cc ()
208
208
{
209
- return static_cast <double >(rand_u32 ())/UINT32_MAX ;
209
+ return static_cast <double >(rand_u32 ())/MD_UINT32_MAX ;
210
210
}
211
211
212
212
extern " C" double randd_co ()
213
213
{
214
- return static_cast <double >(rand_u32 ())/(UINT32_MAX +1.0 );
214
+ return static_cast <double >(rand_u32 ())/(MD_UINT32_MAX +1.0 );
215
215
}
216
216
217
217
extern " C" double randd_oo ()
218
218
{
219
- return (static_cast <double >(rand_u32 ())+0.5 )/(UINT32_MAX +1.0 );
219
+ return (static_cast <double >(rand_u32 ())+0.5 )/(MD_UINT32_MAX +1.0 );
220
220
}
221
221
222
222
extern " C" uint64_t rand_u64 ()
0 commit comments