File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -101,13 +101,16 @@ class beta_distribution {
101
101
template <class URNG >
102
102
RealType operator ()(URNG& urng) const
103
103
{
104
+ static const auto alpha_dist = gamma_distribution<RealType>(_alpha, RealType (1.0 ));
105
+ static const auto beta_dist = gamma_distribution<RealType>(_beta, RealType (1.0 ));
106
+
104
107
RealType a = 0 ;
105
108
RealType b = 0 ;
106
109
107
110
do
108
111
{
109
- a = gamma_distribution<RealType>(_alpha, RealType ( 1.0 )) (urng);
110
- b = gamma_distribution<RealType>(_beta, RealType ( 1.0 )) (urng);
112
+ a = alpha_dist (urng);
113
+ b = beta_dist (urng);
111
114
} while (a + b == RealType (0 ));
112
115
113
116
return a / (a + b);
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ class gamma_distribution
159
159
* the gamma distribution.
160
160
*/
161
161
template <class Engine >
162
- result_type operator ()(Engine& eng)
162
+ result_type operator ()(Engine& eng) const
163
163
{
164
164
#ifndef BOOST_NO_STDC_NAMESPACE
165
165
// allow for Koenig lookup
You can’t perform that action at this time.
0 commit comments