Skip to content

Commit 9d04116

Browse files
committed
Updating cooley-tukey.md and small changes to fft.c
1 parent 69571a8 commit 9d04116

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

chapters/FFT/code/c/fft.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
void dft(double complex *X, const size_t N) {
1010
double complex tmp[N];
1111
for (size_t i = 0; i < N; ++i) {
12-
double complex sum = 0 + 0 * I;
12+
tmp[i] = 0;
1313
for (size_t j = 0; j < N; ++j) {
14-
sum += X[j] * cexp(-2.0 * PI * I * j * i / N);
14+
tmp[i] += X[j] * cexp(-2.0 * PI * I * j * i / N);
1515
}
16-
17-
tmp[i] = sum;
1816
}
1917

2018
for (size_t i = 0; i < N; ++i) {

chapters/FFT/cooley_tukey.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ For some reason, though, putting code to this transformation really helped me fi
7272
{% sample lang="jl" %}
7373
[import:2-11, lang:"julia"](code/julia/fft.jl)
7474
{% sample lang="c" %}
75-
[import:2-11, lang:"julia"](code/julia/fft.jl)
75+
[import:9-21, lang:"c_cpp"](code/c/fft.c)
7676
{% sample lang="cpp" %}
7777
[import:2-11, lang:"julia"](code/julia/fft.jl)
7878
{% sample lang="hs" %}
@@ -117,7 +117,7 @@ In the end, the code looks like:
117117
{% sample lang="jl" %}
118118
[import:14-31, lang:"julia"](code/julia/fft.jl)
119119
{% sample lang="c" %}
120-
[import:9-28, lang:"c_cpp"](code/c/fft.c)
120+
[import:23-42, lang:"c_cpp"](code/c/fft.c)
121121
{% sample lang="cpp" %}
122122
[import:27-57, lang:"c_cpp"](code/c++/fft.cpp)
123123
{% sample lang="hs" %}

0 commit comments

Comments
 (0)