1 #ifndef BLANK_RAND_GALOISLFSR_HPP_
2 #define BLANK_RAND_GALOISLFSR_HPP_
13 // seed should be non-zero
14 explicit GaloisLFSR(std::uint64_t seed) noexcept
18 bool operator ()() noexcept {
19 bool result = state & 1;
22 state |= 0x8000000000000000;
25 state &= 0x7FFFFFFFFFFFFFFF;
31 T operator ()(T &out) noexcept {
32 constexpr int num_bits =
33 std::numeric_limits<T>::digits +
34 std::numeric_limits<T>::is_signed;
35 for (int i = 0; i < num_bits; ++i) {
38 return out = static_cast<T>(state);
49 // bits 64, 63, 61, and 60 set to 1 (counting from 1 lo to hi)
50 static constexpr std::uint64_t mask = 0xD800000000000000;