1 // Mersenne Twister random number generator -- a C++ class MTRand
\r
2 // Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
\r
3 // Richard J. Wagner v1.0 15 May 2003 rjwagner@writeme.com
\r
5 // The Mersenne Twister is an algorithm for generating random numbers. It
\r
6 // was designed with consideration of the flaws in various other generators.
\r
7 // The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
\r
8 // are far greater. The generator is also fast; it avoids multiplication and
\r
9 // division, and it benefits from caches and pipelines. For more information
\r
10 // see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html
\r
13 // M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
\r
14 // Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
\r
15 // Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
\r
17 // Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
\r
18 // Copyright (C) 2000 - 2003, Richard J. Wagner
\r
19 // All rights reserved.
\r
21 // Redistribution and use in source and binary forms, with or without
\r
22 // modification, are permitted provided that the following conditions
\r
25 // 1. Redistributions of source code must retain the above copyright
\r
26 // notice, this list of conditions and the following disclaimer.
\r
28 // 2. Redistributions in binary form must reproduce the above copyright
\r
29 // notice, this list of conditions and the following disclaimer in the
\r
30 // documentation and/or other materials provided with the distribution.
\r
32 // 3. The names of its contributors may not be used to endorse or promote
\r
33 // products derived from this software without specific prior written
\r
36 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
37 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
\r
38 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
\r
39 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
\r
40 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
41 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
\r
42 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
\r
43 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
44 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
45 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
\r
46 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
48 // The original code included the following notice:
\r
50 // When you use this, send an email to: matumoto@math.keio.ac.jp
\r
51 // with an appropriate reference to your work.
\r
53 // It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu
\r
56 // Not thread safe (unless auto-initialization is avoided and each thread has
\r
57 // its own MTRand object)
\r