|
C++ Mersenne Twister pseudo-random number generator
|
|||||||||||||||||
|
Personal
Research
Free source codes
|
On this page, I provide a C++ port of the famous Mersenne Twister
pseudo-random number generator that has
period 219937-1. The algorithm and original C source code
are designed by
M. Matsumoto and T. Nishimura,
Mersenne Twister: A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator, ACM Transactions on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp. 3-30 URL: http://www.math.sci.hiroshima-u.ac.jp/%7Em-mat/MT/emt.html. I wrote a C++ port that takes advantage of the
possibilities of the C++ programming language like inline member functions
to enhance efficiency and the safety of classes. Probably because
of this, the compiled code of this C++
version of the generator runs faster than the original C version, it runs even
faster than the optimized C version written by
Shawn Cokus (tested on a PC with Windows XP, a PC with Linux, and
a Sun UltraSparc machine with Solaris, code was compiled with GNU
C++ compiler and Borland C++ 5.5).
The code is 100% ISO standard C++ and no additional
libraries are needed, so it can be compiled with
any compiler that supports standard C++.
Download mtrand.zip 17 kB FREEWARE
containing (the links below will show syntax highlighted versions,
produced with C++2HTML)
|
||||||||||||||||