|
RandX 1.4.3
基于 xoshiro/xoroshiro 算法族的纯头文件伪随机数生成器库
|
8 个伪随机数生成引擎(7 非 CSPRNG + 1 ChaCha20 CSPRNG) 更多...

命名空间 | |
| namespace | RandX::detail |
类 | |
| class | RandX::SplitMix64 |
| SplitMix64 伪随机数生成器,64 位输出,周期 2^64。 更多... | |
| class | RandX::Xoshiro256StarStar |
| Xoshiro256** 伪随机数生成器,64 位输出,周期 2^256-1。 更多... | |
| class | RandX::Xoroshiro128StarStar |
| Xoroshiro128** 伪随机数生成器,64 位输出,周期 2^128-1。 更多... | |
| class | RandX::Xoshiro128StarStar |
| Xoshiro128** 伪随机数生成器,32 位输出,周期 2^128-1。 更多... | |
| class | RandX::Xoroshiro64StarStar |
| Xoroshiro64** 伪随机数生成器,32 位输出,周期 2^64-1。 更多... | |
| class | RandX::SFC64 |
| SFC64(Small Fast Counter)伪随机数生成器,64 位输出,周期 >= 2^64。 更多... | |
| class | RandX::RomuDuoJr |
| RomuDuoJr 伪随机数生成器,64 位输出,周期估计 >= 2^51。 更多... | |
| class | RandX::ChaCha20 |
| ChaCha20 密码学安全伪随机数生成器(CSPRNG),64 位输出,符合 RFC 8439。 更多... | |
类型定义 | |
| using | RandX::SplitMix64::state_type = std::uint64_t |
| 状态类型(1×uint64) | |
| using | RandX::SplitMix64::result_type = std::uint64_t |
| 输出类型 | |
| using | RandX::Xoshiro256StarStar::state_type = std::array<std::uint64_t, 4> |
| 状态类型(4×uint64) | |
| using | RandX::Xoshiro256StarStar::result_type = std::uint64_t |
| 输出类型 | |
| using | RandX::Xoroshiro128StarStar::state_type = std::array<std::uint64_t, 2> |
| 状态类型(2×uint64) | |
| using | RandX::Xoroshiro128StarStar::result_type = std::uint64_t |
| 输出类型 | |
| using | RandX::Xoshiro128StarStar::state_type = std::array<std::uint32_t, 4> |
| 状态类型(4×uint32) | |
| using | RandX::Xoshiro128StarStar::result_type = std::uint32_t |
| 输出类型 | |
| using | RandX::Xoroshiro64StarStar::state_type = std::array<std::uint32_t, 2> |
| 状态类型(2×uint32) | |
| using | RandX::Xoroshiro64StarStar::result_type = std::uint32_t |
| 输出类型 | |
| using | RandX::SFC64::state_type = std::array<std::uint64_t, 4> |
| 状态类型(4×uint64) | |
| using | RandX::SFC64::result_type = std::uint64_t |
| 输出类型 | |
| using | RandX::RomuDuoJr::state_type = std::array<std::uint64_t, 2> |
| 状态类型(2×uint64) | |
| using | RandX::RomuDuoJr::result_type = std::uint64_t |
| 输出类型 | |
| using | RandX::ChaCha20::result_type = std::uint64_t |
| 输出类型 | |
函数 | |
| constexpr | RandX::SplitMix64::SplitMix64 (state_type state=DefaultSeed) noexcept |
| 以指定状态构造引擎 | |
| template<class SeedSeq> requires (!std::same_as<std::remove_cvref_t<SeedSeq>, SplitMix64>) | |
| constexpr | RandX::SplitMix64::SplitMix64 (SeedSeq &seq) |
| 从 std::seed_seq 播种 | |
| constexpr result_type | RandX::SplitMix64::operator() () noexcept |
| 生成下一个 64 位随机数 | |
| constexpr void | RandX::SplitMix64::discard (unsigned long long n) noexcept |
| 跳过 n 个输出 | |
| template<std::size_t N> | |
| constexpr std::array< std::uint64_t, N > | RandX::SplitMix64::generateSeedSequence () noexcept |
| 生成 N 个高质量的 64 位种子序列 | |
| static constexpr result_type | RandX::SplitMix64::min () noexcept |
| 输出范围下界 | |
| static constexpr result_type | RandX::SplitMix64::max () noexcept |
| 输出范围上界 | |
| constexpr state_type | RandX::SplitMix64::serialize () const noexcept |
| 序列化引擎状态 | |
| constexpr void | RandX::SplitMix64::deserialize (state_type state) noexcept |
| 从状态恢复引擎 | |
| constexpr | RandX::Xoshiro256StarStar::Xoshiro256StarStar (std::uint64_t seed=DefaultSeed) noexcept |
| 以指定种子构造引擎 | |
| template<class SeedSeq> requires (!std::same_as<std::remove_cvref_t<SeedSeq>, Xoshiro256StarStar>) | |
| constexpr | RandX::Xoshiro256StarStar::Xoshiro256StarStar (SeedSeq &seq) |
| 从 std::seed_seq 播种 | |
| constexpr | RandX::Xoshiro256StarStar::Xoshiro256StarStar (state_type state) noexcept |
| 从状态数组直接构造 | |
| constexpr result_type | RandX::Xoshiro256StarStar::operator() () noexcept |
| 生成下一个 64 位随机数 | |
| constexpr void | RandX::Xoshiro256StarStar::discard (unsigned long long n) noexcept |
| 跳过 n 个输出 | |
| constexpr void | RandX::Xoshiro256StarStar::jump () noexcept |
| 前进 2^128 步,用于创建并行子序列 | |
| constexpr void | RandX::Xoshiro256StarStar::longJump () noexcept |
| 前进 2^192 步,用于创建更稀疏的并行子序列 | |
| static constexpr result_type | RandX::Xoshiro256StarStar::min () noexcept |
| 输出范围下界 | |
| static constexpr result_type | RandX::Xoshiro256StarStar::max () noexcept |
| 输出范围上界 | |
| constexpr state_type | RandX::Xoshiro256StarStar::serialize () const noexcept |
| 序列化引擎状态 | |
| constexpr void | RandX::Xoshiro256StarStar::deserialize (state_type state) noexcept |
| 从状态恢复引擎 | |
| constexpr | RandX::Xoroshiro128StarStar::Xoroshiro128StarStar (std::uint64_t seed=DefaultSeed) noexcept |
| 以指定种子构造引擎 | |
| template<class SeedSeq> requires (!std::same_as<std::remove_cvref_t<SeedSeq>, Xoroshiro128StarStar>) | |
| constexpr | RandX::Xoroshiro128StarStar::Xoroshiro128StarStar (SeedSeq &seq) |
| 从 std::seed_seq 播种 | |
| constexpr | RandX::Xoroshiro128StarStar::Xoroshiro128StarStar (state_type state) noexcept |
| 从状态数组直接构造 | |
| constexpr result_type | RandX::Xoroshiro128StarStar::operator() () noexcept |
| 生成下一个 64 位随机数 | |
| constexpr void | RandX::Xoroshiro128StarStar::discard (unsigned long long n) noexcept |
| 跳过 n 个输出 | |
| constexpr void | RandX::Xoroshiro128StarStar::jump () noexcept |
| 前进 2^64 步,用于创建并行子序列 | |
| constexpr void | RandX::Xoroshiro128StarStar::longJump () noexcept |
| 前进 2^96 步,用于创建更稀疏的并行子序列 | |
| static constexpr result_type | RandX::Xoroshiro128StarStar::min () noexcept |
| 输出范围下界 | |
| static constexpr result_type | RandX::Xoroshiro128StarStar::max () noexcept |
| 输出范围上界 | |
| constexpr state_type | RandX::Xoroshiro128StarStar::serialize () const noexcept |
| 序列化引擎状态 | |
| constexpr void | RandX::Xoroshiro128StarStar::deserialize (state_type state) noexcept |
| 从状态恢复引擎 | |
| constexpr | RandX::Xoshiro128StarStar::Xoshiro128StarStar (std::uint64_t seed=DefaultSeed) noexcept |
| 以指定种子构造引擎 | |
| template<class SeedSeq> requires (!std::same_as<std::remove_cvref_t<SeedSeq>, Xoshiro128StarStar>) | |
| constexpr | RandX::Xoshiro128StarStar::Xoshiro128StarStar (SeedSeq &seq) |
| 从 std::seed_seq 播种 | |
| constexpr | RandX::Xoshiro128StarStar::Xoshiro128StarStar (state_type state) noexcept |
| 从状态数组直接构造 | |
| constexpr result_type | RandX::Xoshiro128StarStar::operator() () noexcept |
| 生成下一个 32 位随机数 | |
| constexpr void | RandX::Xoshiro128StarStar::discard (unsigned long long n) noexcept |
| 跳过 n 个输出 | |
| constexpr void | RandX::Xoshiro128StarStar::jump () noexcept |
| 前进 2^64 步,用于创建并行子序列 | |
| constexpr void | RandX::Xoshiro128StarStar::longJump () noexcept |
| 前进 2^96 步,用于创建更稀疏的并行子序列 | |
| static constexpr result_type | RandX::Xoshiro128StarStar::min () noexcept |
| 输出范围下界 | |
| static constexpr result_type | RandX::Xoshiro128StarStar::max () noexcept |
| 输出范围上界 | |
| constexpr state_type | RandX::Xoshiro128StarStar::serialize () const noexcept |
| 序列化引擎状态 | |
| constexpr void | RandX::Xoshiro128StarStar::deserialize (state_type state) noexcept |
| 从状态恢复引擎 | |
| constexpr | RandX::Xoroshiro64StarStar::Xoroshiro64StarStar (std::uint64_t seed=DefaultSeed) noexcept |
| 以指定种子构造引擎 | |
| template<class SeedSeq> requires (!std::same_as<std::remove_cvref_t<SeedSeq>, Xoroshiro64StarStar>) | |
| constexpr | RandX::Xoroshiro64StarStar::Xoroshiro64StarStar (SeedSeq &seq) |
| 从 std::seed_seq 播种 | |
| constexpr | RandX::Xoroshiro64StarStar::Xoroshiro64StarStar (state_type state) noexcept |
| 从状态数组直接构造 | |
| constexpr result_type | RandX::Xoroshiro64StarStar::operator() () noexcept |
| 生成下一个 32 位随机数 | |
| constexpr void | RandX::Xoroshiro64StarStar::discard (unsigned long long n) noexcept |
| 跳过 n 个输出 | |
| static constexpr result_type | RandX::Xoroshiro64StarStar::min () noexcept |
| 输出范围下界 | |
| static constexpr result_type | RandX::Xoroshiro64StarStar::max () noexcept |
| 输出范围上界 | |
| constexpr state_type | RandX::Xoroshiro64StarStar::serialize () const noexcept |
| 序列化引擎状态 | |
| constexpr void | RandX::Xoroshiro64StarStar::deserialize (state_type state) noexcept |
| 从状态恢复引擎 | |
| constexpr | RandX::SFC64::SFC64 (std::uint64_t seed=DefaultSeed) noexcept |
| 以指定种子构造引擎 | |
| template<class SeedSeq> requires (!std::same_as<std::remove_cvref_t<SeedSeq>, SFC64>) | |
| constexpr | RandX::SFC64::SFC64 (SeedSeq &seq) |
| 从 std::seed_seq 播种 | |
| constexpr | RandX::SFC64::SFC64 (state_type state) noexcept |
| 从状态数组直接构造 | |
| constexpr result_type | RandX::SFC64::operator() () noexcept |
| 生成下一个 64 位随机数 | |
| constexpr void | RandX::SFC64::discard (unsigned long long n) noexcept |
| 跳过 n 个输出 | |
| static constexpr result_type | RandX::SFC64::min () noexcept |
| 输出范围下界 | |
| static constexpr result_type | RandX::SFC64::max () noexcept |
| 输出范围上界 | |
| constexpr state_type | RandX::SFC64::serialize () const noexcept |
| 序列化引擎状态 | |
| constexpr void | RandX::SFC64::deserialize (state_type state) noexcept |
| 从状态恢复引擎 | |
| constexpr | RandX::RomuDuoJr::RomuDuoJr (std::uint64_t seed=DefaultSeed) noexcept |
| 以指定种子构造引擎 | |
| template<class SeedSeq> requires (!std::same_as<std::remove_cvref_t<SeedSeq>, RomuDuoJr>) | |
| constexpr | RandX::RomuDuoJr::RomuDuoJr (SeedSeq &seq) |
| 从 std::seed_seq 播种 | |
| constexpr | RandX::RomuDuoJr::RomuDuoJr (state_type state) noexcept |
| 从状态数组直接构造 | |
| constexpr result_type | RandX::RomuDuoJr::operator() () noexcept |
| 生成下一个 64 位随机数 | |
| constexpr void | RandX::RomuDuoJr::discard (unsigned long long n) noexcept |
| 跳过 n 个输出 | |
| static constexpr result_type | RandX::RomuDuoJr::min () noexcept |
| 输出范围下界 | |
| static constexpr result_type | RandX::RomuDuoJr::max () noexcept |
| 输出范围上界 | |
| constexpr state_type | RandX::RomuDuoJr::serialize () const noexcept |
| 序列化引擎状态 | |
| constexpr void | RandX::RomuDuoJr::deserialize (state_type state) noexcept |
| 从状态恢复引擎 | |
| RandX::ChaCha20::ChaCha20 (const ChaCha20 &)=delete | |
| ChaCha20 & | RandX::ChaCha20::operator= (const ChaCha20 &)=delete |
| RandX::ChaCha20::ChaCha20 (ChaCha20 &&other) noexcept | |
| ChaCha20 & | RandX::ChaCha20::operator= (ChaCha20 &&other) noexcept |
| RandX::ChaCha20::~ChaCha20 () noexcept | |
| RandX::ChaCha20::ChaCha20 () | |
| 构造方式 1:从 OS 熵自动播种(密码学安全,默认) | |
| RandX::ChaCha20::ChaCha20 (std::uint64_t seed) | |
| 构造方式 2:以显式 64 位种子构造 | |
| RandX::ChaCha20::ChaCha20 (const std::uint8_t *key, std::size_t keyLen, const std::uint8_t *nonce, std::size_t nonceLen, std::uint32_t counter=0) | |
| 构造方式 3:直接指定 key + nonce + counter(高级用法/测试复现) | |
| result_type | RandX::ChaCha20::operator() () |
| 生成下一个 64 位随机数 | |
| void | RandX::ChaCha20::discard (unsigned long long n) |
| 跳过 n 个输出 | |
| void | RandX::ChaCha20::reseed () |
| 从 OS 熵重新播种 | |
| static constexpr result_type | RandX::ChaCha20::min () noexcept |
| 输出范围下界 | |
| static constexpr result_type | RandX::ChaCha20::max () noexcept |
| 输出范围上界 | |
| template<std::same_as< std::uint32_t > Uint32> | |
| constexpr float | RandX::FloatFromBits (Uint32 i) noexcept |
| template<std::same_as< std::uint64_t > Uint64> | |
| constexpr double | RandX::DoubleFromBits (Uint64 i) noexcept |
| template<class CharT, class Traits, detail::SerializableEngine Engine> | |
| std::basic_ostream< CharT, Traits > & | RandX::operator<< (std::basic_ostream< CharT, Traits > &os, const Engine &engine) |
| template<class CharT, class Traits, detail::SerializableEngine Engine> | |
| std::basic_istream< CharT, Traits > & | RandX::operator>> (std::basic_istream< CharT, Traits > &is, Engine &engine) |
| std::uint64_t | RandX::RandomSeed () |
| 生成非确定性的 64 位种子 | |
| Xoshiro256StarStar & | RandX::DefaultEngine () |
友元 | |
| auto | RandX::SplitMix64::operator<=> (const SplitMix64 &, const SplitMix64 &)=default |
| auto | RandX::Xoshiro256StarStar::operator<=> (const Xoshiro256StarStar &, const Xoshiro256StarStar &)=default |
| auto | RandX::Xoroshiro128StarStar::operator<=> (const Xoroshiro128StarStar &, const Xoroshiro128StarStar &)=default |
| auto | RandX::Xoshiro128StarStar::operator<=> (const Xoshiro128StarStar &, const Xoshiro128StarStar &)=default |
| auto | RandX::Xoroshiro64StarStar::operator<=> (const Xoroshiro64StarStar &, const Xoroshiro64StarStar &)=default |
| auto | RandX::SFC64::operator<=> (const SFC64 &, const SFC64 &)=default |
| auto | RandX::RomuDuoJr::operator<=> (const RomuDuoJr &, const RomuDuoJr &)=default |
8 个伪随机数生成引擎(7 非 CSPRNG + 1 ChaCha20 CSPRNG)
| using RandX::ChaCha20::result_type = std::uint64_t |
输出类型
| using RandX::RomuDuoJr::result_type = std::uint64_t |
输出类型
| using RandX::SFC64::result_type = std::uint64_t |
输出类型
| using RandX::SplitMix64::result_type = std::uint64_t |
输出类型
| using RandX::Xoroshiro128StarStar::result_type = std::uint64_t |
输出类型
| using RandX::Xoroshiro64StarStar::result_type = std::uint32_t |
输出类型
| using RandX::Xoshiro128StarStar::result_type = std::uint32_t |
输出类型
| using RandX::Xoshiro256StarStar::result_type = std::uint64_t |
输出类型
| using RandX::RomuDuoJr::state_type = std::array<std::uint64_t, 2> |
状态类型(2×uint64)
| using RandX::SFC64::state_type = std::array<std::uint64_t, 4> |
状态类型(4×uint64)
| using RandX::SplitMix64::state_type = std::uint64_t |
状态类型(1×uint64)
| using RandX::Xoroshiro128StarStar::state_type = std::array<std::uint64_t, 2> |
状态类型(2×uint64)
| using RandX::Xoroshiro64StarStar::state_type = std::array<std::uint32_t, 2> |
状态类型(2×uint32)
| using RandX::Xoshiro128StarStar::state_type = std::array<std::uint32_t, 4> |
状态类型(4×uint32)
| using RandX::Xoshiro256StarStar::state_type = std::array<std::uint64_t, 4> |
状态类型(4×uint64)
|
inline |
构造方式 1:从 OS 熵自动播种(密码学安全,默认)

|
inlinenoexcept |

|
delete |

|
inline |
构造方式 3:直接指定 key + nonce + counter(高级用法/测试复现)
| key | 密钥指针,须为 32 字节 |
| keyLen | 密钥长度(字节),须为 32,否则抛出 std::invalid_argument |
| nonce | 随机数指针,须为 12 字节 |
| nonceLen | 随机数长度(字节),须为 12,否则抛出 std::invalid_argument |
| counter | 32-bit block 计数器初值(默认 0;KAT 测试时显式传 1) |
|
inlineexplicitnodiscard |
构造方式 2:以显式 64 位种子构造
| seed | 64 位种子值 |
|
inlinenodiscard |

|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inline |
跳过 n 个输出
| n | 跳过次数 |
|
inlineconstexprnoexcept |
跳过 n 个输出
| n | 跳过次数 |

|
inlineconstexprnoexcept |
跳过 n 个输出
| n | 跳过次数 |

|
inlineconstexprnoexcept |
跳过 n 个输出
| n | 跳过次数 |

|
inlineconstexprnoexcept |
跳过 n 个输出
| n | 跳过次数 |

|
inlineconstexprnoexcept |
跳过 n 个输出
| n | 跳过次数 |

|
inlineconstexprnoexcept |
跳过 n 个输出
| n | 跳过次数 |

