Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class splitmix64

boost::random::splitmix64

Synopsis

// In header: <boost/random/splitmix64.hpp>


class splitmix64 {
public:
  // types
  typedef std::uint64_t result_type;
  typedef std::uint64_t seed_type;  

  // private member functions
  std::uint64_t concatenate(std::uint32_t, std::uint32_t) noexcept;

  // public member functions
  void seed(result_type = 0) noexcept;
  template<typename Sseq, 
           typename std::enable_if<!std::is_convertible< Sseq, std::uint64_t >::value, bool >::type = true> 
    void seed(Sseq &);
  template<typename Sseq, 
           typename std::enable_if<!std::is_convertible< Sseq, splitmix64 >::value, bool >::type = true> 
    explicit splitmix64(Sseq &);
  template<typename T, 
           typename std::enable_if< std::is_convertible< T, std::uint64_t >::value, bool >::type = true> 
    void seed(T = 0) noexcept;
  explicit splitmix64(std::uint64_t = 0) noexcept;
  splitmix64(const splitmix64 &) = default;
  splitmix64 & operator=(const splitmix64 &) = default;
  result_type next() noexcept;
  result_type operator()() noexcept;
  void discard(std::uint64_t) noexcept;
  template<typename FIter> void generate(FIter, FIter) noexcept;

  // friend functions
  bool operator==(const splitmix64 &, const splitmix64 &) noexcept;
  bool operator!=(const splitmix64 &, const splitmix64 &) noexcept;
  template<typename CharT, typename Traits> 
    std::basic_ostream< CharT, Traits > & 
    operator<<(std::basic_ostream< CharT, Traits > &, const splitmix64 &);
  template<typename CharT, typename Traits> 
    std::basic_istream< CharT, Traits > & 
    operator>>(std::basic_istream< CharT, Traits > &, splitmix64 &);

  // public static functions
  static constexpr max() noexcept;
  static constexpr min() noexcept;

  // public data members
  static bool has_fixed_range;
};

Description

This is a fixed-increment version of Java 8's SplittableRandom generator See http://dx.doi.org/10.1145/2714064.2660195 and http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html It is a very fast generator passing BigCrush, and it can be useful if for some reason you absolutely want 64 bits of state; otherwise, we rather suggest to use a xoroshiro128+ (for moderately parallel computations) or xorshift1024* (for massively parallel computations) generator.

splitmix64 private member functions

  1. std::uint64_t concatenate(std::uint32_t word1, std::uint32_t word2) noexcept;

splitmix64 public member functions

  1. void seed(result_type value = 0) noexcept;

    Seeds the generator with the default seed.

  2. template<typename Sseq, 
             typename std::enable_if<!std::is_convertible< Sseq, std::uint64_t >::value, bool >::type = true> 
      void seed(Sseq & seq);

    Seeds the generator with 32-bit values produced by seq.generate().

  3. template<typename Sseq, 
             typename std::enable_if<!std::is_convertible< Sseq, splitmix64 >::value, bool >::type = true> 
      explicit splitmix64(Sseq & seq);

    Seeds the generator with 64-bit values produced by seq.generate().

  4. template<typename T, 
             typename std::enable_if< std::is_convertible< T, std::uint64_t >::value, bool >::type = true> 
      void seed(T value = 0) noexcept;

    Seeds the generator with a user provided seed.

  5. explicit splitmix64(std::uint64_t state = 0) noexcept;

    Seeds the generator with a user provided seed.

  6. splitmix64(const splitmix64 & other) = default;
  7. splitmix64 & operator=(const splitmix64 & other) = default;
  8. result_type next() noexcept;

    Returns the next value of the generator.

  9. result_type operator()() noexcept;

    Returns the next value of the generator.

  10. void discard(std::uint64_t z) noexcept;

    Advances the state of the generator by z.

  11. template<typename FIter> void generate(FIter first, FIter last) noexcept;

    Fills a range with random values

splitmix64 friend functions

  1. bool operator==(const splitmix64 & lhs, const splitmix64 & rhs) noexcept;

    Returns true if the two generators will produce identical sequences of values.

  2. bool operator!=(const splitmix64 & lhs, const splitmix64 & rhs) noexcept;

    Returns true if the two generators will produce different sequences of values.

  3. template<typename CharT, typename Traits> 
      std::basic_ostream< CharT, Traits > & 
      operator<<(std::basic_ostream< CharT, Traits > & ost, const splitmix64 & e);

    Writes a splitmix64 to a std::ostream.

  4. template<typename CharT, typename Traits> 
      std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > & ist, splitmix64 & e);

    Writes a splitmix64 to a std::istream.

splitmix64 public static functions

  1. static constexpr max() noexcept;

    Returns the largest value that the splitmix64 can produce.

  2. static constexpr min() noexcept;

    Returns the smallest value that the splitmix64 can produce.


PrevUpHomeNext