1
0
Fork 0

Incorporated comments on Week2

This commit is contained in:
Eric Teunis de Boone 2020-02-20 14:02:28 +01:00
parent 13a84ef642
commit f43a71745f

View file

@ -16,8 +16,7 @@ def DFT(yk):
N = np.size(yk) N = np.size(yk)
xk = 2*np.pi/N*np.arange(N) xk = 2*np.pi/N*np.arange(N)
# beta = np.zeros(N, dtype=np.complex128) beta = np.zeros(N, dtype=np.complex128)
beta = np.zeros(N, dtype=np.float64)
for j in range(N): for j in range(N):
beta[j] = np.dot(yk, np.exp(- 1j * j * xk )) beta[j] = np.dot(yk, np.exp(- 1j * j * xk ))
@ -46,7 +45,7 @@ def FFT(yk):
# Plotting functions # Plotting functions
def plot_DFTs(N = 128, fft1 = DFT, fft2 = np.fft.fft, funcs=[func1,func2]): def plot_DFTs(N = 128, fft1 = DFT, fft2 = np.fft.fft, datafuncs=[func1,func2]):
from matplotlib import pyplot from matplotlib import pyplot
j = np.arange(N) j = np.arange(N)
@ -101,6 +100,7 @@ def plot_FT_func_timing(func = DFT, M_max = 4, repeat = 10, number = 5, show = T
if __name__ == "__main__": if __name__ == "__main__":
plot_DFTs()
plot_DFTs(fft1=DFT,fft2=FFT) plot_DFTs(fft1=DFT,fft2=FFT)
plot_FT_func_timing(M_max = 9, func=FFT, show = False) # 12 takes 10 seconds, 13 takes 50 seconds plot_FT_func_timing(M_max = 9, func=FFT, show = False) # 12 takes 10 seconds, 13 takes 50 seconds