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

SplitMix64 伪随机数生成器,64 位输出,周期 2^64。 更多...

#include <RandX.hpp>

Public 类型

using state_type = std::uint64_t
 状态类型(1×uint64)
using result_type = std::uint64_t
 输出类型
using state_type = std::uint64_t
 状态类型(1×uint64)
using result_type = std::uint64_t
 输出类型

Public 成员函数

constexpr SplitMix64 (state_type state=DefaultSeed) noexcept
 以指定状态构造引擎
template<class SeedSeq>
requires (!std::same_as<std::remove_cvref_t<SeedSeq>, SplitMix64>)
constexpr SplitMix64 (SeedSeq &seq)
 从 std::seed_seq 播种
constexpr result_type operator() () noexcept
 生成下一个 64 位随机数
constexpr void discard (unsigned long long n) noexcept
 跳过 n 个输出
template<std::size_t N>
constexpr std::array< std::uint64_t, N > generateSeedSequence () noexcept
 生成 N 个高质量的 64 位种子序列
constexpr state_type serialize () const noexcept
 序列化引擎状态
constexpr void deserialize (state_type state) noexcept
 从状态恢复引擎
RANDX_NODISCARD_CXX20 constexpr SplitMix64 (state_type state=DefaultSeed) noexcept
 以指定状态构造引擎
template<class SeedSeq, std::enable_if_t<!std::is_same_v< std::decay_t< SeedSeq >, SplitMix64 > > * = nullptr>
RANDX_NODISCARD_CXX20 constexpr SplitMix64 (SeedSeq &seq)
 从 std::seed_seq 播种
constexpr result_type operator() () noexcept
 生成下一个 64 位随机数
constexpr void discard (unsigned long long n) noexcept
 跳过 n 个输出
template<std::size_t N>
constexpr std::array< std::uint64_t, N > generateSeedSequence () noexcept
 生成 N 个高质量的 64 位种子序列
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 >, SplitMix64 > > *>
constexpr SplitMix64 (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 SplitMix64 &, const SplitMix64 &)=default
bool operator== (const SplitMix64 &lhs, const SplitMix64 &rhs) noexcept
bool operator!= (const SplitMix64 &lhs, const SplitMix64 &rhs) noexcept

详细描述

SplitMix64 伪随机数生成器,64 位输出,周期 2^64。

状态 8 字节(1×uint64)。主要用于种子扩展与哈希, 可将单个 64 位种子展开为高质量的状态序列。 原始实现:http://prng.di.unimi.it/splitmix64.c

注解
非通用 PRNG,无 jump 方法。
参见
Xoshiro256StarStar, Xoroshiro128StarStar

成员类型定义说明

◆ result_type

using RandX::SplitMix64::result_type = std::uint64_t

输出类型

◆ state_type

using RandX::SplitMix64::state_type = std::uint64_t

状态类型(1×uint64)

构造及析构函数说明

◆ SplitMix64() [1/3]

RANDX_NODISCARD_CXX20 constexpr RandX::SplitMix64::SplitMix64 ( state_type state = DefaultSeed)
explicitconstexprnoexcept

以指定状态构造引擎

参数
state64 位初始状态值
函数调用图:

◆ SplitMix64() [2/3]

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

从 std::seed_seq 播种

参数
seq种子序列对象

◆ SplitMix64() [3/3]

template<class SeedSeq, std::enable_if_t<!std::is_same_v< std::decay_t< SeedSeq >, SplitMix64 > > *>
RandX::SplitMix64::SplitMix64 ( SeedSeq & seq)
inlineconstexpr

成员函数说明

◆ deserialize()

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

从状态恢复引擎

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

◆ discard()

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

跳过 n 个输出

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

◆ generateSeedSequence()

template<std::size_t N>
std::array< std::uint64_t, N > RandX::SplitMix64::generateSeedSequence ( )
nodiscardconstexprnoexcept

生成 N 个高质量的 64 位种子序列

模板参数
N生成的种子数量
返回
包含 N 个 uint64 的数组,可用于播种其他引擎
函数调用图:

◆ max()

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

输出范围上界

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

◆ min()

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

输出范围下界

返回
0
函数调用图:

◆ operator()()

result_type RandX::SplitMix64::operator() ( )
constexprnoexcept

生成下一个 64 位随机数

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

◆ serialize()

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

序列化引擎状态

返回
当前状态值
参见
deserialize()
函数调用图:

◆ operator!=

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

◆ operator==

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

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