

def tilbert(x, h, period=None, _cache=_cache):
    '\n    Return h-Tilbert transform of a periodic sequence x.\n\n    If x_j and y_j are Fourier coefficients of periodic functions x\n    and y, respectively, then::\n\n        y_j = sqrt(-1)*coth(j*h*2*pi/period) * x_j\n        y_0 = 0\n\n    Parameters\n    ----------\n    x : array_like\n        The input array to transform.\n    h : float\n        Defines the parameter of the Tilbert transform.\n    period : float, optional\n        The assumed period of the sequence.  Default period is ``2*pi``.\n\n    Returns\n    -------\n    tilbert : ndarray\n        The result of the transform.\n\n    Notes\n    -----\n    If ``sum(x, axis=0) == 0`` and ``n = len(x)`` is odd then\n    ``tilbert(itilbert(x)) == x``.\n\n    If ``2 * pi * h / period`` is approximately 10 or larger, then\n    numerically ``tilbert == hilbert``\n    (theoretically oo-Tilbert == Hilbert).\n\n    For even ``len(x)``, the Nyquist mode of ``x`` is taken zero.\n\n    '
    tmp = asarray(x)
    if iscomplexobj(tmp):
        return (tilbert(tmp.real, h, period) + (1j * tilbert(tmp.imag, h, period)))
    if (period is not None):
        h = (((h * 2) * pi) / period)
    n = len(x)
    omega = _cache.get((n, h))
    if (omega is None):
        if (len(_cache) > 20):
            while _cache:
                _cache.popitem()

        def kernel(k, h=h):
            if k:
                return (1.0 / tanh((h * k)))
            return 0
        omega = convolve.init_convolution_kernel(n, kernel, d=1)
        _cache[(n, h)] = omega
    overwrite_x = _datacopied(tmp, x)
    return convolve.convolve(tmp, omega, swap_real_imag=1, overwrite_x=overwrite_x)

dataset/ETHPy150Open scipy/scipy/scipy/fftpack/pseudo_diffs.py tilbert/original