31 template <
unsigned long Base = 2>
class VdCorput {
33 std::array<unsigned long, MAX_REVERSE_BITS>
36 "MAX_REVERSE_BITS must be at least the number of bits in unsigned long");
45 unsigned long factor =
static_cast<unsigned long>(std::pow(Base, scale));
48 this->factor_lst[i] = factor;
57 [[nodiscard]]
constexpr auto pop() ->
unsigned long {
58 unsigned long count = ++this->_count;
59 unsigned long reslt = 0;
62 const unsigned long remainder = count % Base;
64 reslt += remainder * this->factor_lst[idx];
75 constexpr auto reseed(
const unsigned long& seed) ->
void { this->_count = seed; }
94 template <
unsigned long Base1,
unsigned long Base2> class
Halton {
107 constexpr explicit Halton(
const std::array<unsigned int, 2>& scale)
108 : vdc0(scale[0]), vdc1(scale[1]) {}
117 constexpr auto pop() -> array<unsigned long, 2> {
118 return {this->vdc0.
pop(), this->vdc1.
pop()};
128 constexpr auto reseed(
const unsigned long& seed) ->
void {
Halton sequence generator.
Definition ilds.hpp:94
constexpr Halton(const std::array< unsigned int, 2 > &scale)
Construct a new Halton object.
Definition ilds.hpp:107
constexpr auto reseed(const unsigned long &seed) -> void
Reset the state of the Halton sequence generator.
Definition ilds.hpp:128
constexpr auto pop() -> array< unsigned long, 2 >
Generate the next point in the Halton sequence.
Definition ilds.hpp:117
van der Corput sequence generator
Definition ilds.hpp:31
constexpr VdCorput(unsigned int scale=DEFAULT_SCALE)
Construct a new VdCorput object.
Definition ilds.hpp:44
constexpr auto pop() -> unsigned long
Increments count and calculates the next value in the sequence.
Definition ilds.hpp:57
constexpr auto reseed(const unsigned long &seed) -> void
Resets the state of the sequence generator.
Definition ilds.hpp:75
VdCorput(VdCorput &&) noexcept=delete
constexpr unsigned int MAX_REVERSE_BITS
Definition ilds.hpp:22
constexpr unsigned int DEFAULT_SCALE
Default number of digits for the van der Corput sequence.
Definition ilds.hpp:21