Skip to content

Instantly share code, notes, and snippets.

@r9y9
Created March 7, 2015 15:49
Show Gist options
  • Save r9y9/3d67ba57ccd47c243133 to your computer and use it in GitHub Desktop.
Save r9y9/3d67ba57ccd47c243133 to your computer and use it in GitHub Desktop.
DFT
function dft{T}(x::Vector{T})
N = length(x)
X = Array(Complex{T}, N)
for k = 1:N
s = 0.0 + 0.0im
for n = 1:N
s += x[n] * exp(2π * (-im) * k * n / N)
end
X[k] = s
end
X ./= N
X
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment