Here is the output of Numpy
np.fft.ifft([0, 4, 0, 0])
array([ 1.+0.j, 0.+1.j, -1.+0.j, 0.-1.j]) # may vary
Here is the output of Matlab
res = fft([0, 4, 0, 0])
res =
4.0000 + 0.0000i 0.0000 - 4.0000i -4.0000 + 0.0000i 0.0000 + 4.0000i
ifft(res)
ans =
0 4 0 0
What is the reason behind different outputs for composition of FFT & iFFT in Numpy and Matlab considering that both of them are used for scientific computation?
How to remedy the problem above in Numpy so I can get the expected result?(Same result as Matlab)
np.fft
does.np.fft
access thefft
class -- it does not perform a discreet fourier transform. I think you meant to trynp.fft.ifft(np.fft.fft([0, 4, 0, 0]))
$\endgroup$np.fft.fft
is doing. The first.fft
is accessing a set of instructions related to the FFT, including the forward FFT, the inverse FFT, and probably a bunch of other things if you read the documentation.np.fft.fft
is only calling the FFT once. $\endgroup$