Created
March 7, 2015 15:49
-
-
Save r9y9/3d67ba57ccd47c243133 to your computer and use it in GitHub Desktop.
DFT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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