|
inlineconstexprnoexcept |
跳过 n 个输出
| n | 跳过次数 |

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

|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinestaticnodiscardconstexprnoexcept |
输出范围上界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围上界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围上界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围上界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围上界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围上界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围上界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围上界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围下界

|
inlinestaticnodiscardconstexprnoexcept |
输出范围下界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围下界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围下界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围下界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围下界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围下界
|
inlinestaticnodiscardconstexprnoexcept |
输出范围下界
|
inline |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
| std::basic_ostream< CharT, Traits > & RandX::operator<< | ( | std::basic_ostream< CharT, Traits > & | os, |
| const Engine & | engine ) |
| std::basic_istream< CharT, Traits > & RandX::operator>> | ( | std::basic_istream< CharT, Traits > & | is, |
| Engine & | engine ) |
|
inlinenodiscard |
生成非确定性的 64 位种子

|
inline |
从 OS 熵重新播种

|
inlineexplicitnodiscardconstexpr |
从 std::seed_seq 播种
| seq | 种子序列对象 |

|
inlineexplicitnodiscardconstexprnoexcept |
从状态数组直接构造
| state | serialize() 返回的状态 |
|
inlineexplicitnodiscardconstexprnoexcept |
以指定种子构造引擎
| seed | 64 位种子值 |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlineexplicitnodiscardconstexpr |
从 std::seed_seq 播种
| seq | 种子序列对象 |

