From 98350b34d1826e1d6687f18c45b0fbc6a3488742 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 25 Feb 2020 23:12:31 -0500 Subject: More fixes on new features --- dimers_torus.cpp | 26 ++------------------------ euclidean.hpp | 5 +++-- spheres.cpp | 27 ++------------------------- torus_symmetries.hpp | 24 ++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 51 deletions(-) diff --git a/dimers_torus.cpp b/dimers_torus.cpp index f304564..74cf47e 100644 --- a/dimers_torus.cpp +++ b/dimers_torus.cpp @@ -11,28 +11,6 @@ const unsigned D = 2; typedef Model, Dimer> model; -Gen, Dimer> eGen(double L) { - std::vector> torusVectors = torus_vecs(L); - std::vector> torusMatrices = torus_mats(); - return [L, torusVectors, - torusMatrices](Model, Dimer>& M, - Rng& r) -> Transformation, Dimer>* { - Matrix m; - Vector t; - - m = r.pick(torusMatrices); - t(0) = r.uniform(0, L); - t(1) = r.uniform(0, L); - t = t - m * t; - - TorusGroup g = TorusGroup({(double)L, t, m}); - - Spin>* ss = r.pick(M.s); - - return new SpinFlip, Dimer>(M, g, ss); - }; -} - int main(int argc, char* argv[]) { const unsigned D = 2; @@ -97,7 +75,7 @@ int main(int argc, char* argv[]) { return H * s.x(1); }; - auto g1 = eGen(L); + auto g1 = uniformGenTorus>(L); auto tag = std::chrono::high_resolution_clock::now(); @@ -111,7 +89,7 @@ int main(int argc, char* argv[]) { unsigned nx = floor(sqrt(n)); for (unsigned i = 0; i < sphere.s.size(); i++) { Spin>* ss = new Spin>(); - ss->x = {(i / nx) * L / nx - L / 2, (i % nx) * L / nx - L / 2}; + ss->x = {(i / nx) * L / nx, (i % nx) * L / nx}; ss->s = Dimer{.relativePosition = {0.2, 0}, .radius = 0.25}; sphere.s[i] = ss; sphere.dict.insert(ss); diff --git a/euclidean.hpp b/euclidean.hpp index f0e54d4..acf65ac 100644 --- a/euclidean.hpp +++ b/euclidean.hpp @@ -56,7 +56,8 @@ public: Euclidean(const Affine& a) : Affine(a) {} Euclidean(Vector t0, Matrix r0) : Affine(t0, r0) {} - Euclidean act(const Euclidean& t) const { return Affine::actA(t); }; + Euclidean act(const Euclidean& t) const { return Euclidean(Affine::actA(t)); }; + Euclidean inverse() const { return Euclidean(Affine::inverse()); } using Affine::act; }; @@ -78,8 +79,8 @@ protected: public: TorusGroup(T L) : Affine(), L(L) {} - TorusGroup(T L, Vector t0, Matrix r0) : Affine(), L(L) {} TorusGroup(T L, const Affine& t) : Affine(t), L(L) {} + TorusGroup(T L, Vector t0, Matrix r0) : Affine(t0, r0), L(L) {} TorusGroup act(const TorusGroup& t) const { return TorusGroup(L, Affine::actA(t)); } TorusGroup inverse() const { return TorusGroup(L, Affine::inverse()); } diff --git a/spheres.cpp b/spheres.cpp index 0067cc8..9ca2036 100644 --- a/spheres.cpp +++ b/spheres.cpp @@ -8,30 +8,7 @@ #include "animation.hpp" const unsigned D = 2; -typedef Model, double> model; - -Gen, double> eGen(double L) { - std::vector> torusVectors = torus_vecs(L); - std::vector> torusMatrices = torus_mats(); - return [L, torusVectors, - torusMatrices](Model, double>& M, - Rng& r) -> Transformation, double>* { - Matrix m; - Vector t; - - m = r.pick(torusMatrices); - t(0) = r.uniform(0, L); - t(1) = r.uniform(0, L); - t = t - m * t; - - TorusGroup g = TorusGroup({(double)L, t, m}); - - Spin* ss = r.pick(M.s); - - return new SpinFlip, double>(M, g, ss); - }; -} - +typedef Model, Radius> model; int main(int argc, char* argv[]) { const unsigned D = 2; @@ -89,7 +66,7 @@ int main(int argc, char* argv[]) { return H * s.x(1); }; - auto g = eGen(L); + auto g = uniformGenTorus(L); std::ofstream ofile("test.dat"); Animation, Radius> A(L, 750, argc, argv, 1000, true); model sphere(L, Z, B); diff --git a/torus_symmetries.hpp b/torus_symmetries.hpp index 7bcb70b..53f61ac 100644 --- a/torus_symmetries.hpp +++ b/torus_symmetries.hpp @@ -7,6 +7,8 @@ #include "matrix.hpp" #include "vector.hpp" +#include "euclidean.hpp" +#include "transformation.hpp" template void one_sequences(std::list>& sequences, unsigned level) { if (level > 0) { @@ -98,3 +100,25 @@ template std::vector> torus_mats() { return mats; } +template +Gen, S> uniformGenTorus(double L) { + std::vector> torusVectors = torus_vecs(L); + std::vector> torusMatrices = torus_mats(); + return [L, torusVectors, + torusMatrices](Model, S>& M, + Rng& r) -> Transformation, S>* { + Matrix m = r.pick(torusMatrices); + + Vector t; + for (unsigned i = 0; i < D; i++) { + t(i) = r.uniform(0, L); + } + + TorusGroup g = TorusGroup({(double)L, t - m * t, m}); + + Spin* ss = r.pick(M.s); + + return new SpinFlip, S>(M, g, ss); + }; +} + -- cgit v1.2.3-70-g09d2