summaryrefslogtreecommitdiff
path: root/math/fft.cpp
diff options
context:
space:
mode:
authorPaul Jungeblut <paul.jungeblut@gmail.com>2016-09-28 11:28:13 +0200
committerPaul Jungeblut <paul.jungeblut@gmail.com>2016-09-28 11:28:13 +0200
commitd121bf3764d169b296f3101e54feaaf83f8169be (patch)
tree0a463617ca0c289d6626af71659068a4bbd1197e /math/fft.cpp
parent7aa35de0f04d0b1c5b9bcc52cd47fb6787490500 (diff)
Improve usability FFT code.
Diffstat (limited to 'math/fft.cpp')
-rw-r--r--math/fft.cpp6
1 files changed, 3 insertions, 3 deletions
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<double> cplx; // Eigene Implementierung ist noch deutlich schneller.
-// s.size() muss eine Zweierpotenz sein!
-vector<cplx> fft(const vector<cplx> &a, bool inverse = 0) {
+vector<cplx> fft(const vector<cplx> &a, bool inverse = 0) { // a.size() muss eine Zweierpotenz sein!
int logn = 1, n = a.size();
vector<cplx> A(n);
while ((1 << logn) < n) logn++;
@@ -27,7 +26,8 @@ vector<cplx> fft(const vector<cplx> &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<cplx> 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];