29template <
typename T,
typename F>
34 for (
int i = 0; i < len; i++) {
40template <
typename T,
typename F>
41void stepRK2(T t, T dt, T x[],
int len, F f) {
48 for (
int i = 0; i < len; i++) {
49 yi[i] = x[i] + k1[i] * dt / T(2);
51 f(t + dt / T(2), yi, k2);
53 for (
int i = 0; i < len; i++) {
59template <
typename T,
typename F>
60void stepRK4(T t, T dt, T x[],
int len, F f) {
69 for (
int i = 0; i < len; i++) {
70 yi[i] = x[i] + k1[i] * dt / T(2);
72 f(t + dt / T(2), yi, k2);
74 for (
int i = 0; i < len; i++) {
75 yi[i] = x[i] + k2[i] * dt / T(2);
77 f(t + dt / T(2), yi, k3);
79 for (
int i = 0; i < len; i++) {
80 yi[i] = x[i] + k3[i] * dt;
84 for (
int i = 0; i < len; i++) {
85 x[i] += dt * (k1[i] + T(2) * k2[i] + T(2) * k3[i] + k4[i]) / T(6);
void stepRK4(T t, T dt, T x[], int len, F f)
Solves an ODE system using the 4th order Runge-Kutta method.
Definition ode.hpp:60
void stepEuler(T t, T dt, T x[], int len, F f)
The callback function f in each of these stepping functions must have the signature.
Definition ode.hpp:30
void stepRK2(T t, T dt, T x[], int len, F f)
Solves an ODE system using the 2nd order Runge-Kutta method.
Definition ode.hpp:41
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9