0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 22:41:12 +01:00

ircd::rand: Add random distribution vector generation.

This commit is contained in:
Jason Volk 2021-02-26 14:18:14 -08:00
parent 9d1316b412
commit 14662b51ce

View file

@ -41,6 +41,11 @@ namespace ircd::rand
template<> u256x1 vector() noexcept;
template<> u512x1 vector() noexcept;
// Random vector over distribution
template<class T,
class distribution>
T vector(distribution &);
// Random fill of buffer
const_buffer fill(const mutable_buffer &out) noexcept;
@ -98,6 +103,23 @@ noexcept
return dict[pos];
}
template<class T,
class distribution>
inline T
ircd::rand::vector(distribution &dist)
{
constexpr auto lanes
{
simd::lanes<T>()
};
T ret;
for(unsigned i(0); i < lanes; ++i)
ret[i] = dist(mt);
return ret;
}
inline
ircd::rand::xoshiro256p::xoshiro256p()
noexcept