From e5ce48512f5a80933c696811d2fda70f0f9a2141 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 3 Dec 2019 12:32:18 -0500 Subject: ran clang-format --- space_wolff.hpp | 123 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 44 deletions(-) diff --git a/space_wolff.hpp b/space_wolff.hpp index 81ff776..a78116d 100644 --- a/space_wolff.hpp +++ b/space_wolff.hpp @@ -1,5 +1,4 @@ -#include "randutils/randutils.hpp" #include #include #include @@ -11,6 +10,8 @@ #include #include +#include "randutils/randutils.hpp" + const std::array, 16> smiley = { {{{0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0}}, {{0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0}}, @@ -29,13 +30,16 @@ 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; /** brief diff - periodic subtraction of vectors */ -template Vector diff(T L, Vector v1, Vector v2) { +template +Vector diff(T L, Vector v1, Vector v2) { Vector v; for (unsigned i = 0; i < D; i++) { @@ -48,17 +52,19 @@ template Vector diff(T L, Vector v1, Vector v return v; } -template class Spin { -public: +template +class Spin { + public: Vector x; S s; }; -template class Euclidean { -private: +template +class Euclidean { + private: T L; -public: + public: Vector t; Matrix r; @@ -79,7 +85,8 @@ public: r = r0; } - template Spin act(const Spin& s) const { + template + Spin act(const Spin& s) const { Spin s_new; s_new.x = t + r * s.x; @@ -115,13 +122,14 @@ public: } }; -template class Octree { -private: +template +class Octree { + private: T L; unsigned N; std::vector*>> data; -public: + public: Octree(T L, unsigned depth) : L(L), N(pow(2, depth)), data(pow(N, D)){}; unsigned ind(Vector x) const { @@ -140,14 +148,16 @@ public: void remove(Spin* s) { data[ind(s->x)].erase(s); }; - std::set*> neighbors(const Vector& x, unsigned depth) const { + std::set*> neighbors(const Vector& x, + unsigned depth) const { std::set*> ns; std::set seen; nearest_neighbors_of(ind(x), depth, ns, seen); return ns; }; - void nearest_neighbors_of(unsigned ind, unsigned depth, std::set*>& ns, + void nearest_neighbors_of(unsigned ind, unsigned depth, + std::set*>& ns, std::set& seen) const { ns.insert(data[ind].begin(), data[ind].end()); seen.insert(ind); @@ -155,8 +165,9 @@ public: if (depth > 0) { for (unsigned i = 0; i < D; i++) { for (signed j : {-1, 1}) { - unsigned nind = pow(N, i + 1) * (ind / ((unsigned)pow(N, i + 1))) + - fmod(pow(N, i + 1) + ind + j * pow(N, i), pow(N, i + 1)); + unsigned nind = + pow(N, i + 1) * (ind / ((unsigned)pow(N, i + 1))) + + fmod(pow(N, i + 1) + ind + j * pow(N, i), pow(N, i + 1)); if (!seen.contains(nind)) { seen.insert(nind); @@ -169,13 +180,13 @@ public: }; class quantity { -private: + private: double total; double total2; std::vector C; unsigned wait; -public: + public: unsigned n; std::list hist; @@ -235,7 +246,8 @@ public: } double σ() const { - return 2.0 / (n - wait) * this->τ()[0] * (C[0] / (n - wait) - pow(this->avg(), 2)); + return 2.0 / (n - wait) * this->τ()[0] * + (C[0] / (n - wait) - pow(this->avg(), 2)); } double serr() const { return sqrt(this->σ()); } @@ -243,23 +255,32 @@ public: unsigned num_added() const { return n - wait; } }; -template class Model; - template - class measurement { - public: - virtual void pre_cluster(const Model&, unsigned, const Euclidean&) {}; - virtual void plain_bond_visited(const Model&, const Spin*, const Spin*, const Spin& , double) {}; - virtual void plain_site_transformed(const Model&, const Spin*, const Spin&) {}; - - virtual void ghost_bond_visited(const Model&, const Spin&, const Spin&, double) {}; - virtual void ghost_site_transformed(const Model&, const Euclidean&) {}; +class Model; - virtual void post_cluster(const Model&) {}; - }; +template +class measurement { + public: + virtual void pre_cluster(const Model&, unsigned, + const Euclidean&){}; + virtual void plain_bond_visited(const Model&, const Spin*, + const Spin*, const Spin&, + double){}; + virtual void plain_site_transformed(const Model&, + const Spin*, + const Spin&){}; + + virtual void ghost_bond_visited(const Model&, const Spin&, + const Spin&, double){}; + virtual void ghost_site_transformed(const Model&, + const Euclidean&){}; + + virtual void post_cluster(const Model&){}; +}; -template class Model { -public: +template +class Model { + public: U L; Euclidean s0; std::vector> s; @@ -271,9 +292,10 @@ public: std::vector> mats; std::vector> steps; double E; - measurement &A; + measurement& A; - void one_sequences(std::list>& sequences, unsigned level) { + void one_sequences(std::list>& sequences, + unsigned level) { if (level > 0) { unsigned new_level = level - 1; unsigned old_length = sequences.size(); @@ -286,9 +308,18 @@ public: } } - Model(U L, std::function&, const Spin&)> Z, - std::function&)> B, unsigned dDepth, unsigned nDepth, measurement& A) - : L(L), s0(L), dict(L, dDepth), Z(Z), B(B), dDepth(dDepth), nDepth(nDepth), A(A) { + Model(U L, + std::function&, const Spin&)> Z, + std::function&)> B, unsigned dDepth, + unsigned nDepth, measurement& A) + : L(L), + s0(L), + dict(L, dDepth), + Z(Z), + B(B), + dDepth(dDepth), + nDepth(nDepth), + A(A) { std::array ini_sequence; ini_sequence.fill(1); std::list> sequences; @@ -296,7 +327,7 @@ public: one_sequences(sequences, D); - sequences.pop_front(); // don't want the identity matrix! + sequences.pop_front(); // don't want the identity matrix! for (std::array sequence : sequences) { Matrix m; @@ -390,10 +421,13 @@ public: } else { Spin si_new = r.act(*si); std::set*> all_neighbors; - std::set*> current_neighbors = dict.neighbors(si->x, nDepth); - std::set*> new_neighbors = dict.neighbors(si_new.x, nDepth); + std::set*> current_neighbors = + dict.neighbors(si->x, nDepth); + std::set*> new_neighbors = + dict.neighbors(si_new.x, nDepth); - all_neighbors.insert(current_neighbors.begin(), current_neighbors.end()); + all_neighbors.insert(current_neighbors.begin(), + current_neighbors.end()); all_neighbors.insert(new_neighbors.begin(), new_neighbors.end()); all_neighbors.insert(NULL); for (Spin* sj : all_neighbors) { @@ -427,7 +461,8 @@ public: std::uniform_real_distribution t_dist(0, L); std::uniform_int_distribution r_dist(0, D - 1); std::uniform_int_distribution ind_dist(0, s.size() - 1); - std::uniform_int_distribution coin(0, mats.size() + steps.size() - 1); + std::uniform_int_distribution coin( + 0, mats.size() + steps.size() - 1); for (unsigned i = 0; i < N; i++) { Vector t; -- cgit v1.2.3-70-g09d2