Ejemplo n.º 1
0
    def test_invalid_sizes(self):
        with assert_raises(ValueError,
                           match="invalid number of data points"
                           r" \(\[1, 0\]\) specified"):
            ifftn([[]])

        with assert_raises(ValueError,
                           match="invalid number of data points"
                           r" \(\[4, -3\]\) specified"):
            ifftn([[1, 1], [2, 2]], (4, -3))
Ejemplo n.º 2
0
    def test_definition(self, dtype, cdtype, maxnlp):
        x = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=dtype)
        y = ifftn(x)
        assert_equal(y.dtype, cdtype)
        assert_array_almost_equal_nulp(y, direct_idftn(x), maxnlp)

        x = random((20, 26))
        assert_array_almost_equal_nulp(ifftn(x), direct_idftn(x), maxnlp)

        x = random((5, 4, 3, 20))
        assert_array_almost_equal_nulp(ifftn(x), direct_idftn(x), maxnlp)
Ejemplo n.º 3
0
def ifftn(x, shape=None, axes=None, overwrite_x=False):
    """
    Return inverse multidimensional discrete Fourier transform.

    The sequence can be of an arbitrary type.

    The returned array contains::

      y[j_1,..,j_d] = 1/p * sum[k_1=0..n_1-1, ..., k_d=0..n_d-1]
         x[k_1,..,k_d] * prod[i=1..d] exp(sqrt(-1)*2*pi/n_i * j_i * k_i)

    where ``d = len(x.shape)``, ``n = x.shape``, and ``p = prod[i=1..d] n_i``.

    For description of parameters see `fftn`.

    See Also
    --------
    fftn : for detailed information.

    Examples
    --------
    >>> from scipy.fftpack import fftn, ifftn
    >>> import numpy as np
    >>> y = (-np.arange(16), 8 - np.arange(16), np.arange(16))
    >>> np.allclose(y, ifftn(fftn(y)))
    True

    """
    shape = _good_shape(x, shape, axes)
    return _pocketfft.ifftn(x, shape, axes, None, overwrite_x)
Ejemplo n.º 4
0
 def test_no_axes(self):
     x = numpy.random.random((2, 2, 2))
     assert_allclose(ifftn(x, axes=[]), x, atol=1e-7)
Ejemplo n.º 5
0
 def test_random_complex(self, maxnlp, size):
     x = random([size, size]) + 1j * random([size, size])
     assert_array_almost_equal_nulp(ifftn(fftn(x)), x, maxnlp)
     assert_array_almost_equal_nulp(fftn(ifftn(x)), x, maxnlp)