30 #ifndef _EXT_RANDOM_TCC 31 #define _EXT_RANDOM_TCC 1 33 #pragma GCC system_header 35 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
37 _GLIBCXX_BEGIN_NAMESPACE_VERSION
39 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 41 template<
typename _UIntType,
size_t __m,
42 size_t __pos1,
size_t __sl1,
size_t __sl2,
43 size_t __sr1,
size_t __sr2,
44 uint32_t __msk1, uint32_t __msk2,
45 uint32_t __msk3, uint32_t __msk4,
46 uint32_t __parity1, uint32_t __parity2,
47 uint32_t __parity3, uint32_t __parity4>
48 void simd_fast_mersenne_twister_engine<_UIntType, __m,
49 __pos1, __sl1, __sl2, __sr1, __sr2,
50 __msk1, __msk2, __msk3, __msk4,
51 __parity1, __parity2, __parity3,
53 seed(_UIntType __seed)
55 _M_state32[0] =
static_cast<uint32_t
>(__seed);
56 for (
size_t __i = 1; __i < _M_nstate32; ++__i)
57 _M_state32[__i] = (1812433253UL
58 * (_M_state32[__i - 1] ^ (_M_state32[__i - 1] >> 30))
61 _M_period_certification();
67 inline uint32_t _Func1(uint32_t __x)
69 return (__x ^ (__x >> 27)) * UINT32_C(1664525);
72 inline uint32_t _Func2(uint32_t __x)
74 return (__x ^ (__x >> 27)) * UINT32_C(1566083941);
80 template<
typename _UIntType,
size_t __m,
81 size_t __pos1,
size_t __sl1,
size_t __sl2,
82 size_t __sr1,
size_t __sr2,
83 uint32_t __msk1, uint32_t __msk2,
84 uint32_t __msk3, uint32_t __msk4,
85 uint32_t __parity1, uint32_t __parity2,
86 uint32_t __parity3, uint32_t __parity4>
87 template<
typename _Sseq>
89 simd_fast_mersenne_twister_engine<_UIntType, __m,
90 __pos1, __sl1, __sl2, __sr1, __sr2,
91 __msk1, __msk2, __msk3, __msk4,
92 __parity1, __parity2, __parity3,
95 -> _If_seed_seq<_Sseq>
99 if (_M_nstate32 >= 623)
101 else if (_M_nstate32 >= 68)
103 else if (_M_nstate32 >= 39)
107 const size_t __mid = (_M_nstate32 - __lag) / 2;
109 std::fill(_M_state32, _M_state32 + _M_nstate32, UINT32_C(0x8b8b8b8b));
110 uint32_t __arr[_M_nstate32];
111 __q.generate(__arr + 0, __arr + _M_nstate32);
113 uint32_t __r = _Func1(_M_state32[0] ^ _M_state32[__mid]
114 ^ _M_state32[_M_nstate32 - 1]);
115 _M_state32[__mid] += __r;
117 _M_state32[__mid + __lag] += __r;
120 for (
size_t __i = 1, __j = 0; __j < _M_nstate32; ++__j)
122 __r = _Func1(_M_state32[__i]
123 ^ _M_state32[(__i + __mid) % _M_nstate32]
124 ^ _M_state32[(__i + _M_nstate32 - 1) % _M_nstate32]);
125 _M_state32[(__i + __mid) % _M_nstate32] += __r;
126 __r += __arr[__j] + __i;
127 _M_state32[(__i + __mid + __lag) % _M_nstate32] += __r;
128 _M_state32[__i] = __r;
129 __i = (__i + 1) % _M_nstate32;
131 for (
size_t __j = 0; __j < _M_nstate32; ++__j)
133 const size_t __i = (__j + 1) % _M_nstate32;
134 __r = _Func2(_M_state32[__i]
135 + _M_state32[(__i + __mid) % _M_nstate32]
136 + _M_state32[(__i + _M_nstate32 - 1) % _M_nstate32]);
137 _M_state32[(__i + __mid) % _M_nstate32] ^= __r;
139 _M_state32[(__i + __mid + __lag) % _M_nstate32] ^= __r;
140 _M_state32[__i] = __r;
144 _M_period_certification();
148 template<
typename _UIntType,
size_t __m,
149 size_t __pos1,
size_t __sl1,
size_t __sl2,
150 size_t __sr1,
size_t __sr2,
151 uint32_t __msk1, uint32_t __msk2,
152 uint32_t __msk3, uint32_t __msk4,
153 uint32_t __parity1, uint32_t __parity2,
154 uint32_t __parity3, uint32_t __parity4>
155 void simd_fast_mersenne_twister_engine<_UIntType, __m,
156 __pos1, __sl1, __sl2, __sr1, __sr2,
157 __msk1, __msk2, __msk3, __msk4,
158 __parity1, __parity2, __parity3,
160 _M_period_certification(
void)
162 static const uint32_t __parity[4] = { __parity1, __parity2,
163 __parity3, __parity4 };
164 uint32_t __inner = 0;
165 for (
size_t __i = 0; __i < 4; ++__i)
166 if (__parity[__i] != 0)
167 __inner ^= _M_state32[__i] & __parity[__i];
169 if (__builtin_parity(__inner) & 1)
171 for (
size_t __i = 0; __i < 4; ++__i)
172 if (__parity[__i] != 0)
174 _M_state32[__i] ^= 1 << (__builtin_ffs(__parity[__i]) - 1);
177 __builtin_unreachable();
181 template<
typename _UIntType,
size_t __m,
182 size_t __pos1,
size_t __sl1,
size_t __sl2,
183 size_t __sr1,
size_t __sr2,
184 uint32_t __msk1, uint32_t __msk2,
185 uint32_t __msk3, uint32_t __msk4,
186 uint32_t __parity1, uint32_t __parity2,
187 uint32_t __parity3, uint32_t __parity4>
188 void simd_fast_mersenne_twister_engine<_UIntType, __m,
189 __pos1, __sl1, __sl2, __sr1, __sr2,
190 __msk1, __msk2, __msk3, __msk4,
191 __parity1, __parity2, __parity3,
193 discard(
unsigned long long __z)
195 while (__z > state_size - _M_pos)
197 __z -= state_size - _M_pos;
206 #ifndef _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 210 template<
size_t __shift>
211 inline void __rshift(uint32_t *__out,
const uint32_t *__in)
213 uint64_t __th = ((
static_cast<uint64_t
>(__in[3]) << 32)
214 |
static_cast<uint64_t
>(__in[2]));
215 uint64_t __tl = ((
static_cast<uint64_t
>(__in[1]) << 32)
216 |
static_cast<uint64_t
>(__in[0]));
218 uint64_t __oh = __th >> (__shift * 8);
219 uint64_t __ol = __tl >> (__shift * 8);
220 __ol |= __th << (64 - __shift * 8);
221 __out[1] =
static_cast<uint32_t
>(__ol >> 32);
222 __out[0] =
static_cast<uint32_t
>(__ol);
223 __out[3] =
static_cast<uint32_t
>(__oh >> 32);
224 __out[2] =
static_cast<uint32_t
>(__oh);
228 template<
size_t __shift>
229 inline void __lshift(uint32_t *__out,
const uint32_t *__in)
231 uint64_t __th = ((
static_cast<uint64_t
>(__in[3]) << 32)
232 |
static_cast<uint64_t
>(__in[2]));
233 uint64_t __tl = ((
static_cast<uint64_t
>(__in[1]) << 32)
234 |
static_cast<uint64_t
>(__in[0]));
236 uint64_t __oh = __th << (__shift * 8);
237 uint64_t __ol = __tl << (__shift * 8);
238 __oh |= __tl >> (64 - __shift * 8);
239 __out[1] =
static_cast<uint32_t
>(__ol >> 32);
240 __out[0] =
static_cast<uint32_t
>(__ol);
241 __out[3] =
static_cast<uint32_t
>(__oh >> 32);
242 __out[2] =
static_cast<uint32_t
>(__oh);
246 template<
size_t __sl1,
size_t __sl2,
size_t __sr1,
size_t __sr2,
247 uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4>
248 inline void __recursion(uint32_t *__r,
249 const uint32_t *__a,
const uint32_t *__b,
250 const uint32_t *__c,
const uint32_t *__d)
255 __lshift<__sl2>(__x, __a);
256 __rshift<__sr2>(__y, __c);
257 __r[0] = (__a[0] ^ __x[0] ^ ((__b[0] >> __sr1) & __msk1)
258 ^ __y[0] ^ (__d[0] << __sl1));
259 __r[1] = (__a[1] ^ __x[1] ^ ((__b[1] >> __sr1) & __msk2)
260 ^ __y[1] ^ (__d[1] << __sl1));
261 __r[2] = (__a[2] ^ __x[2] ^ ((__b[2] >> __sr1) & __msk3)
262 ^ __y[2] ^ (__d[2] << __sl1));
263 __r[3] = (__a[3] ^ __x[3] ^ ((__b[3] >> __sr1) & __msk4)
264 ^ __y[3] ^ (__d[3] << __sl1));
270 template<
typename _UIntType,
size_t __m,
271 size_t __pos1,
size_t __sl1,
size_t __sl2,
272 size_t __sr1,
size_t __sr2,
273 uint32_t __msk1, uint32_t __msk2,
274 uint32_t __msk3, uint32_t __msk4,
275 uint32_t __parity1, uint32_t __parity2,
276 uint32_t __parity3, uint32_t __parity4>
277 void simd_fast_mersenne_twister_engine<_UIntType, __m,
278 __pos1, __sl1, __sl2, __sr1, __sr2,
279 __msk1, __msk2, __msk3, __msk4,
280 __parity1, __parity2, __parity3,
284 const uint32_t *__r1 = &_M_state32[_M_nstate32 - 8];
285 const uint32_t *__r2 = &_M_state32[_M_nstate32 - 4];
286 static constexpr
size_t __pos1_32 = __pos1 * 4;
289 for (__i = 0; __i < _M_nstate32 - __pos1_32; __i += 4)
291 __recursion<__sl1, __sl2, __sr1, __sr2,
292 __msk1, __msk2, __msk3, __msk4>
293 (&_M_state32[__i], &_M_state32[__i],
294 &_M_state32[__i + __pos1_32], __r1, __r2);
296 __r2 = &_M_state32[__i];
299 for (; __i < _M_nstate32; __i += 4)
301 __recursion<__sl1, __sl2, __sr1, __sr2,
302 __msk1, __msk2, __msk3, __msk4>
303 (&_M_state32[__i], &_M_state32[__i],
304 &_M_state32[__i + __pos1_32 - _M_nstate32], __r1, __r2);
306 __r2 = &_M_state32[__i];
314 #ifndef _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 315 template<
typename _UIntType,
size_t __m,
316 size_t __pos1,
size_t __sl1,
size_t __sl2,
317 size_t __sr1,
size_t __sr2,
318 uint32_t __msk1, uint32_t __msk2,
319 uint32_t __msk3, uint32_t __msk4,
320 uint32_t __parity1, uint32_t __parity2,
321 uint32_t __parity3, uint32_t __parity4>
323 operator==(
const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
324 __m, __pos1, __sl1, __sl2, __sr1, __sr2,
325 __msk1, __msk2, __msk3, __msk4,
326 __parity1, __parity2, __parity3, __parity4>& __lhs,
327 const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
328 __m, __pos1, __sl1, __sl2, __sr1, __sr2,
329 __msk1, __msk2, __msk3, __msk4,
330 __parity1, __parity2, __parity3, __parity4>& __rhs)
332 typedef __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
333 __m, __pos1, __sl1, __sl2, __sr1, __sr2,
334 __msk1, __msk2, __msk3, __msk4,
335 __parity1, __parity2, __parity3, __parity4> __engine;
336 return (std::equal(__lhs._M_stateT,
337 __lhs._M_stateT + __engine::state_size,
339 && __lhs._M_pos == __rhs._M_pos);
343 template<
typename _UIntType,
size_t __m,
344 size_t __pos1,
size_t __sl1,
size_t __sl2,
345 size_t __sr1,
size_t __sr2,
346 uint32_t __msk1, uint32_t __msk2,
347 uint32_t __msk3, uint32_t __msk4,
348 uint32_t __parity1, uint32_t __parity2,
349 uint32_t __parity3, uint32_t __parity4,
350 typename _CharT,
typename _Traits>
352 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
353 const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
354 __m, __pos1, __sl1, __sl2, __sr1, __sr2,
355 __msk1, __msk2, __msk3, __msk4,
356 __parity1, __parity2, __parity3, __parity4>& __x)
359 typedef typename __ostream_type::ios_base __ios_base;
361 const typename __ios_base::fmtflags __flags = __os.
flags();
362 const _CharT __fill = __os.fill();
363 const _CharT __space = __os.widen(
' ');
367 for (
size_t __i = 0; __i < __x._M_nstate32; ++__i)
368 __os << __x._M_state32[__i] << __space;
377 template<
typename _UIntType,
size_t __m,
378 size_t __pos1,
size_t __sl1,
size_t __sl2,
379 size_t __sr1,
size_t __sr2,
380 uint32_t __msk1, uint32_t __msk2,
381 uint32_t __msk3, uint32_t __msk4,
382 uint32_t __parity1, uint32_t __parity2,
383 uint32_t __parity3, uint32_t __parity4,
384 typename _CharT,
typename _Traits>
387 __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
388 __m, __pos1, __sl1, __sl2, __sr1, __sr2,
389 __msk1, __msk2, __msk3, __msk4,
390 __parity1, __parity2, __parity3, __parity4>& __x)
393 typedef typename __istream_type::ios_base __ios_base;
395 const typename __ios_base::fmtflags __flags = __is.
flags();
398 for (
size_t __i = 0; __i < __x._M_nstate32; ++__i)
399 __is >> __x._M_state32[__i];
406 #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 414 template<
typename _RealType>
415 template<
typename _UniformRandomNumberGenerator>
416 typename beta_distribution<_RealType>::result_type
417 beta_distribution<_RealType>::
418 operator()(_UniformRandomNumberGenerator& __urng,
419 const param_type& __param)
421 std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
424 result_type __x, __y;
430 while (__x + __y > result_type(1));
432 return __x / (__x + __y);
435 template<
typename _RealType>
436 template<
typename _OutputIterator,
437 typename _UniformRandomNumberGenerator>
439 beta_distribution<_RealType>::
440 __generate_impl(_OutputIterator __f, _OutputIterator __t,
441 _UniformRandomNumberGenerator& __urng,
442 const param_type& __param)
444 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
447 std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
452 result_type __x, __y;
458 while (__x + __y > result_type(1));
460 *__f++ = __x / (__x + __y);
464 template<
typename _RealType,
typename _CharT,
typename _Traits>
466 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
467 const __gnu_cxx::beta_distribution<_RealType>& __x)
470 typedef typename __ostream_type::ios_base __ios_base;
472 const typename __ios_base::fmtflags __flags = __os.
flags();
473 const _CharT __fill = __os.
fill();
475 const _CharT __space = __os.
widen(
' ');
480 __os << __x.alpha() << __space << __x.beta();
488 template<
typename _RealType,
typename _CharT,
typename _Traits>
491 __gnu_cxx::beta_distribution<_RealType>& __x)
494 typedef typename __istream_type::ios_base __ios_base;
496 const typename __ios_base::fmtflags __flags = __is.
flags();
499 _RealType __alpha_val, __beta_val;
500 __is >> __alpha_val >> __beta_val;
501 __x.param(
typename __gnu_cxx::beta_distribution<_RealType>::
502 param_type(__alpha_val, __beta_val));
509 template<std::
size_t _Dimen,
typename _RealType>
510 template<
typename _InputIterator1,
typename _InputIterator2>
512 normal_mv_distribution<_Dimen, _RealType>::param_type::
513 _M_init_full(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
514 _InputIterator2 __varcovbegin, _InputIterator2 __varcovend)
516 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
517 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
518 std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
519 _M_mean.end(), _RealType(0));
522 auto __w = _M_t.begin();
523 for (
size_t __j = 0; __j < _Dimen; ++__j)
525 _RealType __sum = _RealType(0);
527 auto __slitbegin = __w;
528 auto __cit = _M_t.begin();
529 for (
size_t __i = 0; __i < __j; ++__i)
531 auto __slit = __slitbegin;
532 _RealType __s = *__varcovbegin++;
533 for (
size_t __k = 0; __k < __i; ++__k)
534 __s -= *__slit++ * *__cit++;
536 *__w++ = __s /= *__cit++;
540 __sum = *__varcovbegin - __sum;
541 if (__builtin_expect(__sum <= _RealType(0), 0))
542 std::__throw_runtime_error(__N(
"normal_mv_distribution::" 543 "param_type::_M_init_full"));
550 template<std::
size_t _Dimen,
typename _RealType>
551 template<
typename _InputIterator1,
typename _InputIterator2>
553 normal_mv_distribution<_Dimen, _RealType>::param_type::
554 _M_init_lower(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
555 _InputIterator2 __varcovbegin, _InputIterator2 __varcovend)
557 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
558 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
559 std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
560 _M_mean.end(), _RealType(0));
563 auto __w = _M_t.begin();
564 for (
size_t __j = 0; __j < _Dimen; ++__j)
566 _RealType __sum = _RealType(0);
568 auto __slitbegin = __w;
569 auto __cit = _M_t.begin();
570 for (
size_t __i = 0; __i < __j; ++__i)
572 auto __slit = __slitbegin;
573 _RealType __s = *__varcovbegin++;
574 for (
size_t __k = 0; __k < __i; ++__k)
575 __s -= *__slit++ * *__cit++;
577 *__w++ = __s /= *__cit++;
581 __sum = *__varcovbegin++ - __sum;
582 if (__builtin_expect(__sum <= _RealType(0), 0))
583 std::__throw_runtime_error(__N(
"normal_mv_distribution::" 584 "param_type::_M_init_full"));
589 template<std::
size_t _Dimen,
typename _RealType>
590 template<
typename _InputIterator1,
typename _InputIterator2>
592 normal_mv_distribution<_Dimen, _RealType>::param_type::
593 _M_init_diagonal(_InputIterator1 __meanbegin, _InputIterator1 __meanend,
594 _InputIterator2 __varbegin, _InputIterator2 __varend)
596 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
597 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
598 std::fill(std::copy(__meanbegin, __meanend, _M_mean.begin()),
599 _M_mean.end(), _RealType(0));
601 auto __w = _M_t.begin();
603 while (__varbegin != __varend)
607 if (__builtin_expect(*__varbegin < _RealType(0), 0))
608 std::__throw_runtime_error(__N(
"normal_mv_distribution::" 609 "param_type::_M_init_diagonal"));
614 template<std::
size_t _Dimen,
typename _RealType>
615 template<
typename _UniformRandomNumberGenerator>
616 typename normal_mv_distribution<_Dimen, _RealType>::result_type
617 normal_mv_distribution<_Dimen, _RealType>::
618 operator()(_UniformRandomNumberGenerator& __urng,
619 const param_type& __param)
623 _M_nd.__generate(__ret.begin(), __ret.end(), __urng);
625 auto __t_it = __param._M_t.crbegin();
626 for (
size_t __i = _Dimen; __i > 0; --__i)
628 _RealType __sum = _RealType(0);
629 for (
size_t __j = __i; __j > 0; --__j)
630 __sum += __ret[__j - 1] * *__t_it++;
631 __ret[__i - 1] = __sum;
637 template<std::
size_t _Dimen,
typename _RealType>
638 template<
typename _ForwardIterator,
typename _UniformRandomNumberGenerator>
640 normal_mv_distribution<_Dimen, _RealType>::
641 __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
642 _UniformRandomNumberGenerator& __urng,
643 const param_type& __param)
645 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
648 *__f++ = this->operator()(__urng, __param);
651 template<
size_t _Dimen, typename _RealType>
653 operator==(const
__gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
655 const
__gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
658 return __d1._M_param == __d2._M_param && __d1._M_nd == __d2._M_nd;
661 template<
size_t _Dimen,
typename _RealType,
typename _CharT,
typename _Traits>
663 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
664 const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>& __x)
667 typedef typename __ostream_type::ios_base __ios_base;
669 const typename __ios_base::fmtflags __flags = __os.
flags();
670 const _CharT __fill = __os.fill();
672 const _CharT __space = __os.widen(
' ');
677 auto __mean = __x._M_param.mean();
678 for (
auto __it : __mean)
679 __os << __it << __space;
680 auto __t = __x._M_param.varcov();
681 for (
auto __it : __t)
682 __os << __it << __space;
688 __os.precision(__precision);
692 template<
size_t _Dimen,
typename _RealType,
typename _CharT,
typename _Traits>
695 __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>& __x)
698 typedef typename __istream_type::ios_base __ios_base;
700 const typename __ios_base::fmtflags __flags = __is.
flags();
704 for (
auto& __it : __mean)
706 std::array<_RealType, _Dimen * (_Dimen + 1) / 2> __varcov;
707 for (
auto& __it : __varcov)
712 __x.param(
typename normal_mv_distribution<_Dimen, _RealType>::
713 param_type(__mean.begin(), __mean.end(),
714 __varcov.begin(), __varcov.end()));
721 template<
typename _RealType>
722 template<
typename _OutputIterator,
723 typename _UniformRandomNumberGenerator>
725 rice_distribution<_RealType>::
726 __generate_impl(_OutputIterator __f, _OutputIterator __t,
727 _UniformRandomNumberGenerator& __urng,
728 const param_type& __p)
730 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
736 __px(__p.nu(), __p.sigma()), __py(result_type(0), __p.sigma());
737 result_type __x = this->_M_ndx(__px, __urng);
738 result_type __y = this->_M_ndy(__py, __urng);
739 #if _GLIBCXX_USE_C99_MATH_TR1 740 *__f++ = std::hypot(__x, __y);
742 *__f++ =
std::sqrt(__x * __x + __y * __y);
747 template<
typename _RealType,
typename _CharT,
typename _Traits>
749 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
750 const rice_distribution<_RealType>& __x)
753 typedef typename __ostream_type::ios_base __ios_base;
755 const typename __ios_base::fmtflags __flags = __os.
flags();
756 const _CharT __fill = __os.
fill();
758 const _CharT __space = __os.
widen(
' ');
763 __os << __x.nu() << __space << __x.sigma();
764 __os << __space << __x._M_ndx;
765 __os << __space << __x._M_ndy;
773 template<
typename _RealType,
typename _CharT,
typename _Traits>
776 rice_distribution<_RealType>& __x)
779 typedef typename __istream_type::ios_base __ios_base;
781 const typename __ios_base::fmtflags __flags = __is.
flags();
784 _RealType __nu_val, __sigma_val;
785 __is >> __nu_val >> __sigma_val;
788 __x.param(
typename rice_distribution<_RealType>::
789 param_type(__nu_val, __sigma_val));
796 template<
typename _RealType>
797 template<
typename _OutputIterator,
798 typename _UniformRandomNumberGenerator>
800 nakagami_distribution<_RealType>::
801 __generate_impl(_OutputIterator __f, _OutputIterator __t,
802 _UniformRandomNumberGenerator& __urng,
803 const param_type& __p)
805 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
808 typename
std::gamma_distribution<result_type>::param_type
809 __pg(__p.mu(), __p.omega() / __p.mu());
811 *__f++ =
std::
sqrt(this->_M_gd(__pg, __urng));
814 template<typename _RealType, typename _CharT, typename _Traits>
815 std::basic_ostream<_CharT, _Traits>&
816 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
817 const nakagami_distribution<_RealType>& __x)
820 typedef typename __ostream_type::ios_base __ios_base;
822 const typename __ios_base::fmtflags __flags = __os.
flags();
823 const _CharT __fill = __os.fill();
825 const _CharT __space = __os.widen(
' ');
830 __os << __x.mu() << __space << __x.omega();
831 __os << __space << __x._M_gd;
835 __os.precision(__precision);
839 template<
typename _RealType,
typename _CharT,
typename _Traits>
842 nakagami_distribution<_RealType>& __x)
845 typedef typename __istream_type::ios_base __ios_base;
847 const typename __ios_base::fmtflags __flags = __is.
flags();
850 _RealType __mu_val, __omega_val;
851 __is >> __mu_val >> __omega_val;
853 __x.param(
typename nakagami_distribution<_RealType>::
854 param_type(__mu_val, __omega_val));
861 template<
typename _RealType>
862 template<
typename _OutputIterator,
863 typename _UniformRandomNumberGenerator>
865 pareto_distribution<_RealType>::
866 __generate_impl(_OutputIterator __f, _OutputIterator __t,
867 _UniformRandomNumberGenerator& __urng,
868 const param_type& __p)
870 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
873 result_type __mu_val = __p.mu();
874 result_type __malphinv = -result_type(1) / __p.alpha();
876 *__f++ = __mu_val *
std::
pow(this->_M_ud(__urng), __malphinv);
879 template<typename _RealType, typename _CharT, typename _Traits>
880 std::basic_ostream<_CharT, _Traits>&
881 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
882 const pareto_distribution<_RealType>& __x)
885 typedef typename __ostream_type::ios_base __ios_base;
887 const typename __ios_base::fmtflags __flags = __os.
flags();
888 const _CharT __fill = __os.fill();
890 const _CharT __space = __os.widen(
' ');
895 __os << __x.alpha() << __space << __x.mu();
896 __os << __space << __x._M_ud;
900 __os.precision(__precision);
904 template<
typename _RealType,
typename _CharT,
typename _Traits>
907 pareto_distribution<_RealType>& __x)
910 typedef typename __istream_type::ios_base __ios_base;
912 const typename __ios_base::fmtflags __flags = __is.
flags();
915 _RealType __alpha_val, __mu_val;
916 __is >> __alpha_val >> __mu_val;
918 __x.param(
typename pareto_distribution<_RealType>::
919 param_type(__alpha_val, __mu_val));
926 template<
typename _RealType>
927 template<
typename _UniformRandomNumberGenerator>
928 typename k_distribution<_RealType>::result_type
929 k_distribution<_RealType>::
930 operator()(_UniformRandomNumberGenerator& __urng)
932 result_type __x = this->_M_gd1(__urng);
933 result_type __y = this->_M_gd2(__urng);
937 template<
typename _RealType>
938 template<
typename _UniformRandomNumberGenerator>
939 typename k_distribution<_RealType>::result_type
940 k_distribution<_RealType>::
941 operator()(_UniformRandomNumberGenerator& __urng,
942 const param_type& __p)
945 __p1(__p.lambda(), result_type(1) / __p.lambda()),
946 __p2(__p.nu(), __p.mu() / __p.nu());
947 result_type __x = this->_M_gd1(__p1, __urng);
948 result_type __y = this->_M_gd2(__p2, __urng);
952 template<
typename _RealType>
953 template<
typename _OutputIterator,
954 typename _UniformRandomNumberGenerator>
956 k_distribution<_RealType>::
957 __generate_impl(_OutputIterator __f, _OutputIterator __t,
958 _UniformRandomNumberGenerator& __urng,
959 const param_type& __p)
961 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
964 typename
std::gamma_distribution<result_type>::param_type
965 __p1(__p.lambda(), result_type(1) / __p.lambda()),
966 __p2(__p.nu(), __p.mu() / __p.nu());
969 result_type __x = this->_M_gd1(__p1, __urng);
970 result_type __y = this->_M_gd2(__p2, __urng);
975 template<
typename _RealType,
typename _CharT,
typename _Traits>
977 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
978 const k_distribution<_RealType>& __x)
981 typedef typename __ostream_type::ios_base __ios_base;
983 const typename __ios_base::fmtflags __flags = __os.
flags();
984 const _CharT __fill = __os.
fill();
986 const _CharT __space = __os.
widen(
' ');
991 __os << __x.lambda() << __space << __x.mu() << __space << __x.nu();
992 __os << __space << __x._M_gd1;
993 __os << __space << __x._M_gd2;
1001 template<
typename _RealType,
typename _CharT,
typename _Traits>
1004 k_distribution<_RealType>& __x)
1007 typedef typename __istream_type::ios_base __ios_base;
1009 const typename __ios_base::fmtflags __flags = __is.
flags();
1012 _RealType __lambda_val, __mu_val, __nu_val;
1013 __is >> __lambda_val >> __mu_val >> __nu_val;
1016 __x.param(
typename k_distribution<_RealType>::
1017 param_type(__lambda_val, __mu_val, __nu_val));
1019 __is.
flags(__flags);
1024 template<
typename _RealType>
1025 template<
typename _OutputIterator,
1026 typename _UniformRandomNumberGenerator>
1028 arcsine_distribution<_RealType>::
1029 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1030 _UniformRandomNumberGenerator& __urng,
1031 const param_type& __p)
1033 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1036 result_type __dif = __p.b() - __p.a();
1037 result_type __sum = __p.a() + __p.b();
1040 result_type __x =
std::sin(this->_M_ud(__urng));
1041 *__f++ = (__x * __dif + __sum) / result_type(2);
1045 template<
typename _RealType,
typename _CharT,
typename _Traits>
1047 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1048 const arcsine_distribution<_RealType>& __x)
1051 typedef typename __ostream_type::ios_base __ios_base;
1053 const typename __ios_base::fmtflags __flags = __os.
flags();
1054 const _CharT __fill = __os.
fill();
1056 const _CharT __space = __os.
widen(
' ');
1061 __os << __x.a() << __space << __x.b();
1062 __os << __space << __x._M_ud;
1064 __os.
flags(__flags);
1070 template<
typename _RealType,
typename _CharT,
typename _Traits>
1073 arcsine_distribution<_RealType>& __x)
1076 typedef typename __istream_type::ios_base __ios_base;
1078 const typename __ios_base::fmtflags __flags = __is.
flags();
1084 __x.param(
typename arcsine_distribution<_RealType>::
1085 param_type(__a, __b));
1087 __is.
flags(__flags);
1092 template<
typename _RealType>
1093 template<
typename _UniformRandomNumberGenerator>
1094 typename hoyt_distribution<_RealType>::result_type
1095 hoyt_distribution<_RealType>::
1096 operator()(_UniformRandomNumberGenerator& __urng)
1098 result_type __x = this->_M_ad(__urng);
1099 result_type __y = this->_M_ed(__urng);
1100 return (result_type(2) * this->q()
1101 / (result_type(1) + this->q() * this->q()))
1105 template<
typename _RealType>
1106 template<
typename _UniformRandomNumberGenerator>
1107 typename hoyt_distribution<_RealType>::result_type
1108 hoyt_distribution<_RealType>::
1109 operator()(_UniformRandomNumberGenerator& __urng,
1110 const param_type& __p)
1112 result_type __q2 = __p.q() * __p.q();
1113 result_type __num = result_type(0.5L) * (result_type(1) + __q2);
1114 typename __gnu_cxx::arcsine_distribution<result_type>::param_type
1115 __pa(__num, __num / __q2);
1116 result_type __x = this->_M_ad(__pa, __urng);
1117 result_type __y = this->_M_ed(__urng);
1118 return (result_type(2) * __p.q() / (result_type(1) + __q2))
1122 template<
typename _RealType>
1123 template<
typename _OutputIterator,
1124 typename _UniformRandomNumberGenerator>
1126 hoyt_distribution<_RealType>::
1127 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1128 _UniformRandomNumberGenerator& __urng,
1129 const param_type& __p)
1131 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1134 result_type __2q = result_type(2) * __p.q();
1135 result_type __q2 = __p.q() * __p.q();
1136 result_type __q2p1 = result_type(1) + __q2;
1137 result_type __num = result_type(0.5L) * __q2p1;
1138 result_type __omega = __p.omega();
1139 typename
__gnu_cxx::arcsine_distribution<result_type>::param_type
1140 __pa(__num, __num / __q2);
1143 result_type __x = this->_M_ad(__pa, __urng);
1144 result_type __y = this->_M_ed(__urng);
1145 *__f++ = (__2q / __q2p1) *
std::sqrt(__omega * __x * __y);
1149 template<
typename _RealType,
typename _CharT,
typename _Traits>
1151 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1152 const hoyt_distribution<_RealType>& __x)
1155 typedef typename __ostream_type::ios_base __ios_base;
1157 const typename __ios_base::fmtflags __flags = __os.
flags();
1158 const _CharT __fill = __os.
fill();
1160 const _CharT __space = __os.
widen(
' ');
1165 __os << __x.q() << __space << __x.omega();
1166 __os << __space << __x._M_ad;
1167 __os << __space << __x._M_ed;
1169 __os.
flags(__flags);
1175 template<
typename _RealType,
typename _CharT,
typename _Traits>
1178 hoyt_distribution<_RealType>& __x)
1181 typedef typename __istream_type::ios_base __ios_base;
1183 const typename __ios_base::fmtflags __flags = __is.
flags();
1186 _RealType __q, __omega;
1187 __is >> __q >> __omega;
1190 __x.param(
typename hoyt_distribution<_RealType>::
1191 param_type(__q, __omega));
1193 __is.
flags(__flags);
1198 template<
typename _RealType>
1199 template<
typename _OutputIterator,
1200 typename _UniformRandomNumberGenerator>
1202 triangular_distribution<_RealType>::
1203 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1204 _UniformRandomNumberGenerator& __urng,
1205 const param_type& __param)
1207 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1211 *__f++ = this->operator()(__urng, __param);
1214 template<typename _RealType, typename _CharT, typename _Traits>
1215 std::basic_ostream<_CharT, _Traits>&
1216 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1217 const
__gnu_cxx::triangular_distribution<_RealType>& __x)
1220 typedef typename __ostream_type::ios_base __ios_base;
1222 const typename __ios_base::fmtflags __flags = __os.
flags();
1223 const _CharT __fill = __os.fill();
1225 const _CharT __space = __os.widen(
' ');
1230 __os << __x.a() << __space << __x.b() << __space << __x.c();
1232 __os.flags(__flags);
1234 __os.precision(__precision);
1238 template<
typename _RealType,
typename _CharT,
typename _Traits>
1241 __gnu_cxx::triangular_distribution<_RealType>& __x)
1244 typedef typename __istream_type::ios_base __ios_base;
1246 const typename __ios_base::fmtflags __flags = __is.
flags();
1249 _RealType __a, __b, __c;
1250 __is >> __a >> __b >> __c;
1251 __x.param(
typename __gnu_cxx::triangular_distribution<_RealType>::
1252 param_type(__a, __b, __c));
1254 __is.
flags(__flags);
1259 template<
typename _RealType>
1260 template<
typename _UniformRandomNumberGenerator>
1261 typename von_mises_distribution<_RealType>::result_type
1262 von_mises_distribution<_RealType>::
1263 operator()(_UniformRandomNumberGenerator& __urng,
1264 const param_type& __p)
1266 const result_type __pi
1267 = __gnu_cxx::__math_constants<result_type>::__pi;
1268 std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1274 result_type __rnd =
std::cos(__pi * __aurng());
1275 __f = (result_type(1) + __p._M_r * __rnd) / (__p._M_r + __rnd);
1276 result_type __c = __p._M_kappa * (__p._M_r - __f);
1278 result_type __rnd2 = __aurng();
1279 if (__c * (result_type(2) - __c) > __rnd2)
1281 if (
std::log(__c / __rnd2) >= __c - result_type(1))
1286 #if _GLIBCXX_USE_C99_MATH_TR1 1287 __res = std::copysign(__res, __aurng() - result_type(0.5));
1289 if (__aurng() < result_type(0.5))
1294 __res -= result_type(2) * __pi;
1295 else if (__res < -__pi)
1296 __res += result_type(2) * __pi;
1300 template<
typename _RealType>
1301 template<
typename _OutputIterator,
1302 typename _UniformRandomNumberGenerator>
1304 von_mises_distribution<_RealType>::
1305 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1306 _UniformRandomNumberGenerator& __urng,
1307 const param_type& __param)
1309 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1313 *__f++ = this->operator()(__urng, __param);
1316 template<typename _RealType, typename _CharT, typename _Traits>
1317 std::basic_ostream<_CharT, _Traits>&
1318 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1319 const
__gnu_cxx::von_mises_distribution<_RealType>& __x)
1322 typedef typename __ostream_type::ios_base __ios_base;
1324 const typename __ios_base::fmtflags __flags = __os.
flags();
1325 const _CharT __fill = __os.fill();
1327 const _CharT __space = __os.widen(
' ');
1332 __os << __x.mu() << __space << __x.kappa();
1334 __os.flags(__flags);
1336 __os.precision(__precision);
1340 template<
typename _RealType,
typename _CharT,
typename _Traits>
1343 __gnu_cxx::von_mises_distribution<_RealType>& __x)
1346 typedef typename __istream_type::ios_base __ios_base;
1348 const typename __ios_base::fmtflags __flags = __is.
flags();
1351 _RealType __mu, __kappa;
1352 __is >> __mu >> __kappa;
1353 __x.param(
typename __gnu_cxx::von_mises_distribution<_RealType>::
1354 param_type(__mu, __kappa));
1356 __is.
flags(__flags);
1361 template<
typename _UIntType>
1362 template<
typename _UniformRandomNumberGenerator>
1363 typename hypergeometric_distribution<_UIntType>::result_type
1364 hypergeometric_distribution<_UIntType>::
1365 operator()(_UniformRandomNumberGenerator& __urng,
1366 const param_type& __param)
1368 std::__detail::_Adaptor<_UniformRandomNumberGenerator, double>
1371 result_type __a = __param.successful_size();
1372 result_type __b = __param.total_size();
1373 result_type __k = 0;
1375 if (__param.total_draws() < __param.total_size() / 2)
1377 for (result_type __i = 0; __i < __param.total_draws(); ++__i)
1379 if (__b * __aurng() < __a)
1382 if (__k == __param.successful_size())
1392 for (result_type __i = 0; __i < __param.unsuccessful_size(); ++__i)
1394 if (__b * __aurng() < __a)
1397 if (__k == __param.successful_size())
1398 return __param.successful_size() - __k;
1403 return __param.successful_size() - __k;
1407 template<
typename _UIntType>
1408 template<
typename _OutputIterator,
1409 typename _UniformRandomNumberGenerator>
1411 hypergeometric_distribution<_UIntType>::
1412 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1413 _UniformRandomNumberGenerator& __urng,
1414 const param_type& __param)
1416 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1420 *__f++ = this->operator()(__urng);
1423 template<typename _UIntType, typename _CharT, typename _Traits>
1424 std::basic_ostream<_CharT, _Traits>&
1425 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1426 const
__gnu_cxx::hypergeometric_distribution<_UIntType>& __x)
1429 typedef typename __ostream_type::ios_base __ios_base;
1431 const typename __ios_base::fmtflags __flags = __os.
flags();
1432 const _CharT __fill = __os.fill();
1434 const _CharT __space = __os.widen(
' ');
1439 __os << __x.total_size() << __space << __x.successful_size() << __space
1440 << __x.total_draws();
1442 __os.flags(__flags);
1444 __os.precision(__precision);
1448 template<
typename _UIntType,
typename _CharT,
typename _Traits>
1451 __gnu_cxx::hypergeometric_distribution<_UIntType>& __x)
1454 typedef typename __istream_type::ios_base __ios_base;
1456 const typename __ios_base::fmtflags __flags = __is.
flags();
1459 _UIntType __total_size, __successful_size, __total_draws;
1460 __is >> __total_size >> __successful_size >> __total_draws;
1461 __x.param(
typename __gnu_cxx::hypergeometric_distribution<_UIntType>::
1462 param_type(__total_size, __successful_size, __total_draws));
1464 __is.
flags(__flags);
1469 template<
typename _RealType>
1470 template<
typename _UniformRandomNumberGenerator>
1471 typename logistic_distribution<_RealType>::result_type
1472 logistic_distribution<_RealType>::
1473 operator()(_UniformRandomNumberGenerator& __urng,
1474 const param_type& __p)
1476 std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1479 result_type __arg = result_type(1);
1480 while (__arg == result_type(1) || __arg == result_type(0))
1483 + __p.b() *
std::log(__arg / (result_type(1) - __arg));
1486 template<
typename _RealType>
1487 template<
typename _OutputIterator,
1488 typename _UniformRandomNumberGenerator>
1490 logistic_distribution<_RealType>::
1491 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1492 _UniformRandomNumberGenerator& __urng,
1493 const param_type& __p)
1495 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1498 std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1503 result_type __arg = result_type(1);
1504 while (__arg == result_type(1) || __arg == result_type(0))
1507 + __p.b() *
std::log(__arg / (result_type(1) - __arg));
1511 template<
typename _RealType,
typename _CharT,
typename _Traits>
1513 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1514 const logistic_distribution<_RealType>& __x)
1517 typedef typename __ostream_type::ios_base __ios_base;
1519 const typename __ios_base::fmtflags __flags = __os.
flags();
1520 const _CharT __fill = __os.
fill();
1522 const _CharT __space = __os.
widen(
' ');
1527 __os << __x.a() << __space << __x.b();
1529 __os.
flags(__flags);
1535 template<
typename _RealType,
typename _CharT,
typename _Traits>
1538 logistic_distribution<_RealType>& __x)
1541 typedef typename __istream_type::ios_base __ios_base;
1543 const typename __ios_base::fmtflags __flags = __is.
flags();
1548 __x.param(
typename logistic_distribution<_RealType>::
1549 param_type(__a, __b));
1551 __is.
flags(__flags);
1560 template<std::
size_t _Dimen,
typename _RealType>
1561 class uniform_on_sphere_helper
1563 typedef typename uniform_on_sphere_distribution<_Dimen, _RealType>::
1564 result_type result_type;
1567 template<
typename _NormalDistribution,
1568 typename _UniformRandomNumberGenerator>
1569 result_type operator()(_NormalDistribution& __nd,
1570 _UniformRandomNumberGenerator& __urng)
1573 typename result_type::value_type __norm;
1577 auto __sum = _RealType(0);
1580 [&__nd, &__urng, &__sum](){
1581 _RealType __t = __nd(__urng);
1586 while (__norm == _RealType(0) || ! __builtin_isfinite(__norm));
1589 [__norm](_RealType __val){
return __val / __norm; });
1596 template<
typename _RealType>
1597 class uniform_on_sphere_helper<2, _RealType>
1599 typedef typename uniform_on_sphere_distribution<2, _RealType>::
1600 result_type result_type;
1603 template<
typename _NormalDistribution,
1604 typename _UniformRandomNumberGenerator>
1605 result_type operator()(_NormalDistribution&,
1606 _UniformRandomNumberGenerator& __urng)
1610 std::__detail::_Adaptor<_UniformRandomNumberGenerator,
1611 _RealType> __aurng(__urng);
1615 __ret[0] = _RealType(2) * __aurng() - _RealType(1);
1616 __ret[1] = _RealType(2) * __aurng() - _RealType(1);
1618 __sq = __ret[0] * __ret[0] + __ret[1] * __ret[1];
1620 while (__sq == _RealType(0) || __sq > _RealType(1));
1622 #if _GLIBCXX_USE_C99_MATH_TR1 1625 auto __norm = std::hypot(__ret[0], __ret[1]);
1639 template<std::
size_t _Dimen,
typename _RealType>
1640 template<
typename _UniformRandomNumberGenerator>
1641 typename uniform_on_sphere_distribution<_Dimen, _RealType>::result_type
1642 uniform_on_sphere_distribution<_Dimen, _RealType>::
1643 operator()(_UniformRandomNumberGenerator& __urng,
1644 const param_type& __p)
1646 uniform_on_sphere_helper<_Dimen, _RealType> __helper;
1647 return __helper(_M_nd, __urng);
1650 template<std::
size_t _Dimen,
typename _RealType>
1651 template<
typename _OutputIterator,
1652 typename _UniformRandomNumberGenerator>
1654 uniform_on_sphere_distribution<_Dimen, _RealType>::
1655 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1656 _UniformRandomNumberGenerator& __urng,
1657 const param_type& __param)
1659 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1663 *__f++ = this->operator()(__urng, __param);
1666 template<
std::
size_t _Dimen, typename _RealType, typename _CharT,
1668 std::basic_ostream<_CharT, _Traits>&
1669 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1670 const
__gnu_cxx::uniform_on_sphere_distribution<_Dimen,
1673 return __os << __x._M_nd;
1676 template<std::size_t _Dimen,
typename _RealType,
typename _CharT,
1680 __gnu_cxx::uniform_on_sphere_distribution<_Dimen,
1683 return __is >> __x._M_nd;
1691 template<std::
size_t _Dimen,
bool _SmallDimen,
typename _RealType>
1692 class uniform_inside_sphere_helper;
1694 template<std::
size_t _Dimen,
typename _RealType>
1695 class uniform_inside_sphere_helper<_Dimen, false, _RealType>
1698 =
typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
1702 template<
typename _UniformOnSphereDistribution,
1703 typename _UniformRandomNumberGenerator>
1705 operator()(_UniformOnSphereDistribution& __uosd,
1706 _UniformRandomNumberGenerator& __urng,
1709 std::__detail::_Adaptor<_UniformRandomNumberGenerator,
1710 _RealType> __aurng(__urng);
1712 _RealType __pow = 1 / _RealType(_Dimen);
1713 _RealType __urt = __radius *
std::pow(__aurng(), __pow);
1714 result_type __ret = __uosd(__aurng);
1717 [__urt](_RealType __val)
1718 {
return __val * __urt; });
1726 template<std::
size_t _Dimen,
typename _RealType>
1727 class uniform_inside_sphere_helper<_Dimen, true, _RealType>
1730 =
typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
1734 template<
typename _UniformOnSphereDistribution,
1735 typename _UniformRandomNumberGenerator>
1737 operator()(_UniformOnSphereDistribution&,
1738 _UniformRandomNumberGenerator& __urng,
1743 _RealType __radsq = __radius * __radius;
1744 std::__detail::_Adaptor<_UniformRandomNumberGenerator,
1745 _RealType> __aurng(__urng);
1749 __sq = _RealType(0);
1750 for (
int i = 0; i < _Dimen; ++i)
1752 __ret[i] = _RealType(2) * __aurng() - _RealType(1);
1753 __sq += __ret[i] * __ret[i];
1756 while (__sq > _RealType(1));
1758 for (
int i = 0; i < _Dimen; ++i)
1759 __ret[i] *= __radius;
1770 template<std::
size_t _Dimen,
typename _RealType>
1771 template<
typename _UniformRandomNumberGenerator>
1772 typename uniform_inside_sphere_distribution<_Dimen, _RealType>::result_type
1773 uniform_inside_sphere_distribution<_Dimen, _RealType>::
1774 operator()(_UniformRandomNumberGenerator& __urng,
1775 const param_type& __p)
1777 uniform_inside_sphere_helper<_Dimen, _Dimen < 8, _RealType> __helper;
1778 return __helper(_M_uosd, __urng, __p.radius());
1781 template<std::
size_t _Dimen,
typename _RealType>
1782 template<
typename _OutputIterator,
1783 typename _UniformRandomNumberGenerator>
1785 uniform_inside_sphere_distribution<_Dimen, _RealType>::
1786 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1787 _UniformRandomNumberGenerator& __urng,
1788 const param_type& __param)
1790 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1794 *__f++ = this->operator()(__urng, __param);
1797 template<
std::
size_t _Dimen, typename _RealType, typename _CharT,
1799 std::basic_ostream<_CharT, _Traits>&
1800 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1801 const
__gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
1805 typedef typename __ostream_type::ios_base __ios_base;
1807 const typename __ios_base::fmtflags __flags = __os.
flags();
1808 const _CharT __fill = __os.fill();
1810 const _CharT __space = __os.widen(
' ');
1815 __os << __x.radius() << __space << __x._M_uosd;
1817 __os.flags(__flags);
1819 __os.precision(__precision);
1824 template<std::size_t _Dimen,
typename _RealType,
typename _CharT,
1828 __gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
1832 typedef typename __istream_type::ios_base __ios_base;
1834 const typename __ios_base::fmtflags __flags = __is.
flags();
1837 _RealType __radius_val;
1838 __is >> __radius_val >> __x._M_uosd;
1839 __x.param(
typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
1840 param_type(__radius_val));
1842 __is.
flags(__flags);
1847 _GLIBCXX_END_NAMESPACE_VERSION
1851 #endif // _EXT_RANDOM_TCC ISO C++ entities toplevel namespace is std.
Properties of fundamental types.
ios_base & left(ios_base &__base)
Calls base.setf(ios_base::left, ios_base::adjustfield).
_OutputIterator transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _OutputIterator __result, _BinaryOperation __binary_op)
Perform an operation on corresponding elements of two sequences.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
char_type fill() const
Retrieves the empty character.
A standard container for storing a fixed size sequence of elements.
void generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
Assign the result of a function object to each value in a sequence.
Template class basic_ostream.
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
ios_base & skipws(ios_base &__base)
Calls base.setf(ios_base::skipws).
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
streamsize precision() const
Flags access.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
_OI fill_n(_OI __first, _Size __n, const _Tp &__value)
Fills the range [first,first+n) with copies of value.
Template class basic_istream.
char_type widen(char __c) const
Widens characters.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
ios_base & dec(ios_base &__base)
Calls base.setf(ios_base::dec, ios_base::basefield).
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
fmtflags flags() const
Access to format flags.
GNU extensions for public use.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
ios_base & scientific(ios_base &__base)
Calls base.setf(ios_base::scientific, ios_base::floatfield).
ios_base & fixed(ios_base &__base)
Calls base.setf(ios_base::fixed, ios_base::floatfield).
_GLIBCXX17_CONSTEXPR void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.