
    
9j;$                        S SK Jr  S SKrS SKJr  S SKJr  S SKJr	  S SKJ
r
  \R                  R                  SSS	S
5      rSS jrSS jrSS jrSS jrSS jrSS jrSS jrS rg)    )annotationsN)_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])setxorkernelc                    [         R                  " 5       (       a6  U(       a  [        S5      e[         R                  " [        R
                  XUS9$ [        R                  " U SS9  U R                  XUS9$ )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       K/home/wildlama/miniconda3/lib/python3.13/site-packages/cupy/_logic/truth.pyr   r      k    2 %%''%EG G#22JJ#/ 	/ 
a#&55dh577    c                    [         R                  " 5       (       a6  U(       a  [        S5      e[         R                  " [        R
                  XUS9$ [        R                  " U SS9  U R                  XUS9$ )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                   U R                  5       n UR                  5       nU R                  S:X  d  UR                  S:X  aa  U(       a-  [        R                  " U R                  [        R
                  S9$ [        R                  " U R                  [        R
                  S9$ [        R                  " U5      n[        R                  " XUR                  U5      $ )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
xx1}A99SYYdjj99::ciitzz:: ))C.C!!#CHHf==r   c                   [         R                  " U R                  UR                  5      nU(       dc  U(       a/  [         R                  " U SS9u  p[         R                  " USS9u  pOM[         R                  " U 5      n [         R                  " U5      nO U R	                  5       n UR	                  5       nU(       d5  [
        R                  " XUR                  S5      nX   R                  U5      $ [
        R                  " XUR                  S5      u  pxX   R                  U5      n	[         R                  " U5      n
X   nU(       d
  WU
   n
WU   nXU4$ )a  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#   result_typer    uniquer!   r)   r*   r"   astype_exists_and_searchsorted_kernelflatnonzero)arr1arr2r-   return_indicescommon_dtypeind1ind2maskv1int1darr1_indicesarr2_indicess               r   intersect1drB      s   B ##DJJ

;LT=JDT=JD$;;t$D;;t$Dzz|zz|%%d$))UCz  ..66DIIu&HDJl+E##D)L8LL)L),,r   c                J    [        XUUS9R                  U R                  5      $ )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   isinrH      s&    8 m&ww}}56r   c                    U(       a  [         R                  " U 5      n O,[         R                  " U 5      n [         R                  " U5      nU [        XSSS9   $ )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

TrD   )r#   r!   r3   r/   )r+   r,   r-   s      r   	setdiff1drJ      sD    6 jjokk#kk#tCD>??r   c           
     `   U(       d,  [         R                  " U 5      n [         R                  " U5      n[         R                  " X4SS9nUR                  S:X  a  U$ UR	                  5         U[        X3R                  [         R                  " UR                  [         R                  S95         $ )a  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#   r3   concatenater"   r(   _setxorkernelr'   r&   )r+   r,   r-   auxs       r   setxor1drP     s    . kk#kk#


C:D
1C
xx1}
HHJ}S((!ZZ

CE F Fr   c                V    [         R                  " [         R                  " X4SS95      $ )aY  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

NrL   )r#   r3   rM   )r7   r8   s     r   union1drR   *  s"    * ;;t''4@AAr   )NNF)FF)F)
__future__r   r#   
cupy._corer   r   r   cupy._sortingr   r)   r   _coreElementwiseKernelrN   r   r   r/   rB   rH   rJ   rP   rR    r   r   <module>rY      sk    "  0 + +  

,,H	"8J"8J%>P;-|6@ @F"FJBr   