We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b9acf8c commit 84f7b3dCopy full SHA for 84f7b3d
contents/cooley_tukey/code/c++/fft.cpp
@@ -20,6 +20,19 @@ using std::size_t;
20
using complex = std::complex<double>;
21
static const double pi = 3.14159265358979323846264338327950288419716;
22
23
+template <typename Iter>
24
+void dft(Iter X, Iter last) {
25
+ const auto N = last - X;
26
+ std::vector<complex> tmp(N);
27
+ for (auto i = 0; i < N; ++i) {
28
+ for (auto j = 0; j < N; ++j) {
29
+ using namespace std::literals::complex_literals;
30
+ tmp[i] += X[j] * exp(-2.0 * M_PI * i * j / N * 1i);
31
+ }
32
33
+ std::copy(std::begin(tmp), std::end(tmp), X);
34
+}
35
+
36
// `cooley_tukey` does the cooley-tukey algorithm, recursively
37
template <typename Iter>
38
void cooley_tukey(Iter first, Iter last) {
0 commit comments