]> git.localhorst.tv Git - blank.git/blobdiff - src/rand/GaloisLFSR.hpp
fix rng stability test
[blank.git] / src / rand / GaloisLFSR.hpp
index b0714432c77eb20e8cdeff74d6b2ce7dc7220f43..f5de7ad0bb650f15d9d6870d82e3bd6f3ee97b70 100644 (file)
@@ -48,6 +48,23 @@ public:
                return (*this)(next);
        }
 
+       float SNorm() noexcept {
+               return float(Next<std::uint32_t>()) * (1.0f / 2147483647.5f) - 1.0f;
+       }
+
+       float UNorm() noexcept {
+               return float(Next<std::uint32_t>()) * (1.0f / 4294967295.0f);
+       }
+
+       template<class Container>
+       typename Container::reference From(Container &c) {
+               return c[Next<typename Container::size_type>() % c.size()];
+       }
+       template<class Container>
+       typename Container::const_reference From(const Container &c) {
+               return c[Next<typename Container::size_type>() % c.size()];
+       }
+
 private:
        std::uint64_t state;
        // bits 64, 63, 61, and 60 set to 1 (counting from 1 lo to hi)