
    `i%                         d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 ej
                            dddd	          ZddZddZddZddZddZddZddZd ZddZddZdS )    N)_routines_logic)_fusion_thread_local)search)_utilzraw T X, int64 lenzbool zzBz = (i == 0 || X[i] != X[i-1]) && (i == len - 1 || X[i] != X[i+1])setxorkernelFc                     t          j                    r3|rt          d          t          j        t          j        | ||          S t          j        | d           |                     |||          S )a#  Tests whether all array elements along a given axis evaluate to True.

    Parameters
    ----------
    a : cupy.ndarray
        Input array.
    axis : int or tuple of ints
        Along which axis to compute all.
        The flattened array is used by default.
    out : cupy.ndarray
        Output array.
    keepdims : bool
        If ``True``, the axis is remained as an axis of size one.

    Returns
    -------
    y : cupy.ndarray
        An array reduced of the input array along the axis.

    See Also
    --------
    numpy.all

    z3cupy.all does not support `keepdims` in fusion yet.axisoutaarg_namer
   r   keepdims)r   	is_fusingNotImplementedErrorcall_reduction_logicallr   check_arrayr   r
   r   r   s       e/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupy/_logic/truth.pyr   r          2 %'' / 	G%EG G G#2J#/ / / 	/ 
a#&&&&55dh5777    c                     t          j                    r3|rt          d          t          j        t          j        | ||          S t          j        | d           |                     |||          S )a#  Tests whether any array elements along a given axis evaluate to True.

    Parameters
    ----------
    a : cupy.ndarray
        Input array.
    axis : int or tuple of ints
        Along which axis to compute all.
        The flattened array is used by default.
    out : cupy.ndarray
        Output array.
    keepdims : bool
        If ``True``, the axis is remained as an axis of size one.

    Returns
    -------
    y : cupy.ndarray
        An array reduced of the input array along the axis.

    See Also
    --------
    numpy.any

    z3cupy.any does not support `keepdims` in fusion yet.r	   r   r   r   )r   r   r   r   r   anyr   r   r   s       r   r   r   7   r   r   c                 v   |                                  } |                                 }| j        dk    s|j        dk    rL|r%t          j        | j        t          j                  S t          j        | j        t          j                  S t          j        |          }t          j	        | ||j        |          S )a  Tests whether each element of a 1-D array is also present in a second
    array.

    Returns a boolean array the same length as ``ar1`` that is ``True``
    where an element of ``ar1`` is in ``ar2`` and ``False`` otherwise.

    Parameters
    ----------
    ar1 : cupy.ndarray
        Input array.
    ar2 : cupy.ndarray
        The values against which to test each value of ``ar1``.
    assume_unique : bool, optional
        Ignored
    invert : bool, optional
        If ``True``, the values in the returned array
        are inverted (that is, ``False`` where an element of ``ar1`` is in
        ``ar2`` and ``True`` otherwise). Default is ``False``.

    Returns
    -------
    y : cupy.ndarray, bool
        The values ``ar1[in1d]`` are in ``ar2``.

    r   dtype)
ravelsizecupyonesshapebool_zerossort_search_exists_kernel)ar1ar2assume_uniqueinverts       r   in1dr.   \   s    6 ))++C
))++C
x1}}A 	;9SYdj9999:citz:::: )C..C!#sCHf===r   c                    |s^|r3t          j        | d          \  } }t          j        |d          \  }}nQt          j        |           } t          j        |          }n(|                                 } |                                }|s$t          j        | ||j        d          }| |         S t          j        | ||j        d          \  }}| |         }t          j        |          }	||         }
|s||	         }	||
         }
||	|
fS )ao  Find the intersection of two arrays.
    Returns the sorted, unique values that are in both of the input arrays.

    Parameters
    ----------
    arr1, arr2 : cupy.ndarray
        Input arrays. Arrays will be flattened if they are not in 1D.
    assume_unique : bool
        By default, False. If set True, the input arrays will be
        assumed to be unique, which speeds up the calculation. If set True,
        but the arrays are not unique, incorrect results and out-of-bounds
        indices could result.
    return_indices : bool
       By default, False. If True, the indices which correspond to the
       intersection of the two arrays are returned.

    Returns
    -------
    intersect1d : cupy.ndarray
        Sorted 1D array of common and unique elements.
    comm1 : cupy.ndarray
        The indices of the first occurrences of the common values
        in `arr1`. Only provided if `return_indices` is True.
    comm2 : cupy.ndarray
        The indices of the first occurrences of the common values
        in `arr2`. Only provided if `return_indices` is True.

    See Also
    --------
    numpy.intersect1d

    T)return_indexF)r"   uniquer    r(   r)   r!   _exists_and_searchsorted_kernelflatnonzero)arr1arr2r,   return_indicesind1ind2maskv1int1darr1_indicesarr2_indicess              r   intersect1dr>      s   B  	 	%T===JD$T===JD$$;t$$D;t$$DDzz||zz|| %dD$)UCCDz6dDIu& &HD"JE#D))Ld8L *L)L),,,r   c                 X    t          | |||                              | j                  S )a  Calculates element in ``test_elements``, broadcasting over ``element``
    only. Returns a boolean array of the same shape as ``element`` that is
    ``True`` where an element of ``element`` is in ``test_elements`` and
    ``False`` otherwise.

    Parameters
    ----------
    element : cupy.ndarray
        Input array.
    test_elements : cupy.ndarray
        The values against which to test each
        value of ``element``. This argument is flattened if it is an
        array or array_like.
    assume_unique : bool, optional
        Ignored
    invert : bool, optional
        If ``True``, the values in the returned array
        are inverted, as if calculating element not in ``test_elements``.
        Default is ``False``.

    Returns
    -------
    y : cupy.ndarray, bool
        Has the same shape as ``element``. The values ``element[isin]``
        are in ``test_elements``.

    r,   r-   )r.   reshaper$   )elementtest_elementsr,   r-   s       r   isinrD      s3    8 m  &ww}556r   c                     |rt          j        |           } n(t          j        |           } t          j        |          }| t          | |dd                   S )a  Find the set difference of two arrays. It returns unique
    values in `ar1` that are not in `ar2`.

    Parameters
    ----------
    ar1 : cupy.ndarray
        Input array
    ar2 : cupy.ndarray
        Input array for comparison
    assume_unique : bool
        By default, False, i.e. input arrays are not unique.
        If True, input arrays are assumed to be unique. This can
        speed up the calculation.

    Returns
    -------
    setdiff1d : cupy.ndarray
        Returns a 1D array of values in `ar1` that are not in `ar2`.
        It always returns a sorted output for unsorted input only
        if `assume_unique=False`.

    See Also
    --------
    numpy.setdiff1d

    Tr@   )r"   r    r1   r.   )r*   r+   r,   s      r   	setdiff1drF      sU    6  jook#k#tCD>>>??r   c           	      F   |s(t          j        |           } t          j        |          }t          j        | |fd          }|j        dk    r|S |                                 |t          ||j        t          j        |j        t           j                                     S )a1  Find the set exclusive-or of two arrays.

    Parameters
    ----------
    ar1, ar2 : cupy.ndarray
        Input arrays. They are flattened if they are not already 1-D.
    assume_unique : bool
        By default, False, i.e. input arrays are not unique.
        If True, input arrays are assumed to be unique. This can
        speed up the calculation.

    Returns
    -------
    setxor1d : cupy.ndarray
        Return the sorted, unique values that are in only one
        (not both) of the input arrays.

    See Also
    --------
    numpy.setxor1d

    Nr
   r   r   )r"   r1   concatenater!   r'   _setxorkernelr&   r%   )r*   r+   r,   auxs       r   setxor1drL     s    .  k#k#

C:D
1
1
1C
x1}}
HHJJJ}S#(!Z
CCCE E F Fr   c                 V    t          j        t          j        | |fd                    S )a  Find the union of two arrays.

    Returns the unique, sorted array of values that are in either of
    the two input arrays.

    Parameters
    ----------
    arr1, arr2 : cupy.ndarray
        Input arrays. They are flattened if they are not already 1-D.

    Returns
    -------
    union1d : cupy.ndarray
        Sorted union of the input arrays.

    See Also
    --------
    numpy.union1d

    NrH   )r"   r1   rI   )r4   r5   s     r   union1drN   )  s(    * ;t't4@@@AAAr   c                 Z    t          j        dt                     t          | |||          S )NzPlease use `all` instead.)warningswarnDeprecationWarningr   r   s       r   alltruerS   A  *    M-/ABBBq$X&&&r   c                 Z    t          j        dt                     t          | |||          S )NzPlease use `any` instead.)rP   rQ   rR   r   r   s       r   sometruerV   F  rT   r   )NNF)FF)F)rP   r"   
cupy._corer   r   r   cupy._sortingr   r(   r   _coreElementwiseKernelrJ   r   r   r.   r>   rD   rF   rL   rN   rS   rV    r   r   <module>r\      sc     0 0 0 0 0 0 + + + + + + + + + + + +       
,,H	 "8 "8 "8 "8J"8 "8 "8 "8J%> %> %> %>P:- :- :- :-z6 6 6 6@ @  @  @  @F"F "F "F "FJB B B0' ' ' '
' ' ' ' ' 'r   