From 0ec7cbaf7a33de59796844d4c9fe3f22b83c55e4 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 10 Dec 2019 13:12:37 -0500 Subject: cleanup, and change to initalization with walsh matrices --- hadamard_pt.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'hadamard_pt.hpp') diff --git a/hadamard_pt.hpp b/hadamard_pt.hpp index 4006e0e..404129c 100644 --- a/hadamard_pt.hpp +++ b/hadamard_pt.hpp @@ -9,8 +9,8 @@ void swap(MCMC& s1, MCMC& s2) { class ParallelMeasurement { public: - virtual void after_step(bool, unsigned, unsigned, double, double, const MCMC&, const MCMC&) {}; - virtual void after_sweep(const std::vector&) {}; + virtual void after_step(bool, unsigned, unsigned, double, double, const MCMC&, const MCMC&){}; + virtual void after_sweep(const std::vector&){}; }; class PT { @@ -22,7 +22,8 @@ public: ParallelMeasurement& B; std::vector& As; - PT(double β0, double β1, unsigned N, unsigned n, ParallelMeasurement& B, std::vector& As) + PT(double β0, double β1, unsigned N, unsigned n, ParallelMeasurement& B, + std::vector& As) : B(B), As(As) { Ms.reserve(N); for (unsigned i = 0; i < N; i++) { @@ -44,12 +45,10 @@ public: bool accepted = Δβ * ΔE > 0 || exp(Δβ * ΔE) > rng.uniform((double)0.0, 1.0); - if (accepted) { + if (accepted) swap(Ms[i], Ms[j]); - } B.after_step(accepted, i, j, Δβ, ΔE, Ms[i], Ms[j]); - return accepted; } @@ -68,6 +67,7 @@ public: Ms[j].run(m); } this->sweep(); + B.after_sweep(this->Ms); } } }; -- cgit v1.2.3-54-g00ecf