191 lines
5.5 KiB
Markdown
191 lines
5.5 KiB
Markdown
[rand.predef]
|
|
|
|
# 29 Numerics library [[numerics]](./#numerics)
|
|
|
|
## 29.5 Random number generation [[rand]](rand#predef)
|
|
|
|
### 29.5.6 Engines and engine adaptors with predefined parameters [rand.predef]
|
|
|
|
[ð](#lib:minstd_rand0)
|
|
|
|
`using minstd_rand0 =
|
|
linear_congruential_engine<uint_fast32_t, 16'807, 0, 2'147'483'647>;
|
|
`
|
|
|
|
[1](#1)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3822)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type minstd_rand0 produces the value 1043618065[.](#1.sentence-1)
|
|
|
|
[ð](#lib:minstd_rand)
|
|
|
|
`using minstd_rand =
|
|
linear_congruential_engine<uint_fast32_t, 48'271, 0, 2'147'483'647>;
|
|
`
|
|
|
|
[2](#2)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3837)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type minstd_rand produces the value 399268537[.](#2.sentence-1)
|
|
|
|
[ð](#lib:mt19937)
|
|
|
|
`using mt19937 =
|
|
mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
|
|
0x9908'b0df, 11, 0xffff'ffff, 7, 0x9d2c'5680, 15, 0xefc6'0000, 18, 1'812'433'253>;
|
|
`
|
|
|
|
[3](#3)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3853)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type mt19937 produces the value 4123659995[.](#3.sentence-1)
|
|
|
|
[ð](#lib:mt19937_64)
|
|
|
|
`using mt19937_64 =
|
|
mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
|
|
0xb502'6f5a'a966'19e9, 29, 0x5555'5555'5555'5555, 17,
|
|
0x71d6'7fff'eda6'0000, 37, 0xfff7'eee0'0000'0000, 43, 6'364'136'223'846'793'005>;
|
|
`
|
|
|
|
[4](#4)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3870)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type mt19937_64 produces the value 9981545732273789042[.](#4.sentence-1)
|
|
|
|
[ð](#lib:ranlux24_base)
|
|
|
|
`using ranlux24_base =
|
|
subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>;
|
|
`
|
|
|
|
[5](#5)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3885)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type ranlux24_base produces the value 7937952[.](#5.sentence-1)
|
|
|
|
[ð](#lib:ranlux48_base)
|
|
|
|
`using ranlux48_base =
|
|
subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>;
|
|
`
|
|
|
|
[6](#6)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3901)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type ranlux48_base produces the value 61839128582725[.](#6.sentence-1)
|
|
|
|
[ð](#lib:ranlux24)
|
|
|
|
`using ranlux24 = discard_block_engine<ranlux24_base, 223, 23>;
|
|
`
|
|
|
|
[7](#7)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3916)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type ranlux24 produces the value 9901578[.](#7.sentence-1)
|
|
|
|
[ð](#lib:ranlux48)
|
|
|
|
`using ranlux48 = discard_block_engine<ranlux48_base, 389, 11>;
|
|
`
|
|
|
|
[8](#8)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3931)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type ranlux48 produces the value 249142670248501[.](#8.sentence-1)
|
|
|
|
[ð](#lib:knuth_b)
|
|
|
|
`using knuth_b = shuffle_order_engine<minstd_rand0,256>;
|
|
`
|
|
|
|
[9](#9)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3946)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
of a default-constructed object
|
|
of type knuth_b produces the value 1112339016[.](#9.sentence-1)
|
|
|
|
[ð](#lib:default_random_engine)
|
|
|
|
`using default_random_engine = implementation-defined;
|
|
`
|
|
|
|
[10](#10)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3960)
|
|
|
|
*Remarks*: The choice of engine type
|
|
named by this typedef is implementation-defined[.](#10.sentence-1)
|
|
|
|
[*Note [1](#note-1)*:
|
|
|
|
The implementation
|
|
can select this type
|
|
on the basis of performance,
|
|
size,
|
|
quality,
|
|
or any combination of such factors,
|
|
so as to provide at least acceptable engine behavior
|
|
for relatively casual, inexpert, and/or lightweight use[.](#10.sentence-2)
|
|
|
|
Because different implementations
|
|
can select different underlying engine types,
|
|
code that uses this typedef need not generate identical sequences across implementations[.](#10.sentence-3)
|
|
|
|
â *end note*]
|
|
|
|
[ð](#lib:philox4x32)
|
|
|
|
`using philox4x32 =
|
|
philox_engine<uint_fast32_t, 32, 4, 10,
|
|
0xCD9E8D57, 0x9E3779B9, 0xD2511F53, 0xBB67AE85>;
|
|
`
|
|
|
|
[11](#11)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L3989)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
a default-constructed object of type philox4x32 produces the value 1955073260[.](#11.sentence-1)
|
|
|
|
[ð](#lib:philox4x64)
|
|
|
|
`using philox4x64 =
|
|
philox_engine<uint_fast64_t, 64, 4, 10,
|
|
0xCA5A826395121157, 0x9E3779B97F4A7C15, 0xD2E7470EE14C6C93, 0xBB67AE8584CAA73B>;
|
|
`
|
|
|
|
[12](#12)
|
|
|
|
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L4004)
|
|
|
|
*Required behavior*: The 10000th consecutive invocation
|
|
a default-constructed object of type philox4x64 produces the value 3409172418970261260[.](#12.sentence-1)
|