Example #1
0
    def check_djbfft(self):
        from numpy.fft import ifft as numpy_ifft

        for i in range(2, 14):
            n = 2 ** i
            x = range(n)
            x1 = zeros((n,), dtype=cdouble)
            x1[0] = x[0]
            for k in range(1, n / 2):
                x1[k] = x[2 * k - 1] + 1j * x[2 * k]
                x1[n - k] = x[2 * k - 1] - 1j * x[2 * k]
            x1[n / 2] = x[-1]
            y1 = numpy_ifft(x1)
            y = fftpack.drfft(x, direction=-1)
            assert_array_almost_equal(y, y1)
Example #2
0
    def check_djbfft(self):
        from numpy.fft import fft as numpy_fft

        for i in range(2, 14):
            n = 2 ** i
            x = range(n)
            y2 = numpy_fft(x)
            y1 = zeros((n,), dtype=double)
            y1[0] = y2[0].real
            y1[-1] = y2[n / 2].real
            for k in range(1, n / 2):
                y1[2 * k - 1] = y2[k].real
                y1[2 * k] = y2[k].imag
            y = fftpack.drfft(x)
            assert_array_almost_equal(y, y1)