sampler.hpp 619 B

12345678910111213141516171819202122
  1. #ifndef E_SAMPLER_HPP
  2. #define E_SAMPLER_HPP
  3. #include <xoshiro.hpp>
  4. #include <Eigen/Core>
  5. template<typename RNG>
  6. struct sampler_tmplt{
  7. RNG m_rng;
  8. std::uniform_real_distribution<float> m_dis;
  9. sampler_tmplt() : m_rng(), m_dis(0,1){};
  10. sampler_tmplt(uint64_t seed) : m_rng(seed), m_dis(0,1){};
  11. float next1D(){
  12. return m_dis(m_rng);
  13. }
  14. Eigen::Vector2f next2D(){
  15. return Eigen::Vector2f(m_dis(m_rng), m_dis(m_rng));
  16. }
  17. Eigen::Vector3f next3D(){
  18. return Eigen::Vector3f(m_dis(m_rng), m_dis(m_rng), m_dis(m_rng));
  19. }
  20. };
  21. using sampler = sampler_tmplt<xoshiro_256>;
  22. #endif