o
    ְi                     @   s   d dl Z d dlZd dlmZ d dlmZ d dlmZ eddddZed	dd
dZeddddZ	eddddZ
eddddZeddddZeddddZeddddZejdd d!d"d#Zejd$d d%d&d#Zd+de j d(d)d*ZeZeZdS ),    N)_core)sumprod)ufuncsin   cupy_sinzDElementwise sine function.

    .. seealso:: :data:`numpy.sin`

    coscupy_coszFElementwise cosine function.

    .. seealso:: :data:`numpy.cos`

    tancupy_tanzGElementwise tangent function.

    .. seealso:: :data:`numpy.tan`

    asincupy_arcsinziElementwise inverse-sine function (a.k.a. arcsine function).

    .. seealso:: :data:`numpy.arcsin`

    acoscupy_arccoszmElementwise inverse-cosine function (a.k.a. arccosine function).

    .. seealso:: :data:`numpy.arccos`

    atancupy_arctanzoElementwise inverse-tangent function (a.k.a. arctangent function).

    .. seealso:: :data:`numpy.arctan`

    hypot   
cupy_hypotzComputes the hypoteneous of orthogonal vectors of given length.

    This is equivalent to ``sqrt(x1 **2 + x2 ** 2)``, while this function is
    more efficient.

    .. seealso:: :data:`numpy.hypot`

    atan2cupy_arctan2zeElementwise inverse-tangent of the ratio of two arrays.

    .. seealso:: :data:`numpy.arctan2`

    cupy_deg2rad)ze->ezf->fzd->dz$out0 = in0 * (out0_type)(M_PI / 180)zyConverts angles from degrees to radians elementwise.

    .. seealso:: :data:`numpy.deg2rad`, :data:`numpy.radians`

    )doccupy_rad2degz$out0 = in0 * (out0_type)(180 / M_PI)zyConverts angles from radians to degrees elementwise.

    .. seealso:: :data:`numpy.rad2deg`, :data:`numpy.degrees`

    )periodc                C   s  t | } | j}tj| |d}|du r|d }tddg| }tdd||< t|}t|j	|}t
|tjrDt|d\}}	|	dk}
n|d }d}
| }t || || }|
rgt j||||k|dk@ d || }t j|dt||k d t j| d|d}| | t j||d ||< |S )	a  Unwrap by taking the complement of large deltas w.r.t. the period.

    This unwraps a signal `p` by changing elements which have an absolute
    difference from their predecessor of more than ``max(discont, period/2)``
    to their `period`-complementary values.

    For the default case where `period` is :math:`2\pi` and is ``discont``
    is :math:`\pi`, this unwraps a radian phase `p` such that adjacent
    differences are never greater than :math:`\pi` by adding :math:`2k\pi`
    for some integer :math:`k`.

    Args:
        p (cupy.ndarray): Input array.
            discont (float): Maximum discontinuity between values, default is
            ``period/2``. Values below ``period/2`` are treated as if they were
            ``period/2``. To have an effect different from the default,
            ``discont`` should be larger than ``period/2``.
        axis (int): Axis along which unwrap will operate, default is the last
            axis.
        period: float, optional
            Size of the range over which the input wraps. By default, it is
            :math:`2\pi`.
    Returns:
        cupy.ndarray: The result array.

    .. seealso:: :func:`numpy.unwrap`
    )axisNr   r   r   T)where)copydtype)cupyasarrayndimr   diffslicetuplenumpyresult_typer   
issubdtypeintegerdivmodmodcopytoabsarraycumsum)pdiscontr   r   ndddslice1r   interval_highremboundary_ambiguousinterval_lowddmod
ph_correctup r<   L/home/ubuntu/.local/lib/python3.10/site-packages/cupy/_math/trigonometric.pyunwrapj   s2   

r>   )Nr   )r&   r    r   
cupy._mathr   r   create_math_ufuncr   r   r
   arcsinarccosarctanr   arctan2create_ufuncdeg2radrad2degpir>   degreesradiansr<   r<   r<   r=   <module>   sh    							8