summaryrefslogtreecommitdiff
path: root/examples/src/models/potts/symmetric.hpp
blob: 8636f153bad08707f9232a3c4be591741138b4a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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;
    }
};