RandX 1.4.3
基于 xoshiro/xoroshiro 算法族的纯头文件伪随机数生成器库
载入中...
搜索中...
未找到
RandX::SFC64类 参考

SFC64(Small Fast Counter)伪随机数生成器,64 位输出,周期 >= 2^64。 更多...

#include <RandX.hpp>

Public 类型

using state_type = std::array<std::uint64_t, 4>
 状态类型(4×uint64)
using result_type = std::uint64_t
 输出类型
using state_type = std::array<std::uint64_t, 4>
 状态类型(4×uint64)
using result_type = std::uint64_t
 输出类型

Public 成员函数

constexpr SFC64 (std::uint64_t seed=DefaultSeed) noexcept
 以指定种子构造引擎
template<class SeedSeq>
requires (!std::same_as<std::remove_cvref_t<SeedSeq>, SFC64>)
constexpr SFC64 (SeedSeq &seq)
 从 std::seed_seq 播种
constexpr SFC64 (state_type state) noexcept
 从状态数组直接构造
constexpr result_type operator() () noexcept
 生成下一个 64 位随机数
constexpr void discard (unsigned long long n) noexcept
 跳过 n 个输出
constexpr state_type serialize () const noexcept
 序列化引擎状态
constexpr void deserialize (state_type state) noexcept
 从状态恢复引擎
constexpr SFC64 (std::uint64_t seed=DefaultSeed) noexcept
 以指定种子构造引擎
template<class SeedSeq, std::enable_if_t<!std::is_same_v< std::decay_t< SeedSeq >, SFC64 > > * = nullptr>
RANDX_NODISCARD_CXX20 constexpr SFC64 (SeedSeq &seq)
 从 std::seed_seq 播种
constexpr SFC64 (state_type state) noexcept
 从状态数组直接构造
constexpr result_type operator() () noexcept
 生成下一个 64 位随机数
constexpr void discard (unsigned long long n) noexcept
 跳过 n 个输出
constexpr state_type serialize () const noexcept
 序列化引擎状态
constexpr void deserialize (state_type state) noexcept
 从状态恢复引擎
template<class SeedSeq, std::enable_if_t<!std::is_same_v< std::decay_t< SeedSeq >, SFC64 > > *>
constexpr SFC64 (SeedSeq &seq)

静态 Public 成员函数

static constexpr result_type min () noexcept
 输出范围下界
static constexpr result_type max () noexcept
 输出范围上界
static constexpr result_type min () noexcept
 输出范围下界
static constexpr result_type max () noexcept
 输出范围上界

友元

auto operator<=> (const SFC64 &, const SFC64 &)=default
bool operator== (const SFC64 &lhs, const SFC64 &rhs) noexcept
bool operator!= (const SFC64 &lhs, const SFC64 &rhs) noexcept

详细描述

SFC64(Small Fast Counter)伪随机数生成器,64 位输出,周期 >= 2^64。

状态 32 字节(4×uint64)。由 Chris Doty-Humphrey(PractRand)设计, 速度极快,通过 PractRand 全部统计测试。满足 std::uniform_random_bit_generator 概念。

注解
周期由 counter 保证 >= 2^64。无 jump 方法。 非 CSPRNG,不可用于密码学场景。安全场景请使用 ChaCha20。
参见
Xoshiro256StarStar, RomuDuoJr, ChaCha20

成员类型定义说明

◆ result_type

using RandX::SFC64::result_type = std::uint64_t

输出类型

◆ state_type

using RandX::SFC64::state_type = std::array<std::uint64_t, 4>

状态类型(4×uint64)

构造及析构函数说明

◆ SFC64() [1/4]

RandX::SFC64::SFC64 ( std::uint64_t seed = DefaultSeed)
explicitnodiscardconstexprnoexcept

以指定种子构造引擎

参数
seed64 位种子值
函数调用图:

◆ SFC64() [2/4]

template<class SeedSeq, std::enable_if_t<!std::is_same_v< std::decay_t< SeedSeq >, SFC64 > > * = nullptr>
RANDX_NODISCARD_CXX20 constexpr RandX::SFC64::SFC64 ( SeedSeq & seq)
explicitconstexpr

从 std::seed_seq 播种

参数
seq种子序列对象

◆ SFC64() [3/4]

RandX::SFC64::SFC64 ( state_type state)
explicitnodiscardconstexprnoexcept

从状态数组直接构造

参数
stateserialize() 返回的状态

◆ SFC64() [4/4]

template<class SeedSeq, std::enable_if_t<!std::is_same_v< std::decay_t< SeedSeq >, SFC64 > > *>
RandX::SFC64::SFC64 ( SeedSeq & seq)
inlineconstexpr
函数调用图:

成员函数说明

◆ deserialize()

void RandX::SFC64::deserialize ( state_type state)
constexprnoexcept

从状态恢复引擎

参数
stateserialize() 返回的状态
参见
serialize()
函数调用图:

◆ discard()

void RandX::SFC64::discard ( unsigned long long n)
constexprnoexcept

跳过 n 个输出

参数
n跳过次数
函数调用图:

◆ max()

constexpr result_type RandX::SFC64::max ( )
staticnodiscardconstexprnoexcept

输出范围上界

返回
2^64 - 1
函数调用图:

◆ min()

constexpr result_type RandX::SFC64::min ( )
staticnodiscardconstexprnoexcept

输出范围下界

返回
0
函数调用图:

◆ operator()()

result_type RandX::SFC64::operator() ( )
constexprnoexcept

生成下一个 64 位随机数

返回
[min(), max()] 区间内的伪随机数

◆ serialize()

state_type RandX::SFC64::serialize ( ) const
nodiscardconstexprnoexcept

序列化引擎状态

返回
状态数组(4 个 uint64)
参见
deserialize()
函数调用图:

◆ operator!=

bool operator!= ( const SFC64 & lhs,
const SFC64 & rhs )
friend

◆ operator==

bool operator== ( const SFC64 & lhs,
const SFC64 & rhs )
friend

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