def arfft(x):
if use_numpy_arfft:
y = numpy.fft.rfft(x)
y = abs(y)
return y
else:
assert (len(x) % 2) == 0
y = scipy.fftpack.rfft(x)
if type(y[0]) == numpy.float32:
cty = numpy.complex64
elif type(y[0]) == numpy.float64:
cty = numpy.complex128
else:
assert False
# y = [ Re0, Re1, Im1, Re2, Im2, ..., ReN ]
#y1 = numpy.sqrt(numpy.add(numpy.square(y[1:-1:2]),
# numpy.square(y[2:-1:2])))
y0 = abs(y[0])
yn = abs(y[-1])
y = abs(y[1:-1].view(cty))
y = numpy.concatenate(([y0], y, [yn]))
return y
评论列表
文章目录