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

线性同余随机数生成器 更多...

#include <random.hpp>

Public 类型

using seed_type = uint32_t
 种子类型

Public 成员函数

 random_lcd ()
 默认构造函数 默认使用当前时间戳值作为种子。
 random_lcd (const seed_type seed)
 带种子构造函数
 random_lcd (const random_lcd &)=default
 拷贝构造函数
random_lcdoperator= (const random_lcd &)=default
 拷贝赋值运算符
 random_lcd (random_lcd &&)=default
 移动构造函数
random_lcdoperator= (random_lcd &&)=default
 移动赋值运算符
int next_int (const int max)
 生成[0, max)范围内的随机整数
int next_int (const int min, const int max)
 生成[min, max)范围内的随机整数
int next_int ()
 生成[0, INT32_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)范围内的随机双精度浮点数

详细描述

线性同余随机数生成器

使用线性同余算法 LCD 生成伪随机数,速度快但随机性一般。

在文件 random.hpp27 行定义.

构造及析构函数说明

◆ random_lcd()

random_lcd::random_lcd ( const seed_type seed)
inlineexplicit

带种子构造函数

参数
seed初始种子值

在文件 random.hpp49 行定义.

成员函数说明

◆ next_double() [1/3]

double random_lcd::next_double ( )
inline

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

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

在文件 random.hpp89 行定义.

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

◆ next_double() [2/3]

double random_lcd::next_double ( const double max)
inline

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

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

在文件 random.hpp110 行定义.

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

◆ next_double() [3/3]

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

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

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

在文件 random.hpp101 行定义.

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

◆ next_int() [1/3]

int random_lcd::next_int ( )
inline

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

返回
[0, INT32_MAX)范围内的随机整数

在文件 random.hpp81 行定义.

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

◆ next_int() [2/3]

int random_lcd::next_int ( const int max)
inline

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

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

在文件 random.hpp61 行定义.

引用了 max().

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

◆ next_int() [3/3]

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

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

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

在文件 random.hpp73 行定义.

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


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