1010#define _LIBCPP___RANDOM_GAMMA_DISTRIBUTION_H
1111
1212#include < __config>
13+ #include < __math/exponential_functions.h>
14+ #include < __math/logarithms.h>
15+ #include < __math/roots.h>
1316#include < __random/exponential_distribution.h>
1417#include < __random/is_valid.h>
1518#include < __random/uniform_real_distribution.h>
16- #include < cmath>
1719#include < iosfwd>
1820#include < limits>
1921
@@ -114,13 +116,13 @@ _RealType gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type
114116 const result_type __v = __gen (__g);
115117 const result_type __w = __u * (1 - __u);
116118 if (__w != 0 ) {
117- const result_type __y = std ::sqrt (__c / __w) * (__u - result_type (0.5 ));
119+ const result_type __y = __math ::sqrt (__c / __w) * (__u - result_type (0.5 ));
118120 __x = __b + __y;
119121 if (__x >= 0 ) {
120122 const result_type __z = 64 * __w * __w * __w * __v * __v;
121123 if (__z <= 1 - 2 * __y * __y / __x)
122124 break ;
123- if (std ::log (__z) <= 2 * (__b * std ::log (__x / __b) - __y))
125+ if (__math ::log (__z) <= 2 * (__b * __math ::log (__x / __b) - __y))
124126 break ;
125127 }
126128 }
@@ -131,12 +133,12 @@ _RealType gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type
131133 const result_type __u = __gen (__g);
132134 const result_type __es = __egen (__g);
133135 if (__u <= 1 - __a) {
134- __x = std ::pow (__u, 1 / __a);
136+ __x = __math ::pow (__u, 1 / __a);
135137 if (__x <= __es)
136138 break ;
137139 } else {
138- const result_type __e = -std ::log ((1 - __u) / __a);
139- __x = std ::pow (1 - __a + __a * __e, 1 / __a);
140+ const result_type __e = -__math ::log ((1 - __u) / __a);
141+ __x = __math ::pow (1 - __a + __a * __e, 1 / __a);
140142 if (__x <= __e + __es)
141143 break ;
142144 }
0 commit comments