diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-21 19:43:16 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-21 19:43:16 -0400 |
commit | e3fbb92e68f0410f106285c9a49ecf8cd0a488a9 (patch) | |
tree | 7b7412af76032746e3b5c4281a7c7ba076302791 /lib/symmetric.h | |
parent | 0af22d23f860d7ab1c0e9355f55cade310afd748 (diff) | |
download | c++-e3fbb92e68f0410f106285c9a49ecf8cd0a488a9.tar.gz c++-e3fbb92e68f0410f106285c9a49ecf8cd0a488a9.tar.bz2 c++-e3fbb92e68f0410f106285c9a49ecf8cd0a488a9.zip |
added visualization, and started potts
Diffstat (limited to 'lib/symmetric.h')
-rw-r--r-- | lib/symmetric.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/lib/symmetric.h b/lib/symmetric.h index c71521d..0b292a6 100644 --- a/lib/symmetric.h +++ b/lib/symmetric.h @@ -5,6 +5,10 @@ #include "types.h" +#ifdef __cplusplus +extern "C" { +#endif + q_t *symmetric_compose(q_t q, const q_t *g1, const q_t *g2); q_t symmetric_act(const q_t *g, q_t s); @@ -13,3 +17,87 @@ q_t *symmetric_invert(q_t q, const q_t *g); q_t *symmetric_gen_transformations(q_t q); +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +template <q_t q> +class symmetric_t { + public: + q_t *perm; +}; + +template <q_t q> +void init(symmetric_t<q> *p) { + p->perm = (q_t *)malloc(q * sizeof(q_t)); + + for (q_t i = 0; i < q; i++) { + p->perm[i] = i; + } +} + +template <q_t q> +void free_spin(symmetric_t<q> p) { + free(p->perm); +} + +template <q_t q> +symmetric_t<q_t> copy(symmetric_t<q_t> x) { + symmetric_t<q> x2; + x2.perm = (q_t *)malloc(q * sizeof(q_t)); + + for (q_t i = 0; i < q; i++) { + x2.perm[i] = x.perm[i]; + } + + return x2; +} + +template <q_t q> +potts_t<q> act(symmetric_t<q> r, potts_t<q> s) { + potts_t<q> s2; + s2.x = r.perm[s.x]; + return s2; +} + +template <q_t q> +symmetric_t<q> act(symmetric_t<q> r1, symmetric_t<q> r2) { + symmetric_t<q> r3; + r3.perm = (q_t *)malloc(q * sizeof(q_t)); + for (q_t i = 0; i < q; i++) { + r3.perm[i] = r1.perm[r2.perm[i]]; + } + + return r3; +} + +template <q_t q> +potts_t<q> act_inverse(symmetric_t<q> r, potts_t<q> s) { + potts_t<q> s2; + + q_t i; + + for (i = 0; i < q; i++) { + if (r.perm[i] == s.x) { + break; + } + } + + s2.x = i; + + return s2; +} + +template <q_t q> +symmetric_t<q> act_inverse(symmetric_t<q> r1, symmetric_t<q> r2) { + symmetric_t<q> r3; + r3.perm = (q_t *)malloc(q * sizeof(q_t)); + for (q_t i = 0; i < q; i++) { + r3.perm[r1.perm[i]] = r2.perm[i]; + } + + return r3; +} +#endif + |