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:
parent
9d1316b412
commit
14662b51ce
1 changed files with 22 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue