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>
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];
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>
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();
484 __os.precision(__precision);
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_lower"));
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)
605 std::fill_n(__w, __step, _RealType(0));
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>
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)
715 __x.param(
typename normal_mv_distribution<_Dimen, _RealType>::
716 param_type(__mean, __varcov));
723 template<
typename _RealType>
724 template<
typename _OutputIterator,
725 typename _UniformRandomNumberGenerator>
727 rice_distribution<_RealType>::
728 __generate_impl(_OutputIterator __f, _OutputIterator __t,
729 _UniformRandomNumberGenerator& __urng,
730 const param_type& __p)
732 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
738 __px(__p.nu(), __p.sigma()), __py(result_type(0), __p.sigma());
739 result_type __x = this->_M_ndx(__px, __urng);
740 result_type __y = this->_M_ndy(__py, __urng);
741 #if _GLIBCXX_USE_C99_MATH_TR1
742 *__f++ = std::hypot(__x, __y);
744 *__f++ =
std::sqrt(__x * __x + __y * __y);
749 template<
typename _RealType,
typename _CharT,
typename _Traits>
752 const rice_distribution<_RealType>& __x)
755 typedef typename __ostream_type::ios_base __ios_base;
757 const typename __ios_base::fmtflags __flags = __os.flags();
758 const _CharT __fill = __os.fill();
760 const _CharT __space = __os.widen(
' ');
765 __os << __x.nu() << __space << __x.sigma();
766 __os << __space << __x._M_ndx;
767 __os << __space << __x._M_ndy;
771 __os.precision(__precision);
775 template<
typename _RealType,
typename _CharT,
typename _Traits>
778 rice_distribution<_RealType>& __x)
781 typedef typename __istream_type::ios_base __ios_base;
783 const typename __ios_base::fmtflags __flags = __is.
flags();
786 _RealType __nu_val, __sigma_val;
787 __is >> __nu_val >> __sigma_val;
790 __x.param(
typename rice_distribution<_RealType>::
791 param_type(__nu_val, __sigma_val));
798 template<
typename _RealType>
799 template<
typename _OutputIterator,
800 typename _UniformRandomNumberGenerator>
802 nakagami_distribution<_RealType>::
803 __generate_impl(_OutputIterator __f, _OutputIterator __t,
804 _UniformRandomNumberGenerator& __urng,
805 const param_type& __p)
807 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
810 typename
std::gamma_distribution<result_type>::param_type
811 __pg(__p.mu(), __p.omega() / __p.mu());
813 *__f++ =
std::
sqrt(this->_M_gd(__pg, __urng));
816 template<typename _RealType, typename _CharT, typename _Traits>
817 std::basic_ostream<_CharT, _Traits>&
818 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
819 const nakagami_distribution<_RealType>& __x)
822 typedef typename __ostream_type::ios_base __ios_base;
824 const typename __ios_base::fmtflags __flags = __os.flags();
825 const _CharT __fill = __os.fill();
827 const _CharT __space = __os.widen(
' ');
832 __os << __x.mu() << __space << __x.omega();
833 __os << __space << __x._M_gd;
837 __os.precision(__precision);
841 template<
typename _RealType,
typename _CharT,
typename _Traits>
844 nakagami_distribution<_RealType>& __x)
847 typedef typename __istream_type::ios_base __ios_base;
849 const typename __ios_base::fmtflags __flags = __is.
flags();
852 _RealType __mu_val, __omega_val;
853 __is >> __mu_val >> __omega_val;
855 __x.param(
typename nakagami_distribution<_RealType>::
856 param_type(__mu_val, __omega_val));
863 template<
typename _RealType>
864 template<
typename _OutputIterator,
865 typename _UniformRandomNumberGenerator>
867 pareto_distribution<_RealType>::
868 __generate_impl(_OutputIterator __f, _OutputIterator __t,
869 _UniformRandomNumberGenerator& __urng,
870 const param_type& __p)
872 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
875 result_type __mu_val = __p.mu();
876 result_type __malphinv = -result_type(1) / __p.alpha();
878 *__f++ = __mu_val *
std::
pow(this->_M_ud(__urng), __malphinv);
881 template<typename _RealType, typename _CharT, typename _Traits>
882 std::basic_ostream<_CharT, _Traits>&
883 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
884 const pareto_distribution<_RealType>& __x)
887 typedef typename __ostream_type::ios_base __ios_base;
889 const typename __ios_base::fmtflags __flags = __os.flags();
890 const _CharT __fill = __os.fill();
892 const _CharT __space = __os.widen(
' ');
897 __os << __x.alpha() << __space << __x.mu();
898 __os << __space << __x._M_ud;
902 __os.precision(__precision);
906 template<
typename _RealType,
typename _CharT,
typename _Traits>
909 pareto_distribution<_RealType>& __x)
912 typedef typename __istream_type::ios_base __ios_base;
914 const typename __ios_base::fmtflags __flags = __is.
flags();
917 _RealType __alpha_val, __mu_val;
918 __is >> __alpha_val >> __mu_val;
920 __x.param(
typename pareto_distribution<_RealType>::
921 param_type(__alpha_val, __mu_val));
928 template<
typename _RealType>
929 template<
typename _UniformRandomNumberGenerator>
930 typename k_distribution<_RealType>::result_type
931 k_distribution<_RealType>::
932 operator()(_UniformRandomNumberGenerator& __urng)
934 result_type __x = this->_M_gd1(__urng);
935 result_type __y = this->_M_gd2(__urng);
939 template<
typename _RealType>
940 template<
typename _UniformRandomNumberGenerator>
941 typename k_distribution<_RealType>::result_type
942 k_distribution<_RealType>::
943 operator()(_UniformRandomNumberGenerator& __urng,
944 const param_type& __p)
947 __p1(__p.lambda(), result_type(1) / __p.lambda()),
948 __p2(__p.nu(), __p.mu() / __p.nu());
949 result_type __x = this->_M_gd1(__p1, __urng);
950 result_type __y = this->_M_gd2(__p2, __urng);
954 template<
typename _RealType>
955 template<
typename _OutputIterator,
956 typename _UniformRandomNumberGenerator>
958 k_distribution<_RealType>::
959 __generate_impl(_OutputIterator __f, _OutputIterator __t,
960 _UniformRandomNumberGenerator& __urng,
961 const param_type& __p)
963 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
966 typename
std::gamma_distribution<result_type>::param_type
967 __p1(__p.lambda(), result_type(1) / __p.lambda()),
968 __p2(__p.nu(), __p.mu() / __p.nu());
971 result_type __x = this->_M_gd1(__p1, __urng);
972 result_type __y = this->_M_gd2(__p2, __urng);
977 template<
typename _RealType,
typename _CharT,
typename _Traits>
980 const k_distribution<_RealType>& __x)
983 typedef typename __ostream_type::ios_base __ios_base;
985 const typename __ios_base::fmtflags __flags = __os.flags();
986 const _CharT __fill = __os.fill();
988 const _CharT __space = __os.widen(
' ');
993 __os << __x.lambda() << __space << __x.mu() << __space << __x.nu();
994 __os << __space << __x._M_gd1;
995 __os << __space << __x._M_gd2;
999 __os.precision(__precision);
1003 template<
typename _RealType,
typename _CharT,
typename _Traits>
1006 k_distribution<_RealType>& __x)
1009 typedef typename __istream_type::ios_base __ios_base;
1011 const typename __ios_base::fmtflags __flags = __is.
flags();
1014 _RealType __lambda_val, __mu_val, __nu_val;
1015 __is >> __lambda_val >> __mu_val >> __nu_val;
1018 __x.param(
typename k_distribution<_RealType>::
1019 param_type(__lambda_val, __mu_val, __nu_val));
1021 __is.
flags(__flags);
1026 template<
typename _RealType>
1027 template<
typename _OutputIterator,
1028 typename _UniformRandomNumberGenerator>
1030 arcsine_distribution<_RealType>::
1031 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1032 _UniformRandomNumberGenerator& __urng,
1033 const param_type& __p)
1035 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1038 result_type __dif = __p.b() - __p.a();
1039 result_type __sum = __p.a() + __p.b();
1042 result_type __x =
std::sin(this->_M_ud(__urng));
1043 *__f++ = (__x * __dif + __sum) / result_type(2);
1047 template<
typename _RealType,
typename _CharT,
typename _Traits>
1050 const arcsine_distribution<_RealType>& __x)
1053 typedef typename __ostream_type::ios_base __ios_base;
1055 const typename __ios_base::fmtflags __flags = __os.flags();
1056 const _CharT __fill = __os.fill();
1058 const _CharT __space = __os.widen(
' ');
1063 __os << __x.a() << __space << __x.b();
1064 __os << __space << __x._M_ud;
1066 __os.flags(__flags);
1068 __os.precision(__precision);
1072 template<
typename _RealType,
typename _CharT,
typename _Traits>
1075 arcsine_distribution<_RealType>& __x)
1078 typedef typename __istream_type::ios_base __ios_base;
1080 const typename __ios_base::fmtflags __flags = __is.
flags();
1086 __x.param(
typename arcsine_distribution<_RealType>::
1087 param_type(__a, __b));
1089 __is.
flags(__flags);
1094 template<
typename _RealType>
1095 template<
typename _UniformRandomNumberGenerator>
1096 typename hoyt_distribution<_RealType>::result_type
1097 hoyt_distribution<_RealType>::
1098 operator()(_UniformRandomNumberGenerator& __urng)
1100 result_type __x = this->_M_ad(__urng);
1101 result_type __y = this->_M_ed(__urng);
1102 return (result_type(2) * this->q()
1103 / (result_type(1) + this->q() * this->q()))
1107 template<
typename _RealType>
1108 template<
typename _UniformRandomNumberGenerator>
1109 typename hoyt_distribution<_RealType>::result_type
1110 hoyt_distribution<_RealType>::
1111 operator()(_UniformRandomNumberGenerator& __urng,
1112 const param_type& __p)
1114 result_type __q2 = __p.q() * __p.q();
1115 result_type __num = result_type(0.5L) * (result_type(1) + __q2);
1116 typename __gnu_cxx::arcsine_distribution<result_type>::param_type
1117 __pa(__num, __num / __q2);
1118 result_type __x = this->_M_ad(__pa, __urng);
1119 result_type __y = this->_M_ed(__urng);
1120 return (result_type(2) * __p.q() / (result_type(1) + __q2))
1124 template<
typename _RealType>
1125 template<
typename _OutputIterator,
1126 typename _UniformRandomNumberGenerator>
1128 hoyt_distribution<_RealType>::
1129 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1130 _UniformRandomNumberGenerator& __urng,
1131 const param_type& __p)
1133 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1136 result_type __2q = result_type(2) * __p.q();
1137 result_type __q2 = __p.q() * __p.q();
1138 result_type __q2p1 = result_type(1) + __q2;
1139 result_type __num = result_type(0.5L) * __q2p1;
1140 result_type __omega = __p.omega();
1141 typename
__gnu_cxx::arcsine_distribution<result_type>::param_type
1142 __pa(__num, __num / __q2);
1145 result_type __x = this->_M_ad(__pa, __urng);
1146 result_type __y = this->_M_ed(__urng);
1147 *__f++ = (__2q / __q2p1) *
std::sqrt(__omega * __x * __y);
1151 template<
typename _RealType,
typename _CharT,
typename _Traits>
1154 const hoyt_distribution<_RealType>& __x)
1157 typedef typename __ostream_type::ios_base __ios_base;
1159 const typename __ios_base::fmtflags __flags = __os.flags();
1160 const _CharT __fill = __os.fill();
1162 const _CharT __space = __os.widen(
' ');
1167 __os << __x.q() << __space << __x.omega();
1168 __os << __space << __x._M_ad;
1169 __os << __space << __x._M_ed;
1171 __os.flags(__flags);
1173 __os.precision(__precision);
1177 template<
typename _RealType,
typename _CharT,
typename _Traits>
1180 hoyt_distribution<_RealType>& __x)
1183 typedef typename __istream_type::ios_base __ios_base;
1185 const typename __ios_base::fmtflags __flags = __is.
flags();
1188 _RealType __q, __omega;
1189 __is >> __q >> __omega;
1192 __x.param(
typename hoyt_distribution<_RealType>::
1193 param_type(__q, __omega));
1195 __is.
flags(__flags);
1200 template<
typename _RealType>
1201 template<
typename _OutputIterator,
1202 typename _UniformRandomNumberGenerator>
1204 triangular_distribution<_RealType>::
1205 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1206 _UniformRandomNumberGenerator& __urng,
1207 const param_type& __param)
1209 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1213 *__f++ = this->operator()(__urng, __param);
1216 template<typename _RealType, typename _CharT, typename _Traits>
1217 std::basic_ostream<_CharT, _Traits>&
1218 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1219 const
__gnu_cxx::triangular_distribution<_RealType>& __x)
1222 typedef typename __ostream_type::ios_base __ios_base;
1224 const typename __ios_base::fmtflags __flags = __os.flags();
1225 const _CharT __fill = __os.fill();
1227 const _CharT __space = __os.widen(
' ');
1232 __os << __x.a() << __space << __x.b() << __space << __x.c();
1234 __os.flags(__flags);
1236 __os.precision(__precision);
1240 template<
typename _RealType,
typename _CharT,
typename _Traits>
1243 __gnu_cxx::triangular_distribution<_RealType>& __x)
1246 typedef typename __istream_type::ios_base __ios_base;
1248 const typename __ios_base::fmtflags __flags = __is.
flags();
1251 _RealType __a, __b, __c;
1252 __is >> __a >> __b >> __c;
1253 __x.param(
typename __gnu_cxx::triangular_distribution<_RealType>::
1254 param_type(__a, __b, __c));
1256 __is.
flags(__flags);
1261 template<
typename _RealType>
1262 template<
typename _UniformRandomNumberGenerator>
1263 typename von_mises_distribution<_RealType>::result_type
1264 von_mises_distribution<_RealType>::
1265 operator()(_UniformRandomNumberGenerator& __urng,
1266 const param_type& __p)
1268 const result_type __pi
1269 = __gnu_cxx::__math_constants<result_type>::__pi;
1270 std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1276 result_type __rnd =
std::cos(__pi * __aurng());
1277 __f = (result_type(1) + __p._M_r * __rnd) / (__p._M_r + __rnd);
1278 result_type __c = __p._M_kappa * (__p._M_r - __f);
1280 result_type __rnd2 = __aurng();
1281 if (__c * (result_type(2) - __c) > __rnd2)
1283 if (
std::log(__c / __rnd2) >= __c - result_type(1))
1288 #if _GLIBCXX_USE_C99_MATH_TR1
1289 __res = std::copysign(__res, __aurng() - result_type(0.5));
1291 if (__aurng() < result_type(0.5))
1296 __res -= result_type(2) * __pi;
1297 else if (__res < -__pi)
1298 __res += result_type(2) * __pi;
1302 template<
typename _RealType>
1303 template<
typename _OutputIterator,
1304 typename _UniformRandomNumberGenerator>
1306 von_mises_distribution<_RealType>::
1307 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1308 _UniformRandomNumberGenerator& __urng,
1309 const param_type& __param)
1311 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1315 *__f++ = this->operator()(__urng, __param);
1318 template<typename _RealType, typename _CharT, typename _Traits>
1319 std::basic_ostream<_CharT, _Traits>&
1320 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1321 const
__gnu_cxx::von_mises_distribution<_RealType>& __x)
1324 typedef typename __ostream_type::ios_base __ios_base;
1326 const typename __ios_base::fmtflags __flags = __os.flags();
1327 const _CharT __fill = __os.fill();
1329 const _CharT __space = __os.widen(
' ');
1334 __os << __x.mu() << __space << __x.kappa();
1336 __os.flags(__flags);
1338 __os.precision(__precision);
1342 template<
typename _RealType,
typename _CharT,
typename _Traits>
1345 __gnu_cxx::von_mises_distribution<_RealType>& __x)
1348 typedef typename __istream_type::ios_base __ios_base;
1350 const typename __ios_base::fmtflags __flags = __is.
flags();
1353 _RealType __mu, __kappa;
1354 __is >> __mu >> __kappa;
1355 __x.param(
typename __gnu_cxx::von_mises_distribution<_RealType>::
1356 param_type(__mu, __kappa));
1358 __is.
flags(__flags);
1363 template<
typename _UIntType>
1364 template<
typename _UniformRandomNumberGenerator>
1365 typename hypergeometric_distribution<_UIntType>::result_type
1366 hypergeometric_distribution<_UIntType>::
1367 operator()(_UniformRandomNumberGenerator& __urng,
1368 const param_type& __param)
1370 std::__detail::_Adaptor<_UniformRandomNumberGenerator, double>
1373 result_type __a = __param.successful_size();
1374 result_type __b = __param.total_size();
1375 result_type __k = 0;
1377 if (__param.total_draws() < __param.total_size() / 2)
1379 for (result_type __i = 0; __i < __param.total_draws(); ++__i)
1381 if (__b * __aurng() < __a)
1384 if (__k == __param.successful_size())
1394 for (result_type __i = 0; __i < __param.unsuccessful_size(); ++__i)
1396 if (__b * __aurng() < __a)
1399 if (__k == __param.successful_size())
1400 return __param.successful_size() - __k;
1405 return __param.successful_size() - __k;
1409 template<
typename _UIntType>
1410 template<
typename _OutputIterator,
1411 typename _UniformRandomNumberGenerator>
1413 hypergeometric_distribution<_UIntType>::
1414 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1415 _UniformRandomNumberGenerator& __urng,
1416 const param_type& __param)
1418 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1422 *__f++ = this->operator()(__urng);
1425 template<typename _UIntType, typename _CharT, typename _Traits>
1426 std::basic_ostream<_CharT, _Traits>&
1427 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1428 const
__gnu_cxx::hypergeometric_distribution<_UIntType>& __x)
1431 typedef typename __ostream_type::ios_base __ios_base;
1433 const typename __ios_base::fmtflags __flags = __os.flags();
1434 const _CharT __fill = __os.fill();
1436 const _CharT __space = __os.widen(
' ');
1441 __os << __x.total_size() << __space << __x.successful_size() << __space
1442 << __x.total_draws();
1444 __os.flags(__flags);
1446 __os.precision(__precision);
1450 template<
typename _UIntType,
typename _CharT,
typename _Traits>
1453 __gnu_cxx::hypergeometric_distribution<_UIntType>& __x)
1456 typedef typename __istream_type::ios_base __ios_base;
1458 const typename __ios_base::fmtflags __flags = __is.
flags();
1461 _UIntType __total_size, __successful_size, __total_draws;
1462 __is >> __total_size >> __successful_size >> __total_draws;
1463 __x.param(
typename __gnu_cxx::hypergeometric_distribution<_UIntType>::
1464 param_type(__total_size, __successful_size, __total_draws));
1466 __is.
flags(__flags);
1471 template<
typename _RealType>
1472 template<
typename _UniformRandomNumberGenerator>
1473 typename logistic_distribution<_RealType>::result_type
1474 logistic_distribution<_RealType>::
1475 operator()(_UniformRandomNumberGenerator& __urng,
1476 const param_type& __p)
1478 std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1481 result_type __arg = result_type(1);
1482 while (__arg == result_type(1) || __arg == result_type(0))
1485 + __p.b() *
std::log(__arg / (result_type(1) - __arg));
1488 template<
typename _RealType>
1489 template<
typename _OutputIterator,
1490 typename _UniformRandomNumberGenerator>
1492 logistic_distribution<_RealType>::
1493 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1494 _UniformRandomNumberGenerator& __urng,
1495 const param_type& __p)
1497 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1500 std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
1505 result_type __arg = result_type(1);
1506 while (__arg == result_type(1) || __arg == result_type(0))
1509 + __p.b() *
std::log(__arg / (result_type(1) - __arg));
1513 template<
typename _RealType,
typename _CharT,
typename _Traits>
1516 const logistic_distribution<_RealType>& __x)
1519 typedef typename __ostream_type::ios_base __ios_base;
1521 const typename __ios_base::fmtflags __flags = __os.flags();
1522 const _CharT __fill = __os.fill();
1524 const _CharT __space = __os.widen(
' ');
1529 __os << __x.a() << __space << __x.b();
1531 __os.flags(__flags);
1533 __os.precision(__precision);
1537 template<
typename _RealType,
typename _CharT,
typename _Traits>
1540 logistic_distribution<_RealType>& __x)
1543 typedef typename __istream_type::ios_base __ios_base;
1545 const typename __ios_base::fmtflags __flags = __is.
flags();
1550 __x.param(
typename logistic_distribution<_RealType>::
1551 param_type(__a, __b));
1553 __is.
flags(__flags);
1562 template<std::
size_t _Dimen,
typename _RealType>
1563 class uniform_on_sphere_helper
1565 typedef typename uniform_on_sphere_distribution<_Dimen, _RealType>::
1566 result_type result_type;
1569 template<
typename _NormalDistribution,
1570 typename _UniformRandomNumberGenerator>
1571 result_type operator()(_NormalDistribution& __nd,
1572 _UniformRandomNumberGenerator& __urng)
1575 typename result_type::value_type __norm;
1579 auto __sum = _RealType(0);
1581 std::generate(__ret.begin(), __ret.end(),
1582 [&__nd, &__urng, &__sum](){
1583 _RealType __t = __nd(__urng);
1588 while (__norm == _RealType(0) || ! __builtin_isfinite(__norm));
1590 std::transform(__ret.begin(), __ret.end(), __ret.begin(),
1591 [__norm](_RealType __val){ return __val / __norm; });
1598 template<
typename _RealType>
1599 class uniform_on_sphere_helper<2, _RealType>
1601 typedef typename uniform_on_sphere_distribution<2, _RealType>::
1602 result_type result_type;
1605 template<
typename _NormalDistribution,
1606 typename _UniformRandomNumberGenerator>
1607 result_type operator()(_NormalDistribution&,
1608 _UniformRandomNumberGenerator& __urng)
1612 std::__detail::_Adaptor<_UniformRandomNumberGenerator,
1613 _RealType> __aurng(__urng);
1617 __ret[0] = _RealType(2) * __aurng() - _RealType(1);
1618 __ret[1] = _RealType(2) * __aurng() - _RealType(1);
1620 __sq = __ret[0] * __ret[0] + __ret[1] * __ret[1];
1622 while (__sq == _RealType(0) || __sq > _RealType(1));
1624 #if _GLIBCXX_USE_C99_MATH_TR1
1627 auto __norm = std::hypot(__ret[0], __ret[1]);
1641 template<std::
size_t _Dimen,
typename _RealType>
1642 template<
typename _UniformRandomNumberGenerator>
1643 typename uniform_on_sphere_distribution<_Dimen, _RealType>::result_type
1644 uniform_on_sphere_distribution<_Dimen, _RealType>::
1645 operator()(_UniformRandomNumberGenerator& __urng,
1646 const param_type& __p)
1648 uniform_on_sphere_helper<_Dimen, _RealType> __helper;
1649 return __helper(_M_nd, __urng);
1652 template<std::
size_t _Dimen,
typename _RealType>
1653 template<
typename _OutputIterator,
1654 typename _UniformRandomNumberGenerator>
1656 uniform_on_sphere_distribution<_Dimen, _RealType>::
1657 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1658 _UniformRandomNumberGenerator& __urng,
1659 const param_type& __param)
1661 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1665 *__f++ = this->operator()(__urng, __param);
1668 template<
std::
size_t _Dimen, typename _RealType, typename _CharT,
1670 std::basic_ostream<_CharT, _Traits>&
1671 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1672 const
__gnu_cxx::uniform_on_sphere_distribution<_Dimen,
1675 return __os << __x._M_nd;
1678 template<std::size_t _Dimen,
typename _RealType,
typename _CharT,
1682 __gnu_cxx::uniform_on_sphere_distribution<_Dimen,
1685 return __is >> __x._M_nd;
1693 template<std::
size_t _Dimen,
bool _SmallDimen,
typename _RealType>
1694 class uniform_inside_sphere_helper;
1696 template<std::
size_t _Dimen,
typename _RealType>
1697 class uniform_inside_sphere_helper<_Dimen, false, _RealType>
1700 =
typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
1704 template<
typename _UniformOnSphereDistribution,
1705 typename _UniformRandomNumberGenerator>
1707 operator()(_UniformOnSphereDistribution& __uosd,
1708 _UniformRandomNumberGenerator& __urng,
1711 std::__detail::_Adaptor<_UniformRandomNumberGenerator,
1712 _RealType> __aurng(__urng);
1714 _RealType __pow = 1 / _RealType(_Dimen);
1715 _RealType __urt = __radius *
std::pow(__aurng(), __pow);
1716 result_type __ret = __uosd(__aurng);
1718 std::transform(__ret.begin(), __ret.end(), __ret.begin(),
1719 [__urt](_RealType __val)
1720 { return __val * __urt; });
1728 template<std::
size_t _Dimen,
typename _RealType>
1729 class uniform_inside_sphere_helper<_Dimen, true, _RealType>
1732 =
typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
1736 template<
typename _UniformOnSphereDistribution,
1737 typename _UniformRandomNumberGenerator>
1739 operator()(_UniformOnSphereDistribution&,
1740 _UniformRandomNumberGenerator& __urng,
1745 _RealType __radsq = __radius * __radius;
1746 std::__detail::_Adaptor<_UniformRandomNumberGenerator,
1747 _RealType> __aurng(__urng);
1751 __sq = _RealType(0);
1752 for (
int i = 0; i < _Dimen; ++i)
1754 __ret[i] = _RealType(2) * __aurng() - _RealType(1);
1755 __sq += __ret[i] * __ret[i];
1758 while (__sq > _RealType(1));
1760 for (
int i = 0; i < _Dimen; ++i)
1761 __ret[i] *= __radius;
1772 template<std::
size_t _Dimen,
typename _RealType>
1773 template<
typename _UniformRandomNumberGenerator>
1774 typename uniform_inside_sphere_distribution<_Dimen, _RealType>::result_type
1775 uniform_inside_sphere_distribution<_Dimen, _RealType>::
1776 operator()(_UniformRandomNumberGenerator& __urng,
1777 const param_type& __p)
1779 uniform_inside_sphere_helper<_Dimen, _Dimen < 8, _RealType> __helper;
1780 return __helper(_M_uosd, __urng, __p.radius());
1783 template<std::
size_t _Dimen,
typename _RealType>
1784 template<
typename _OutputIterator,
1785 typename _UniformRandomNumberGenerator>
1787 uniform_inside_sphere_distribution<_Dimen, _RealType>::
1788 __generate_impl(_OutputIterator __f, _OutputIterator __t,
1789 _UniformRandomNumberGenerator& __urng,
1790 const param_type& __param)
1792 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
1796 *__f++ = this->operator()(__urng, __param);
1799 template<
std::
size_t _Dimen, typename _RealType, typename _CharT,
1801 std::basic_ostream<_CharT, _Traits>&
1802 operator<<(
std::basic_ostream<_CharT, _Traits>& __os,
1803 const
__gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
1807 typedef typename __ostream_type::ios_base __ios_base;
1809 const typename __ios_base::fmtflags __flags = __os.flags();
1810 const _CharT __fill = __os.fill();
1812 const _CharT __space = __os.widen(
' ');
1817 __os << __x.radius() << __space << __x._M_uosd;
1819 __os.flags(__flags);
1821 __os.precision(__precision);
1826 template<std::size_t _Dimen,
typename _RealType,
typename _CharT,
1830 __gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
1834 typedef typename __istream_type::ios_base __ios_base;
1836 const typename __ios_base::fmtflags __flags = __is.
flags();
1839 _RealType __radius_val;
1840 __is >> __radius_val >> __x._M_uosd;
1841 __x.param(
typename uniform_inside_sphere_distribution<_Dimen, _RealType>::
1842 param_type(__radius_val));
1844 __is.
flags(__flags);
1849 _GLIBCXX_END_NAMESPACE_VERSION
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
ISO C++ entities toplevel namespace is std.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
ios_base & scientific(ios_base &__base)
Calls base.setf(ios_base::scientific, ios_base::floatfield).
ios_base & dec(ios_base &__base)
Calls base.setf(ios_base::dec, ios_base::basefield).
ios_base & left(ios_base &__base)
Calls base.setf(ios_base::left, ios_base::adjustfield).
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
ios_base & skipws(ios_base &__base)
Calls base.setf(ios_base::skipws).
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
ios_base & fixed(ios_base &__base)
Calls base.setf(ios_base::fixed, ios_base::floatfield).
GNU extensions for public use.
A standard container for storing a fixed size sequence of elements.
Template class basic_istream.
Template class basic_ostream.
Properties of fundamental types.
fmtflags flags() const
Access to format flags.