summaryrefslogtreecommitdiff
path: root/lib/include/wolff/cluster.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/include/wolff/cluster.hpp')
-rw-r--r--lib/include/wolff/cluster.hpp57
1 files changed, 29 insertions, 28 deletions
diff --git a/lib/include/wolff/cluster.hpp b/lib/include/wolff/cluster.hpp
index 055cdf3..b66f367 100644
--- a/lib/include/wolff/cluster.hpp
+++ b/lib/include/wolff/cluster.hpp
@@ -7,20 +7,19 @@
#include <vector>
#include <queue>
-#include "types.h"
#include "system.hpp"
-#include "graph.hpp"
-#include "measurement.hpp"
+
+namespace wolff {
template <class R_t, class X_t>
-void wolff_cluster_flip(wolff_system<R_t, X_t>& S, v_t i0, const R_t& r,
- std::mt19937& rng, wolff_measurement<R_t, X_t>& A) {
+void system<R_t, X_t>::flip_cluster(v_t i0, const R_t& r,
+ std::mt19937& rng, measurement<R_t, X_t>& A) {
std::uniform_real_distribution<double> dist(0.0, 1.0);
std::queue<v_t> queue;
queue.push(i0);
- std::vector<bool> marks(S.G.nv, false);
+ std::vector<bool> marks(G.nv, false);
while (!queue.empty()) {
v_t i = queue.front();
@@ -33,21 +32,21 @@ void wolff_cluster_flip(wolff_system<R_t, X_t>& S, v_t i0, const R_t& r,
#ifndef WOLFF_NO_FIELD
R_t s0_new;
- bool we_are_ghost = (i == S.nv);
+ bool we_are_ghost = (i == nv);
if (we_are_ghost) {
- s0_new = r.act(S.s0);
+ s0_new = r.act(s0);
} else
#endif
{
- si_new = r.act(S.s[i]);
+ si_new = r.act(s[i]);
}
- for (const v_t &j : S.G.adj[i]) {
+ for (const v_t &j : G.adjacency[i]) {
double dE, p;
#ifndef WOLFF_NO_FIELD
- bool neighbor_is_ghost = (j == S.nv);
+ bool neighbor_is_ghost = (j == nv);
if (we_are_ghost || neighbor_is_ghost) {
X_t s0s_old, s0s_new;
@@ -55,18 +54,18 @@ void wolff_cluster_flip(wolff_system<R_t, X_t>& S, v_t i0, const R_t& r,
if (neighbor_is_ghost) {
non_ghost = i;
- s0s_old = S.s0.act_inverse(S.s[i]);
- s0s_new = S.s0.act_inverse(si_new);
+ s0s_old = s0.act_inverse(s[i]);
+ s0s_new = s0.act_inverse(si_new);
} else {
non_ghost = j;
- s0s_old = S.s0.act_inverse(S.s[j]);
- s0s_new = s0_new.act_inverse(S.s[j]);
+ s0s_old = s0.act_inverse(s[j]);
+ s0s_new = s0_new.act_inverse(s[j]);
}
#ifdef WOLFF_SITE_DEPENDENCE
- dE = S.B(non_ghost, s0s_old) - S.B(non_ghost, s0s_new);
+ dE = B(non_ghost, s0s_old) - B(non_ghost, s0s_new);
#else
- dE = S.B(s0s_old) - S.B(s0s_new);
+ dE = B(s0s_old) - B(s0s_new);
#endif
#ifdef WOLFF_FINITE_STATES
@@ -75,28 +74,28 @@ void wolff_cluster_flip(wolff_system<R_t, X_t>& S, v_t i0, const R_t& r,
#endif
// run measurement hooks for encountering a ghost bond
- A.ghost_bond_visited(S, non_ghost, s0s_old, s0s_new, dE);
+ A.ghost_bond_visited(*this, non_ghost, s0s_old, s0s_new, dE);
} else // this is a perfectly normal bond!
#endif
{
#ifdef WOLFF_BOND_DEPENDENCE
- dE = S.Z(i, S.s[i], j, S.s[j]) - S.Z(i, si_new, j, S.s[j]);
+ dE = Z(i, s[i], j, s[j]) - Z(i, si_new, j, s[j]);
#else
- dE = S.Z(S.s[i], S.s[j]) - S.Z(si_new, S.s[j]);
+ dE = Z(s[i], s[j]) - Z(si_new, s[j]);
#endif
#ifdef WOLFF_FINITE_STATES
- p = finite_states_Zp[finite_states_enum(S.s[i])]
+ p = finite_states_Zp[finite_states_enum(s[i])]
[finite_states_enum(si_new)]
- [finite_states_enum(S.s[j])];
+ [finite_states_enum(s[j])];
#endif
// run measurement hooks for encountering a plain bond
- A.plain_bond_visited(S, i, si_new, j, dE);
+ A.plain_bond_visited(*this, i, si_new, j, dE);
}
#ifndef FINITE_STATES
- p = 1.0 - exp(-dE / S.T);
+ p = 1.0 - exp(-dE / T);
#endif
if (dist(rng) < p) {
@@ -106,17 +105,19 @@ void wolff_cluster_flip(wolff_system<R_t, X_t>& S, v_t i0, const R_t& r,
#ifndef WOLFF_NO_FIELD
if (we_are_ghost) {
- A.ghost_site_transformed(S, s0_new);
- S.s0 = s0_new;
+ A.ghost_site_transformed(*this, s0_new);
+ s0 = s0_new;
} else
#endif
{
- A.plain_site_transformed(S, i, si_new);
- S.s[i] = si_new;
+ A.plain_site_transformed(*this, i, si_new);
+ s[i] = si_new;
}
}
}
}
+}
+
#endif