Anonymous user
Fast Fourier transform: Difference between revisions
→{{header|Haskell}}
(→{{header|ALGOL 68}}: replace array SLICE operator with array DICE operator... simpler.) |
|||
Line 360:
=={{header|Haskell}}==
<lang haskell>import
-- Cooley-Tukey
Line 369 ⟶ 367:
fft xs = zipWith (+) ys ts ++ zipWith (-) ys ts
where n = length xs
split [x] = ([x], [])
split (x:y:xs) = (x:xt, y:yt) where (xt, yt) = split xs
ts = zipWith (\z k -> exp' k n * z) zs [0..]
exp' k n = cis $ -2 * pi * (fromIntegral k) / (fromIntegral n)
▲ do let res = fft [1,1,1,1,0,0,0,0]
And the output:
|