JuliaLang/julia — pull request #5741 by mschauer (2014-02-09 10:38:14+00:00)
Title: Use single call to dsfmt_gv_genrand_uint32() for small ranges (Take 2)

This fixes #5549 and is an extended version of #5578 to accommodate for future changes to Range1, see #5585
* This version constructs RandIntGen's from first() and last() instead of length() for Integer ranges, see #2537
* As known, tests in test/linalg.jl are sensitive to changes in the RNG and will break, see #5605
* This fixes also #5550: internally in RandIntGen full ranges from typemin to typemax have nominal length zero ``last()-first()+1 == 0`` and are handled correctly by using a variant of ``rem``
* Using the full entropy: 2^31 fits two times into 2^32 and no samples get rejected
* I find it overall faster than before
* I could add checks for empty Ranges if desired, currently rand(one(T):zero(T)) produces full range rand(T)

This is tricky to test (e.g. it is not possible to check if rand(1:2^50) covers the full range or is exactly uniform...) so please have a close look for one-off-errors and ideas for good tests are welcome.