[SciPy-user] FFTs broken on Mac OSX
Rob Managan
managan at llnl.gov
Wed Dec 7 13:14:07 EST 2005
I can't get rid of errors in the fftpack stuff in the new scipy. When
I installed fftw2.1.5 I did a make check and it said it all was fine.
This is on Mac OSX 10.3.9
Here is a test script based on the first failure I get in scipy.test()
The k=1 case is OK, the k=2 case gives effectively zeros and should
be a -1*sine curve if I understand this properly.
******
from scipy.fftpack import diff,fft,ifft
from scipy.fftpack import fftfreq
import scipy.base as Numeric
from scipy.base import arange, add, array, sin, cos, pi,exp,tanh,sum
def direct_diff(x,k=1,period=None):
print 'x',x
fx = fft(x)
print ' '
print 'fx', fx
n = len (fx)
print 'n',n
if period is None:
period = 2*pi
print 'fftfreq',fftfreq(n)
w = fftfreq(n)*2j*pi/period*n
print 'k, w', k,w
if k<0:
w = 1 / w**k
w[0] = 0.0
else:
w = w**k
print 'w', w
if n>2000:
w[250:n-250] = 0.0
print "result",ifft(w*fx)
return ifft(w*fx).real
def check_definition():
n=16
x = arange(n)*2*pi/n
print ' k= 1 test '
aaaaa = direct_diff(sin(x),1)
print ' k= 2 test '
aaaaa = direct_diff(sin(x),2)
check_definition()
***
OUTPUT
k= 1 test
x [ 0.00000000e+00 3.82683432e-01 7.07106781e-01 9.23879533e-01
1.00000000e+00 9.23879533e-01 7.07106781e-01 3.82683432e-01
1.22464680e-16 -3.82683432e-01 -7.07106781e-01 -9.23879533e-01
-1.00000000e+00 -9.23879533e-01 -7.07106781e-01 -3.82683432e-01]
fx [ 1.77975831e-16 +0.00000000e+00j -1.35945820e-15 -8.00000000e+00j
-3.87815369e-16 -8.43346956e-16j 5.48376387e-17 -5.45964141e-16j
1.14423775e-17 -4.99600361e-16j 4.98926849e-16 -5.45964141e-16j
6.32744729e-16 -1.77213142e-16j 3.15834992e-16 +0.00000000e+00j
2.88998134e-16 +0.00000000e+00j 3.15834992e-16 -0.00000000e+00j
6.32744729e-16 +1.77213142e-16j 4.98926849e-16 +5.45964141e-16j
1.14423775e-17 +4.99600361e-16j 5.48376387e-17 +5.45964141e-16j
-3.87815369e-16 +8.43346956e-16j -1.35945820e-15 +8.00000000e+00j]
n 16
fftfreq [ 0. 0.0625 0.125 0.1875 0.25 0.3125 0.375 0.4375 -0.5
-0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625]
k, w 1 [ 0.+0.j 0.+1.j 0.+2.j 0.+3.j 0.+4.j 0.+5.j 0.+6.j 0.+7.j 0.-8.j
0.-7.j 0.-6.j 0.-5.j 0.-4.j 0.-3.j 0.-2.j 0.-1.j]
w [ 0.00000000e+00+0.j 6.12323400e-17+1.j 1.22464680e-16+2.j
1.83697020e-16+3.j 2.44929360e-16+4.j 3.06161700e-16+5.j
3.67394040e-16+6.j 4.28626380e-16+7.j 4.89858720e-16-8.j
4.28626380e-16-7.j 3.67394040e-16-6.j 3.06161700e-16-5.j
2.44929360e-16-4.j 1.83697020e-16-3.j 1.22464680e-16-2.j
6.12323400e-17-1.j]
result [ 1.00000000e+00 +0.00000000e+00j 9.23879533e-01 -2.77555756e-17j
7.07106781e-01 +0.00000000e+00j 3.82683432e-01 +5.26704453e-33j
-9.39464148e-17 -0.00000000e+00j -3.82683432e-01 -5.26704453e-33j
-7.07106781e-01 -0.00000000e+00j -9.23879533e-01 -2.77555756e-17j
-1.00000000e+00 +0.00000000e+00j -9.23879533e-01 +2.77555756e-17j
-7.07106781e-01 +0.00000000e+00j -3.82683432e-01 +5.26704453e-33j
-9.39464148e-17 +0.00000000e+00j 3.82683432e-01 -5.26704453e-33j
7.07106781e-01 -0.00000000e+00j 9.23879533e-01 +2.77555756e-17j]
k= 2 test
x [ 0.00000000e+00 3.82683432e-01 7.07106781e-01 9.23879533e-01
1.00000000e+00 9.23879533e-01 7.07106781e-01 3.82683432e-01
1.22464680e-16 -3.82683432e-01 -7.07106781e-01 -9.23879533e-01
-1.00000000e+00 -9.23879533e-01 -7.07106781e-01 -3.82683432e-01]
fx [ 1.77975831e-16 +0.00000000e+00j -1.35945820e-15 -8.00000000e+00j
-3.87815369e-16 -8.43346956e-16j 5.48376387e-17 -5.45964141e-16j
1.14423775e-17 -4.99600361e-16j 4.98926849e-16 -5.45964141e-16j
6.32744729e-16 -1.77213142e-16j 3.15834992e-16 +0.00000000e+00j
2.88998134e-16 +0.00000000e+00j 3.15834992e-16 -0.00000000e+00j
6.32744729e-16 +1.77213142e-16j 4.98926849e-16 +5.45964141e-16j
1.14423775e-17 +4.99600361e-16j 5.48376387e-17 +5.45964141e-16j
-3.87815369e-16 +8.43346956e-16j -1.35945820e-15 +8.00000000e+00j]
n 16
fftfreq [ 0. 0.0625 0.125 0.1875 0.25 0.3125 0.375 0.4375 -0.5
-0.4375 -0.375 -0.3125 -0.25 -0.1875 -0.125 -0.0625]
k, w 2 [ 0.+0.j 0.+1.j 0.+2.j 0.+3.j 0.+4.j 0.+5.j 0.+6.j 0.+7.j 0.-8.j
0.-7.j 0.-6.j 0.-5.j 0.-4.j 0.-3.j 0.-2.j 0.-1.j]
w [ 0. +0.00000000e+00j -1. +1.22464680e-16j -4. +4.89858720e-16j
-9. +1.10218212e-15j -16. +1.95943488e-15j -25. +3.06161700e-15j
-36. +4.40872848e-15j -49. +6.00076932e-15j -64. -7.83773951e-15j
-49. -6.00076932e-15j -36. -4.40872848e-15j -25. -3.06161700e-15j
-16. -1.95943488e-15j -9. -1.10218212e-15j -4. -4.89858720e-16j
-1. -1.22464680e-16j]
result [ -7.09525200e-15 +0.00000000e+00j 5.93691289e-15 -1.64869810e-32j
-1.14813636e-15 +0.00000000e+00j -1.52577697e-15 +1.31424439e-31j
1.47456631e-15 -0.00000000e+00j -4.63227633e-16 -1.31424439e-31j
-1.11807920e-15 -0.00000000e+00j 6.76061857e-16 -2.79335858e-31j
-5.69389769e-16 +0.00000000e+00j 6.76061857e-16 +2.79335858e-31j
-1.11807920e-15 +0.00000000e+00j -4.63227633e-16 +1.31424439e-31j
1.47456631e-15 +0.00000000e+00j -1.52577697e-15 -1.31424439e-31j
-1.14813636e-15 -0.00000000e+00j 5.93691289e-15 +1.64869810e-32j]
--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Rob Managan email managan at llnl.gov
LLNL phone: 925-423-0903
P.O. Box 808, L-095 FAX: 925-422-3389
Livermore, CA 94551-0808
More information about the SciPy-User
mailing list