diff options
-rw-r--r-- | hadamard.cpp | 4 | ||||
-rw-r--r-- | hadamard_pt.hpp | 18 |
2 files changed, 16 insertions, 6 deletions
diff --git a/hadamard.cpp b/hadamard.cpp index b8ebdde..9364d3c 100644 --- a/hadamard.cpp +++ b/hadamard.cpp @@ -104,7 +104,9 @@ int main(int argc, char* argv[]) { } MeasureTransitionRates B(num); - PT p(β0, βf, num, n, B, As); + range r = {β0, βf, num}; + + PT p({r}, n, B, As); for (MCMC& sim : p.Ms) { sim.M = walsh(k); diff --git a/hadamard_pt.hpp b/hadamard_pt.hpp index 404129c..744c866 100644 --- a/hadamard_pt.hpp +++ b/hadamard_pt.hpp @@ -1,6 +1,7 @@ #pragma once #include "hadamard_mcmc.hpp" +#include <list> void swap(MCMC& s1, MCMC& s2) { std::swap(s1.M, s2.M); @@ -13,6 +14,12 @@ public: virtual void after_sweep(const std::vector<MCMC>&){}; }; +typedef struct range { + double β0; + double β1; + unsigned N; +} range; + class PT { private: randutils::mt19937_rng rng; @@ -22,13 +29,14 @@ public: ParallelMeasurement& B; std::vector<Measurement*>& As; - PT(double β0, double β1, unsigned N, unsigned n, ParallelMeasurement& B, + PT(std::list<range> ranges, unsigned n, ParallelMeasurement& B, std::vector<Measurement*>& As) : B(B), As(As) { - Ms.reserve(N); - for (unsigned i = 0; i < N; i++) { - double β = β0 + i * (β1 - β0) / (N - 1); - Ms.push_back(MCMC(n, β, *As[i])); + for (range r : ranges) { + for (unsigned i = 0; i < r.N; i++) { + double β = r.β0 + i * (r.β1 - r.β0) / (r.N - 1); + Ms.push_back(MCMC(n, β, *As[i])); + } } } |