diff options
Diffstat (limited to 'lib/wolff_models/height.hpp')
-rw-r--r-- | lib/wolff_models/height.hpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/wolff_models/height.hpp b/lib/wolff_models/height.hpp new file mode 100644 index 0000000..ae3ad82 --- /dev/null +++ b/lib/wolff_models/height.hpp @@ -0,0 +1,56 @@ + +#pragma once + +#include <cmath> + +namespace wolff { + + template <class T> + struct height_t { + T x; + + height_t() : x(0) {} + height_t(T x) : x(x) {} + + typedef T M_t; + typedef double F_t; + + inline T operator*(unsigned a) const { + return x * a; + } + + inline double operator*(double a) const { + return x * a; + } + + inline T operator-(const height_t& h) const { + return x - h.x; + } + }; + + template <class T> + inline typename height_t<T>::M_t operator*(unsigned a, height_t<T> h) { + return h * a; + } + + template <class T> + inline typename height_t<T>::F_t operator*(double a, height_t<T> h) { + return h * a; + } + + template <class T> + inline T& operator+=(T& M, const height_t<T> &h) { + M += h.x; + + return M; + } + + template <class T> + inline T& operator-=(T& M, const height_t<T> &h) { + M -= h.x; + + return M; + } + +} + |