From 49ac78a6c04e215950bc9c0f97368605e63da15b Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 14 Jan 2019 15:47:59 -0500 Subject: 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. --- lib/wolff_models/height.hpp | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 lib/wolff_models/height.hpp (limited to 'lib/wolff_models/height.hpp') 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 + +namespace wolff { + + template + 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 + inline typename height_t::M_t operator*(unsigned a, height_t h) { + return h * a; + } + + template + inline typename height_t::F_t operator*(double a, height_t h) { + return h * a; + } + + template + inline T& operator+=(T& M, const height_t &h) { + M += h.x; + + return M; + } + + template + inline T& operator-=(T& M, const height_t &h) { + M -= h.x; + + return M; + } + +} + -- cgit v1.2.3-70-g09d2