From a43ff1f98e9b9814f858bccb11c174b418458491 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 10 Oct 2018 21:45:32 -0400 Subject: big rearrangement of files to make libraries and example (research) files clearer, and changed to c++ std lib random numbers --- examples/src/models/potts/symmetric.hpp | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 examples/src/models/potts/symmetric.hpp (limited to 'examples/src/models/potts/symmetric.hpp') diff --git a/examples/src/models/potts/symmetric.hpp b/examples/src/models/potts/symmetric.hpp new file mode 100644 index 0000000..8636f15 --- /dev/null +++ b/examples/src/models/potts/symmetric.hpp @@ -0,0 +1,51 @@ + +#pragma once + +#include +#include +#include +#include "potts.hpp" + +template +class symmetric_t : public std::array { + public: + + symmetric_t() { + for (q_t i = 0; i < q; i++) { + (*this)[i] = i; + } + } + + potts_t act(const potts_t &s) const { + return potts_t((*this)[s.x]); + } + + symmetric_t act(const symmetric_t& r) const { + symmetric_t r_rot; + for (q_t i = 0; i < q; i++) { + r_rot[i] = (*this)[r[i]]; + } + + return r_rot; + } + + potts_t act_inverse(const potts_t& s) const { + for (q_t i = 0; i < q; i++) { + if ((*this)[i] == s.x) { + return potts_t(i); + } + } + + exit(EXIT_FAILURE); + } + + symmetric_t act_inverse(const symmetric_t& r) const { + symmetric_t r_rot; + for (q_t i = 0; i < q; i++) { + r_rot[(*this)[i]] = r[i]; + } + + return r_rot; + } +}; + -- cgit v1.2.3-70-g09d2