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
22 bool operator ()() noexcept {
23 bool result = state & 1;
26 state |= 0x8000000000000000;
29 state &= 0x7FFFFFFFFFFFFFFF;
35 T operator ()(T &out) noexcept {
36 constexpr int num_bits =
37 std::numeric_limits<T>::digits +
38 std::numeric_limits<T>::is_signed;
39 for (int i = 0; i < num_bits; ++i) {
42 return out = static_cast<T>(state);
53 // bits 64, 63, 61, and 60 set to 1 (counting from 1 lo to hi)
54 static constexpr std::uint64_t mask = 0xD800000000000000;