diff --git a/matrix/integration.hpp b/matrix/integration.hpp index 61f7574cca..2582819078 100644 --- a/matrix/integration.hpp +++ b/matrix/integration.hpp @@ -6,21 +6,21 @@ namespace matrix { template int integrate_rk4( - Vector (*f)(Type, Vector), + Vector (*f)(Type, Vector), Vector & y, Type & t, - Type h - ) + Type h +) { - // https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods - Vector k1, k2, k3, k4; - k1 = f(t, y); - k2 = f(t + h/2, y + k1*h/2); - k3 = f(t + h/2, y + k2*h/2); - k4 = f(t + h, y + k3*h); - y += (k1 + k2*2 + k3*2 + k4)*(h/6); - t += h; - return 0; + // https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods + Vector k1, k2, k3, k4; + k1 = f(t, y); + k2 = f(t + h/2, y + k1*h/2); + k3 = f(t + h/2, y + k2*h/2); + k4 = f(t + h, y + k3*h); + y += (k1 + k2*2 + k3*2 + k4)*(h/6); + t += h; + return 0; } }; // namespace matrix