Skip to content

Commit f732a95

Browse files
leiosc252
authored andcommitted
using isapprox(a,b) function in julia instead of rolling our own (#612)
* using function in julia instead of rolling our own * fixing typo with iterative and recursive cooley tukey implementations
1 parent e348b15 commit f732a95

File tree

1 file changed

+6
-12
lines changed
  • contents/cooley_tukey/code/julia

1 file changed

+6
-12
lines changed

contents/cooley_tukey/code/julia/fft.jl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,17 @@ function butterfly(x)
110110
return y
111111
end
112112

113-
function approx(x, y)
114-
val = true
115-
for i = 1:length(x)
116-
if (abs(x[i]) - abs(y[i]) > 1e-5)
117-
val = false
118-
end
119-
end
120-
println(val)
121-
end
122-
123113
function main()
124114
x = rand(128)
125115
y = cooley_tukey(x)
126116
z = iterative_cooley_tukey(x)
127117
w = fft(x)
128-
approx(y, w)
129-
approx(z, w)
118+
if(isapprox(y, w))
119+
println("Recursive Cooley Tukey matches fft() from FFTW package.")
120+
end
121+
if(isapprox(z, w))
122+
println("Iterative Cooley Tukey matches fft() from FFTW package.")
123+
end
130124
end
131125

132126
main()

0 commit comments

Comments
 (0)