MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
random_mt类 参考

梅森旋转随机数生成器 更多...

#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_mtoperator= (const random_mt &other)=default
 拷贝赋值运算符
 random_mt (random_mt &&other) noexcept=default
 移动构造函数
random_mtoperator= (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.hpp123 行定义.

构造及析构函数说明

◆ random_mt()

random_mt::random_mt ( const seed_type seed)
inlineexplicit

带种子构造函数

参数
seed初始种子值

在文件 random.hpp157 行定义.

引用了 set_seed().

成员函数说明

◆ next_double() [1/3]

double random_mt::next_double ( )

生成[0.0, 1.0)范围内的随机双精度浮点数

返回
[0.0, 1.0)范围内的随机双精度浮点数

被这些函数引用 next_double() , 以及 next_double().

◆ next_double() [2/3]

double random_mt::next_double ( const double max)
inline

生成[0.0, max)范围内的随机双精度浮点数

参数
max上限(不包含)
返回
[0.0, max)范围内的随机双精度浮点数

在文件 random.hpp218 行定义.

引用了 max() , 以及 next_double().

◆ next_double() [3/3]

double random_mt::next_double ( const double min,
const double max )
inline

生成[min, max)范围内的随机双精度浮点数

参数
min下限(包含)
max上限(不包含)
返回
[min, max)范围内的随机双精度浮点数

在文件 random.hpp208 行定义.

引用了 max(), min() , 以及 next_double().

◆ next_int() [1/3]

int random_mt::next_int ( )
inline

生成[0, numeric_traits<int32_t>::max())范围内的随机整数

返回
[0, numeric_traits<int32_t>::max())范围内的随机整数

在文件 random.hpp192 行定义.

引用了 numeric_traits< T, Dummy >::max() , 以及 next_int().

◆ next_int() [2/3]

int random_mt::next_int ( const int min,
const int max )
inline

生成[min, max)范围内的随机整数

参数
min下限(包含)
max上限(不包含)
返回
[min, max)范围内的随机整数

在文件 random.hpp183 行定义.

引用了 max(), min() , 以及 next_int().

◆ next_int() [3/3]

int random_mt::next_int ( int max)

生成[0, max)范围内的随机整数

参数
max上限(不包含)
返回
[0, max)范围内的随机整数

引用了 max().

被这些函数引用 next_int() , 以及 next_int().

◆ set_seed()

void random_mt::set_seed ( seed_type seed)

设置随机数种子

参数
seed新种子值

被这些函数引用 random_mt().


该类的文档由以下文件生成: