On 05/18/2016 10:42 PM, Sven Van Caekenberghe wrote:
Martin,
Would you be willing to contribute your implementation to Pharo ? Possibly with
some tests ?
I'll ask GemTalk management if they're OK with that. I imagine it'll be
OK. But you might be better off taking the Squeak implementation, or
reading and understanding the CMWC papers and implementing from scratch.
My implementation is based on reference implementations and constants
for 32-bit numbers in C. This works well if your SmallIntegers are
64-bit, as they are in GemStone. A straight port to Pharo would be
handling large integers all the time. This might be OK, but is something
to think about. Transposing it to 29-bit numbers would be possible, but
would require finding new prime numbers with the appropriate properties.
I consider that fairly heavy lifting, but perhaps you've got somebody
with better numerical methods chops than I've got.
My API is a bit unconventional, too, though *I* think it makes sense. :-)
Example code:
| random foo |
random := Random new.
foo := random integerBetween: 4 and: 27. "works until you get close
to 2**32"
foo := random integer. "[0..2**32-1]"
foo := random float. "Double in [0..1)"
Tests: I don't recall what automated tests we have. Some, I'm sure. The
tough thing is testing a generator for randomness -- you need something
like 650GB of free disk space and a couple of days to generate the
random numbers and run the tests over them. I did all that manually.
Those tests come from here: http://simul.iro.umontreal.ca/testu01/tu01.html
They're the most complete randomness tests of which I'm aware.
Regards,
-Martin