KalmanFilter
double.h
1 #ifndef VECTORDOUBLE
2 #define VECTORDOUBLE
3 
4 #include <stdexcept>
5 #include <random>
6 
7 
9  private:
10  double value;
11  public:
12  vectorDouble(){
13  value = 0;
14  }
15 
16  vectorDouble(double value):value(value){}
17 
18  double getSystemValue() const{
19  return value;
20  }
21 
22 
23  static vectorDouble randomVector(int dimension,uint32_t seed){
24  std::mt19937 generator(seed);
25  std::normal_distribution<double> distribution(0.0,1.0);
26  double value = distribution(generator);
27  return vectorDouble(value);
28  }
29 };
30 
31 
32 
33 
34 vectorDouble operator-(const vectorDouble &lhs,const vectorDouble &rhs){
35  vectorDouble res(lhs.getSystemValue() - rhs.getSystemValue());
36  return res;
37 };
38 
39 vectorDouble operator+(const vectorDouble &lhs,const vectorDouble &rhs){
40  vectorDouble res(lhs.getSystemValue() + rhs.getSystemValue());
41  return res;
42 };
43 
44 std::ostream& operator<<(std::ostream& stream, const vectorDouble & vec) {
45  double v = vec.getSystemValue();
46  stream<<v;
47  return stream;
48 }
49 
50 
51 
52 
54  private:
55  double value;
56 
57  public:
58  matrixDouble(){
59  value = 0;
60  }
61 
62  matrixDouble(double value):value(value){}
63 
64 
65  static matrixDouble Identity(int dimension, int dimension2){
66  return matrixDouble(1);
67  }
68 
69  matrixDouble transpose(){
70  matrixDouble t(value);
71  return t;
72  }
73 
74  matrixDouble inverse(){
75  if(value == 0){
76  throw std::overflow_error("Divide by zero exception");
77  }
78  matrixDouble t(1.0/value);
79  return t;
80  }
81 
82  double getSystemValue() const{
83  return value;
84  }
85 };
86 
87 matrixDouble operator*(const matrixDouble &lhs, const matrixDouble &rhs){
88  matrixDouble res(lhs.getSystemValue()*rhs.getSystemValue());
89  return res;
90 }
91 
92 matrixDouble operator+(const matrixDouble &lhs,const matrixDouble &rhs){
93  matrixDouble res(lhs.getSystemValue() + rhs.getSystemValue());
94  return res;
95 };
96 
97 matrixDouble operator-(const matrixDouble &lhs,const matrixDouble &rhs){
98  matrixDouble res(lhs.getSystemValue() - rhs.getSystemValue());
99  return res;
100 };
101 
102 std::ostream& operator<<(std::ostream& stream, const matrixDouble & vec) {
103  double v = vec.getSystemValue();
104  stream<<v;
105  return stream;
106 }
107 
108 
109 
110 
111 vectorDouble operator*(const matrixDouble &lhs, const vectorDouble &rhs){
112  vectorDouble res(lhs.getSystemValue()*rhs.getSystemValue());
113  return res;
114 }
115 
116 vectorDouble operator*(const vectorDouble &lhs, const matrixDouble &rhs){
117  vectorDouble res(lhs.getSystemValue()*rhs.getSystemValue());
118  return res;
119 }
120 
121 
122 
123 
124 
125 #endif
Definition: double.h:53
Definition: double.h:8