|
MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
|
梅森旋转随机数生成器 更多...
#include <random.hpp>
Public 类型 | |
| using | seed_type = uint32_t |
| 种子类型 | |
Public 成员函数 | |
| random_mt () | |
| 默认构造函数 默认使用当前时间戳值作为种子。 | |
| random_mt (const seed_type seed) | |
| 带种子构造函数 | |
| random_mt (const random_mt &other)=default | |
| 拷贝构造函数 | |
| random_mt & | operator= (const random_mt &other)=default |
| 拷贝赋值运算符 | |
| random_mt (random_mt &&other) noexcept=default | |
| 移动构造函数 | |
| random_mt & | operator= (random_mt &&other) noexcept=default |
| 移动赋值运算符 | |
| void | set_seed (seed_type seed) |
| 设置随机数种子 | |
| int | next_int (int max) |
| 生成[0, max)范围内的随机整数 | |
| int | next_int (const int min, const int max) |
| 生成[min, max)范围内的随机整数 | |
| int | next_int () |
| 生成[0, numeric_traits<int32_t>::max())范围内的随机整数 | |
| double | next_double () |
| 生成[0.0, 1.0)范围内的随机双精度浮点数 | |
| double | next_double (const double min, const double max) |
| 生成[min, max)范围内的随机双精度浮点数 | |
| double | next_double (const double max) |
| 生成[0.0, max)范围内的随机双精度浮点数 | |
梅森旋转随机数生成器
使用梅森旋转算法 Mersenne Twister 生成高质量伪随机数, 周期长(2^19937-1), 随机性良好,但生成速度较慢。
在文件 random.hpp 第 123 行定义.
|
inlineexplicit |
| double random_mt::next_double | ( | ) |
|
inline |
生成[0.0, max)范围内的随机双精度浮点数
| max | 上限(不包含) |
在文件 random.hpp 第 218 行定义.
引用了 max() , 以及 next_double().
|
inline |
生成[min, max)范围内的随机双精度浮点数
| min | 下限(包含) |
| max | 上限(不包含) |
在文件 random.hpp 第 208 行定义.
引用了 max(), min() , 以及 next_double().
|
inline |
生成[0, numeric_traits<int32_t>::max())范围内的随机整数
在文件 random.hpp 第 192 行定义.
引用了 numeric_traits< T, Dummy >::max() , 以及 next_int().
|
inline |
生成[min, max)范围内的随机整数
| min | 下限(包含) |
| max | 上限(不包含) |
在文件 random.hpp 第 183 行定义.
引用了 max(), min() , 以及 next_int().
| int random_mt::next_int | ( | int | max | ) |
| void random_mt::set_seed | ( | seed_type | seed | ) |