weakutil.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:weakmon 作者: rtmrtmrtmrtm 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号