+ using namespace std::complex_literals;
+
+ const double runtime = getRuntime();
+
+ for (int m = -m_surface->size()/2; m < m_surface->size()/2; ++m) {
+ const int positiveM = (m + m_surface->size()) % m_surface->size();
+
+ for (int n = -m_surface->size()/2; n < m_surface->size()/2; ++n) {
+ const double k = sqrt(pow(spatialFrequencyForIndex(n), 2) +
+ pow(spatialFrequencyForIndex(m), 2));
+ const double omega = sqrt(GRAVITATIONAL_CONSTANT * k);
+
+ std::complex<double> amplitude =
+ fourierAmplitudeAt(n, m).first * exp(1i * omega * runtime) +
+ fourierAmplitudeAt(n, m).second * exp(-1i * omega * runtime);
+
+ const int positiveN = (n + m_surface->size()) % m_surface->size();
+ int fftwIndex = positiveM + positiveN * m_surface->size();
+
+ m_fftwIn[fftwIndex][0] = std::real(amplitude);
+ m_fftwIn[fftwIndex][1] = std::imag(amplitude);
+ }
+ }
+
+ fftw_execute(m_fftwPlan);
+