summaryrefslogtreecommitdiff
path: root/hadamard_pt.hpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-12-10 13:12:37 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-12-10 13:12:37 -0500
commit0ec7cbaf7a33de59796844d4c9fe3f22b83c55e4 (patch)
treeefebb25ff8afccdbb01185df4fd9be05be665724 /hadamard_pt.hpp
parent84edbcb1b0dd1c5ac5c1626e7dc8cf22bbf10139 (diff)
downloadcode-0ec7cbaf7a33de59796844d4c9fe3f22b83c55e4.tar.gz
code-0ec7cbaf7a33de59796844d4c9fe3f22b83c55e4.tar.bz2
code-0ec7cbaf7a33de59796844d4c9fe3f22b83c55e4.zip
cleanup, and change to initalization with walsh matrices
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);
}
}
};