From 1fbb858f18de973b27abfc2dce88c6ba8fc1b971 Mon Sep 17 00:00:00 2001 From: leios Date: Fri, 14 Jun 2019 06:37:45 +0900 Subject: [PATCH 1/2] using function in julia instead of rolling our own --- contents/cooley_tukey/code/julia/fft.jl | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/contents/cooley_tukey/code/julia/fft.jl b/contents/cooley_tukey/code/julia/fft.jl index fe54d31df..572074836 100644 --- a/contents/cooley_tukey/code/julia/fft.jl +++ b/contents/cooley_tukey/code/julia/fft.jl @@ -110,23 +110,17 @@ function butterfly(x) return y end -function approx(x, y) - val = true - for i = 1:length(x) - if (abs(x[i]) - abs(y[i]) > 1e-5) - val = false - end - end - println(val) -end - function main() x = rand(128) y = cooley_tukey(x) z = iterative_cooley_tukey(x) w = fft(x) - approx(y, w) - approx(z, w) + if(isapprox(y, w)) + println("Recursive Cooley Tukey matches fft() from FFTW package.") + end + if(isapprox(z, w)) + println("Recursive Cooley Tukey matches fft() from FFTW package.") + end end main() From 037819f36e760616e80dc894b6a7b97f5d3a3682 Mon Sep 17 00:00:00 2001 From: leios Date: Fri, 14 Jun 2019 06:49:39 +0900 Subject: [PATCH 2/2] fixing typo with iterative and recursive cooley tukey implementations --- contents/cooley_tukey/code/julia/fft.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/cooley_tukey/code/julia/fft.jl b/contents/cooley_tukey/code/julia/fft.jl index 572074836..68a1103ce 100644 --- a/contents/cooley_tukey/code/julia/fft.jl +++ b/contents/cooley_tukey/code/julia/fft.jl @@ -119,7 +119,7 @@ function main() println("Recursive Cooley Tukey matches fft() from FFTW package.") end if(isapprox(z, w)) - println("Recursive Cooley Tukey matches fft() from FFTW package.") + println("Iterative Cooley Tukey matches fft() from FFTW package.") end end