summaryrefslogtreecommitdiff
path: root/lib/wolff_models/height.hpp
blob: ae3ad8229a89720354bef8308b45c23606709f06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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;
  }

}