Skip to content

Commit

Permalink
batch and scalar generating has exactly the same output
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouyan committed Mar 14, 2016
1 parent ea81c8f commit ef5ee75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions include/vsmc/rng/counter.hpp
Expand Up @@ -362,6 +362,12 @@ class CounterEngine
return;
}

std::memcpy(
r, buffer_.data() + index_, sizeof(result_type) * (M_ - index_));
r += M_ - index_;
n -= M_ - index_;
index_ = M_;

const std::size_t k = 1024 / M_;
if (k != 0) {
const std::size_t m = (n / M_) / k;
Expand Down
4 changes: 2 additions & 2 deletions include/vsmc/rng/u01_distribution.hpp
Expand Up @@ -107,8 +107,8 @@ inline void u01_distribution(RNGType &rng, std::size_t n, RealType *r)
const std::size_t m = n / k;
const std::size_t l = n % k;
for (std::size_t i = 0; i != m; ++i, r += k)
internal::u01_distribution_impl<k, RealType>(rng, k, r);
internal::u01_distribution_impl<k, RealType>(rng, l, r);
internal::u01_distribution_impl<k>(rng, k, r);
internal::u01_distribution_impl<k>(rng, l, r);
}

VSMC_DEFINE_RNG_DISTRIBUTION_RAND_0(U01, u01, RealType)
Expand Down

0 comments on commit ef5ee75

Please sign in to comment.