diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-01-14 15:47:59 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-01-14 15:47:59 -0500 |
commit | 49ac78a6c04e215950bc9c0f97368605e63da15b (patch) | |
tree | 64b770c543a0c90bc7dcbc06ceaaa31e96e541ce /lib/wolff_models/dihedral_inf.hpp | |
parent | 994cbf1a3b611ff4c94ced3b1630e51fd249d7ed (diff) | |
download | c++-49ac78a6c04e215950bc9c0f97368605e63da15b.tar.gz c++-49ac78a6c04e215950bc9c0f97368605e63da15b.tar.bz2 c++-49ac78a6c04e215950bc9c0f97368605e63da15b.zip |
Large refactoring around changes in the graph class.
- Graphs now use lists of references instead of vectors of indicies.
- Vertices and edges have associated classes that can be given arbitrary properties via template specification.
- All essential library headers have been combined into one, wolff.hpp.
Diffstat (limited to 'lib/wolff_models/dihedral_inf.hpp')
-rw-r--r-- | lib/wolff_models/dihedral_inf.hpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/wolff_models/dihedral_inf.hpp b/lib/wolff_models/dihedral_inf.hpp new file mode 100644 index 0000000..0b09c59 --- /dev/null +++ b/lib/wolff_models/dihedral_inf.hpp @@ -0,0 +1,55 @@ + +#ifndef WOLFF_MODELS_DIHEDRAL_INF_H +#define WOLFF_MODELS_DIHEDRAL_INF_H + +#include <cmath> +#include "height.hpp" + +namespace wolff { + + template <class T> + class dihedral_inf_t { + public: + bool is_reflection; + T x; + + dihedral_inf_t() : is_reflection(false), x(0) {} + dihedral_inf_t(bool x, T y) : is_reflection(x), x(y) {} + + height_t<T> act(const height_t<T>& h) const { + if (this->is_reflection) { + return height_t(this->x - h.x); + } else { + return height_t(this->x + h.x); + } + } + + dihedral_inf_t<T> act(const dihedral_inf_t<T>& r) const { + if (this->is_reflection) { + return dihedral_inf_t<T>(!r.is_reflection, this->x - r.x); + } else { + return dihedral_inf_t<T>(r.is_reflection, this->x + r.x); + } + } + + height_t<T> act_inverse(const height_t<T>& h) const { + if (this->is_reflection) { + return this->act(h); + } else { + return height_t(h.x - this->x); + } + } + + dihedral_inf_t<T> act_inverse(const dihedral_inf_t<T>& r) const { + if (this->is_reflection) { + return this->act(r); + } else { + return dihedral_inf_t<T>(r.is_reflection, r.x - this->x); + } + } + }; + +} + +#endif + |