From 94f7d887981f0626f166f5645fa98115d4f9a478 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Thu, 26 Jul 2018 01:17:53 -0400 Subject: everything compiles now, and fixed a major bug in the graph code --- lib/height.h | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) (limited to 'lib/height.h') diff --git a/lib/height.h b/lib/height.h index 81d3a2d..a4cbbed 100644 --- a/lib/height.h +++ b/lib/height.h @@ -32,50 +32,32 @@ struct height_t { typedef T M_t; typedef double F_t; -}; - -template -void init(height_t *ptr) { - ptr->x = (T)0; -} -template -void free_spin(height_t h) { - // do nothing! -} + height_t() : x(0) {} -template -void free_spin(T h) { - // do nothing! -} + height_t(T x) : x(x) {} -void free_spin(double h) { - // do nothing! -} + inline T operator*(v_t a) const { + return x * a; + } -template -height_t copy(height_t h) { - return h; -} + inline double operator*(double a) const { + return x * a; + } +}; template -void add(T *h1, int a, height_t h2) { - (*h1) += a * h2.x; -} +inline T& operator+=(T& M, const height_t &h) { + M += h.x; -template -void add(double *h1, double a, height_t h2) { - (*h1) += a * h2.x; + return M; } template -T scalar_multiple(int factor, height_t h) { - return factor * h.x; -} +inline T& operator-=(T& M, const height_t &h) { + M -= h.x; -template -double scalar_multiple(double factor, height_t h) { - return factor * h.x; + return M; } double norm_squared(double h) { -- cgit v1.2.3-70-g09d2