vSMC
vSMC: Scalable Monte Carlo
common.hpp
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/rng/internal/common.hpp
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2015, 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_INTERNAL_COMMON_HPP
33 #define VSMC_RNG_INTERNAL_COMMON_HPP
34 
35 #include <vsmc/internal/common.hpp>
36 #include <vsmc/utility/simd.hpp>
37 #if VSMC_HAS_MKL
38 #include <vsmc/utility/mkl.hpp>
39 #endif
40 
41 #define VSMC_RUNTIME_ASSERT_RNG_DISTRIBUTION_PARAM(flag, Name) \
42  VSMC_RUNTIME_ASSERT((flag), \
43  "**" #Name "Distribution** CONSTRUCTED WITH INVALID PARAMETERS")
44 
45 #define VSMC_DEFINE_RNG_DISTRIBUTION_1(Name, name, T, T1, p1, v1) \
46  public: \
47  using result_type = T; \
48  using distribution_type = Name##Distribution<T>; \
49  \
50  class param_type \
51  { \
52  public: \
53  using result_type = T; \
54  using distribution_type = Name##Distribution<T>; \
55  \
56  explicit param_type(T1 p1 = v1) : p1##_(p1) \
57  { \
58  VSMC_RUNTIME_ASSERT_RNG_DISTRIBUTION_PARAM( \
59  internal::name##_distribution_check_param(p1), Name); \
60  } \
61  \
62  T1 p1() const { return p1##_; } \
63  \
64  friend bool operator==( \
65  const param_type &param1, const param_type &param2) \
66  { \
67  if (!internal::is_equal(param1.p1##_, param2.p1##_)) \
68  return false; \
69  return true; \
70  } \
71  \
72  friend bool operator!=( \
73  const param_type &param1, const param_type &param2) \
74  { \
75  return !(param1 == param2); \
76  } \
77  \
78  template <typename CharT, typename Traits> \
79  friend std::basic_ostream<CharT, Traits> &operator<<( \
80  std::basic_ostream<CharT, Traits> &os, const param_type &param) \
81  { \
82  if (!os.good()) \
83  return os; \
84  \
85  os << param.p1##_; \
86  \
87  return os; \
88  } \
89  \
90  template <typename CharT, typename Traits> \
91  friend std::basic_istream<CharT, Traits> &operator>>( \
92  std::basic_istream<CharT, Traits> &is, param_type &param) \
93  { \
94  if (!is.good()) \
95  return is; \
96  \
97  T1 p1 = 0; \
98  is >> std::ws >> p1; \
99  \
100  if (is.good()) { \
101  if (internal::name##_distribution_check_param(p1)) \
102  param.p1##_ = p1; \
103  else \
104  is.setstate(std::ios_base::failbit); \
105  } \
106  \
107  return is; \
108  } \
109  \
110  private: \
111  T1 p1##_; \
112  }; \
113  \
114  explicit Name##Distribution(T1 p1 = v1) : param_(p1) { reset(); } \
115  \
116  explicit Name##Distribution(const param_type &param) : param_(param) \
117  { \
118  reset(); \
119  } \
120  \
121  T1 p1() const { return param_.p1(); } \
122  \
123  param_type param() const { return param_; } \
124  \
125  void param(const param_type &parm) \
126  { \
127  param_ = parm; \
128  reset(); \
129  } \
130  \
131  template <typename RNGType> \
132  result_type operator()(RNGType &rng) \
133  { \
134  return operator()(rng, param_); \
135  } \
136  \
137  template <typename RNGType> \
138  result_type operator()(RNGType &rng, const param_type &param) \
139  { \
140  return generate(rng, param); \
141  } \
142  \
143  template <typename RNGType> \
144  void operator()(RNGType &rng, std::size_t n, result_type *r) \
145  { \
146  operator()(rng, n, r, param_); \
147  } \
148  \
149  template <typename RNGType> \
150  void operator()( \
151  RNGType &rng, std::size_t n, result_type *r, const param_type &param) \
152  { \
153  name##_distribution(rng, n, r, param.p1()); \
154  } \
155  \
156  private: \
157  param_type param_;
158 
159 #define VSMC_DEFINE_RNG_DISTRIBUTION_2(Name, name, T, T1, p1, v1, T2, p2, v2) \
160  public: \
161  using result_type = T; \
162  using distribution_type = Name##Distribution<T>; \
163  \
164  class param_type \
165  { \
166  public: \
167  using result_type = T; \
168  using distribution_type = Name##Distribution<T>; \
169  \
170  explicit param_type(T1 p1 = v1, T2 p2 = v2) : p1##_(p1), p2##_(p2) \
171  { \
172  VSMC_RUNTIME_ASSERT_RNG_DISTRIBUTION_PARAM( \
173  internal::name##_distribution_check_param(p1, p2), Name); \
174  } \
175  \
176  T1 p1() const { return p1##_; } \
177  T2 p2() const { return p2##_; } \
178  \
179  friend bool operator==( \
180  const param_type &param1, const param_type &param2) \
181  { \
182  if (!internal::is_equal(param1.p1##_, param2.p1##_)) \
183  return false; \
184  if (!internal::is_equal(param1.p2##_, param2.p2##_)) \
185  return false; \
186  return true; \
187  } \
188  \
189  friend bool operator!=( \
190  const param_type &param1, const param_type &param2) \
191  { \
192  return !(param1 == param2); \
193  } \
194  \
195  template <typename CharT, typename Traits> \
196  friend std::basic_ostream<CharT, Traits> &operator<<( \
197  std::basic_ostream<CharT, Traits> &os, const param_type &param) \
198  { \
199  if (!os.good()) \
200  return os; \
201  \
202  os << param.p1##_ << ' '; \
203  os << param.p2##_; \
204  \
205  return os; \
206  } \
207  \
208  template <typename CharT, typename Traits> \
209  friend std::basic_istream<CharT, Traits> &operator>>( \
210  std::basic_istream<CharT, Traits> &is, param_type &param) \
211  { \
212  if (!is.good()) \
213  return is; \
214  \
215  T1 p1 = 0; \
216  T2 p2 = 0; \
217  is >> std::ws >> p1; \
218  is >> std::ws >> p2; \
219  \
220  if (is.good()) { \
221  if (internal::name##_distribution_check_param(p1, p2)) { \
222  param.p1##_ = p1; \
223  param.p2##_ = p2; \
224  } else { \
225  is.setstate(std::ios_base::failbit); \
226  } \
227  } \
228  \
229  return is; \
230  } \
231  \
232  private: \
233  T1 p1##_; \
234  T2 p2##_; \
235  }; \
236  \
237  explicit Name##Distribution(T1 p1 = v1, T2 p2 = v2) : param_(p1, p2) \
238  { \
239  reset(); \
240  } \
241  \
242  explicit Name##Distribution(const param_type &param) : param_(param) \
243  { \
244  reset(); \
245  } \
246  \
247  T1 p1() const { return param_.p1(); } \
248  T2 p2() const { return param_.p2(); } \
249  \
250  param_type param() const { return param_; } \
251  \
252  void param(const param_type &parm) \
253  { \
254  param_ = parm; \
255  reset(); \
256  } \
257  \
258  template <typename RNGType> \
259  result_type operator()(RNGType &rng) \
260  { \
261  return operator()(rng, param_); \
262  } \
263  \
264  template <typename RNGType> \
265  result_type operator()(RNGType &rng, const param_type &param) \
266  { \
267  return generate(rng, param); \
268  } \
269  \
270  template <typename RNGType> \
271  void operator()(RNGType &rng, std::size_t n, result_type *r) \
272  { \
273  operator()(rng, n, r, param_); \
274  } \
275  \
276  template <typename RNGType> \
277  void operator()( \
278  RNGType &rng, std::size_t n, result_type *r, const param_type &param) \
279  { \
280  name##_distribution(rng, n, r, param.p1(), param.p2()); \
281  } \
282  \
283  private: \
284  param_type param_;
285 
286 #define VSMC_DEFINE_RNG_DISTRIBUTION_OPERATORS \
287  public: \
288  friend bool operator==( \
289  const distribution_type &dist1, const distribution_type &dist2) \
290  { \
291  return dist1.param_ == dist2.param_; \
292  } \
293  \
294  friend bool operator!=( \
295  const distribution_type &dist1, const distribution_type &dist2) \
296  { \
297  return dist1.param_ != dist2.param_; \
298  } \
299  \
300  template <typename CharT, typename Traits> \
301  friend std::basic_ostream<CharT, Traits> &operator<<( \
302  std::basic_ostream<CharT, Traits> &os, const distribution_type &dist) \
303  { \
304  os << dist.param_; \
305  \
306  return os; \
307  } \
308  \
309  template <typename CharT, typename Traits> \
310  friend std::basic_istream<CharT, Traits> &operator>>( \
311  std::basic_istream<CharT, Traits> &is, distribution_type &dist) \
312  { \
313  is >> std::ws >> dist.param_; \
314  dist.reset(); \
315  \
316  return is; \
317  }
318 
319 namespace vsmc
320 {
321 
322 namespace internal
323 {
324 
326 
327 #ifdef VSMC_CLANG
328 #pragma clang diagnostic push
329 #pragma clang diagnostic ignored "-Wfloat-equal"
330 #endif
331 
332 template <typename T>
333 inline bool is_equal(const T &a, const T &b)
334 {
335  return a == b;
336 }
337 
338 #ifdef VSMC_CLANG
339 #pragma clang diagnostic pop
340 #endif
341 
342 template <int N>
344 {
345  public:
346  static constexpr std::uint64_t
347  value = std::numeric_limits<std::uint64_t>::max VSMC_MNE() >> (64 - N);
348 }; // class RNGBitsNMax
349 
350 template <std::uint64_t UMax, int N>
351 class RNGBitsN
352 {
353  static constexpr std::uint64_t bmax = RNGBitsNMax<N>::value;
354 
355  public:
356  static constexpr int value =
357  UMax < bmax ? RNGBitsN<UMax, N - 1>::value : N;
358 }; // class RNGMaxBitsN
359 
360 template <std::uint64_t UMax>
361 class RNGBitsN<UMax, 0>
362 {
363  public:
364  static constexpr int value = 0;
365 }; // class RNGMaxBitsN
366 
367 template <typename RNGType>
369  : public std::integral_constant<int,
370  RNGBitsN<static_cast<std::uint64_t>(RNGType::min VSMC_MNE()),
371  64>::value>
372 {
373 }; // class RNGMinBits
374 
375 template <typename RNGType>
377  : public std::integral_constant<int,
378  RNGBitsN<static_cast<std::uint64_t>(RNGType::max VSMC_MNE()),
379  64>::value>
380 {
381 }; // class RNGMaxBits
382 
383 template <typename RNGType>
384 class RNGBits : public std::integral_constant<int,
385  RNGMaxBits<RNGType>::value - RNGMinBits<RNGType>::value>
386 {
387 }; // class RNGBits
388 
389 template <std::size_t>
390 class IntBitsN;
391 
392 template <>
393 class IntBitsN<sizeof(int8_t)> : public std::integral_constant<int, 8>
394 {
395 }; // class IntBitsN
396 
397 template <>
398 class IntBitsN<sizeof(int16_t)> : public std::integral_constant<int, 16>
399 {
400 }; // class IntBitsN
401 
402 template <>
403 class IntBitsN<sizeof(int32_t)> : public std::integral_constant<int, 32>
404 {
405 }; // class IntBitsN
406 
407 template <>
408 class IntBitsN<sizeof(int64_t)> : public std::integral_constant<int, 64>
409 {
410 }; // class IntBitsN
411 
412 template <typename IntType>
413 class IntBits : public IntBitsN<sizeof(IntType)>
414 {
415 }; // class IntBits
416 
417 template <typename SeedSeq, typename U, typename V = U, typename W = V>
419  : public std::integral_constant<bool,
420  !std::is_convertible<SeedSeq, U>::value &&
421  !std::is_convertible<SeedSeq, V>::value &&
422  !std::is_convertible<SeedSeq, W>::value &&
423  !std::is_same<typename std::remove_cv<SeedSeq>::type,
424  U>::value &&
425  !std::is_same<typename std::remove_cv<SeedSeq>::type,
426  V>::value &&
427  !std::is_same<typename std::remove_cv<SeedSeq>::type, W>::value>
428 {
429 }; // class is_seed_seq
430 
431 } // namespace vsmc::internal
432 
435 class Open;
436 
439 class Closed;
440 
443 template <typename RNGType>
444 void rng_rand(RNGType &rng, std::size_t n, typename RNGType::result_type *r)
445 {
446  for (std::size_t i = 0; i != n; ++i)
447  r[i] = rng();
448 }
449 
450 template <typename>
451 class CounterEngine;
452 
453 template <typename Generator>
454 inline void rng_rand(CounterEngine<Generator> &, std::size_t,
456 
457 template <typename = int>
459 
460 template <typename = unsigned>
462 
463 template <typename = int>
465 
466 template <typename = double>
467 class BetaDistribution;
468 
469 template <typename = double>
470 class CauchyDistribution;
471 
472 template <typename = double>
474 
475 template <typename = double>
477 
478 template <typename = double>
480 
481 template <typename = double>
482 class FisherFDistribution;
483 
484 template <typename = double>
485 class GammaDistribution;
486 
487 template <typename = double>
489 
490 template <typename = double>
492 
493 template <typename = double>
495 
496 template <typename = double>
498 
499 template <typename = double>
501 
502 template <typename = double>
504 
505 template <typename = double>
507 
508 template <typename = double>
510 
511 template <typename = double, typename = Closed, typename = Open>
513 
514 template <typename = double, typename = Closed, typename = Open>
516 
517 template <typename = double>
519 
520 template <typename IntType, typename RNGType>
521 inline void rng_rand(
522  RNGType &, BernoulliIntDistribution<IntType> &, std::size_t, IntType *);
523 
524 template <typename UIntType, typename RNGType>
525 inline void rng_rand(
526  RNGType &, UniformBitsDistribution<UIntType> &, std::size_t, UIntType *);
527 
528 template <typename RealType, typename RNGType>
529 inline void rng_rand(
530  RNGType &, BetaDistribution<RealType> &, std::size_t, RealType *);
531 
532 template <typename RealType, typename RNGType>
533 inline void rng_rand(
534  RNGType &, CauchyDistribution<RealType> &, std::size_t, RealType *);
535 
536 template <typename RealType, typename RNGType>
537 inline void rng_rand(
538  RNGType &, ChiSquaredDistribution<RealType> &, std::size_t, RealType *);
539 
540 template <typename RealType, typename RNGType>
541 inline void rng_rand(
542  RNGType &, DiscreteDistribution<RealType> &, std::size_t, RealType *);
543 
544 template <typename RealType, typename RNGType>
545 inline void rng_rand(
546  RNGType &, ExponentialDistribution<RealType> &, std::size_t, RealType *);
547 
548 template <typename RealType, typename RNGType>
549 inline void rng_rand(
550  RNGType &, ExtremeValueDistribution<RealType> &, std::size_t, RealType *);
551 
552 template <typename RealType, typename RNGType>
553 inline void rng_rand(
554  RNGType &, FisherFDistribution<RealType> &, std::size_t, RealType *);
555 
556 template <typename RealType, typename RNGType>
557 inline void rng_rand(
558  RNGType &, GammaDistribution<RealType> &, std::size_t, RealType *);
559 
560 template <typename RealType, typename RNGType>
561 inline void rng_rand(
562  RNGType &, LaplaceDistribution<RealType> &, std::size_t, RealType *);
563 
564 template <typename RealType, typename RNGType>
565 inline void rng_rand(
566  RNGType &, LevyDistribution<RealType> &, std::size_t, RealType *);
567 
568 template <typename RealType, typename RNGType>
569 inline void rng_rand(
570  RNGType &, LogisticDistribution<RealType> &, std::size_t, RealType *);
571 
572 template <typename RealType, typename RNGType>
573 inline void rng_rand(
574  RNGType &, LognormalDistribution<RealType> &, std::size_t, RealType *);
575 
576 template <typename RealType, typename RNGType>
577 inline void rng_rand(
578  RNGType &, NormalDistribution<RealType> &, std::size_t, RealType *);
579 
580 template <typename RealType, typename RNGType>
581 inline void rng_rand(
582  RNGType &, ParetoDistribution<RealType> &, std::size_t, RealType *);
583 
584 template <typename RealType, typename RNGType>
585 inline void rng_rand(
586  RNGType &, RayleighDistribution<RealType> &, std::size_t, RealType *);
587 
588 template <typename RealType, typename RNGType>
589 inline void rng_rand(
590  RNGType &, StudentTDistribution<RealType> &, std::size_t, RealType *);
591 
592 template <typename RealType, typename RNGType, typename Left, typename Right>
593 inline void rng_rand(RNGType &, U01LRDistribution<RealType, Left, Right> &,
594  std::size_t, RealType *);
595 
596 template <typename RealType, typename RNGType, typename Left, typename Right>
597 inline void rng_rand(RNGType &,
599  RealType *);
600 
601 template <typename RealType, typename RNGType>
602 inline void rng_rand(
603  RNGType &, WeibullDistribution<RealType> &, std::size_t, RealType *);
604 
605 template <typename IntType, typename RNGType>
606 inline void bernoulli_distribution(RNGType &, std::size_t, IntType *, double);
607 
608 template <typename UIntType, typename RNGType>
609 inline void uniform_bits_distribution(RNGType &, std::size_t, UIntType *);
610 
611 template <typename RealType, typename RNGType>
612 inline void beta_distribution(
613  RNGType &, std::size_t, RealType *, RealType, RealType);
614 
615 template <typename RealType, typename RNGType>
616 inline void cauchy_distribution(
617  RNGType &, std::size_t, RealType *, RealType, RealType);
618 
619 template <typename RealType, typename RNGType>
620 inline void chi_squared_distribution(
621  RNGType &, std::size_t, RealType *, RealType);
622 
623 template <typename RealType, typename RNGType>
624 inline void exponential_distribution(
625  RNGType &, std::size_t, RealType *, RealType);
626 
627 template <typename RealType, typename RNGType>
628 inline void extreme_value_distribution(
629  RNGType &, std::size_t, RealType *, RealType, RealType);
630 
631 template <typename RealType, typename RNGType>
632 inline void fisher_f_distribution(
633  RNGType &, std::size_t, RealType *, RealType, RealType);
634 
635 template <typename RealType, typename RNGType>
636 inline void gamma_distribution(
637  RNGType &, std::size_t, RealType *, RealType, RealType);
638 
639 template <typename RealType, typename RNGType>
640 inline void laplace_distribution(
641  RNGType &, std::size_t, RealType *, RealType, RealType);
642 
643 template <typename RealType, typename RNGType>
644 inline void levy_distribution(
645  RNGType &, std::size_t, RealType *, RealType, RealType);
646 
647 template <typename RealType, typename RNGType>
648 inline void logistic_distribution(
649  RNGType &, std::size_t, RealType *, RealType, RealType);
650 
651 template <typename RealType, typename RNGType>
652 inline void lognormal_distribution(
653  RNGType &, std::size_t, RealType *, RealType, RealType);
654 
655 template <typename RealType, typename RNGType>
656 inline void normal_distribution(
657  RNGType &, std::size_t, RealType *, RealType, RealType);
658 
659 template <typename RealType, typename RNGType>
660 inline void pareto_distribution(
661  RNGType &, std::size_t, RealType *, RealType, RealType);
662 
663 template <typename RealType, typename RNGType>
664 inline void rayleigh_distribution(
665  RNGType &, std::size_t, RealType *, RealType);
666 
667 template <typename RealType, typename RNGType>
668 inline void student_t_distribution(
669  RNGType &, std::size_t, RealType *, RealType);
670 
671 template <typename RealType, typename Left, typename Right, typename RNGType>
672 inline void u01_distribution(RNGType &, std::size_t, RealType *);
673 
674 template <typename RealType, typename RNGType>
675 inline void u01_lr_distribution(RNGType &, std::size_t, RealType *);
676 
677 template <typename RealType, typename RNGType>
678 inline void uniform_real_distribution(
679  RNGType &, std::size_t, RealType *, RealType, RealType);
680 
681 template <typename RealType, typename Left, typename Right, typename RNGType>
682 inline void uniform_real_lr_distribution(
683  RNGType &, std::size_t, RealType *, RealType, RealType);
684 
685 template <typename RealType, typename RNGType>
686 inline void weibull_distribution(
687  RNGType &, std::size_t, RealType *, RealType, RealType);
688 
689 #if VSMC_HAS_MKL
690 
691 template <MKL_INT, int>
692 class MKLEngine;
693 
694 template <MKL_INT BRNG, int Bits>
695 inline void rng_rand(MKLEngine<BRNG, Bits> &, std::size_t,
697 
698 template <MKL_INT BRNG, int Bits>
699 inline void bernoulli_distribution(
700  MKLEngine<BRNG, Bits> &, std::size_t, MKL_INT *, double);
701 
702 template <MKL_INT BRNG, int Bits>
703 inline void uniform_real_distribution(
704  MKLEngine<BRNG, Bits> &, std::size_t, float *, float, float);
705 
706 template <MKL_INT BRNG, int Bits>
707 inline void uniform_real_distribution(
708  MKLEngine<BRNG, Bits> &, std::size_t, double *, double, double);
709 
710 template <MKL_INT BRNG, int Bits>
711 inline void u01_distribution(MKLEngine<BRNG, Bits> &, std::size_t, float *);
712 
713 template <MKL_INT BRNG, int Bits>
714 inline void u01_distribution(MKLEngine<BRNG, Bits> &, std::size_t, double *);
715 
716 template <MKL_INT BRNG, int Bits>
717 inline void normal_distribution(
718  MKLEngine<BRNG, Bits> &, std::size_t, float *r, float, float);
719 
720 template <MKL_INT BRNG, int Bits>
721 inline void normal_distribution(
722  MKLEngine<BRNG, Bits> &, std::size_t, double *r, double, double);
723 
724 template <MKL_INT BRNG, int Bits>
725 inline void exponential_distribution(
726  MKLEngine<BRNG, Bits> &, std::size_t, float *, float);
727 
728 template <MKL_INT BRNG, int Bits>
729 inline void exponential_distribution(
730  MKLEngine<BRNG, Bits> &, std::size_t, double *, double);
731 
732 template <MKL_INT BRNG, int Bits>
733 inline void laplace_distribution(
734  MKLEngine<BRNG, Bits> &, std::size_t, float *, float, float);
735 
736 template <MKL_INT BRNG, int Bits>
737 inline void laplace_distribution(
738  MKLEngine<BRNG, Bits> &, std::size_t, double *, double, double);
739 
740 template <MKL_INT BRNG, int Bits>
741 inline void weibull_distribution(
742  MKLEngine<BRNG, Bits> &, std::size_t, float *, float, float);
743 
744 template <MKL_INT BRNG, int Bits>
745 inline void weibull_distribution(
746  MKLEngine<BRNG, Bits> &, std::size_t, double *, double, double);
747 
748 template <MKL_INT BRNG, int Bits>
749 inline void cauchy_distribution(
750  MKLEngine<BRNG, Bits> &, std::size_t, float *, float, float);
751 
752 template <MKL_INT BRNG, int Bits>
753 inline void cauchy_distribution(
754  MKLEngine<BRNG, Bits> &, std::size_t, double *, double, double);
755 
756 template <MKL_INT BRNG, int Bits>
757 inline void rayleigh_distribution(
758  MKLEngine<BRNG, Bits> &, std::size_t, float *, float);
759 
760 template <MKL_INT BRNG, int Bits>
761 inline void rayleigh_distribution(
762  MKLEngine<BRNG, Bits> &, std::size_t, double *, double);
763 
764 template <MKL_INT BRNG, int Bits>
765 inline void lognormal_distribution(
766  MKLEngine<BRNG, Bits> &, std::size_t, float *, float, float);
767 
768 template <MKL_INT BRNG, int Bits>
769 inline void lognormal_distribution(
770  MKLEngine<BRNG, Bits> &, std::size_t, double *, double, double);
771 
772 template <MKL_INT BRNG, int Bits>
773 inline void extreme_value_distribution(
774  MKLEngine<BRNG, Bits> &, std::size_t, float *, float, float);
775 
776 template <MKL_INT BRNG, int Bits>
777 inline void extreme_value_distribution(
778  MKLEngine<BRNG, Bits> &, std::size_t, double *, double, double);
779 
780 template <MKL_INT BRNG, int Bits>
781 inline void gamma_distribution(
782  MKLEngine<BRNG, Bits> &, std::size_t, float *, float, float);
783 
784 template <MKL_INT BRNG, int Bits>
785 inline void gamma_distribution(
786  MKLEngine<BRNG, Bits> &, std::size_t, double *, double, double);
787 
788 template <MKL_INT BRNG, int Bits>
789 inline void beta_distribution(
790  MKLEngine<BRNG, Bits> &, std::size_t, float *, float, float);
791 
792 template <MKL_INT BRNG, int Bits>
793 inline void beta_distribution(
794  MKLEngine<BRNG, Bits> &, std::size_t, double *, double, double);
795 
796 #endif // VSMC_HAS_MKL
797 
798 } // namespace vsmc
799 
800 #endif // VSMC_RNG_INTERNAL_COMMON_HPP
#define VSMC_DEFINE_TYPE_DISPATCH_TRAIT(Outer, Inner, Default)
Definition: traits.hpp:40
Definition: monitor.hpp:49
Standard uniform distribution with open/closed variants.
Definition: common.hpp:512
Rayleigh distribution.
Definition: common.hpp:506
void laplace_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating laplace random variates.
void bernoulli_distribution(RNGType &rng, std::size_t n, IntType *r, IntType p)
Generating bernoulli random variates.
void student_t_distribution(RNGType &, std::size_t, RealType *, RealType)
Generating student-t random variates.
void logistic_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating logistic random variates.
void cauchy_distribution(RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
Generating cauchy random variates.
ulong uint64_t
Definition: opencl.h:40
bool is_equal(const T &a, const T &b)
Definition: common.hpp:333
void lognormal_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating lognormal random variates.
Counter based RNG engine.
Definition: counter.hpp:290
MKL RNG C++11 engine.
Definition: common.hpp:692
void rng_rand(RNGType &rng, BernoulliDistribution< IntType > &dist, std::size_t n, IntType *r)
void exponential_distribution(RNGType &rng, std::size_t n, RealType *r, RealType lambda)
Generating exponential random variates.
Student-t distribution.
Definition: common.hpp:509
void u01_distribution(RNGType &, std::size_t, RealType *)
Generate standard uniform random variates.
void normal_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating normal random variates.
void rayleigh_distribution(RNGType &, std::size_t, RealType *, RealType)
Generating rayleigh random variates.
void pareto_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating pareto random variates.
typename KeyTypeTrait< T >::type KeyType
Definition: common.hpp:325
void u01_lr_distribution(RNGType &, std::size_t, RealType *)
Generate standard uniform random variates with open/closed variants.
#define VSMC_MNE
Definition: defines.hpp:38
Normal distribution.
Definition: common.hpp:500
typename Generator::result_type result_type
Definition: counter.hpp:293
void weibull_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating weibull random variates.
void uniform_real_lr_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generate uniform real random variates with open/closed variants.
void extreme_value_distribution(RNGType &rng, std::size_t n, RealType *r, RealType a, RealType b)
Generating extreme_value random variates.
Levy distribution.
Definition: common.hpp:491
void chi_squared_distribution(RNGType &rng, std::size_t n, RealType *r, RealType df)
Generating random variates.
static constexpr std::uint64_t value
Definition: common.hpp:347
void beta_distribution(RNGType &rng, std::size_t n, RealType *r, RealType alpha, RealType beta)
Generating beta random variates.
void uniform_bits_distribution(RNGType &, std::size_t, UIntType *)
Draw a single sample given weights.
void fisher_f_distribution(RNGType &rng, std::size_t n, RealType *r, RealType df1, RealType df2)
Generating Fisher-F random variates.
void uniform_real_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generate uniform real random variates.
Uniform bits distribution.
Definition: common.hpp:461
Weibull distribution.
Definition: common.hpp:518
Lognormal distribution.
Definition: common.hpp:497
void gamma_distribution(RNGType &rng, std::size_t n, RealType *r, RealType alpha, RealType beta)
Generating gamma random variates.
Laplace distribution.
Definition: common.hpp:488
internal::MKLResultType< Bits > result_type
Definition: mkl.hpp:210
Uniform real distribution with open/closed variants.
Definition: common.hpp:515
Pareto distribution.
Definition: common.hpp:503
void levy_distribution(RNGType &, std::size_t, RealType *, RealType, RealType)
Generating levy random variates.
Logistic distribution.
Definition: common.hpp:494