在线文档教程
C++
数字 | Numerics

std::mersenne_twister_engine

STD:Mersenne[医]捻线机[医]发动机

Defined in header
template< class UIntType, size_t w, size_t n, size_t m, size_t r, UIntType a, size_t u, UIntType d, size_t s, UIntType b, size_t t, UIntType c, size_t l, UIntType f > class mersenne_twister_engine;(since C++11)

mersenne_twister_engine是一个基于梅森扭子算法。它产生高质量的无符号整数型随机数。UIntType关于区间。[0,2w

-1]。

以下类型别名定义了具有两个常用参数集的随机数引擎:

在标头中定义<random>

*。

类型定义

mt 19937 STD::Mersenne[医]捻线机[医]引擎<std::uint[医]扣件32[医]t,32,624,397,31,0x9908b0df,11,0xffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253>32位Mersenne Twister,松本和西村,1998。

19937[医]64性病::Mersenne[医]捻线机[医]引擎<std::uint[医]快64[医]t,64,312,156,31,0xb5026f5a96619e9,29,0x555555555555555555,17,0x71d67fffeda60000,37,0xfff7eee0000000,43,6364136223846793005>64位Mersenne Twister,松本和西村,2000。

成员类型

Member typeDefinition
result_typeThe integral type generated by the engine. Results are undefined if this is not an unsigned integral type.

成员函数

建设与播种

*。

%28构造函数%29构造引擎%28公共成员函数%29

种子设置引擎%28公共成员函数%29的当前状态。

世代

运算符%28%29提升引擎%27s状态并返回生成值%28公共成员函数%29

丢弃将引擎%27s状态提升指定数量%28公共成员函数%29

特征

敏静态获取输出范围%28公共静态成员函数%29中的最小可能值。

马克斯静态获取输出范围%28公共静态成员函数%29中的最大可能值。

非会员职能

operator==operator!=compares the internal states of two pseudo-random number engines (function template)
operator<<operator>>performs stream input and output on pseudo-random number engine (function template)

成员对象

constexpr size_t word_size staticthe template parameter w, determines the range of values generated by the engine. (public static member constant)
constexpr size_t state_size staticthe template parameter n. The engine state is n values of UIntType (public static member constant)
constexpr size_t shift_size staticthe template parameter m (public static member constant)
constexpr size_t mask_bits staticthe template parameter r, also known as the twist value. (public static member constant)
constexpr UIntType xor_mask staticthe template parameter a, the conditional xor-mask. (public static member constant)
constexpr size_t tempering_u staticthe template parameter u, first component of the bit-scrambling (tempering) matrix (public static member constant)
constexpr UIntType tempering_d staticthe template parameter d, second component of the bit-scrambling (tempering) matrix (public static member constant)
constexpr size_t tempering_s staticthe template parameter s, third component of the bit-scrambling (tempering) matrix (public static member constant)
constexpr UIntType tempering_b staticthe template parameter b, fourth component of the bit-scrambling (tempering) matrix (public static member constant)
constexpr size_t tempering_t staticthe template parameter t, fifth component of the bit-scrambling (tempering) matrix (public static member constant)
constexpr UIntType tempering_c staticthe template parameter c, sixth component of the bit-scrambling (tempering) matrix (public static member constant)
constexpr size_t tempering_l staticthe template parameter l, seventh component of the bit-scrambling (tempering) matrix (public static member constant)
constexpr UIntType initialization_multiplier staticthe template parameter f (public static member constant)
constexpr UIntType default_seed staticthe constant value 5489u (public static member constant)

注记

默认构造的第一万个连续调用。std::mt19937是产生价值的必要条件。4123659995...

默认构造的第一万个连续调用。std::mt19937_64是产生价值的必要条件。9981545732273789042...

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/数值/随机/Mersenne[医]捻线机[医]发动机