From debd18ad06b40e30c67490ae3c7573089d52ae4f Mon Sep 17 00:00:00 2001 From: Jaron Kent-Debias Date: Mon, 28 Oct 2019 16:30:50 -0400 Subject: renamed classes with capital letters --- space_wolff.hpp | 116 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/space_wolff.hpp b/space_wolff.hpp index 4c02406..f95c68a 100644 --- a/space_wolff.hpp +++ b/space_wolff.hpp @@ -29,12 +29,13 @@ const std::array, 16> smiley = { {{0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0}}, {{0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0}}}}; -template using vector = Eigen::Matrix; +template using Vector = Eigen::Matrix; -template using matrix = Eigen::Matrix; +template using Matrix = Eigen::Matrix; -template vector diff(U L, vector v1, vector v2) { - vector v; +template +Vector diff(U L, Vector v1, Vector v2) { + Vector v; for (unsigned i = 0; i < D; i++) { v(i) = std::abs(v1(i) - v2(i)); @@ -46,20 +47,20 @@ template vector diff(U L, vector v1, vector class spin { +template class Spin { public: - vector x; + Vector x; state s; }; -template class euclidean { +template class Euclidean { private: U L; public: - vector t; - matrix r; - euclidean(U L) : L(L) { + Vector t; + Matrix r; + Euclidean(U L) : L(L) { for (unsigned i = 0; i < D; i++) { t(i) = 0; r(i, i) = 1; @@ -69,14 +70,14 @@ public: } } - euclidean(U L, vector t0, matrix r0) : L(L) { + Euclidean(U L, Vector t0, Matrix r0) : L(L) { t = t0; r = r0; } template - spin act(const spin &s) const { - spin s_new; + Spin act(const Spin &s) const { + Spin s_new; s_new.x = t + r * s.x; s_new.s = s.s; @@ -88,39 +89,39 @@ public: return s_new; } - euclidean act(const euclidean& x) const { - vector tnew = r * x.t + t; - matrix rnew = r * x.r; + Euclidean act(const Euclidean &x) const { + Vector tnew = r * x.t + t; + Matrix rnew = r * x.r; for (unsigned i = 0; i < D; i++) { tnew(i) = fmod(L + tnew(i), L); } - euclidean pnew(this->L, tnew, rnew); + Euclidean pnew(this->L, tnew, rnew); return pnew; } - euclidean inverse() const { - vector tnew = -r.transpose() * t; - matrix rnew = r.transpose(); + Euclidean inverse() const { + Vector tnew = -r.transpose() * t; + Matrix rnew = r.transpose(); - euclidean pnew(this->L, tnew, rnew); + Euclidean pnew(this->L, tnew, rnew); return pnew; } }; -template class dictionary { +template class Dictionary { private: unsigned N; T L; std::vector> d; public: - dictionary(unsigned Ni, double Li) : N(Ni), L(Li), d(pow(Ni, D)) {}; + Dictionary(unsigned Ni, double Li) : N(Ni), L(Li), d(pow(Ni, D)){}; - unsigned dictionary_index(vector x) const { + unsigned dictionary_index(Vector x) const { unsigned pos_ind = 0; for (unsigned i = 0; i < D; i++) { @@ -130,15 +131,15 @@ public: return pos_ind; } - void record(vector x, unsigned ind) { + void record(Vector x, unsigned ind) { d[this->dictionary_index(x)].insert(ind); }; - void remove(vector x, unsigned ind) { + void remove(Vector x, unsigned ind) { d[this->dictionary_index(x)].erase(ind); }; - std::set neighbors(vector x, unsigned depth) const { + std::set neighbors(Vector x, unsigned depth) const { return nearest_neighbors_of(this->dictionary_index(x), depth, {}); }; @@ -169,7 +170,7 @@ public: }; }; -class quantity { +class Quantity { private: double total; double total2; @@ -180,7 +181,7 @@ public: unsigned n; std::list hist; - quantity(unsigned lag, unsigned wait) : C(lag), wait(wait) { + Quantity(unsigned lag, unsigned wait) : C(lag), wait(wait) { n = 0; total = 0; total2 = 0; @@ -244,20 +245,22 @@ public: unsigned num_added() const { return n - wait; } }; -template class model { +template class Model { public: U L; - euclidean s0; - std::vector> s; - dictionary dict; - std::function(model&, unsigned, spin)> neighbors; - std::function, spin)> Z; - std::function)> B; - std::vector> mats; - std::vector> steps; + Euclidean s0; + std::vector> s; + Dictionary dict; + std::function(Model &, unsigned, + Spin)> + neighbors; + std::function, Spin)> Z; + std::function)> B; + std::vector> mats; + std::vector> steps; long double E; - quantity Eq; - quantity Cq; + Quantity Eq; + Quantity Cq; void one_sequences(std::list>& sequences, unsigned level) { if (level > 0) { @@ -272,10 +275,14 @@ public: } } - model(U L, unsigned N, std::function, spin)> Z, - std::function)> B, - std::function(model&, unsigned, spin)> ns) - : L(L), s0(L), dict(N, L), neighbors(ns), Z(Z), B(B), Eq(1000, 1000), Cq(1000, 1000) { + Model(U L, unsigned N, + std::function, Spin)> Z, + std::function)> B, + std::function(Model &, unsigned, + Spin)> + ns) + : L(L), s0(L), dict(N, L), neighbors(ns), Z(Z), B(B), Eq(1000, 1000), + Cq(1000, 1000) { std::array ini_sequence; ini_sequence.fill(1); std::list> sequences; @@ -286,7 +293,7 @@ public: sequences.pop_front(); // don't want the identity matrix! for (std::array sequence : sequences) { - matrix m; + Matrix m; for (unsigned i = 0; i < D; i++) { for (unsigned j = 0; j < D; j++) { if (i == j) { @@ -299,7 +306,7 @@ public: mats.push_back(m); - vector v; + Vector v; for (unsigned i = 0; i < D; i++) { if (sequence[i] == 1) { v(i) = 0; @@ -314,7 +321,7 @@ public: for (unsigned i = 0; i < D; i++) { for (unsigned j = 0; j < D; j++) { if (i != j) { - matrix m; + Matrix m; for (unsigned k = 0; k < D; k++) { for (unsigned l = 0; l < D; l++) { if ((k == i && l == j) || (k == j && l == i)) { @@ -345,7 +352,7 @@ public: } } - void step(double T, unsigned ind, euclidean r, std::mt19937& rng) { + void step(double T, unsigned ind, Euclidean r, std::mt19937 &rng) { unsigned cluster_size = 0; std::uniform_real_distribution dist(0.0, 1.0); @@ -363,8 +370,8 @@ public: bool we_are_ghost = i == s.size(); - spin si_new; - euclidean s0_new(L); + Spin si_new; + Euclidean s0_new(L); if (we_are_ghost) { s0_new = r.act(s0); @@ -378,7 +385,7 @@ public: bool neighbor_is_ghost = j == s.size(); if (we_are_ghost || neighbor_is_ghost) { - spin s0s_old, s0s_new; + Spin s0s_old, s0s_new; unsigned non_ghost; if (neighbor_is_ghost) { @@ -423,8 +430,8 @@ public: std::uniform_int_distribution coin(0, mats.size() + steps.size() - 1); for (unsigned i = 0; i < N; i++) { - vector t; - matrix m; + Vector t; + Matrix m; unsigned flip = coin(rng); if (flip < mats.size()) { for (unsigned j = 0; j < D; j++) { @@ -445,7 +452,7 @@ public: t = steps[flip - mats.size()]; } - euclidean g(L, t, m); + Euclidean g(L, t, m); this->step(T, ind_dist(rng), g, rng); @@ -454,4 +461,3 @@ public: } } }; - -- cgit v1.2.3-54-g00ecf