-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generate high quality pseudorandom numbers using a SIMD Fast Mersenne Twister -- -- The Mersenne twister is a pseudorandom number generator developed by -- Makoto Matsumoto and Takuji Nishimura that is based on a matrix linear -- recurrence over a finite binary field. It provides for fast generation -- of very high quality pseudorandom numbers -- -- This library uses SFMT, the SIMD-oriented Fast Mersenne Twister, a -- variant of Mersenne Twister that is much faster than the original. It -- is designed to be fast when it runs on 128-bit SIMD. It can be -- compiled with either SSE2 and PowerPC AltiVec support, to take -- advantage of these instructions. -- --
-- cabal install -fuse_sse2 ---- -- On an x86 system, for performance win. -- -- By default the period of the function is 2^19937-1, however, you can -- compile in other defaults. Note that this algorithm on its own is not -- cryptographically secure. -- -- For more information about the algorithm and implementation, see the -- SFMT homepage, -- -- http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html -- -- and, Mutsuo Saito and Makoto Matsumoto, /SIMD-oriented Fast Mersenne -- Twister: a 128-bit Pseudorandom Number Generator/, in the Proceedings -- of MCQMC2006, here: -- -- -- http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/sfmt.pdf @package mersenne-random @version 1.0 -- | Tested with: GHC 6.8.2 -- -- Generate pseudo-random numbers using the SIMD-oriented Fast Mersenne -- Twister(SFMT) pseudorandom number generator. This is a much -- faster generator than the default System.Random generator for -- Haskell (~50x faster generation for Doubles, on a core 2 duo), -- however, it is not nearly as flexible. -- -- This library may be compiled with the '-f use_sse2' or '-f -- use_altivec' flags to configure, on intel and powerpc machines -- respectively, to enable high performance vector instructions to be -- used. This typically results in a 2-3x speedup in generation time. -- -- This will work for newer intel chips such as Pentium 4s, and Core, -- Core2* chips. module System.Random.Mersenne -- | A single, global SIMD fast mersenne twister random number generator -- This generator is evidence that you have initialised the generator, data MTGen -- | Return an initialised SIMD Fast Mersenne Twister. The generator is -- initialised based on the clock time, if Nothing is passed as a seed. -- For deterministic behaviour, pass an explicit seed. -- -- Due to the current SFMT library being vastly impure, currently only a -- single generator is allowed per-program. Attempts to reinitialise it -- will fail. newMTGen :: Maybe Word32 -> IO MTGen -- | Given an initialised SFMT generator, the MTRandom allows the -- programmer to extract values of a variety of types. -- -- Minimal complete definition: random. class MTRandom a random :: MTRandom a => MTGen -> IO a randoms :: MTRandom a => MTGen -> IO [a] randomIO :: MTRandom a => IO a -- | Uses the supplied function to get a value from the current global -- random generator, and updates the global generator with the new -- generator returned by the function. For example, rollDice -- gets a random integer between 1 and 6: -- --
-- rollDice :: IO Int -- rollDice = getMTRandom (randomR (1,6)) --getStdRandom :: (MTGen -> IO a) -> IO a -- | Gets the global random number generator. getStdGen :: IO MTGen -- | Sets the global random number generator. setStdGen :: MTGen -> IO () -- | Returns the identification string for the SMFT version. The string -- shows the word size, the Mersenne exponent, and all parameters of this -- generator. version :: String instance MTRandom Bool instance MTRandom Integer instance MTRandom Int8 instance MTRandom Int16 instance MTRandom Int32 instance MTRandom Int64 instance MTRandom Int instance MTRandom Double instance MTRandom Word8 instance MTRandom Word16 instance MTRandom Word32 instance MTRandom Word64 instance MTRandom Word