summaryrefslogtreecommitdiff
path: root/hadamard_pt.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'hadamard_pt.hpp')
-rw-r--r--hadamard_pt.hpp12
1 files changed, 6 insertions, 6 deletions
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<MCMC>&) {};
+ virtual void after_step(bool, unsigned, unsigned, double, double, const MCMC&, const MCMC&){};
+ virtual void after_sweep(const std::vector<MCMC>&){};
};
class PT {
@@ -22,7 +22,8 @@ public:
ParallelMeasurement& B;
std::vector<Measurement*>& As;
- PT(double β0, double β1, unsigned N, unsigned n, ParallelMeasurement& B, std::vector<Measurement*>& As)
+ PT(double β0, double β1, unsigned N, unsigned n, ParallelMeasurement& B,
+ std::vector<Measurement*>& 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);
}
}
};