27 size_t dim = tInterval.size();
28 size_t elem_size = y0.
columns();
29 if(h == 0) { h = (tInterval[dim - 1] - tInterval[0]) / 1000; }
32 auto result_dim = ((tInterval[dim - 1] - tInterval[0]) / h) + 1;
34 size_t n = result_dim;
35 auto y =
zeros(n, elem_size);
37 t(0, 0) = tInterval[0];
38 for(
unsigned long i = 0; i < y0.
columns(); ++i) y(0, i) = y0(0, i);
40 for(
size_t i = 1; i < n; i++) {
41 auto cur_t = t(i - 1, 0);
45 auto yi = cur_y + fun_value * h;
46 y.
SetRow(i, yi.GetSlice(0, 0, 0, elem_size - 1));
ODEResult ODEExpEuler(const ODE &fun, const std::vector< double > &tInterval, const Matrix< double > &y0, double h=0.0)
Definition: ExplicitEuler.h:26
void SetRow(size_t index, const Matrix< T > &other)
Definition: Matrix.h:541
size_t columns() const
Definition: Matrix.h:198
Matrix< double > zeros(size_t rows, size_t columns, size_t elements=1)
std::function< Matrix< double >(double, Matrix< double >)> ODE
alias for ODE
Definition: ode.h:17