blob: f7c4297c16d4d6ddd86ed6c64d8268448636d31c (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include "types.h"
#include <cmath>
#include "height.h"
template <class T>
struct dihedral_inf_t { bool is_reflection; T x; };
template <class T>
void init(dihedral_inf_t<T> *ptr) {
ptr->is_reflection = false;
ptr->x = (T)0;
}
template <class T>
dihedral_inf_t<T> copy(dihedral_inf_t<T> r) {
return r;
}
template <class T>
void free_spin(dihedral_inf_t<T> r) {
// do nothing!
}
template <class T>
height_t<T> act(dihedral_inf_t<T> r, height_t<T> h) {
height_t<T> h2;
if (r.is_reflection) {
h2.x = r.x - h.x;
} else {
h2.x = r.x + h.x;
}
return h2;
}
template <class T>
dihedral_inf_t<T> act(dihedral_inf_t<T> r1, dihedral_inf_t<T> r2) {
dihedral_inf_t<T> r3;
if (r1.is_reflection) {
r3.is_reflection = !(r2.is_reflection);
r3.x = r1.x - r2.x;
} else {
r3.is_reflection = r2.is_reflection;
r3.x = r1.x + r2.x;
}
return r3;
}
template <class T>
height_t<T> act_inverse(dihedral_inf_t<T> r, height_t<T> h) {
height_t<T> h2;
if (r.is_reflection) {
h2.x = r.x - h.x;
} else {
h2.x = h.x - r.x;
}
return h2;
}
template <class T>
dihedral_inf_t<T> act_inverse(dihedral_inf_t<T> r1, dihedral_inf_t<T> r2) {
dihedral_inf_t<T> r3;
if (r1.is_reflection) {
r3.is_reflection = !(r2.is_reflection);
r3.x = r1.x - r2.x;
} else {
r3.is_reflection = r2.is_reflection;
r3.x = r2.x - r1.x;
}
return r3;
}
|