💬 例1:Discrete Fourier Transform
import numpy as np
def DFT(x): # 离散傅里叶变换
N = x.shape[0]
n = np.arange(N)
k = n.reshape((N, 1))
M = np.exp(-2j * np.pi * k * n / N)
return np.dot(M, x)
def IDFT(x): # 逆离散傅里叶变换
N = x.shape[0]
n = np.arange(N)
k = n.reshape((N, 1))
M = np.exp(2j * np.pi * k * n / N)/N
return np.dot(M, x)
d = np.array([1, 0, 2, 1])
F = DFT(d)
print('离散傅里叶变换: ', F)
D = IDFT(F)
print('逆离散傅里叶变换结果: ', D)
?🚩 运行结果:
离散傅里叶变换: ?[ 4.+0.0000000e+00j -1.+1.0000000e+00j ?2.+1.2246468e-16j ?-1.-1.0000000e+00j] 逆离散傅里叶变换结果: ?[ 1.00000000e+00-1.91428435e-16j -1.11022302e-16-1.02440519e-16j ? ? 2.00000000e+00+7.73141507e-18j ?1.00000000e+00+1.63672859e-16j]
参考文献
Introduction to Linear Algebra, International 4 th Edition by Gilbert Strang, Wellesley Cambridge Press.
百度百科[EB/OL]. []. https://baike.baidu.com/
本篇完。
|