rand/xoshiro: simplify state initialisation from seed_seq

This commit is contained in:
Danny Robson 2020-11-12 11:07:14 +10:00
parent 7185af7961
commit 82d3c36ebd

View File

@ -39,18 +39,11 @@ xoshiro256plusplus::xoshiro256plusplus (u64 _seed)
//-----------------------------------------------------------------------------
xoshiro256plusplus::xoshiro256plusplus (std::seed_seq &seq)
{
std::generate (
std::begin (m_state),
std::end (m_state),
[&] (void) {
u64 parts[2];
seq.generate (
std::begin (parts),
std::end (parts)
);
return parts[0] << 4 | parts[1];
}
);
u32 parts[8];
seq.generate (std::begin (parts), std::end (parts));
for (int i = 0; i < std::ssize (m_state); ++i)
m_state[i] = u64 (parts[i * 2]) << 32 | parts[i * 2 + 1];
}