A.3.2 Random Number Engines

The library defines three classes that implement different algorithms for generating random numbers. The library also defines three adaptors that modify the sequences produced by a given engine. The engine and engine adaptor classes are templates. Unlike the parameters to the distributions, the parameters to these engines are complex and require detailed understanding of the math used by the particular engine. We list the engines here so that the reader is aware of their existence, but describing how to generate these types is beyond the scope of this Primer.

The library also defines several types that are built from the engines or adaptors. The default_random_engine type is a type alias for one of the engine types parameterized by variables designed to yield good performance for casual use. The library also defines several classes that are fully specialized versions of an engine or adaptor. The engines and the specializations defined by the library are:

default_random_engine

Type alias for one of the other engines intended to be used for most purposes.

linear_congruential_engine

minstd_rand0 Has a multiplier of 16807, a modulus of 2147483647, and an increment of 0.

minstd_rand Has a multiplier of 48271, a modulus of 2147483647, and an increment of 0.

mersenne_twister_engine

mt19937 32-bit unsigned Mersenne twister generator.

mt19937_64 64-bit unsigned Mersenne twister generator.

subtract_with_carry_engine

ranlux24_base 32-bit unsigned subtract with carry generator.

ranlux48_base 64-bit unsigned subtract with carry generator.

discard_block_engine

Engine adaptor that discards results from its underlying engine. Parameterized by the underlying engine to use the block size, and size of the used blocks.

ranlux24 Uses the ranlux24_base engine with a block size of 223 and a used block size of 23.

ranlux48 Uses the ranlux48_base engine with a block size of 389 and a used block size of 11.

independent_bits_engine

Engine adaptor that generates numbers with a specified number of bits. Parameterized by the underlying engine to use, the number of bits to generate in its results, and an unsigned integral type to use to hold the generated bits. The number of bits specified must be less than the number of digits that the specified unsigned type can hold.

shuffle_order_engine

Engine adaptor that returns the same numbers as its underlying engine but delivers them in a different sequence. Parameterized by the underlying engine to use and the number of elements to shuffle.

knuth_b Uses the minstd_rand0 engine with a table size of 256.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.108.119