diff --git a/include/dsp/ode.hpp b/include/dsp/ode.hpp index d757b2fd..ec8bb925 100644 --- a/include/dsp/ode.hpp +++ b/include/dsp/ode.hpp @@ -1,6 +1,5 @@ #pragma once #include -#include namespace rack { @@ -29,7 +28,7 @@ For example, the following solves the system x''(t) = -x(t) using a fixed timest /** Solves an ODE system using the 1st order Euler method */ template void stepEuler(T t, T dt, T x[], int len, F f) { - T *k = (T*) alloca(len); + T k[len]; f(t, x, k); for (int i = 0; i < len; i++) { @@ -40,9 +39,9 @@ void stepEuler(T t, T dt, T x[], int len, F f) { /** Solves an ODE system using the 2nd order Runge-Kutta method */ template void stepRK2(T t, T dt, T x[], int len, F f) { - T *k1 = (T*) alloca(len); - T *k2 = (T*) alloca(len); - T *yi = (T*) alloca(len); + T k1[len]; + T k2[len]; + T yi[len]; f(t, x, k1); @@ -59,11 +58,11 @@ void stepRK2(T t, T dt, T x[], int len, F f) { /** Solves an ODE system using the 4th order Runge-Kutta method */ template void stepRK4(T t, T dt, T x[], int len, F f) { - T *k1 = (T*) alloca(len); - T *k2 = (T*) alloca(len); - T *k3 = (T*) alloca(len); - T *k4 = (T*) alloca(len); - T *yi = (T*) alloca(len); + T k1[len]; + T k2[len]; + T k3[len]; + T k4[len]; + T yi[len]; f(t, x, k1);