[Scipy-tickets] [SciPy] #1353: scipy.fftpack.fft modifies the input vector if fftsize is less than vector size

SciPy Trac scipy-tickets@scipy....
Mon Jan 10 10:33:55 CST 2011


#1353: scipy.fftpack.fft modifies the input vector if fftsize is less than vector
size
---------------------------+------------------------------------------------
 Reporter:  promenade      |       Owner:  somebody
     Type:  defect         |      Status:  new     
 Priority:  normal         |   Milestone:  0.9.0   
Component:  scipy.fftpack  |     Version:  0.7.0   
 Keywords:  fft            |  
---------------------------+------------------------------------------------
 When I use scipy.fftpack.fft, if my fft size is smaller than the length on
 my input vector, the first fft size samples of the input vector are
 overwritten with the FFT results.  This is highly undesirable.  Setting
 'overwrite_x=False' does not make a difference.

 I am using Fedora 13-686, Python 2.6.4, scipy 0.7.1.



 Here's a script :
 ================================================================
 {{{
     import scipy.fftpack as FFT

     SNR= 0
     MSGLEN= 2**12
     FFTSIZE= 2**10

     fs= 100.e3
     fc= fs / 5.
     fshift= 2. * np.pi * fc / fs

     for FFTSIZE in [256,512,1024,2048,4096]:
         np.random.seed( 24681357 )
         xmitsig= np.exp( 1.j*fshift * np.arange(MSGLEN) )
         xpower= np.average( xmitsig * xmitsig.conj() ).real
         n1= np.random.normal( 0, np.sqrt(xpower/2.), MSGLEN )
         n2= np.random.normal( 0, np.sqrt(xpower/2.), MSGLEN )
         rcvrsig= xmitsig + ( n1 + 1.j*n2 )


         XMIT= FFT.fft( xmitsig, FFTSIZE, overwrite_x=False )
         RCVR= FFT.fft( rcvrsig, FFTSIZE, overwrite_x=False )

         cs= np.exp( 1.j*fshift * np.arange(MSGLEN) )
         x1= (xmitsig==cs).sum()
         x2= (XMIT==xmitsig[:FFTSIZE]).sum()
         r1= (rcvrsig==(cs+ ( n1 + 1.j*n2 ))).sum()
         r2= (RCVR==rcvrsig[:FFTSIZE]).sum()
         print '%4i: %4i %4i :: %4i %4i' % (FFTSIZE,x1,r1,x2,r2)
 }}}
 ================================================================

 My print out from running the script:
 {{{
  256: 3840 3840 ::  256  256
  512: 3584 3584 ::  512  512
 1024: 3072 3072 :: 1024 1024
 2048: 2048 2048 :: 2048 2048
 4096: 4096 4096 ::    0    0
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1353>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list