o
    W۷i                     @  s   d dl mZ d dlZd dlZd dlmZ ejdddddZejdd	d
ddZdd Zdd Z	ejdddddZ
dd ZejdddddZdd Zejdd	dddZdd ZdS )    )annotationsN)_corezfloat32 alphazfloat64 outzH
    out = 0.42 - 0.5 * cos(i * alpha) + 0.08 * cos(2 * alpha * i);
    cupy_blackman)namezT arrzY
    if (i < alpha)
        arr = i / alpha;
    else
        arr = 2.0 - i / alpha;
    cupy_bartlettc                 C  sP   | dkrt jdt jdS | dkrt g S | d d }t j| t jd}t||S )a  Returns the Bartlett window.

    The Bartlett window is defined as

    .. math::
            w(n) = \frac{2}{M-1} \left(
            \frac{M-1}{2} - \left|n - \frac{M-1}{2}\right|
            \right)

    Args:
        M (int):
            Number of points in the output window. If zero or less, an empty
            array is returned.

    Returns:
        ~cupy.ndarray: Output ndarray.

    .. seealso:: :func:`numpy.bartlett`
       dtyper          @)cupyonesfloat64arrayempty_bartlett_kernelMalphaout r   G/home/ubuntu/vllm_env/lib/python3.10/site-packages/cupy/_math/window.pybartlett   s   

r   c                 C  V   | dkrt jdt jdS | dkrt g S tjd | d  }t j| t jd}t||S )a  Returns the Blackman window.

    The Blackman window is defined as

    .. math::
        w(n) = 0.42 - 0.5 \cos\left(\frac{2\pi{n}}{M-1}\right)
        + 0.08 \cos\left(\frac{4\pi{n}}{M-1}\right)
        \qquad 0 \leq n \leq M-1

    Args:
        M (:class:`~int`):
            Number of points in the output window. If zero or less, an empty
            array is returned.

    Returns:
        ~cupy.ndarray: Output ndarray.

    .. seealso:: :func:`numpy.blackman`
    r   r   r      )r   r   r   r   numpypir   _blackman_kernelr   r   r   r   blackman8   s   

r   z-
    out = 0.54 - 0.46 * cos(i * alpha);
    cupy_hammingc                 C  r   )a  Returns the Hamming window.

    The Hamming window is defined as

    .. math::
        w(n) = 0.54 - 0.46\cos\left(\frac{2\pi{n}}{M-1}\right)
        \qquad 0 \leq n \leq M-1

    Args:
        M (:class:`~int`):
            Number of points in the output window. If zero or less, an empty
            array is returned.

    Returns:
        ~cupy.ndarray: Output ndarray.

    .. seealso:: :func:`numpy.hamming`
    r   r   r   r   )r   r   r   r   r   r   r   _hamming_kernelr   r   r   r   hamming]      

r    z+
    out = 0.5 - 0.5 * cos(i * alpha);
    cupy_hanningc                 C  r   )a  Returns the Hanning window.

    The Hanning window is defined as

    .. math::
        w(n) = 0.5 - 0.5\cos\left(\frac{2\pi{n}}{M-1}\right)
        \qquad 0 \leq n \leq M-1

    Args:
        M (:class:`~int`):
            Number of points in the output window. If zero or less, an empty
            array is returned.

    Returns:
        ~cupy.ndarray: Output ndarray.

    .. seealso:: :func:`numpy.hanning`
    r   r   r   r   )r   r   r   r   r   r   r   _hanning_kernelr   r   r   r   hanning   r!   r$   zfloat32 beta, float32 alphaz
    float temp = (i - alpha) / alpha;
    arr = cyl_bessel_i0(beta * sqrt(1 - (temp * temp)));
    arr /= cyl_bessel_i0(beta);
    cupy_kaiserc                 C  sN   | dkr
t dgS | dkrt g S | d d }t j| t jd}t|||S )a  Return the Kaiser window.
    The Kaiser window is a taper formed by using a Bessel function.

    .. math::  w(n) = I_0\left( \beta \sqrt{1-\frac{4n^2}{(M-1)^2}}
               \right)/I_0(\beta)

    with

    .. math:: \quad -\frac{M-1}{2} \leq n \leq \frac{M-1}{2}

    where :math:`I_0` is the modified zeroth-order Bessel function.

     Args:
        M (int):
            Number of points in the output window. If zero or less, an empty
            array is returned.
        beta (float):
            Shape parameter for window

    Returns:
        ~cupy.ndarray:  The window, with the maximum value normalized to one
        (the value one appears only if the number of samples is odd).

    .. seealso:: :func:`numpy.kaiser`
    r   g      ?r   r
   r   )r   r   r   r   _kaiser_kernel)r   betar   r   r   r   r   kaiser   s   
r(   )
__future__r   r   r   r   ElementwiseKernelr   r   r   r   r   r    r#   r$   r&   r(   r   r   r   r   <module>   sN    
