diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-10-10 21:45:32 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-10-10 21:45:32 -0400 |
commit | a43ff1f98e9b9814f858bccb11c174b418458491 (patch) | |
tree | ae7e094d914eddb8a1ae9548420ba8c2f329ffae /examples/src/models/potts/symmetric.hpp | |
parent | 6e264d243f0b29d90e90b605b6cdeab8227129c9 (diff) | |
download | c++-a43ff1f98e9b9814f858bccb11c174b418458491.tar.gz c++-a43ff1f98e9b9814f858bccb11c174b418458491.tar.bz2 c++-a43ff1f98e9b9814f858bccb11c174b418458491.zip |
big rearrangement of files to make libraries and example (research) files clearer, and changed to c++ std lib random numbers
Diffstat (limited to 'examples/src/models/potts/symmetric.hpp')
-rw-r--r-- | examples/src/models/potts/symmetric.hpp | 51 |
1 files changed, 51 insertions, 0 deletions
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 <stdlib.h> +#include <array> +#include <wolff/types.h> +#include "potts.hpp" + +template <q_t q> +class symmetric_t : public std::array<q_t, q> { + public: + + symmetric_t() { + for (q_t i = 0; i < q; i++) { + (*this)[i] = i; + } + } + + potts_t<q> act(const potts_t<q> &s) const { + return potts_t<q>((*this)[s.x]); + } + + symmetric_t<q> act(const symmetric_t<q>& r) const { + symmetric_t<q> r_rot; + for (q_t i = 0; i < q; i++) { + r_rot[i] = (*this)[r[i]]; + } + + return r_rot; + } + + potts_t<q> act_inverse(const potts_t<q>& s) const { + for (q_t i = 0; i < q; i++) { + if ((*this)[i] == s.x) { + return potts_t<q>(i); + } + } + + exit(EXIT_FAILURE); + } + + symmetric_t<q> act_inverse(const symmetric_t<q>& r) const { + symmetric_t<q> r_rot; + for (q_t i = 0; i < q; i++) { + r_rot[(*this)[i]] = r[i]; + } + + return r_rot; + } +}; + |