[Numpy-tickets] [NumPy] #748: Ifft pads incorrectly

NumPy numpy-tickets@scipy....
Sun Apr 20 08:23:24 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      |    Keywords:          
-----------------------+----------------------------------------------------
 Ifft should pad with zeros in the middle of the input, not at the end.

 {{{
 import numpy as np
 from matplotlib import pylab as pp
 from math import *

 def pad(x,n,centre=False):
     if not centre:
         return np.hstack((x,np.zeros(n)))
     else:
         return np.hstack((x[:len(x)/2],np.zeros(n),x[len(x)/2:]))

 p = pp.hamming(10)
 Fp = np.fft.fft(p,n=2**10)
 p1 = np.fft.ifft(Fp)
 p2=np.fft.ifft(Fp,n=2**12)
 p3=np.fft.ifft(pad(Fp, 2**12, centre=True))


 pp.subplot(311)
 pp.title('Input')
 pp.plot(p)

 pp.subplot(312)
 pp.title('ifft padding')
 pp.plot(p2[:45])

 pp.subplot(313)
 pp.title('Correct ifft padding')
 pp.plot(p3[:45])

 pp.show()
 }}}

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/748>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list