This code is based on C-code described in Matsumoto and Nishimura's Mersenne Twister and the Harase and Kimoto MELG repository. The MELG-based classes, like the original C-code versions, provide various period lengths from 2607-1 to 244497-1.
This repository includes Eiffel classes for:
- RANDOMS_DEMO -- Root class for system randoms_demo.ecf
- TWISTER_32 -- 32-bit Mersenne Twister
- TWISTER_64 -- 64-bit Mersenne Twister
The MELG-type classes as well as the 64-bit Twister are based on MELG which contains all the functionality for the generators of various period lengths:
To conform to Eiffel's command-query separation principle, these classes depart from the paradigm used in the C versions.
- Getting a random number does not advance the state (i.e. calling item multiple times returns the same random number).
- State advancement (i.e. moving to the next random number) is in feature forth which calls the non-exported feature twist.
- "Tempering" is handled in feature forth.
The demo program RANDOMS_DEMO uses TWISTER_32_TESTS, TWISTER_64_TESTS, and MELG_TESTS to display feature calls and the results of the calls. It also verifies the output against files produced by the original C files. When the demo system is open in EiffelStudio, you can also execute some features in AutoTest.