Skip to content
Prev Previous commit
Next Next commit
Updating cooley-tukey.md and small changes to fft.c
  • Loading branch information
Gathros committed May 13, 2018
commit 9d04116d88483d65328d45f382760f3f2a2b42c6
6 changes: 2 additions & 4 deletions chapters/FFT/code/c/fft.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
void dft(double complex *X, const size_t N) {
double complex tmp[N];
for (size_t i = 0; i < N; ++i) {
double complex sum = 0 + 0 * I;
tmp[i] = 0;
for (size_t j = 0; j < N; ++j) {
sum += X[j] * cexp(-2.0 * PI * I * j * i / N);
tmp[i] += X[j] * cexp(-2.0 * PI * I * j * i / N);
}

tmp[i] = sum;
}

for (size_t i = 0; i < N; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a memcpy

Expand Down
4 changes: 2 additions & 2 deletions chapters/FFT/cooley_tukey.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ For some reason, though, putting code to this transformation really helped me fi
{% sample lang="jl" %}
[import:2-11, lang:"julia"](code/julia/fft.jl)
{% sample lang="c" %}
[import:2-11, lang:"julia"](code/julia/fft.jl)
[import:9-21, lang:"c_cpp"](code/c/fft.c)
{% sample lang="cpp" %}
[import:2-11, lang:"julia"](code/julia/fft.jl)
{% sample lang="hs" %}
Expand Down Expand Up @@ -117,7 +117,7 @@ In the end, the code looks like:
{% sample lang="jl" %}
[import:14-31, lang:"julia"](code/julia/fft.jl)
{% sample lang="c" %}
[import:9-28, lang:"c_cpp"](code/c/fft.c)
[import:23-42, lang:"c_cpp"](code/c/fft.c)
{% sample lang="cpp" %}
[import:27-57, lang:"c_cpp"](code/c++/fft.cpp)
{% sample lang="hs" %}
Expand Down