diff options
author | cookedm <cookedm@localhost> | 2007-04-02 12:08:34 +0000 |
---|---|---|
committer | cookedm <cookedm@localhost> | 2007-04-02 12:08:34 +0000 |
commit | f03bfaeca406ff6b8ba90ba2043a64a8fdc45a67 (patch) | |
tree | ba4a49b1b50b68620259ead75b6d27d89334ec3f | |
parent | f11fdaee8baeb00fc2a7156cda67c8b0d1eb54ae (diff) | |
download | numpy-f03bfaeca406ff6b8ba90ba2043a64a8fdc45a67.tar.gz |
Fixes #488. In rk_interval, use rk_random if the interval size is less than 2**32.
For 64-bit machines, this means results will agree with 32-bit machines,
and will be faster for these interval sizes (one less rk_random evaluation).
-rw-r--r-- | numpy/random/mtrand/randomkit.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/random/mtrand/randomkit.c b/numpy/random/mtrand/randomkit.c index eddef16af..56f52c0b4 100644 --- a/numpy/random/mtrand/randomkit.c +++ b/numpy/random/mtrand/randomkit.c @@ -248,7 +248,15 @@ unsigned long rk_interval(unsigned long max, rk_state *state) #endif /* Search a random value in [0..mask] <= max */ +#if ULONG_MAX > 0xffffffffUL + if (max <= 0xffffffffUL) { + while ((value = (rk_random(state) & mask)) > max); + } else { + while ((value = (rk_ulong(state) & mask)) > max); + } +#else while ((value = (rk_ulong(state) & mask)) > max); +#endif return value; } |