-
-
Save mikezink/290f7eeceeca3b80699667b24034917f to your computer and use it in GitHub Desktop.
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
import numpy as np | |
from timeit import Timer | |
pi2 = np.pi * 2 | |
def DFT(x): | |
N = len(x) | |
FmList = [] | |
for m in range(N): | |
Fm = 0.0 | |
for n in range(N): | |
Fm += x[n] * np.exp(- 1j * pi2 * m * n / N) | |
FmList.append(Fm / N) | |
return FmList | |
N = 1000 | |
x = np.arange(N) | |
t = Timer(lambda: DFT(x)) | |
print('Elapsed time: {} s'.format(str(t.timeit(number=1)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment