vSMC
vSMC: Scalable Monte Carlo
xorshift.hpp
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/rng/xorshift.hpp
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013,2014, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_RNG_XORSHIFT_HPP
33 #define VSMC_RNG_XORSHIFT_HPP
34 
36 
37 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT_ORDER(K) \
38  VSMC_STATIC_ASSERT((K != 0), USE_XorshiftEngine_WITH_ORDER_EUQAL_TO_ZERO)
39 
40 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT_UNSIGNED(ResultType) \
41  VSMC_STATIC_ASSERT((cxx11::is_unsigned<ResultType>::value), \
42  USE_XorshiftEngine_WITH_A_ResultType_NOT_AN_UNSIGNED_INTEGER_TYPE)
43 
44 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT_UINT_SIZE(ResultType) \
45  VSMC_STATIC_ASSERT((sizeof(ResultType) >= sizeof(uint32_t)), \
46  USE_XorshiftEngine_WITH_A_ResultType_SMALLER_THAN_32_BITS)
47 
48 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT_INDEX(I, K) \
49  VSMC_STATIC_ASSERT((I != 0 || K == 1), \
50  USE_XorshiftEngine_WITH_INDEX_##I##_EQUAL_TO_ZERO)
51 
52 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT_INDEX_ORDER(R, S, K) \
53  VSMC_STATIC_ASSERT((R > S || K == 1), \
54  USE_XorshiftEngine_WITH_INDEX_##R##_NOT_LARGER_THAN_##S)
55 
56 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT_SHIFT_BITS(A) \
57  VSMC_STATIC_ASSERT((A != 0), \
58  USE_XorshiftEngine_WITH_SHIFT_BITS_##A##_EQUAL_TO_ZERO);
59 
60 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT_SHIFT_BITS_C(C, K) \
61  VSMC_STATIC_ASSERT((C != 0 || K != 1), \
62  USE_XorshiftEngine_WITH_SHIFT_BITS_##C##_EQUAL_TO_ZERO);
63 
64 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT_SHIFT_BITS_D(D, K) \
65  VSMC_STATIC_ASSERT((D != 0 || K == 1), \
66  USE_XorshiftEngine_WITH_SHIFT_BITS_##A##_EQUAL_TO_ZERO);
67 
68 #define VSMC_STATIC_ASSERT_RNG_XORSHIFT \
69  VSMC_STATIC_ASSERT_RNG_XORSHIFT_ORDER(K); \
70  VSMC_STATIC_ASSERT_RNG_XORSHIFT_UNSIGNED(ResultType); \
71  VSMC_STATIC_ASSERT_RNG_XORSHIFT_UINT_SIZE(ResultType); \
72  VSMC_STATIC_ASSERT_RNG_XORSHIFT_INDEX(R, K); \
73  VSMC_STATIC_ASSERT_RNG_XORSHIFT_INDEX(S, K); \
74  VSMC_STATIC_ASSERT_RNG_XORSHIFT_INDEX_ORDER(R, S, K); \
75  VSMC_STATIC_ASSERT_RNG_XORSHIFT_SHIFT_BITS(A); \
76  VSMC_STATIC_ASSERT_RNG_XORSHIFT_SHIFT_BITS(B); \
77  VSMC_STATIC_ASSERT_RNG_XORSHIFT_SHIFT_BITS_C(C, K); \
78  VSMC_STATIC_ASSERT_RNG_XORSHIFT_SHIFT_BITS_D(D, K);
79 
80 namespace vsmc {
81 
82 namespace traits {
83 
86 template <typename ResultType>
88 {
106  static VSMC_CONSTEXPR const std::size_t max_loop_unroll = 4;
107 }; // struct XorshiftEngineTrait
108 
109 } // namespace vsmc::traits
110 
111 namespace internal {
112 
113 template <bool, typename ResultType, unsigned>
115 {static ResultType shift (ResultType x) {return x;}};
116 
117 template <typename ResultType, unsigned A>
118 struct XorshiftLeft<true, ResultType, A>
119 {static ResultType shift (ResultType x) {return x^(x<<A);}};
120 
121 template <bool, typename ResultType, unsigned>
123 {static ResultType shift (ResultType x) {return x;}};
124 
125 template <typename ResultType, unsigned A>
126 struct XorshiftRight<true, ResultType, A>
127 {static ResultType shift (ResultType x) {return x^(x>>A);}};
128 
129 template <typename ResultType, std::size_t K, std::size_t R, std::size_t S,
130  bool =
131  (K <= traits::XorshiftEngineTrait<ResultType>::max_loop_unroll)>
133 {
134  void reset () {}
135 
136  static VSMC_CONSTEXPR std::size_t r () {return K - R;}
137  static VSMC_CONSTEXPR std::size_t s () {return K - S;}
138  static VSMC_CONSTEXPR std::size_t k () {return K - 1;}
139 
140  static void shift (Array<ResultType, K> &state)
141  {rng_array_left_shift<K, 1, false>(state);}
142 }; // struct XorshiftIndex
143 
144 template <typename ResultType, std::size_t K, std::size_t R, std::size_t S>
146 {
147  XorshiftIndex () : iter_(0) {}
148 
149  void reset () {iter_ = 0;}
150 
151  std::size_t r () {return (K - R + iter_) % K;}
152  std::size_t s () {return (K - S + iter_) % K;}
153  std::size_t k () {return (K - 1 + iter_) % K;}
154 
156  {iter_ = (iter_ + 1) % K;}
157 
158  private :
159 
160  std::size_t iter_;
161 }; // struct XorshiftIndex
162 
163 template <unsigned A, unsigned B, unsigned C, unsigned,
164  typename ResultType, std::size_t R, std::size_t S>
165 inline ResultType xorshift (Array<ResultType, 1> &state,
167 {
168  state.front() ^= (state.front())<<A;
169  state.front() ^= (state.front())>>B;
170  state.front() ^= (state.front())<<C;
171 
172  return state.front();
173 }
174 
175 template <unsigned A, unsigned B, unsigned C, unsigned D,
176  typename ResultType, std::size_t K, std::size_t R, std::size_t S>
177 inline ResultType xorshift (Array<ResultType, K> &state,
179 {
180  ResultType xr = state[index.r()];
183 
184  ResultType xs = state[index.s()];
187 
188  index.shift(state);
189 
190  return state[index.k()] = xs^xr;
191 }
192 
193 } // namespace vsmc::internal
194 
211 template <typename ResultType, std::size_t K,
212  unsigned A, unsigned B, unsigned C, unsigned D,
213  std::size_t R, std::size_t S>
215 {
216  public :
217 
218  typedef ResultType result_type;
219 
220  explicit XorshiftEngine (result_type s = 1)
221  {
223  if (s == 0)
224  s = 1;
225  seed(s);
226  }
227 
228  template <typename SeedSeq>
229  explicit XorshiftEngine (SeedSeq &seq,
230  typename cxx11::enable_if<internal::is_seed_seq<SeedSeq,
232  >::value>::type * = VSMC_NULLPTR)
233  {
235  seed(seq);
236  }
237 
238  void seed (result_type s)
239  {
240  index_.reset();
242  seed.front() = static_cast<uint32_t>(s % uint32_t_max_);
244  for (std::size_t i = 0; i != K; ++i)
245  state_[i] = internal::xorshift<13, 17, 5, 0>(seed, index);
246  discard(4 * K);
247  }
248 
249  template <typename SeedSeq>
250  void seed (SeedSeq &seq,
251  typename cxx11::enable_if<internal::is_seed_seq<SeedSeq,
253  >::value>::type * = VSMC_NULLPTR)
254  {
255  index_.reset();
256  seq.generate(state_.begin(), state_.end());
257  discard(4 * K);
258  }
259 
260  result_type operator() ()
261  {return internal::xorshift<A, B, C, D>(state_, index_);}
262 
263  void discard (std::size_t nskip)
264  {
265  for (std::size_t i = 0; i != nskip; ++i)
266  operator()();
267  }
268 
269  static VSMC_CONSTEXPR const result_type _Min = 0;
270  static VSMC_CONSTEXPR const result_type _Max = static_cast<result_type>(
271  ~(static_cast<result_type>(0)));
272 
273  static VSMC_CONSTEXPR result_type min VSMC_MNE () {return _Min;}
274  static VSMC_CONSTEXPR result_type max VSMC_MNE () {return _Max;}
275 
276  friend inline bool operator== (
279  {return eng1.state_ == eng2.state_;}
280 
281  friend inline bool operator!= (
284  {return !(eng1 == eng2);}
285 
286  template <typename CharT, typename Traits>
287  friend inline std::basic_ostream<CharT, Traits> &operator<< (
288  std::basic_ostream<CharT, Traits> &os,
290  {
291  if (!os.good())
292  return os;
293 
294  os << eng.state_;
295 
296  return os;
297  }
298 
299  template <typename CharT, typename Traits>
300  friend inline std::basic_istream<CharT, Traits> &operator>> (
301  std::basic_istream<CharT, Traits> &is,
303  {
304  if (!is.good())
305  return is;
306 
308  is >> std::ws >> tmp;
309 
310  if (is.good()) {
311 #if VSMC_HAS_CXX11_RVALUE_REFERENCES
312  eng.state_ = cxx11::move(tmp);
313 #else
314  eng.state_ = tmp;
315 #endif
316  }
317 
318  return is;
319  }
320 
321  private :
322 
324  Array<ResultType, K> state_;
325 
326  static VSMC_CONSTEXPR const result_type uint32_t_max_ =
327  static_cast<result_type>(static_cast<uint32_t>(
328  ~(static_cast<uint32_t>(0))));
329 }; // class XorshiftEngine
330 
336 template <typename Eng,
337  typename Eng::result_type D = 362437,
338  typename Eng::result_type DInit = 6615241>
340 {
341  public :
342 
343  typedef typename Eng::result_type result_type;
344  typedef Eng engine_type;
345 
346  explicit XorwowEngine (result_type s = 1) : eng_(s), weyl_(DInit) {}
347 
348  template <typename SeedSeq>
349  explicit XorwowEngine (SeedSeq &seq,
350  typename cxx11::enable_if<internal::is_seed_seq<SeedSeq,
351  result_type, XorwowEngine<Eng, D, DInit>
352  >::value>::type * = VSMC_NULLPTR) : eng_(seq), weyl_(DInit) {}
353 
354  void seed (result_type s)
355  {
356  eng_.seed(s);
357  weyl_ = DInit;
358  }
359 
360  template <typename SeedSeq>
361  void seed (SeedSeq &seq,
362  typename cxx11::enable_if<internal::is_seed_seq<SeedSeq,
363  result_type, XorwowEngine<Eng, D, DInit>
364  >::value>::type * = VSMC_NULLPTR)
365  {
366  eng_.seed(seq);
367  weyl_ = DInit;
368  }
369 
370  result_type operator() ()
371  {return eng_() + (weyl_ += D);}
372 
373  void discard (std::size_t nskip)
374  {
375  eng_.discard(nskip);
376  weyl_ += D * nskip;
377  }
378 
379  static VSMC_CONSTEXPR const result_type _Min = 0;
380  static VSMC_CONSTEXPR const result_type _Max = static_cast<result_type>(
381  ~(static_cast<result_type>(0)));
382 
383  static VSMC_CONSTEXPR result_type min VSMC_MNE () {return _Min;}
384  static VSMC_CONSTEXPR result_type max VSMC_MNE () {return _Max;}
385 
386  friend inline bool operator== (
387  const XorwowEngine<Eng, D, DInit> &eng1,
388  const XorwowEngine<Eng, D, DInit> &eng2)
389  {return eng1.eng_ == eng2.eng_ && eng1.weyl_ == eng2.weyl_;}
390 
391  friend inline bool operator!= (
392  const XorwowEngine<Eng, D, DInit> &eng1,
393  const XorwowEngine<Eng, D, DInit> &eng2)
394  {return !(eng1 == eng2);}
395 
396  template <typename CharT, typename Traits>
397  friend inline std::basic_ostream<CharT, Traits> &operator<< (
398  std::basic_ostream<CharT, Traits> &os,
399  const XorwowEngine<Eng, D, DInit> &eng)
400  {
401  if (!os.good())
402  return os;
403 
404  os << eng.eng_ << ' ' << eng.weyl_;
405 
406  return os;
407  }
408 
409  template <typename CharT, typename Traits>
410  friend inline std::basic_istream<CharT, Traits> &operator>> (
411  std::basic_istream<CharT, Traits> &is,
413  {
414  if (!is.good())
415  return is;
416 
417  engine_type eng_tmp;
418  result_type weyl_tmp = 0;
419  is >> std::ws >> eng_tmp;
420  is >> std::ws >> weyl_tmp;
421 
422  if (is.good()) {
423 #if VSMC_HAS_CXX11_RVALUE_REFERENCES
424  eng.eng_ = cxx11::move(eng_tmp);
425 #else
426  eng.eng_ = eng_tmp;
427 #endif
428  eng.weyl_ = weyl_tmp;
429  }
430 
431  return is;
432  }
433 
434  private :
435 
436  Eng eng_;
437  result_type weyl_;
438 }; // class XorwowEngine
439 
443 
447 
451 
455 
459 
463 
467 
471 
475 
479 
483 
487 
491 
495 
499 
502 typedef Xorshift128x32 Xorshift;
503 
506 typedef Xorshift64x64 Xorshift_64;
507 
511 
515 
519 
523 
527 
531 
535 
539 
543 
547 
551 
555 
559 
563 
567 
570 typedef Xorwow128x32 Xorwow;
571 
574 typedef Xorwow64x64 Xorwow_64;
575 
576 } // namespace vsmc
577 
578 #endif // VSMC_RNG_XORSHIFT_HPP
XorshiftEngine< uint32_t, 4, 15, 14, 12, 17, 4, 3 > Xorshift4x32
Xorshift RNG engine generating 32-bits integers.
Definition: xorshift.hpp:454
Definition: adapter.hpp:37
static constexpr const result_type _Min
Definition: xorshift.hpp:269
friend bool operator==(const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng1, const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng2)
Definition: xorshift.hpp:276
static ResultType shift(ResultType x)
Definition: xorshift.hpp:123
result_type operator()()
Definition: xorshift.hpp:260
Xorshift128x32 Xorshift
The default 32-bits Xorshift RNG engine.
Definition: xorshift.hpp:502
static constexpr const std::size_t max_loop_unroll
Maximum number of states (e.g., 4 in Xorshift4x64) that an unrolled loop will be used.
Definition: xorshift.hpp:106
void discard(std::size_t nskip)
Definition: xorshift.hpp:263
XorshiftEngine< uint32_t, 2, 17, 14, 12, 19, 2, 1 > Xorshift2x32
Xorshift RNG engine generating 32-bits integers.
Definition: xorshift.hpp:450
XorwowEngine< Xorshift4x32 > Xorwow4x32
Xorwow RNG engine using Xorshfit 32-bits integers.
Definition: xorshift.hpp:522
XorshiftEngine< uint64_t, 1, 13, 7, 17, 0, 0, 0 > Xorshift1x64
Xorshift RNG engine generating 64-bits integers.
Definition: xorshift.hpp:446
#define VSMC_CONSTEXPR
constexpr
Definition: defines.hpp:55
XorwowEngine< Xorshift8x32 > Xorwow8x32
Xorwow RNG engine using Xorshfit 32-bits integers.
Definition: xorshift.hpp:526
XorshiftEngine< uint32_t, 64, 19, 12, 14, 15, 64, 59 > Xorshift64x32
Xorshift RNG engine generating 32-bits integers.
Definition: xorshift.hpp:470
XorshiftEngine< uint32_t, 1, 13, 17, 5, 0, 0, 0 > Xorshift1x32
Xorshift RNG engine generating 32-bits integers.
Definition: xorshift.hpp:442
static constexpr const result_type _Max
Definition: xorshift.hpp:380
XorwowEngine< Xorshift2x64 > Xorwow2x64
Xorwow RNG engine using Xorshfit 64-bits integers.
Definition: xorshift.hpp:546
XorshiftEngine< uint64_t, 2, 33, 31, 28, 29, 2, 1 > Xorshift2x64
Xorshift RNG engine generating 64-bits integers.
Definition: xorshift.hpp:478
static constexpr std::size_t r()
Definition: xorshift.hpp:136
XorwowEngine(SeedSeq &seq, typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, XorwowEngine< Eng, D, DInit > >::value >::type *=nullptr)
Definition: xorshift.hpp:349
XorwowEngine< Xorshift8x64 > Xorwow8x64
Xorwow RNG engine using Xorshfit 64-bits integers.
Definition: xorshift.hpp:554
XorwowEngine< Xorshift16x32 > Xorwow16x32
Xorwow RNG engine using Xorshfit 32-bits integers.
Definition: xorshift.hpp:530
iterator begin()
Definition: array.hpp:131
static void shift(Array< ResultType, K > &state)
Definition: xorshift.hpp:140
friend bool operator!=(const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng1, const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng2)
Definition: xorshift.hpp:281
XorwowEngine< Xorshift1x32 > Xorwow1x32
Xorwow RNG engine using Xorshfit 32-bits integers.
Definition: xorshift.hpp:510
XorshiftEngine(result_type s=1)
Definition: xorshift.hpp:220
ResultType xorshift(Array< ResultType, 1 > &state, XorshiftIndex< ResultType, 1, R, S > &)
Definition: xorshift.hpp:165
XorshiftEngine(SeedSeq &seq, typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, XorshiftEngine< ResultType, K, A, B, C, D, R, S > >::value >::type *=nullptr)
Definition: xorshift.hpp:229
XorwowEngine< Xorshift32x32 > Xorwow32x32
Xorwow RNG engine using Xorshfit 32-bits integers.
Definition: xorshift.hpp:534
reference front()
Definition: array.hpp:119
Xorwow128x32 Xorwow
The default 32-bits Xorwow RNG engine.
Definition: xorshift.hpp:570
XorshiftEngine< uint32_t, 16, 17, 15, 13, 14, 16, 1 > Xorshift16x32
Xorshift RNG engine generating 32-bits integers.
Definition: xorshift.hpp:462
XorshiftEngine< uint32_t, 32, 19, 11, 13, 16, 32, 15 > Xorshift32x32
Xorshift RNG engine generating 32-bits integers.
Definition: xorshift.hpp:466
XorshiftEngine< uint64_t, 4, 37, 27, 29, 33, 4, 3 > Xorshift4x64
Xorshift RNG engine generating 64-bits integers.
Definition: xorshift.hpp:482
Xorshift64x64 Xorshift_64
The default 64-bits Xorshift RNG engine.
Definition: xorshift.hpp:506
static constexpr std::size_t s()
Definition: xorshift.hpp:137
XorwowEngine< Xorshift32x64 > Xorwow32x64
Xorwow RNG engine using Xorshfit 64-bits integers.
Definition: xorshift.hpp:562
static constexpr result_type min()
Definition: xorshift.hpp:273
static constexpr const result_type _Max
Definition: xorshift.hpp:270
XorwowEngine(result_type s=1)
Definition: xorshift.hpp:346
void seed(SeedSeq &seq, typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, XorshiftEngine< ResultType, K, A, B, C, D, R, S > >::value >::type *=nullptr)
Definition: xorshift.hpp:250
result_type operator()()
Definition: xorshift.hpp:370
Xorshift RNG engine.
Definition: xorshift.hpp:214
static constexpr const result_type _Min
Definition: xorshift.hpp:379
friend bool operator!=(const XorwowEngine< Eng, D, DInit > &eng1, const XorwowEngine< Eng, D, DInit > &eng2)
Definition: xorshift.hpp:391
XorwowEngine< Xorshift16x64 > Xorwow16x64
Xorwow RNG engine using Xorshfit 64-bits integers.
Definition: xorshift.hpp:558
void seed(result_type s)
Definition: xorshift.hpp:238
XorwowEngine< Xorshift4x64 > Xorwow4x64
Xorwow RNG engine using Xorshfit 64-bits integers.
Definition: xorshift.hpp:550
XorshiftEngine< uint32_t, 128, 17, 12, 13, 15, 128, 95 > Xorshift128x32
Xorshift RNG engine generating 32-bits integers.
Definition: xorshift.hpp:474
void discard(std::size_t nskip)
Definition: xorshift.hpp:373
#define VSMC_MNE
Avoid MSVC stupid behavior: MNE = Macro No Expansion.
Definition: defines.hpp:38
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng)
Definition: xorshift.hpp:300
static constexpr std::size_t k()
Definition: xorshift.hpp:138
XorshiftEngine< uint64_t, 32, 35, 27, 26, 37, 32, 1 > Xorshift32x64
Xorshift RNG engine generating 64-bits integers.
Definition: xorshift.hpp:494
XorshiftEngine< uint64_t, 64, 33, 26, 27, 29, 64, 53 > Xorshift64x64
Xorshift RNG engine generating 64-bits integers.
Definition: xorshift.hpp:498
static constexpr result_type max()
Definition: xorshift.hpp:274
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const XorshiftEngine< ResultType, K, A, B, C, D, R, S > &eng)
Definition: xorshift.hpp:287
remove_reference< T >::type && move(T &&t) noexcept
XorshiftEngine< uint64_t, 16, 34, 29, 25, 31, 16, 7 > Xorshift16x64
Xorshift RNG engine generating 64-bits integers.
Definition: xorshift.hpp:490
#define VSMC_STATIC_ASSERT_RNG_XORSHIFT
Definition: xorshift.hpp:68
Traits of XorshiftEngine.
Definition: xorshift.hpp:87
XorshiftEngine< uint64_t, 8, 37, 26, 29, 34, 8, 1 > Xorshift8x64
Xorshift RNG engine generating 64-bits integers.
Definition: xorshift.hpp:486
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const XorwowEngine< Eng, D, DInit > &eng)
Definition: xorshift.hpp:397
#define VSMC_NULLPTR
nullptr
Definition: defines.hpp:79
Xorwow64x64 Xorwow_64
The default 64-bits Xorwow RNG engine.
Definition: xorshift.hpp:574
XorwowEngine< Xorshift64x64 > Xorwow64x64
Xorwow RNG engine using Xorshfit 64-bits integers.
Definition: xorshift.hpp:566
static constexpr result_type min()
Definition: xorshift.hpp:383
friend bool operator==(const XorwowEngine< Eng, D, DInit > &eng1, const XorwowEngine< Eng, D, DInit > &eng2)
Definition: xorshift.hpp:386
XorwowEngine< Xorshift2x32 > Xorwow2x32
Xorwow RNG engine using Xorshfit 32-bits integers.
Definition: xorshift.hpp:518
ResultType result_type
Definition: xorshift.hpp:218
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, XorwowEngine< Eng, D, DInit > &eng)
Definition: xorshift.hpp:410
XorwowEngine< Xorshift128x32 > Xorwow128x32
Xorwow RNG engine using Xorshfit 32-bits integers.
Definition: xorshift.hpp:542
static ResultType shift(ResultType x)
Definition: xorshift.hpp:115
static constexpr result_type max()
Definition: xorshift.hpp:384
XorwowEngine< Xorshift1x64 > Xorwow1x64
Xorwow RNG engine using Xorshfit 64-bits integers.
Definition: xorshift.hpp:514
XorwowEngine< Xorshift64x32 > Xorwow64x32
Xorwow RNG engine using Xorshfit 32-bits integers.
Definition: xorshift.hpp:538
XorshiftEngine< uint32_t, 8, 18, 13, 14, 15, 8, 3 > Xorshift8x32
Xorshift RNG engine generating 32-bits integers.
Definition: xorshift.hpp:458
void seed(result_type s)
Definition: xorshift.hpp:354
iterator end()
Definition: array.hpp:133
Eng::result_type result_type
Definition: xorshift.hpp:343
Xorwow RNG engine.
Definition: xorshift.hpp:339
void seed(SeedSeq &seq, typename cxx11::enable_if< internal::is_seed_seq< SeedSeq, result_type, XorwowEngine< Eng, D, DInit > >::value >::type *=nullptr)
Definition: xorshift.hpp:361