Helios++
Helios software for LiDAR simulations
IterativeEulerMethod.h
1 #pragma once
2 
3 #include <fluxionum/Function.h>
4 
5 namespace fluxionum{
6 
25 template <typename A, typename B>
26 class IterativeEulerMethod : public Function<A, B>{
27 protected:
28  // *** ATTRIBUTES *** //
29  // ******************** //
43  A t0;
49  A t;
54  B y0;
60  B y;
61 
62 public:
63  // *** CONSTRUCTION / DESTRUCTION *** //
64  // ************************************ //
73  A const &t0,
74  B const &y0
75  ) :
76  Function<A, B>(),
77  dydt(dydt),
78  t0(t0),
79  t(t0),
80  y0(y0),
81  y(y0)
82  {}
83  virtual ~IterativeEulerMethod() = default;
84 
85  // *** FUNCTION METHODS *** //
86  // ************************** //
100  B eval(A const &h) override{
101  y = y + h*dydt(t);
102  t = t+h;
103  return y;
104  }
105 
110  virtual void restart(){
111  setT(getT0());
112  setY(getY0());
113  }
114 
115  // *** GETTERs and SETTERs *** //
116  // ***************************** //
120  inline Function<A, B> const& getDydt() const {return dydt;};
124  inline A getT() const {return t;};
128  inline void setT(A const t) {this->t = t;}
132  inline A getT0() const {return t0;}
136  inline B getY() const {return y;}
140  inline void setY(B const y) {this->y = y;}
144  inline B getY0() const {return y0;}
145 };
146 
147 }
Abstract class representing a function.
Definition: Function.h:27
Iterative Euler method.
Definition: IterativeEulerMethod.h:26
A getT() const
Definition: IterativeEulerMethod.h:124
A t
The current value of .
Definition: IterativeEulerMethod.h:49
B eval(A const &h) override
Iteratively compute the next value using Euler method.
Definition: IterativeEulerMethod.h:100
void setY(B const y)
Definition: IterativeEulerMethod.h:140
B getY0() const
Definition: IterativeEulerMethod.h:144
void setT(A const t)
Definition: IterativeEulerMethod.h:128
Function< A, B > & dydt
Reference to the derivative function.
Definition: IterativeEulerMethod.h:38
A getT0() const
Definition: IterativeEulerMethod.h:132
B getY() const
Definition: IterativeEulerMethod.h:136
A t0
The initial value of , .
Definition: IterativeEulerMethod.h:43
virtual void restart()
Restart the IterativeEulerMethod so it is at its initial state again .
Definition: IterativeEulerMethod.h:110
B y0
The initial value of , .
Definition: IterativeEulerMethod.h:54
Function< A, B > const & getDydt() const
Definition: IterativeEulerMethod.h:120
B y
The current value of .
Definition: IterativeEulerMethod.h:60
IterativeEulerMethod(Function< A, B > &dydt, A const &t0, B const &y0)
IterativeEulerMethod default constructor.
Definition: IterativeEulerMethod.h:71