|
inlineexplicitnodiscardconstexprnoexcept |
从状态数组直接构造
| state | serialize() 返回的状态 |
|
inlineexplicitnodiscardconstexprnoexcept |
以指定种子构造引擎
| seed | 64 位种子值 |

|
inlineexplicitnodiscardconstexpr |
从 std::seed_seq 播种
| seq | 种子序列对象 |

|
inlineexplicitnodiscardconstexprnoexcept |
以指定状态构造引擎
| state | 64 位初始状态值 |
|
inlineexplicitnodiscardconstexpr |
从 std::seed_seq 播种
| seq | 种子序列对象 |

|
inlineexplicitnodiscardconstexprnoexcept |
|
inlineexplicitnodiscardconstexprnoexcept |
以指定种子构造引擎
| seed | 64 位种子值 |
|
inlineexplicitnodiscardconstexpr |
从 std::seed_seq 播种
| seq | 种子序列对象 |

|
inlineexplicitnodiscardconstexprnoexcept |
|
inlineexplicitnodiscardconstexprnoexcept |
以指定种子构造引擎
| seed | 64 位种子值 |

|
inlineexplicitnodiscardconstexpr |
从 std::seed_seq 播种
| seq | 种子序列对象 |

|
inlineexplicitnodiscardconstexprnoexcept |
|
inlineexplicitnodiscardconstexprnoexcept |
以指定种子构造引擎
| seed | 64 位种子值 |

|
inlineexplicitnodiscardconstexpr |
从 std::seed_seq 播种
| seq | 种子序列对象 |

|
inlineexplicitnodiscardconstexprnoexcept |
|
inlineexplicitnodiscardconstexprnoexcept |
以指定种子构造引擎
| seed | 64 位种子值 |
|
inlinenoexcept |

|
friend |
|
friend |
|
friend |
|
friend |
|
friend |