diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-26 01:17:53 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-26 01:17:53 -0400 |
commit | 94f7d887981f0626f166f5645fa98115d4f9a478 (patch) | |
tree | b5653f58f288a9619dc82d3ac5867dfd5c89ad45 /lib/height.h | |
parent | d3b3e39a525d0c3aa9663f824ba96e0c429a8313 (diff) | |
download | c++-94f7d887981f0626f166f5645fa98115d4f9a478.tar.gz c++-94f7d887981f0626f166f5645fa98115d4f9a478.tar.bz2 c++-94f7d887981f0626f166f5645fa98115d4f9a478.zip |
everything compiles now, and fixed a major bug in the graph code
Diffstat (limited to 'lib/height.h')
-rw-r--r-- | lib/height.h | 48 |
1 files changed, 15 insertions, 33 deletions
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 <class T> -void init(height_t<T> *ptr) { - ptr->x = (T)0; -} -template <class T> -void free_spin(height_t<T> h) { - // do nothing! -} + height_t() : x(0) {} -template <class T> -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 <class T> -height_t<T> copy(height_t<T> h) { - return h; -} + inline double operator*(double a) const { + return x * a; + } +}; template <class T> -void add(T *h1, int a, height_t<T> h2) { - (*h1) += a * h2.x; -} +inline T& operator+=(T& M, const height_t<T> &h) { + M += h.x; -template <class T> -void add(double *h1, double a, height_t<T> h2) { - (*h1) += a * h2.x; + return M; } template <class T> -T scalar_multiple(int factor, height_t<T> h) { - return factor * h.x; -} +inline T& operator-=(T& M, const height_t<T> &h) { + M -= h.x; -template <class T> -double scalar_multiple(double factor, height_t<T> h) { - return factor * h.x; + return M; } double norm_squared(double h) { |