From d121bf3764d169b296f3101e54feaaf83f8169be Mon Sep 17 00:00:00 2001 From: Paul Jungeblut Date: Wed, 28 Sep 2016 11:28:13 +0200 Subject: Improve usability FFT code. --- math/fft.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'math/fft.cpp') diff --git a/math/fft.cpp b/math/fft.cpp index 8fe38e5..b234d4e 100644 --- a/math/fft.cpp +++ b/math/fft.cpp @@ -1,7 +1,6 @@ // Laufzeit: O(n log(n)). typedef complex cplx; // Eigene Implementierung ist noch deutlich schneller. -// s.size() muss eine Zweierpotenz sein! -vector fft(const vector &a, bool inverse = 0) { +vector fft(const vector &a, bool inverse = 0) { // a.size() muss eine Zweierpotenz sein! int logn = 1, n = a.size(); vector A(n); while ((1 << logn) < n) logn++; @@ -27,7 +26,8 @@ vector fft(const vector &a, bool inverse = 0) { return A; } -// Polynome: a_0, a_1, ... & b_0, b_1, ... +// Polynome: a[0] = a_0, a[1] = a_1, ... und b[0] = b_0, b[1] = b_1, ... +// Integer-Koeffizienten: Runde beim Auslesen der Koeffizienten: (int)round(a[i].real()) vector a = {0,0,0,0,1,2,3,4}, b = {0,0,0,0,2,3,0,1}; a = fft(a); b = fft(b); for (int i = 0; i < (int)a.size(); i++) a[i] *= b[i]; -- cgit v1.2.3