[Numpy-tickets] [NumPy] #748: Ifft pads incorrectly
NumPy
numpy-tickets@scipy....
Thu May 1 17:58:38 CDT 2008
#748: Ifft pads incorrectly
-----------------------+----------------------------------------------------
Reporter: stefan | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.1.0
Component: numpy.fft | Version: devel
Severity: major | Resolution:
Keywords: |
-----------------------+----------------------------------------------------
Comment (by charris):
When the input to the fft is complex and has high frequencies. The middle
padding is what you get when the upper half of the transform are aliases
of negative frequencies, i.e., you want low frequency interpolation. In
that case you should also split the value at the nyquist frequency and put
half at each end of the middle padding, using one less zero in the
padding. But what bugs me most is that the scaling is screwed up. If you
are padding for interpolation, then you should divide by the original
number of points, not the padded number of points. Note the factor of two
I had to insert below in the inverse fft.
Example of high frequency interpolation:
{{{
In [13]: x = exp(1j*pi*arange(8))
In [14]: xt = numpy.fft.fft(x)
In [15]: xi = numpy.fft.ifft(xt, n=16)*2
In [16]: xi
Out[16]:
array([ 1.00000000e+00 +0.00000000e+00j,
-6.45783293e-17 +1.00000000e+00j,
-1.00000000e+00 +1.22460635e-16j,
-2.41157599e-16 -1.00000000e+00j,
1.00000000e+00 -2.44921271e-16j,
2.81792654e-16 +1.00000000e+00j,
-1.00000000e+00 +3.67381906e-16j,
-4.28612224e-16 -1.00000000e+00j,
1.00000000e+00 -4.89842542e-16j,
5.75431794e-16 +1.00000000e+00j,
-1.00000000e+00 +6.12303177e-16j,
-6.16066849e-16 -1.00000000e+00j,
1.00000000e+00 -7.34763812e-16j,
9.21802777e-16 +1.00000000e+00j,
-1.00000000e+00 +8.57224448e-16j, -4.28612224e-16
-1.00000000e+00j])
In [17]: xtrue = exp(.5j*pi*arange(16))
In [18]: xtrue
Out[18]:
array([ 1.00000000e+00 +0.00000000e+00j,
6.12303177e-17 +1.00000000e+00j,
-1.00000000e+00 +1.22460635e-16j,
-1.83690953e-16 -1.00000000e+00j,
1.00000000e+00 -2.44921271e-16j,
3.06151588e-16 +1.00000000e+00j,
-1.00000000e+00 +3.67381906e-16j,
-4.28612224e-16 -1.00000000e+00j,
1.00000000e+00 -4.89842542e-16j,
5.51072859e-16 +1.00000000e+00j,
-1.00000000e+00 +6.12303177e-16j,
-2.44989033e-15 -1.00000000e+00j,
1.00000000e+00 -7.34763812e-16j,
-9.80362709e-16 +1.00000000e+00j,
-1.00000000e+00 +8.57224448e-16j, -2.69481160e-15
-1.00000000e+00j])
}}}
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/748#comment:3>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list