This PR adds tests to improve code coverage. In addition:
* The implementation of `Rational.isProper is corrected` for negative values.
* Add tests for Float and Double extensions
* Adjust accuracy for Glibc
* Add tests for RNG initialization using device entropy
* Expand testing of Rational and fix implementation of Rational.isProper
* Further expand testing of Rational
* Expand tests for Float and Double extensions
* Expand tests for Rational
* Adjust accuracy for Glibc
* Expand tests for Float and Double extensions
* Adjust accuracy for Glibc
* Re-adjust accuracy for Glibc
* Expand testing of Complex
This PR introduces a protocol named `PRNG` for pseudo-random number generators, which is class-constrained and refines `IteratorProtocol` and `Sequence`. Extension methods on `PRNG` should not be susceptible to "modulo bias" problems that can occur when `Element.max - Element.min + 1` is not a power of two.
It also introduces a (final) class named `Random`, which conforms to `PRNG` and implements the `xorshift128+` algorithm, and another (final) class named `Random.Xoroshiro`, which conforms to `PRNG` and implements the `xoroshiro128+` algorithm. Much work remains to be done, including testing the code using [TestU01](http://simul.iro.umontreal.ca/testu01/tu01.html).
* Initial implementation of Random
* Implement discrete uniform distribution
* Make minor change to Random.init?()
* Create protocol PRNG and make changes to Random accordingly
* Revert "Modify FloatingPointMath to refine BinaryFloatingPoint"
* Update README.md
* Simplify some implementations
* Update README.md
* Make minor stylistic changes
* Update implementation of Random.init?()
* Implement MT19937 and xoroshiro128+
* Improve implementation of PRNG.uniform<T : BinaryFloatingPoint>()
* Implement PRNG.exponential and PRNG.weibull
* Refine implementation of Random.MersenneTwister
* Revise description of Xoroshiro128+
* Implement PRNG.bernoulli functions
* Add tests for xorshift128+ and xoroshiro128+, fix and update implementations, make minor stylistic changes
* Change visibility of MT19937 parameters
* Remove Random.MersenneTwister, avoid undefined behavior in PRNG._entropy
* Update to avoid heterogeneous comparison
* Revert "Update to avoid heterogeneous comparison"
* Document methods on PRNG
* Update README.md
...and correct some implementations in Rational.
Although it was possible to implement many of the simpler algorithms using a two's complement representation, it proved to be difficult to implement multiplication or division without taking the absolute value. Some reading suggests that most (if not all) arbitrary-precision integer implementations use sign-and-magnitude representation. Thus, I have switched back to that representation (which was one option that I had already explored).
This PR contains working implementations of comparison, addition, subtraction, long multiplication, and negation. Additional testing is required to verify correctness.
No attempt has yet been made to implement division or bit shifting, and no updated implementation is included for other bitwise operations. It remains unclear to me whether generic use of such operations always assumes two's complement representation, or whether it is appropriate to simply perform these bitwise operations on the native sign-and-magnitude representation.
Future directions include implementation of more sophisticated multiplication algorithms such as Karatsuba.