summaryrefslogtreecommitdiff
path: root/lib/include/wolff/models/dihedral.hpp
blob: cf4b067bb07953143223885428f59286621b06cc (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
52
53
54
55
56

#ifndef WOLFF_MODELS_DIHEDRAL_H
#define WOLFF_MODELS_DIHEDRAL_H

#include "potts.hpp"

namespace wolff {

#include "../types.h"

template <q_t q>
class dihedral_t {
  public:
    bool is_reflection;
    q_t x;

    dihedral_t() : is_reflection(false), x(0) {}
    dihedral_t(bool x, q_t y) : is_reflection(x), x(y) {}

    potts_t<q> act(const potts_t<q>& s) const {
      if (this->is_reflection) {
        return potts_t<q>(((q + this->x) - s.x) % q);
      } else {
        return potts_t<q>((this->x + s.x) % q);
      }
    }

    dihedral_t<q> act(dihedral_t<q> r) const {
      if (this->is_reflection) {
        return dihedral_t<q>(!(r.is_reflection), ((q + this->x) - r.x) % q); 
      } else {
        return dihedral_t<q>(r.is_reflection, (this->x + r.x) % q);
      }
    }

    potts_t<q> act_inverse(potts_t<q> s) const {
      if (this->is_reflection) {
        return this->act(s);
      } else {
        return potts_t<q>(((s.x + q) - this->x) % q);
      }
    }

    dihedral_t<q> act_inverse(dihedral_t<q> r) const {
      if (this->is_reflection) {
        return this->act(r);
      } else {
        return dihedral_t<q>(r.is_reflection, ((r.x + q) - this->x) % q);
      }
    }
};

}

#endif