From 49ac78a6c04e215950bc9c0f97368605e63da15b Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 14 Jan 2019 15:47:59 -0500 Subject: Large refactoring around changes in the graph class. - Graphs now use lists of references instead of vectors of indicies. - Vertices and edges have associated classes that can be given arbitrary properties via template specification. - All essential library headers have been combined into one, wolff.hpp. --- examples/On.cpp | 22 +++++------ examples/clock.cpp | 30 +++++++------- examples/continuous_gaussian.cpp | 33 ++++++++-------- examples/discrete_gaussian.cpp | 41 ++++++++++---------- examples/ising.cpp | 18 ++++----- examples/ising_animation.cpp | 84 +++++++++++++++++++--------------------- examples/ising_no_field.cpp | 20 ++++------ examples/ising_random_field.cpp | 31 +++++++-------- examples/ising_standalone.cpp | 25 ++++++------ examples/potts.cpp | 36 ++++++++--------- examples/simple_measurement.hpp | 36 +++++++++-------- 11 files changed, 179 insertions(+), 197 deletions(-) (limited to 'examples') diff --git a/examples/On.cpp b/examples/On.cpp index 6c3f0fd..6885d2e 100644 --- a/examples/On.cpp +++ b/examples/On.cpp @@ -3,23 +3,21 @@ #include #include -#include "simple_measurement.hpp" - -#include -#include +#include +#include -#include +#include "simple_measurement.hpp" int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 0.8; vector_t H; H.fill(0.0); - q_t Hi = 0; + unsigned Hi = 0; int opt; @@ -27,7 +25,7 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "N:D:L:T:H:")) != -1) { switch (opt) { case 'N': // number of steps - N = (N_t)atof(optarg); + N = (unsigned)atof(optarg); break; case 'D': // dimension D = atoi(optarg); @@ -58,12 +56,12 @@ int main(int argc, char *argv[]) { }; // initialize the lattice - graph G(D, L); + graph<> G(D, L); // initialize the system system, vector_t> S(G, T, Z, B); - std::function (std::mt19937&, const system, vector_t>&, v_t)> gen_R = generate_rotation_uniform; + std::function (std::mt19937&, const system, vector_t, graph<>>&, const graph<>::vertex)> gen_R = generate_rotation_uniform>; // initailze the measurement object simple_measurement A(S); diff --git a/examples/clock.cpp b/examples/clock.cpp index 0cba8f6..3403f23 100644 --- a/examples/clock.cpp +++ b/examples/clock.cpp @@ -5,26 +5,24 @@ #define WOLFF_USE_FINITE_STATES #define WOLFF_FINITE_STATES_N WOLFF_POTTSQ - -#include -#include +#include +#include +#include #include "simple_measurement.hpp" -#include - using namespace wolff; int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 2.26918531421; vector_t<2, double> H; H.fill(0.0); - q_t Hi = 0; + unsigned Hi = 0; int opt; @@ -32,7 +30,7 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "N:D:L:T:H:")) != -1) { switch (opt) { case 'N': // number of steps - N = (N_t)atof(optarg); + N = (unsigned)atof(optarg); break; case 'D': // dimension D = atoi(optarg); @@ -63,22 +61,22 @@ int main(int argc, char *argv[]) { }; // initialize the lattice - graph G(D, L); + graph<> G(D, L); // initialize the system - system, potts_t> S(G, T, Z, B); + system, potts_t, graph<>> S(G, T, Z, B); // initialize the random number generator auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count(); std::mt19937 rng{seed}; // define function that generates self-inverse rotations - std::function (std::mt19937&, const system, potts_t>&, v_t)> gen_r = [] (std::mt19937& r, const system, potts_t>& S, v_t i0) -> dihedral_t { + std::function (std::mt19937&, const system, potts_t, graph<>>&, const graph<>::vertex&)> gen_r = [] (std::mt19937& r, const system, potts_t, graph<>>& S, const graph<>::vertex& v) -> dihedral_t { dihedral_t rot; rot.is_reflection = true; - std::uniform_int_distribution dist(0, WOLFF_POTTSQ - 2); - q_t x = dist(r); - rot.x = (2 * S.s[i0].x + x + 1) % WOLFF_POTTSQ; + std::uniform_int_distribution dist(0, WOLFF_POTTSQ - 2); + unsigned x = dist(r); + rot.x = (2 * S.s[v.ind].x + x + 1) % WOLFF_POTTSQ; return rot; }; diff --git a/examples/continuous_gaussian.cpp b/examples/continuous_gaussian.cpp index ef08247..eda22cb 100644 --- a/examples/continuous_gaussian.cpp +++ b/examples/continuous_gaussian.cpp @@ -3,19 +3,18 @@ #include #include -#include "simple_measurement.hpp" - -#include -#include - +#include +#include #include +#include "simple_measurement.hpp" + int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 0.8; double H = 0.0; @@ -25,7 +24,7 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "N:D:L:T:H:")) != -1) { switch (opt) { case 'N': // number of steps - N = (N_t)atof(optarg); + N = (unsigned)atof(optarg); break; case 'D': // dimension D = atoi(optarg); @@ -55,25 +54,25 @@ int main(int argc, char *argv[]) { }; // initialize the lattice - graph G(D, L); + graph<> G(D, L); // initialize the system - system, height_t> S(G, T, Z, B); + system, height_t, graph<>> S(G, T, Z, B); bool odd_run = false; - std::function (std::mt19937&, const system, height_t>&, v_t)> gen_R_IH = [&](std::mt19937& r, const system, height_t>& S, v_t i0) -> dihedral_inf_t { + std::function (std::mt19937&, const system, height_t, graph<>>&, const graph<>::vertex&)> gen_R_IH = [&](std::mt19937& r, const system, height_t, graph<>>& S, const graph<>::vertex& v) -> dihedral_inf_t { dihedral_inf_t rot; rot.is_reflection = true; if (odd_run) { - std::uniform_int_distribution dist(0, S.nv - 2); - v_t j = i0; + std::uniform_int_distribution dist(0, S.nv - 2); + unsigned j = v.ind; //while (S.s[j].x == S.s[i0].x) { - v_t tmp = dist(r); + unsigned tmp = dist(r); - if (tmp < i0) { + if (tmp < v.ind) { j = tmp; } else { j = tmp + 1; @@ -83,7 +82,7 @@ int main(int argc, char *argv[]) { rot.x = 2 * S.s[j].x; } else { std::normal_distribution dist(0.0,1.0); - rot.x = 2 * S.s[i0].x + dist(r); + rot.x = 2 * S.s[v.ind].x + dist(r); } odd_run = !odd_run; diff --git a/examples/discrete_gaussian.cpp b/examples/discrete_gaussian.cpp index 75ea0f9..a6d6ceb 100644 --- a/examples/discrete_gaussian.cpp +++ b/examples/discrete_gaussian.cpp @@ -3,19 +3,18 @@ #include #include -#include "simple_measurement.hpp" - -#include -#include - +#include +#include #include +#include "simple_measurement.hpp" + int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 0.8; double H = 0.0; @@ -25,7 +24,7 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "N:D:L:T:H:")) != -1) { switch (opt) { case 'N': // number of steps - N = (N_t)atof(optarg); + N = (unsigned)atof(optarg); break; case 'D': // dimension D = atoi(optarg); @@ -45,35 +44,35 @@ int main(int argc, char *argv[]) { } // define the spin-spin coupling - std::function &, const height_t&)> Z = [] (const height_t& s1, const height_t& s2) -> double { + std::function &, const height_t&)> Z = [] (const height_t& s1, const height_t& s2) -> double { return - pow(s1.x - s2.x, 2); }; // define the spin-field coupling - std::function &)> B = [&] (const height_t& s) -> double { + std::function &)> B = [&] (const height_t& s) -> double { return - H * pow(s.x, 2); }; // initialize the lattice - graph G(D, L); + graph<> G(D, L); // initialize the system - system, height_t> S(G, T, Z, B); + system, height_t, graph<>> S(G, T, Z, B); bool odd_run = false; - std::function (std::mt19937&, const system, height_t>&, v_t)> gen_R_IH = [&](std::mt19937& r, const system, height_t>& S, v_t i0) -> dihedral_inf_t { - dihedral_inf_t rot; + std::function (std::mt19937&, const system, height_t, graph<>>&, const graph<>::vertex&)> gen_R_IH = [&](std::mt19937& r, const system, height_t, graph<>>& S, const graph<>::vertex &v) -> dihedral_inf_t { + dihedral_inf_t rot; rot.is_reflection = true; if (odd_run) { - std::uniform_int_distribution dist(0, S.nv - 2); - v_t j = i0; + std::uniform_int_distribution dist(0, S.nv - 2); + unsigned j = v.ind; //while (S.s[j].x == S.s[i0].x) { - v_t tmp = dist(r); + unsigned tmp = dist(r); - if (tmp < i0) { + if (tmp < v.ind) { j = tmp; } else { j = tmp + 1; @@ -85,9 +84,9 @@ int main(int argc, char *argv[]) { std::uniform_int_distribution dist(0, 1); int j = dist(r); if (j) { - rot.x = 2 * S.s[i0].x + 1; + rot.x = 2 * S.s[v.ind].x + 1; } else { - rot.x = 2 * S.s[i0].x - 1; + rot.x = 2 * S.s[v.ind].x - 1; } } diff --git a/examples/ising.cpp b/examples/ising.cpp index c6e75fb..ecb296b 100644 --- a/examples/ising.cpp +++ b/examples/ising.cpp @@ -5,9 +5,7 @@ #define WOLFF_USE_FINITE_STATES -#include - -#include +#include #include "simple_measurement.hpp" @@ -16,9 +14,9 @@ using namespace wolff; int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 2.26918531421; double H = 0.0; @@ -28,7 +26,7 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "N:D:L:T:H:")) != -1) { switch (opt) { case 'N': // number of steps - N = (N_t)atof(optarg); + N = (unsigned)atof(optarg); break; case 'D': // dimension D = atoi(optarg); @@ -58,17 +56,17 @@ int main(int argc, char *argv[]) { }; // initialize the lattice - graph G(D, L); + graph<> G(D, L); // initialize the system - system S(G, T, Z, B); + system> S(G, T, Z, B); // initialize the random number generator auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count(); std::mt19937 rng{seed}; // define function that generates self-inverse rotations - std::function &, v_t)> gen_r = gen_ising; + std::function >&, const graph<>::vertex&)> gen_r = gen_ising>; // initailze the measurement object simple_measurement A(S); diff --git a/examples/ising_animation.cpp b/examples/ising_animation.cpp index 7bafcf8..bcaa589 100644 --- a/examples/ising_animation.cpp +++ b/examples/ising_animation.cpp @@ -6,19 +6,18 @@ #include #define WOLFF_USE_FINITE_STATES - -#include - -#include +#include using namespace wolff; -class draw_ising : public measurement { +typedef system> sys; + +class draw_ising : public measurement> { private: unsigned int frame_skip; - v_t C; + unsigned C; public: - draw_ising(const system& S, unsigned int window_size, unsigned int frame_skip, int argc, char *argv[]) : frame_skip(frame_skip){ + draw_ising(const sys& S, unsigned int window_size, unsigned int frame_skip, int argc, char *argv[]) : frame_skip(frame_skip){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(window_size, window_size); @@ -29,9 +28,9 @@ class draw_ising : public measurement { gluOrtho2D(0.0, S.G.L, 0.0, S.G.L); } - void pre_cluster(N_t, N_t, const system& S, v_t, const ising_t&) { + void pre_cluster(unsigned, unsigned, const sys& S, const graph<>::vertex&, const ising_t&) override { glClear(GL_COLOR_BUFFER_BIT); - for (v_t i = 0; i < pow(S.G.L, 2); i++) { + for (unsigned i = 0; i < pow(S.G.L, 2); i++) { if (S.s[i].x == S.s0.x) { glColor3f(0.0, 0.0, 0.0); } else { @@ -43,9 +42,9 @@ class draw_ising : public measurement { C = 0; } - void plain_site_transformed(const system& S, v_t i, const ising_t&) { + void plain_site_transformed(const sys& S, const graph<>::vertex& v, const ising_t&) override { glColor3f(1.0, 0.0, 0.0); - glRecti(i / S.G.L, i % S.G.L, (i / S.G.L) + 1, (i % S.G.L) + 1); + glRecti(v.ind / S.G.L, v.ind % S.G.L, (v.ind / S.G.L) + 1, (v.ind % S.G.L) + 1); C++; if (C % frame_skip == 0) { glFlush(); @@ -56,9 +55,9 @@ class draw_ising : public measurement { int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 2.26918531421; double H = 0.0; unsigned int window_size = 512; @@ -69,29 +68,29 @@ int main(int argc, char *argv[]) { // take command line arguments while ((opt = getopt(argc, argv, "N:D:L:T:H:w:f:")) != -1) { switch (opt) { - case 'N': // number of steps - N = (N_t)atof(optarg); - break; - case 'D': // dimension - D = atoi(optarg); - break; - case 'L': // linear size - L = atoi(optarg); - break; - case 'T': // temperature - T = atof(optarg); - break; - case 'H': // external field - H = atof(optarg); - break; - case 'w': - window_size = atoi(optarg); - break; - case 'f': - frame_skip = atoi(optarg); - break; - default: - exit(EXIT_FAILURE); + case 'N': // number of steps + N = (unsigned)atof(optarg); + break; + case 'D': // dimension + D = atoi(optarg); + break; + case 'L': // linear size + L = atoi(optarg); + break; + case 'T': // temperature + T = atof(optarg); + break; + case 'H': // external field + H = atof(optarg); + break; + case 'w': + window_size = atoi(optarg); + break; + case 'f': + frame_skip = atoi(optarg); + break; + default: + exit(EXIT_FAILURE); } } @@ -106,15 +105,10 @@ int main(int argc, char *argv[]) { }; // initialize the lattice - graph G(D, L); + graph<> G(D, L); // initialize the system - system S(G, T, Z, B); - - // define function that generates self-inverse rotations - std::function &, v_t)> gen_R = [] (std::mt19937&, const system&, v_t) -> ising_t { - return ising_t(true); - }; + sys S(G, T, Z, B); // initailze the measurement object draw_ising A(S, window_size, frame_skip, argc, argv); @@ -124,7 +118,7 @@ int main(int argc, char *argv[]) { std::mt19937 rng{seed}; // run wolff N times - S.run_wolff(N, gen_R, A, rng); + S.run_wolff(N, gen_ising>, A, rng); // exit return 0; diff --git a/examples/ising_no_field.cpp b/examples/ising_no_field.cpp index 28d7c70..0a5b722 100644 --- a/examples/ising_no_field.cpp +++ b/examples/ising_no_field.cpp @@ -5,22 +5,18 @@ #define WOLFF_NO_FIELD #define WOLFF_USE_FINITE_STATES - -#include - -#include +#include #include "simple_measurement.hpp" - using namespace wolff; int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 2.26918531421; int opt; @@ -29,7 +25,7 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "N:D:L:T:")) != -1) { switch (opt) { case 'N': // number of steps - N = (N_t)atof(optarg); + N = (unsigned)atof(optarg); break; case 'D': // dimension D = atoi(optarg); @@ -51,17 +47,17 @@ int main(int argc, char *argv[]) { }; // initialize the lattice - graph G(D, L); + graph<> G(D, L); // initialize the system - system S(G, T, Z); + system> S(G, T, Z); // initialize the random number generator auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count(); std::mt19937 rng{seed}; // define function that generates self-inverse rotations - std::function &, v_t)> gen_r = gen_ising; + std::function >&, const graph<>::vertex&)> gen_r = gen_ising>; // initailze the measurement object simple_measurement A(S); diff --git a/examples/ising_random_field.cpp b/examples/ising_random_field.cpp index b37b0ce..9284797 100644 --- a/examples/ising_random_field.cpp +++ b/examples/ising_random_field.cpp @@ -4,21 +4,18 @@ #include #define WOLFF_SITE_DEPENDENCE +#include #include "simple_measurement.hpp" -#include - -#include - using namespace wolff; int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 2.26918531421; double H = 0.0; @@ -28,7 +25,7 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "N:D:L:T:H:")) != -1) { switch (opt) { case 'N': // number of steps - N = (N_t)atof(optarg); + N = (unsigned)atof(optarg); break; case 'D': // dimension D = atoi(optarg); @@ -52,29 +49,29 @@ int main(int argc, char *argv[]) { return (double)(s1 * s2); }; - // initialize the lattice - graph G(D, L); + // initialize the lattice. vertex_prop is set to double and will contain the + // value of the random field at that site + graph G(D, L); // initialize the random number generator auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count(); std::mt19937 rng{seed}; // define the spin-field coupling - std::vector H_vals(G.nv); std::normal_distribution distribution(0.0, H); - for (v_t i = 0; i < G.nv; i++) { - H_vals[i] = distribution(rng); + for (auto &v : G.vertices) { + v.prop = distribution(rng); } - std::function B = [&] (v_t i, const ising_t& s) -> double { - return H_vals[i] * s; + std::function ::vertex&, const ising_t&)> B = [] (const graph::vertex& v, const ising_t& s) -> double { + return v.prop * s; }; // initialize the system - system S(G, T, Z, B); + system> S(G, T, Z, B); // define function that generates self-inverse rotations - std::function &, v_t)> gen_r = gen_ising; + std::function >&, const graph::vertex&)> gen_r = gen_ising>; // initailze the measurement object simple_measurement A(S); diff --git a/examples/ising_standalone.cpp b/examples/ising_standalone.cpp index 40572fd..6863ba5 100644 --- a/examples/ising_standalone.cpp +++ b/examples/ising_standalone.cpp @@ -21,27 +21,30 @@ class ising_t { } }; +typedef graph<> G_t; +typedef system sys; + class measure_clusters : public measurement { private: - v_t C; + unsigned C; public: double Ctotal; measure_clusters() { Ctotal = 0; } - void pre_cluster(N_t, N_t, const system&, v_t, const ising_t&) { C = 0; } + void pre_cluster(unsigned, unsigned, const sys&, const G_t::vertex&, const ising_t&) override { C = 0; } - void plain_site_transformed(const system&, v_t, const ising_t&) { C++; } + void plain_site_transformed(const sys&, const G_t::vertex&, const ising_t&) override { C++; } - void post_cluster(N_t, N_t, const system&) { Ctotal += C; } + void post_cluster(unsigned, unsigned, const sys&) override { Ctotal += C; } }; int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e3; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e3; + unsigned D = 2; + unsigned L = 128; double T = 2.26918531421; double H = 0.01; @@ -58,14 +61,14 @@ int main(int argc, char *argv[]) { }; // initialize the lattice - graph G(D, L); + G_t G(D, L); // initialize the system - system S(G, T, Z, B); + sys S(G, T, Z, B); // define function that generates self-inverse rotations - std::function &, v_t)> gen_R = - [] (std::mt19937&, const system&, v_t) -> ising_t { + std::function gen_R = + [] (std::mt19937&, const sys&, const G_t::vertex&) -> ising_t { return ising_t(-1); }; diff --git a/examples/potts.cpp b/examples/potts.cpp index 24be2b3..c15de8d 100644 --- a/examples/potts.cpp +++ b/examples/potts.cpp @@ -5,26 +5,24 @@ #define WOLFF_USE_FINITE_STATES #define WOLFF_FINITE_STATES_N WOLFF_POTTSQ - -#include -#include +#include +#include +#include #include "simple_measurement.hpp" -#include - using namespace wolff; int main(int argc, char *argv[]) { // set defaults - N_t N = (N_t)1e4; - D_t D = 2; - L_t L = 128; + unsigned N = (unsigned)1e4; + unsigned D = 2; + unsigned L = 128; double T = 2.26918531421; vector_t H; H.fill(0.0); - q_t Hi = 0; + unsigned Hi = 0; int opt; @@ -32,7 +30,7 @@ int main(int argc, char *argv[]) { while ((opt = getopt(argc, argv, "N:D:L:T:H:")) != -1) { switch (opt) { case 'N': // number of steps - N = (N_t)atof(optarg); + N = (unsigned)atof(optarg); break; case 'D': // dimension D = atoi(optarg); @@ -67,30 +65,30 @@ int main(int argc, char *argv[]) { }; // initialize the lattice - graph G(D, L); + graph<> G(D, L); // initialize the system - system, potts_t> S(G, T, Z, B); + system, potts_t, graph<>> S(G, T, Z, B); // initialize the random number generator auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count(); std::mt19937 rng{seed}; // define function that generates self-inverse rotations - std::function (std::mt19937&, const system, potts_t>&, v_t)> gen_r = [] (std::mt19937& r, const system, potts_t>& S, v_t i0) -> symmetric_t { + std::function (std::mt19937&, const system, potts_t, graph<>>&, const graph<>::vertex&)> gen_r = [] (std::mt19937& r, const system, potts_t, graph<>>& S, const graph<>::vertex& v) -> symmetric_t { symmetric_t rot; - std::uniform_int_distribution dist(0, WOLFF_POTTSQ - 2); - q_t j = dist(r); - q_t swap_v; - if (j < S.s[i0].x) { + std::uniform_int_distribution dist(0, WOLFF_POTTSQ - 2); + unsigned j = dist(r); + unsigned swap_v; + if (j < S.s[v.ind].x) { swap_v = j; } else { swap_v = j + 1; } - rot[S.s[i0].x] = swap_v; - rot[swap_v] = S.s[i0].x; + rot[S.s[v.ind].x] = swap_v; + rot[swap_v] = S.s[v.ind].x; return rot; }; diff --git a/examples/simple_measurement.hpp b/examples/simple_measurement.hpp index 217f4f0..140da3b 100644 --- a/examples/simple_measurement.hpp +++ b/examples/simple_measurement.hpp @@ -1,31 +1,31 @@ -#include +#include using namespace wolff; -template -class simple_measurement : public measurement { +template +class simple_measurement : public measurement { private: - N_t n; + unsigned n; double E; typename X_t::M_t M; - v_t C; + unsigned C; double totalE; typename X_t::F_t totalM; double totalC; public: - simple_measurement(const system& S) { + simple_measurement(const system& S) { n = 0; M = S.nv * S.s[0]; E = 0; #ifdef WOLFF_BOND_DEPENDENCE - for (v_t i = 0; i < S.nv; i++) { - for (v_t j : S.G.adjacency[i]) { - E -= 0.5 * S.Z(i, S.s[i], j, S.s[j]); + for (unsigned i = 0; i < S.nv; i++) { + for (const typename G_t::halfedge& e : S.G.vertices[i].edges) { + E -= 0.5 * S.Z(e, S.s[i], S.s[j]); } } #else @@ -34,8 +34,8 @@ class simple_measurement : public measurement { #ifndef WOLFF_NO_FIELD #ifdef WOLFF_SITE_DEPENDENCE - for (v_t i = 0; i < S.nv; i++) { - E -= S.B(i, S.s[i]); + for (unsigned i = 0; i < S.nv; i++) { + E -= S.B(S.G.vertices[i], S.s[i]); } #else E -= S.nv * S.B(S.s[0]); @@ -47,28 +47,30 @@ class simple_measurement : public measurement { totalC = 0; } - void pre_cluster(N_t, N_t, const system&, v_t, const R_t&) { + void pre_cluster(unsigned, unsigned, const system&, const typename G_t::vertex&, const R_t&) override { C = 0; } - void plain_bond_visited(const system&, v_t, const X_t&, v_t, double dE) { + void plain_bond_visited(const system&, const typename G_t::halfedge&, const X_t&, double dE) override { E += dE; } - void ghost_bond_visited(const system&, v_t, const X_t& s_old, const X_t& s_new, double dE) { +#ifndef WOLFF_NO_FIELD + void ghost_bond_visited(const system&, const typename G_t::vertex&, const X_t& s_old, const X_t& s_new, double dE) override { E += dE; M += s_new - s_old; } +#endif - void plain_site_transformed(const system& S, v_t i, const X_t& si_new) { + void plain_site_transformed(const system& S, const typename G_t::vertex& v, const X_t& si_new) override { C++; #ifdef WOLFF_NO_FIELD - M += si_new - S.s[i]; + M += si_new - S.s[v.ind]; #endif } - void post_cluster(N_t, N_t, const system&) { + void post_cluster(unsigned, unsigned, const system&) override { totalE += E; totalM += M; totalC += C; -- cgit v1.2.3-70-g09d2