summaryrefslogtreecommitdiff
path: root/euclidean.hpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2020-01-15 19:17:50 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2020-01-15 19:17:50 -0500
commit53f05e5f0bc0b79b4422ecfbb3dde7e346fdddd4 (patch)
tree7dc204f70eef4796812a45621de2b5e2da2c8ce6 /euclidean.hpp
parent614575bb88a2cadc9e35b684d0f1712de822ef0d (diff)
downloadspace_wolff-53f05e5f0bc0b79b4422ecfbb3dde7e346fdddd4.tar.gz
space_wolff-53f05e5f0bc0b79b4422ecfbb3dde7e346fdddd4.tar.bz2
space_wolff-53f05e5f0bc0b79b4422ecfbb3dde7e346fdddd4.zip
refactor
Diffstat (limited to 'euclidean.hpp')
-rw-r--r--euclidean.hpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/euclidean.hpp b/euclidean.hpp
new file mode 100644
index 0000000..b1a5e80
--- /dev/null
+++ b/euclidean.hpp
@@ -0,0 +1,116 @@
+
+#pragma once
+
+#include "matrix.hpp"
+#include "spin.hpp"
+#include "vector.hpp"
+
+template <class T, int D> class Euclidean {
+public:
+ Vector<T, D> t;
+ Matrix<T, D> r;
+
+ Euclidean(T L) {
+ for (unsigned i = 0; i < D; i++) {
+ t(i) = 0;
+ r(i, i) = 1;
+ for (unsigned j = 1; j < D; j++) {
+ r(i, (i + j) % D) = 0;
+ }
+ }
+ }
+
+ Euclidean(Vector<T, D> t0, Matrix<T, D> r0) {
+ t = t0;
+ r = r0;
+ }
+
+ template <class S> Spin<T, D, S> act(const Spin<T, D, S>& s) const {
+ Spin<T, D, S> s_new;
+
+ s_new.x = t + r * s.x;
+ s_new.s = s.s;
+
+ return s_new;
+ }
+
+ Euclidean act(const Euclidean& x) const {
+ Vector<T, D> tnew = r * x.t + t;
+ Matrix<T, D> rnew = r * x.r;
+
+ Euclidean pnew(tnew, rnew);
+
+ return pnew;
+ }
+
+ Euclidean inverse() const {
+ Vector<T, D> tnew = -r.transpose() * t;
+ Matrix<T, D> rnew = r.transpose();
+
+ Euclidean pnew(tnew, rnew);
+
+ return pnew;
+ }
+};
+
+template <class T, int D> class TorusGroup {
+private:
+ T L;
+
+public:
+ Vector<T, D> t;
+ Matrix<T, D> r;
+
+ /** brief TorusGroup - default constructor, constructs the identity
+ */
+ TorusGroup(T L) : L(L) {
+ for (unsigned i = 0; i < D; i++) {
+ t(i) = 0;
+ r(i, i) = 1;
+ for (unsigned j = 1; j < D; j++) {
+ r(i, (i + j) % D) = 0;
+ }
+ }
+ }
+
+ TorusGroup(T L, Vector<T, D> t0, Matrix<T, D> r0) : L(L) {
+ t = t0;
+ r = r0;
+ }
+
+ template <class S> Spin<T, D, S> act(const Spin<T, D, S>& s) const {
+ Spin<T, D, S> s_new;
+
+ s_new.x = t + r * s.x;
+ s_new.s = s.s;
+
+ for (unsigned i = 0; i < D; i++) {
+ s_new.x(i) = fmod(L + s_new.x(i), L);
+ }
+
+ return s_new;
+ }
+
+ TorusGroup act(const TorusGroup& x) const {
+ Vector<T, D> tnew = r * x.t + t;
+ Matrix<T, D> rnew = r * x.r;
+
+ for (unsigned i = 0; i < D; i++) {
+ tnew(i) = fmod(L + tnew(i), L);
+ }
+
+ TorusGroup pnew(this->L, tnew, rnew);
+
+ return pnew;
+ }
+
+ TorusGroup inverse() const {
+ Vector<T, D> tnew = -r.transpose() * t;
+ Matrix<T, D> rnew = r.transpose();
+
+ TorusGroup pnew(this->L, tnew, rnew);
+
+ return pnew;
+ }
+};
+