Skip to content

Commit 729da22

Browse files
committed
Improved efficiency by modifying the distribution object instead of recreating it
1 parent 225d27d commit 729da22

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/boot.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ void mexFunction (int nlhs, mxArray* plhs[],
191191
// Initialize pseudo-random number generator (Mersenne Twister 19937)
192192
mt19937_64 rng (seed);
193193
uniform_int_distribution<long long unsigned int> distr (0, n - 1);
194+
uniform_int_distribution<long long unsigned int> distk (0, N - 1);
194195

195196
// Perform balanced sampling
196197
for ( int b = 0; b < nboot ; b++ ) {
@@ -214,7 +215,7 @@ void mexFunction (int nlhs, mxArray* plhs[],
214215
loo = false;
215216
}
216217
}
217-
uniform_int_distribution<long long unsigned int> distk (0, N - m - 1);
218+
distk.param (uniform_int_distribution<long long unsigned int>::param_type (0, N - m - 1));
218219
k = distk (rng);
219220
d = c[0];
220221
for ( int j = 0; j < n ; j++ ) {

0 commit comments

Comments
 (0)