#include "types.h" #include #include "height.h" template struct dihedral_inf_t { bool is_reflection; T x; }; template void init(dihedral_inf_t *ptr) { ptr->is_reflection = false; ptr->x = (T)0; } template dihedral_inf_t copy(dihedral_inf_t r) { return r; } template void free_spin(dihedral_inf_t r) { // do nothing! } template height_t act(dihedral_inf_t r, height_t h) { height_t h2; if (r.is_reflection) { h2.x = r.x - h.x; } else { h2.x = r.x + h.x; } return h2; } template dihedral_inf_t act(dihedral_inf_t r1, dihedral_inf_t r2) { dihedral_inf_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 height_t act_inverse(dihedral_inf_t r, height_t h) { height_t h2; if (r.is_reflection) { h2.x = r.x - h.x; } else { h2.x = h.x - r.x; } return h2; } template dihedral_inf_t act_inverse(dihedral_inf_t r1, dihedral_inf_t r2) { dihedral_inf_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; }