LdsGen 1.2.6
Loading...
Searching...
No Matches
lds_n.hpp
Go to the documentation of this file.
1#pragma once
2
7#include <memory> // for unique_ptr
8#include <vector> // for vector
9
10#include "lds.hpp" // for GeneratorBase, SequenceGenerator, VdCorput
11
12namespace ldsgen {
13 using std::vector;
14
34 class HaltonN : public GeneratorBase<HaltonN, vector<double>> {
35 private:
36 vector<std::unique_ptr<VdCorput>> vdcs;
37
38 public:
46 explicit HaltonN(const vector<unsigned long>& base) {
47 for (const auto& base_value : base) {
48 this->vdcs.emplace_back(std::make_unique<ldsgen::VdCorput>(base_value));
49 }
50 }
51
62 auto value_at(unsigned long n) const -> vector<double> {
63 auto res = vector<double>{};
64 for (const auto& vdc : this->vdcs) {
65 res.emplace_back(vdc->value_at(n));
66 }
67 return res;
68 }
69 };
70
71 // Compile-time contract check: HaltonN satisfies the protocol concept.
72 static_assert(SequenceGenerator<HaltonN, vector<double>>);
73
74} // namespace ldsgen
CRTP base implementing the sequence generator protocol.
Definition lds.hpp:182
Halton(n) sequence generator.
Definition lds_n.hpp:34
auto value_at(unsigned long n) const -> vector< double >
Evaluate the N-dimensional Halton point at a given index (pure, no state change)
Definition lds_n.hpp:62
HaltonN(const vector< unsigned long > &base)
Construct a new Halton N object.
Definition lds_n.hpp:46
Low-discrepancy sequence generators with thread-safe runtime polymorphism (ldsgen).
Definition lds.hpp:19
constexpr auto vdc(unsigned long count, unsigned long base) -> double
Van der Corput sequence.
Definition lds.hpp:301