在下面的程序中,我想計算由U給出的給定場的快速傅立葉變換。對於fft和fft2,返回值之間的差異是什麼?任何幫助,將不勝感激!謝謝。應用於矩陣的fft/fft2的返回值之間的區別是什麼?
import numpy as np
from numpy import sin, cos, pi
nx=3
ny=3
px=2*pi
py=2*pi
qx=1.0*px/(nx-1)
qy=1.0*py/(ny-1)
x = np.linspace(0,px,nx)
y = np.linspace(0,py,ny)
X,Y = np.meshgrid(x,y)
U=cos(X)*sin(Y)
#compite fft's
Uh1=np.fft.fft(U)
Uh2=np.fft.fft2(U)
print('For fft')
print(Uh1)
print('For fft2')
print(Uh2)
#What is the difference between Uh1 and Uh2? Thank you!
這裏是我所得到的:
For fft
[[ 0.00000000e+00 +0.00000000e+00j 0.00000000e+00 +0.00000000e+00j
0.00000000e+00 +0.00000000e+00j]
[ 1.22464680e-16 +0.00000000e+00j 1.22464680e-16 +2.12115048e-16j
1.22464680e-16 -2.12115048e-16j]
[ -2.44929360e-16 +0.00000000e+00j -2.44929360e-16 -4.24230095e-16j
-2.44929360e-16 +4.24230095e-16j]]
For fft2
[[ -1.22464680e-16 +0.00000000e+00j -1.22464680e-16 -2.12115048e-16j
-1.22464680e-16 +2.12115048e-16j]
[ 6.12323400e-17 -3.18172572e-16j 6.12323400e-16 -2.12115048e-16j
-4.89858720e-16 -4.24230095e-16j]
[ 6.12323400e-17 +3.18172572e-16j -4.89858720e-16 +4.24230095e-16j
6.12323400e-16 +2.12115048e-16j]]
謝謝!
有你看着這個值從每個返回? 'numpy'文檔? – jonrsharpe
@jonrsharpe是的。我查看了文檔,但我想知道這兩個函數的返回結果有什麼不同。 –
@jonrsharpe請問我剛剛添加了一些關於這個問題的細節!謝謝 –