Esempio n. 1
0
def test_unnormalized_1D():
    x = np.random.randn(128) + 1j * np.random.randn(128)
    z = _fftn(x, axes=(0, ), shift=0, inplace=False)
    x2 = _ifftn(z, axes=(0, ), shift=0, inplace=False, normalize=False)
    yield npt.assert_almost_equal(np.linalg.norm(x2),
                                  np.linalg.norm(x) * len(x))
    z = _fftn(x, axes=(0, ), shift=1, inplace=False, normalize=False)
    x2 = _ifftn(z, axes=(0, ), shift=1, inplace=False, normalize=False)
    yield npt.assert_almost_equal(np.linalg.norm(x2),
                                  np.linalg.norm(x) * len(x))
Esempio n. 2
0
def test_unnormalized_1D():
    x = np.random.randn(128) + 1j*np.random.randn(128)
    z = _fftn(x, axes=(0,), shift=0, inplace=False)
    x2 = _ifftn(z, axes=(0,), shift=0, inplace=False, normalize=False)
    yield npt.assert_almost_equal(
        np.linalg.norm(x2), np.linalg.norm(x)*len(x)
        )
    z = _fftn(x, axes=(0,), shift=1, inplace=False, normalize=False)
    x2 = _ifftn(z, axes=(0,), shift=1, inplace=False, normalize=False)
    yield npt.assert_almost_equal(
        np.linalg.norm(x2), np.linalg.norm(x)*len(x)
        )
Esempio n. 3
0
def test_roundtrip_inplace_1_D():
    shift = 1
    dt = 'D'
    grid = np.arange(128)
    mu = 43.
    stdv = 3.
    g = (np.exp(-(grid - mu)**2 / (2 * stdv**2)) /
         (2 * np.pi * stdv**2)).astype(dt)
    g2 = g.copy()
    g_bkp = g.copy()
    _fftn(g, inplace=True, shift=shift)
    gw_np = reference_fftn(g2, shift=shift, axes=(0, ))
    yield npt.assert_array_almost_equal(
        g, gw_np, err_msg='differs from numpy fft ref, shift=%d' % shift)
    yield sum_of_sqr_comp(g, gw_np)

    _ifftn(g, inplace=True, shift=shift)
    yield npt.assert_array_almost_equal(
        g_bkp, g, err_msg='roundtrip transforms diverge, shift=%d' % shift)
    yield sum_of_sqr_comp(g_bkp, g)
Esempio n. 4
0
def test_roundtrip_inplace_1_D():
    shift = 1
    dt = 'D'
    grid = np.arange(128)
    mu = 43.
    stdv = 3.
    g = (np.exp(-(grid-mu)**2 / (2*stdv**2)) / (2*np.pi*stdv**2)).astype(dt)
    g2 = g.copy()
    g_bkp = g.copy()
    _fftn(g, inplace=True, shift=shift)
    gw_np = reference_fftn(g2, shift=shift, axes=(0,))
    yield npt.assert_array_almost_equal(
        g, gw_np, err_msg='differs from numpy fft ref, shift=%d'%shift
        )
    yield sum_of_sqr_comp(g, gw_np)

    _ifftn(g, inplace=True, shift=shift)
    yield npt.assert_array_almost_equal(
        g_bkp, g, err_msg='roundtrip transforms diverge, shift=%d'%shift
        )
    yield sum_of_sqr_comp(g_bkp, g)