Skip to content Skip to sidebar Skip to footer

Scipy, Fftpack And Float64

I would like to use the dct functionality from the scipy.fftpack with an array of numpy float64. However, it seems it is only implemented for np.float32. Is there any quick workaro

Solution 1:

The problem is not the double precision. Double precision is of course supported. The problem is that you have a little endian computer and (maybe loading a file from a file?) have big endian data, note the > in dtype >f8 not supported. It seems you will simply have to cast it to native double yourself. If you know its double precision, you probably just want to convert everytiong to your native order once:

c = c.astype(float)

Though I guess you could also check c.dtype.byteorder which I think should be '=', and if, switch... something along:

if c.dtype.byteorder != '=':
    c = c.astype(c.dtype.newbyteorder('=')) 

Which should work also if you happen to have single precision or integers...

Post a Comment for "Scipy, Fftpack And Float64"