
    vh                      d Z ddlmZ ddlmZ ddlmZ ddlZddlm	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 ddlmZ ddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* ddl+m,Z,  e,d      Z-ej\                  Z/ej`                  ejb                  ejd                  dZ3d Z4ddZ5ddZ6ddZ7	 	 	 	 d	 	 	 	 	 	 	 ddZ8e- eed      dd              Z9e- eed      dd              Z:e- eed      dd              Z;e- eed      dd              Z<e7dd        Z=e- eed      dd!              Z>e- eed      dd"              Z?e- eed      dd#              Z@e- eed      dd$              ZAe- eed      dd%              ZBe- eed      dd&              ZCe- eed      dd'              ZDe- eed      dd(              ZEe- eed      dd)              ZFe- eed      dd*              ZGe- eed      dd+              ZHe- eed      dd,              ZIe- eed      dd-              ZJe- eed      dd.              ZKe- eed      dd/              ZLe- eed      dd0              ZMe- eed      dd1              ZNe-edd2              ZOe- eed      dd3              ZPe- eed      dd4              ZQe- eed      dd5              ZRe- eed      dd6              ZSdd7ZT e8dej                  ej                  eT8      dd9       ZWdd:ZX e8d;ej                  ej                  eX8      dd<       Z[ e8d=ej                  >      dd?       Z] e8dej                  >      dd@       Z_ e8dej                  >      ddA       Zae- eed      ddB              Zbe- eed      ddC              Zce- eed      ddD              Zde- eed      ddE              ZeddFZf e8defG      ddH       Zge- eed      ddI              Zh e8dej                  >      ddJ       Zj e8dej                  >      ddK       Zle- eed      ddL              Zme- eed      ddM              Zne- eed      ddN              Zo e8dej                  >      ddO       Zq e8dPej                  >      ddQ       Zs e8dPej                  >      ddR       Zue- eed      ddS              Zv	 	 	 	 ddTZwe- eed      ddU              Zxe- eed      ddV              Zye- eed      ddW              Zze- eed      ddX              Z{e- eed      ddY              Z|e- eed      ddZ              Z}e- eed      dd[              Z~e- eed      dd\              Ze- eed      dd]              Ze- eed      dd^              Ze- eed      dd_              Ze-edd`              Ze- eed      dda              Ze- eed      ddb              Ze- eed      ddc              Ze- eed      ddd              Ze-edde              Ze-eddf              Ze- eed      ddg              Ze-ddh       Ze-eddi              Ze-eddj              ZddkZe-ddl       Ze-ddm       Z eed      ddn       Zdo Z e8ej&                   ej(                  >      ddp       Z e8ej&                   ej,                  >      ddq       Ze- eed      ddr              Ze- eed      dds              Ze- eed      ddt              Ze-eddu              Zdv Ze-eddw              Ze-eddx              Zedy        Zej@                  dz        Ze-edd{              Ze-dd|       Ze-edd}              Ze- eed      dd~              Ze- eed      dd              Ze- eed      dd              Ze-dd       Ze-dd       Ze- eed      dd              Ze-dd       Ze- eed      dd              Ze- eed      dd              Ze-eddd              Ze- eed      dd              Ze-edd              ZddZe-dd       Ze-dd       Ze- eed      dd              Ze-edd              Ze-edd              Ze- eed      dd              Ze-edd              Z eed      d        Zej@                  d        Zy)z"
Implements ufuncs for jax.numpy.
    )annotations)Callable)partialN)Any)core)dtypes)jit)
custom_jvp)lax)other)Array	ArrayLike)error)
reductions)ufunc)
check_arraylikeensure_arraylikepromote_argspromote_args_inexactpromote_args_numericpromote_dtypes_inexactpromote_dtypes_numericpromote_shapes_wherecheck_no_float0s)
set_modulez	jax.numpy)       @   c                V    t        j                  |t        j                  |             S )Ndtype)nparrayr   r"   )xconsts     P/opt/face_recognition/venv/lib/python3.12/site-packages/jax/_src/numpy/ufuncs.py_constant_liker(   7   s    	%v||A	//    c                z    t        j                  t        t        |             t        j                  |       |       S N)r   selectisposinfreal_zerosr%   s    r'   _replace_infr1   :   s&    	HT!W%szz!}a	88r)   c                l    | j                   t        k(  r| S t        j                  | t	        | d            S )Nr   )r"   boolr   ne
_lax_constr0   s    r'   _to_boolr6   =   s)    ggo>366!Z1-=#>>r)   c                P    t        | d      }t        || j                  dd|      S )z6An internal helper function for defining unary ufuncs.Tinline   )nameninnoutcallr	   r   __name__)funcfunc_jits     r'   unary_ufuncrC   A   s%    d#(	xdmm	JJr)   c                $     d fd}|S )z7An internal helper function for defining binary ufuncs.c                \    t        | d      }t        || j                  dd|
      S )NTr8      r:   )	r;   r<   r=   r>   identityreduce
accumulateatreduceatr?   )rA   rB   rI   rJ   rG   rH   rK   s     r'   	decoratorzbinary_ufunc.<locals>.decoratorL   s8    4%H118"6jRZbd dr)   )rA   'Callable[[ArrayLike, ArrayLike], Array]returnr    )rG   rH   rI   rJ   rK   rL   s   ````` r'   binary_ufuncrP   G   s    
d d 
r)   Tr8   c                   t        d|       } t        j                  t        j                  |       t        j
                        rt        d      t        j                  t        d|        S )a  Compute the element-wise absolute values of the real-valued input.

  JAX implementation of :obj:`numpy.fabs`.

  Args:
    x: input array or scalar. Must not have a complex dtype.

  Returns:
    An array with same shape as ``x`` and dtype float, containing the element-wise
    absolute values.

  See also:
    - :func:`jax.numpy.absolute`: Computes the absolute values of the input including
      complex dtypes.
    - :func:`jax.numpy.abs`: Computes the absolute values of the input including
      complex dtypes.

  Examples:
    For integer inputs:

    >>> x = jnp.array([-5, -9, 1, 10, 15])
    >>> jnp.fabs(x)
    Array([ 5.,  9.,  1., 10., 15.], dtype=float32)

    For float type inputs:

    >>> x1 = jnp.array([-1.342, 5.649, 3.927])
    >>> jnp.fabs(x1)
    Array([1.342, 5.649, 3.927], dtype=float32)

    For boolean inputs:

    >>> x2 = jnp.array([True, False])
    >>> jnp.fabs(x2)
    Array([1., 0.], dtype=float32)
  fabsz,ufunc 'fabs' does not support complex dtypes)
r   r   
issubdtyper"   r#   complexfloating	TypeErrorr   absr   r0   s    r'   rR   rR   S   sR    N vq!!v||A(:(:;
B
CC	&vq1	22r)   c               :    t        j                  t        d|        S )"Alias of :func:`jax.numpy.invert`.bitwise_invertr   bitwise_notr   r0   s    r'   rY   rY      s     
,'7;	<<r)   c               :    t        j                  t        d|        S )rX   r[   rZ   r0   s    r'   r[   r[      s     
,}a8	99r)   c               :    t        j                  t        d|        S )a  Compute the bitwise inversion of an input.

  JAX implementation of :func:`numpy.invert`. This function provides the
  implementation of the ``~`` operator for JAX arrays.

  Args:
    x: input array, must be boolean or integer typed.

  Returns:
    An array of the same shape and dtype as ```x``, with the bits inverted.

  See also:
    - :func:`jax.numpy.bitwise_invert`: Array API alias of this function.
    - :func:`jax.numpy.logical_not`: Invert after casting input to boolean.

  Examples:
    >>> x = jnp.arange(5, dtype='uint8')
    >>> print(x)
    [0 1 2 3 4]
    >>> print(jnp.invert(x))
    [255 254 253 252 251]

    This function implements the unary ``~`` operator for JAX arrays:

    >>> print(~x)
    [255 254 253 252 251]

    :func:`invert` operates bitwise on the input, and so the meaning of its
    output may be more clear by showing the bitwise representation:

    >>> with jnp.printoptions(formatter={'int': lambda x: format(x, '#010b')}):
    ...   print(f"{x  = }")
    ...   print(f"{~x = }")
    x  = Array([0b00000000, 0b00000001, 0b00000010, 0b00000011, 0b00000100], dtype=uint8)
    ~x = Array([0b11111111, 0b11111110, 0b11111101, 0b11111100, 0b11111011], dtype=uint8)

    For boolean inputs, :func:`invert` is equivalent to :func:`logical_not`:

    >>> x = jnp.array([True, False, True, True, False])
    >>> jnp.invert(x)
    Array([False,  True, False, False,  True], dtype=bool)
  invertrZ   r0   s    r'   r^   r^      s    Z 
,x3	44r)   c               :    t        j                  t        d|        S )a|  Return element-wise negative values of the input.

  JAX implementation of :obj:`numpy.negative`.

  Args:
    x: input array or scalar.

  Returns:
    An array with same shape and dtype as ``x`` containing ``-x``.

  See also:
    - :func:`jax.numpy.positive`: Returns element-wise positive values of the input.
    - :func:`jax.numpy.sign`: Returns element-wise indication of sign of the input.

  Note:
    ``jnp.negative``, when applied over ``unsigned integer``, produces the result
    of their two's complement negation, which typically results in unexpected
    large positive values due to integer underflow.

  Examples:
    For real-valued inputs:

    >>> x = jnp.array([0., -3., 7])
    >>> jnp.negative(x)
    Array([-0.,  3., -7.], dtype=float32)

    For complex inputs:

    >>> x1 = jnp.array([1-2j, -3+4j, 5-6j])
    >>> jnp.negative(x1)
    Array([-1.+2.j,  3.-4.j, -5.+6.j], dtype=complex64)

    For unit32:

    >>> x2 = jnp.array([5, 0, -7]).astype(jnp.uint32)
    >>> x2
    Array([         5,          0, 4294967289], dtype=uint32)
    >>> jnp.negative(x2)
    Array([4294967291,          0,          7], dtype=uint32)
  negative)r   negr   r0   s    r'   r`   r`      s    T 
,z1-	..r)   c               :    t        j                  t        d|        S )a  Return element-wise positive values of the input.

  JAX implementation of :obj:`numpy.positive`.

  Args:
    x: input array or scalar

  Returns:
    An array of same shape and dtype as ``x`` containing ``+x``.

  Note:
    ``jnp.positive`` is equivalent to ``x.copy()`` and is defined only for the
    types that support arithmetic operations.

  See also:
    - :func:`jax.numpy.negative`: Returns element-wise negative values of the input.
    - :func:`jax.numpy.sign`: Returns element-wise indication of sign of the input.

  Examples:
    For real-valued inputs:

    >>> x = jnp.array([-5, 4, 7., -9.5])
    >>> jnp.positive(x)
    Array([-5. ,  4. ,  7. , -9.5], dtype=float32)
    >>> x.copy()
    Array([-5. ,  4. ,  7. , -9.5], dtype=float32)

    For complex inputs:

    >>> x1 = jnp.array([1-2j, -3+4j, 5-6j])
    >>> jnp.positive(x1)
    Array([ 1.-2.j, -3.+4.j,  5.-6.j], dtype=complex64)
    >>> x1.copy()
    Array([ 1.-2.j, -3.+4.j,  5.-6.j], dtype=complex64)

    For uint32:

    >>> x2 = jnp.array([6, 0, -4]).astype(jnp.uint32)
    >>> x2
    Array([         6,          0, 4294967292], dtype=uint32)
    >>> jnp.positive(x2)
    Array([         6,          0, 4294967292], dtype=uint32)
  positive)r   asarrayr   r0   s    r'   rc   rc      s    \ 
l:q1	22r)   c               :    t        j                  t        d|        S )al  Return an element-wise indication of sign of the input.

  JAX implementation of :obj:`numpy.sign`.

  The sign of ``x`` for real-valued input is:

  .. math::
    \mathrm{sign}(x) = \begin{cases}
      1, & x > 0\\
      0, & x = 0\\
      -1, & x < 0
    \end{cases}

  For complex valued input, ``jnp.sign`` returns a unit vector representing the
  phase. For generalized case, the sign of ``x`` is given by:

  .. math::
    \mathrm{sign}(x) = \begin{cases}
      \frac{x}{abs(x)}, & x \ne 0\\
      0, & x = 0
    \end{cases}

  Args:
    x: input array or scalar.

  Returns:
    An array with same shape and dtype as ``x`` containing the sign indication.

  See also:
    - :func:`jax.numpy.positive`: Returns element-wise positive values of the input.
    - :func:`jax.numpy.negative`: Returns element-wise negative values of the input.

  Examples:
    For Real-valued inputs:

    >>> x = jnp.array([0., -3., 7.])
    >>> jnp.sign(x)
    Array([ 0., -1.,  1.], dtype=float32)

    For complex-inputs:

    >>> x1 = jnp.array([1, 3+4j, 5j])
    >>> jnp.sign(x1)
    Array([1. +0.j , 0.6+0.8j, 0. +1.j ], dtype=complex64)
  sign)r   rf   r   r0   s    r'   rf   rf     s    ` 
<*	++r)   c                   t        d|       } t        j                  t        j                  |       d      r| S t	        j
                  t        d|        S )a  Round input to the nearest integer downwards.

  JAX implementation of :obj:`numpy.floor`.

  Args:
    x: input array or scalar. Must not have complex dtype.

  Returns:
    An array with same shape and dtype as ``x`` containing the values rounded to
    the nearest integer that is less than or equal to the value itself.

  See also:
    - :func:`jax.numpy.fix`: Rounds the input to the nearest integer towards zero.
    - :func:`jax.numpy.trunc`: Rounds the input to the nearest integer towards
      zero.
    - :func:`jax.numpy.ceil`: Rounds the input up to the nearest integer.

  Examples:
    >>> key = jax.random.key(42)
    >>> x = jax.random.uniform(key, (3, 3), minval=-5, maxval=5)
    >>> with jnp.printoptions(precision=2, suppress=True):
    ...     print(x)
    [[-0.11  1.8   1.16]
     [ 0.61 -0.49  0.86]
     [-4.25  2.75  1.99]]
    >>> jnp.floor(x)
    Array([[-1.,  1.,  1.],
           [ 0., -1.,  0.],
           [-5.,  2.,  1.]], dtype=float32)
  floorintegralr3   )r   r   isdtyper"   r   rh   r   r0   s    r'   rh   rh   O  sD    B w"!^^FLLO%9:H	(!4	55r)   c                   t        d|       } t        j                  t        j                  |       d      rt	        j
                  |       S t	        j                  t        d|        S )a  Round input to the nearest integer upwards.

  JAX implementation of :obj:`numpy.ceil`.

  Args:
    x: input array or scalar. Must not have complex dtype.

  Returns:
    An array with same shape and dtype as ``x`` containing the values rounded to
    the nearest integer that is greater than or equal to the value itself.

  See also:
    - :func:`jax.numpy.fix`: Rounds the input to the nearest integer towards zero.
    - :func:`jax.numpy.trunc`: Rounds the input to the nearest integer towards
      zero.
    - :func:`jax.numpy.floor`: Rounds the input down to the nearest integer.

  Examples:
    >>> key = jax.random.key(1)
    >>> x = jax.random.uniform(key, (3, 3), minval=-5, maxval=5)
    >>> with jnp.printoptions(precision=2, suppress=True):
    ...     print(x)
    [[-0.61  0.34 -0.54]
     [-0.62  3.97  0.59]
     [ 4.84  3.42 -1.14]]
    >>> jnp.ceil(x)
    Array([[-0.,  1., -0.],
           [-0.,  4.,  1.],
           [ 5.,  4., -1.]], dtype=float32)
  ceilri   )r   r   rk   r"   r   rd   rm   r   r0   s    r'   rm   rm   v  sM    B vq!!^^FLLO%9:;;q>	'2	33r)   c               :    t        j                  t        d|        S )aV  Calculate element-wise exponential of the input.

  JAX implementation of :obj:`numpy.exp`.

  Args:
    x: input array or scalar

  Returns:
    An array containing the exponential of each element in ``x``, promotes to
    inexact dtype.

  See also:
    - :func:`jax.numpy.log`: Calculates element-wise logarithm of the input.
    - :func:`jax.numpy.expm1`: Calculates :math:`e^x-1` of each element of the
      input.
    - :func:`jax.numpy.exp2`: Calculates base-2 exponential of each element of
      the input.

  Examples:
    ``jnp.exp`` follows the properties of exponential such as :math:`e^{(a+b)}
    = e^a * e^b`.

    >>> x1 = jnp.array([2, 4, 3, 1])
    >>> x2 = jnp.array([1, 3, 2, 3])
    >>> with jnp.printoptions(precision=2, suppress=True):
    ...   print(jnp.exp(x1+x2))
    [  20.09 1096.63  148.41   54.6 ]
    >>> with jnp.printoptions(precision=2, suppress=True):
    ...   print(jnp.exp(x1)*jnp.exp(x2))
    [  20.09 1096.63  148.41   54.6 ]

    This property holds for complex input also:

    >>> jnp.allclose(jnp.exp(3-4j), jnp.exp(3)*jnp.exp(-4j))
    Array(True, dtype=bool)
  exp)r   ro   r   r0   s    r'   ro   ro     s    N 
&ua0	11r)   c               h    t        j                  t        d|        }t        j                  |       |S )a4  Calculate element-wise natural logarithm of the input.

  JAX implementation of :obj:`numpy.log`.

  Args:
    x: input array or scalar.

  Returns:
    An array containing the logarithm of each element in ``x``, promotes to inexact
    dtype.

  See also:
    - :func:`jax.numpy.exp`: Calculates element-wise exponential of the input.
    - :func:`jax.numpy.log2`: Calculates base-2 logarithm of each element of input.
    - :func:`jax.numpy.log1p`: Calculates element-wise logarithm of one plus input.

  Examples:
    ``jnp.log`` and ``jnp.exp`` are inverse functions of each other. Applying
    ``jnp.log`` on the result of ``jnp.exp(x)`` yields the original input ``x``.

    >>> x = jnp.array([2, 3, 4, 5])
    >>> jnp.log(jnp.exp(x))
    Array([2., 3., 4., 5.], dtype=float32)

    Using ``jnp.log`` we can demonstrate well-known properties of logarithms, such
    as :math:`log(a*b) = log(a)+log(b)`.

    >>> x1 = jnp.array([2, 1, 3, 1])
    >>> x2 = jnp.array([1, 3, 2, 4])
    >>> jnp.allclose(jnp.log(x1*x2), jnp.log(x1)+jnp.log(x2))
    Array(True, dtype=bool)
  log)r   rq   r   	jnp_error_set_error_if_nanr%   outs     r'   rq   rq     s.    F 	%eQ/0#c"	*r)   c               :    t        j                  t        d|        S )a  Calculate ``exp(x)-1`` of each element of the input.

  JAX implementation of :obj:`numpy.expm1`.

  Args:
    x: input array or scalar.

  Returns:
    An array containing ``exp(x)-1`` of each element in ``x``, promotes to inexact
    dtype.

  Note:
    ``jnp.expm1`` has much higher precision than the naive computation of
    ``exp(x)-1`` for small values of ``x``.

  See also:
    - :func:`jax.numpy.log1p`: Calculates element-wise logarithm of one plus input.
    - :func:`jax.numpy.exp`: Calculates element-wise exponential of the input.
    - :func:`jax.numpy.exp2`: Calculates base-2 exponential of each element of
      the input.

  Examples:
    >>> x = jnp.array([2, -4, 3, -1])
    >>> with jnp.printoptions(precision=2, suppress=True):
    ...   print(jnp.expm1(x))
    [ 6.39 -0.98 19.09 -0.63]
    >>> with jnp.printoptions(precision=2, suppress=True):
    ...   print(jnp.exp(x)-1)
    [ 6.39 -0.98 19.09 -0.63]

    For values very close to 0, ``jnp.expm1(x)`` is much more accurate than
    ``jnp.exp(x)-1``:

    >>> x1 = jnp.array([1e-4, 1e-6, 2e-10])
    >>> jnp.expm1(x1)
    Array([1.0000500e-04, 1.0000005e-06, 2.0000000e-10], dtype=float32)
    >>> jnp.exp(x1)-1
    Array([1.00016594e-04, 9.53674316e-07, 0.00000000e+00], dtype=float32)
  expm1)r   rw   r   r0   s    r'   rw   rw     s    T 
(!4	55r)   c               h    t        j                  t        d|        }t        j                  |       |S )a  Calculates element-wise logarithm of one plus input, ``log(x+1)``.

  JAX implementation of :obj:`numpy.log1p`.

  Args:
    x: input array or scalar.

  Returns:
    An array containing the logarithm of one plus of each element in ``x``,
    promotes to inexact dtype.

  Note:
    ``jnp.log1p`` is more accurate than when using the naive computation of
    ``log(x+1)`` for small values of ``x``.

  See also:
    - :func:`jax.numpy.expm1`: Calculates :math:`e^x-1` of each element of the
      input.
    - :func:`jax.numpy.log2`: Calculates base-2 logarithm of each element of input.
    - :func:`jax.numpy.log`: Calculates element-wise logarithm of the input.

  Examples:
    >>> x = jnp.array([2, 5, 9, 4])
    >>> jnp.allclose(jnp.log1p(x), jnp.log(x+1))
    Array(True, dtype=bool)

    For values very close to 0, ``jnp.log1p(x)`` is more accurate than
    ``jnp.log(x+1)``:

    >>> x1 = jnp.array([1e-4, 1e-6, 2e-10])
    >>> jnp.expm1(jnp.log1p(x1))  # doctest: +SKIP
    Array([1.00000005e-04, 9.99999997e-07, 2.00000003e-10], dtype=float32)
    >>> jnp.expm1(jnp.log(x1+1))  # doctest: +SKIP
    Array([1.000166e-04, 9.536743e-07, 0.000000e+00], dtype=float32)
  log1p)r   ry   r   rr   rs   rt   s     r'   ry   ry     s.    L 			'34#c"	*r)   c               h    t        j                  t        d|        }t        j                  |       |S )a  Compute a trigonometric sine of each element of input.

  JAX implementation of :obj:`numpy.sin`.

  Args:
    x: array or scalar. Angle in radians.

  Returns:
    An array containing the sine of each element in ``x``, promotes to inexact
    dtype.

  See also:
    - :func:`jax.numpy.cos`: Computes a trigonometric cosine of each element of
      input.
    - :func:`jax.numpy.tan`: Computes a trigonometric tangent of each element of
      input.
    - :func:`jax.numpy.arcsin` and :func:`jax.numpy.asin`: Computes the inverse of
      trigonometric sine of each element of input.

  Examples:
    >>> pi = jnp.pi
    >>> x = jnp.array([pi/4, pi/2, 3*pi/4, pi])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   print(jnp.sin(x))
    [ 0.707  1.     0.707 -0.   ]
  sin)r   r{   r   rr   rs   rt   s     r'   r{   r{   G  s-    : 	%eQ/0#c"	*r)   c               h    t        j                  t        d|        }t        j                  |       |S )a  Compute a trigonometric cosine of each element of input.

  JAX implementation of :obj:`numpy.cos`.

  Args:
    x: scalar or array. Angle in radians.

  Returns:
    An array containing the cosine of each element in ``x``, promotes to inexact
    dtype.

  See also:
    - :func:`jax.numpy.sin`: Computes a trigonometric sine of each element of input.
    - :func:`jax.numpy.tan`: Computes a trigonometric tangent of each element of
      input.
    - :func:`jax.numpy.arccos` and :func:`jax.numpy.acos`: Computes the inverse of
      trigonometric cosine of each element of input.

  Examples:
    >>> pi = jnp.pi
    >>> x = jnp.array([pi/4, pi/2, 3*pi/4, 5*pi/6])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   print(jnp.cos(x))
    [ 0.707 -0.    -0.707 -0.866]
  cos)r   r}   r   rr   rs   rt   s     r'   r}   r}   i  -    8 	%eQ/0#c"	*r)   c               h    t        j                  t        d|        }t        j                  |       |S )a#  Compute a trigonometric tangent of each element of input.

  JAX implementation of :obj:`numpy.tan`.

  Args:
    x: scalar or array. Angle in radians.

  Returns:
    An array containing the tangent of each element in ``x``, promotes to inexact
    dtype.

  See also:
    - :func:`jax.numpy.sin`: Computes a trigonometric sine of each element of input.
    - :func:`jax.numpy.cos`: Computes a trigonometric cosine of each element of
      input.
    - :func:`jax.numpy.arctan` and :func:`jax.numpy.atan`: Computes the inverse of
      trigonometric tangent of each element of input.

  Examples:
    >>> pi = jnp.pi
    >>> x = jnp.array([0, pi/6, pi/4, 3*pi/4, 5*pi/6])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   print(jnp.tan(x))
    [ 0.     0.577  1.    -1.    -0.577]
  tan)r   r   r   rr   rs   rt   s     r'   r   r     r~   r)   c               h    t        j                  t        d|        }t        j                  |       |S )a'  Compute element-wise inverse of trigonometric sine of input.

  JAX implementation of :obj:`numpy.arcsin`.

  Args:
    x: input array or scalar.

  Returns:
    An array containing the inverse trigonometric sine of each element of ``x``
    in radians in the range ``[-pi/2, pi/2]``, promoting to inexact dtype.

  Note:
    - ``jnp.arcsin`` returns ``nan`` when ``x`` is real-valued and not in the closed
      interval ``[-1, 1]``.
    - ``jnp.arcsin`` follows the branch cut convention of :obj:`numpy.arcsin` for
      complex inputs.

  See also:
    - :func:`jax.numpy.sin`: Computes a trigonometric sine of each element of input.
    - :func:`jax.numpy.arccos` and :func:`jax.numpy.acos`: Computes the inverse of
      trigonometric cosine of each element of input.
    - :func:`jax.numpy.arctan` and :func:`jax.numpy.atan`: Computes the inverse of
      trigonometric tangent of each element of input.

  Examples:
    >>> x = jnp.array([-2, -1, -0.5, 0, 0.5, 1, 2])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arcsin(x)
    Array([   nan, -1.571, -0.524,  0.   ,  0.524,  1.571,    nan], dtype=float32)

    For complex-valued inputs:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arcsin(3+4j)
    Array(0.634+2.306j, dtype=complex64, weak_type=True)
  arcsin)r   asinr   rr   rs   rt   s     r'   r   r     s.    N 	&x34#c"	*r)   c               h    t        j                  t        d|        }t        j                  |       |S )a  Compute element-wise inverse of trigonometric cosine of input.

  JAX implementation of :obj:`numpy.arccos`.

  Args:
    x: input array or scalar.

  Returns:
    An array containing the inverse trigonometric cosine of each element of ``x``
    in radians in the range ``[0, pi]``, promoting to inexact dtype.

  Note:
    - ``jnp.arccos`` returns ``nan`` when ``x`` is real-valued and not in the closed
      interval ``[-1, 1]``.
    - ``jnp.arccos`` follows the branch cut convention of :obj:`numpy.arccos` for
      complex inputs.

  See also:
    - :func:`jax.numpy.cos`: Computes a trigonometric cosine of each element of
      input.
    - :func:`jax.numpy.arcsin` and :func:`jax.numpy.asin`: Computes the inverse of
      trigonometric sine of each element of input.
    - :func:`jax.numpy.arctan` and :func:`jax.numpy.atan`: Computes the inverse of
      trigonometric tangent of each element of input.

  Examples:
    >>> x = jnp.array([-2, -1, -0.5, 0, 0.5, 1, 2])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arccos(x)
    Array([  nan, 3.142, 2.094, 1.571, 1.047, 0.   ,   nan], dtype=float32)

    For complex inputs:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arccos(4-1j)
    Array(0.252+2.097j, dtype=complex64, weak_type=True)
  arccos)r   acosr   rr   rs   rt   s     r'   r   r     s.    P 	&x34#c"	*r)   c               :    t        j                  t        d|        S )a  Compute element-wise inverse of trigonometric tangent of input.

  JAX implement of :obj:`numpy.arctan`.

  Args:
    x: input array or scalar.

  Returns:
    An array containing the inverse trigonometric tangent of each element ``x``
    in radians in the range ``[-pi/2, pi/2]``, promoting to inexact dtype.

  Note:
    ``jnp.arctan`` follows the branch cut convention of :obj:`numpy.arctan` for
    complex inputs.

  See also:
    - :func:`jax.numpy.tan`: Computes a trigonometric tangent of each element of
      input.
    - :func:`jax.numpy.arcsin` and :func:`jax.numpy.asin`: Computes the inverse of
      trigonometric sine of each element of input.
    - :func:`jax.numpy.arccos` and :func:`jax.numpy.atan`: Computes the inverse of
      trigonometric cosine of each element of input.

  Examples:
    >>> x = jnp.array([-jnp.inf, -20, -1, 0, 1, 20, jnp.inf])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arctan(x)
    Array([-1.571, -1.521, -0.785,  0.   ,  0.785,  1.521,  1.571], dtype=float32)

    For complex-valued inputs:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arctan(2+7j)
    Array(1.532+0.133j, dtype=complex64, weak_type=True)
  arctan)r   atanr   r0   s    r'   r   r     s    L 
'!4	55r)   c               :    t        j                  t        d|        S )a  Calculate element-wise hyperbolic sine of input.

  JAX implementation of :obj:`numpy.sinh`.

  The hyperbolic sine is defined by:

  .. math::

    sinh(x) = \frac{e^x - e^{-x}}{2}

  Args:
    x: input array or scalar.

  Returns:
    An array containing the hyperbolic sine of each element of ``x``, promoting
    to inexact dtype.

  Note:
    ``jnp.sinh`` is equivalent to computing ``-1j * jnp.sin(1j * x)``.

  See also:
    - :func:`jax.numpy.cosh`: Computes the element-wise hyperbolic cosine of the
      input.
    - :func:`jax.numpy.tanh`: Computes the element-wise hyperbolic tangent of the
      input.
    - :func:`jax.numpy.arcsinh`:  Computes the element-wise inverse of hyperbolic
      sine of the input.

  Examples:
    >>> x = jnp.array([[-2, 3, 5],
    ...                [0, -1, 4]])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.sinh(x)
    Array([[-3.627, 10.018, 74.203],
           [ 0.   , -1.175, 27.29 ]], dtype=float32)
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   -1j * jnp.sin(1j * x)
    Array([[-3.627+0.j, 10.018-0.j, 74.203-0.j],
           [ 0.   -0.j, -1.175+0.j, 27.29 -0.j]],      dtype=complex64, weak_type=True)

    For complex-valued input:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.sinh(3-2j)
    Array(-4.169-9.154j, dtype=complex64, weak_type=True)
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   -1j * jnp.sin(1j * (3-2j))
    Array(-4.169-9.154j, dtype=complex64, weak_type=True)
  sinh)r   r   r   r0   s    r'   r   r   -  s    h 
'2	33r)   c               :    t        j                  t        d|        S )a  Calculate element-wise hyperbolic cosine of input.

  JAX implementation of :obj:`numpy.cosh`.

  The hyperbolic cosine is defined by:

  .. math::

    cosh(x) = \frac{e^x + e^{-x}}{2}

  Args:
    x: input array or scalar.

  Returns:
    An array containing the hyperbolic cosine of each element of ``x``, promoting
    to inexact dtype.

  Note:
    ``jnp.cosh`` is equivalent to computing ``jnp.cos(1j * x)``.

  See also:
    - :func:`jax.numpy.sinh`: Computes the element-wise hyperbolic sine of the input.
    - :func:`jax.numpy.tanh`: Computes the element-wise hyperbolic tangent of the
      input.
    - :func:`jax.numpy.arccosh`:  Computes the element-wise inverse of hyperbolic
      cosine of the input.

  Examples:
    >>> x = jnp.array([[3, -1, 0],
    ...                [4, 7, -5]])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.cosh(x)
    Array([[ 10.068,   1.543,   1.   ],
           [ 27.308, 548.317,  74.21 ]], dtype=float32)
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.cos(1j * x)
    Array([[ 10.068+0.j,   1.543+0.j,   1.   +0.j],
           [ 27.308+0.j, 548.317+0.j,  74.21 +0.j]],      dtype=complex64, weak_type=True)

    For complex-valued input:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.cosh(5+1j)
    Array(40.096+62.44j, dtype=complex64, weak_type=True)
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.cos(1j * (5+1j))
    Array(40.096+62.44j, dtype=complex64, weak_type=True)
  cosh)r   r   r   r0   s    r'   r   r   d      f 
'2	33r)   c               :    t        j                  t        d|        S )ag  Calculate element-wise inverse of hyperbolic sine of input.

  JAX implementation of :obj:`numpy.arcsinh`.

  The inverse of hyperbolic sine is defined by:

  .. math::

    arcsinh(x) = \ln(x + \sqrt{1 + x^2})

  Args:
    x: input array or scalar.

  Returns:
    An array of same shape as ``x`` containing the inverse of hyperbolic sine of
    each element of ``x``, promoting to inexact dtype.

  Note:
    - ``jnp.arcsinh`` returns ``nan`` for values outside the range ``(-inf, inf)``.
    - ``jnp.arcsinh`` follows the branch cut convention of :obj:`numpy.arcsinh`
      for complex inputs.

  See also:
    - :func:`jax.numpy.sinh`: Computes the element-wise hyperbolic sine of the input.
    - :func:`jax.numpy.arccosh`: Computes the element-wise inverse of hyperbolic
      cosine of the input.
    - :func:`jax.numpy.arctanh`: Computes the element-wise inverse of hyperbolic
      tangent of the input.

  Examples:
    >>> x = jnp.array([[-2, 3, 1],
    ...                [4, 9, -5]])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arcsinh(x)
    Array([[-1.444,  1.818,  0.881],
           [ 2.095,  2.893, -2.312]], dtype=float32)

    For complex-valued inputs:

    >>> x1 = jnp.array([4-3j, 2j])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arcsinh(x1)
    Array([2.306-0.634j, 1.317+1.571j], dtype=complex64)
  arcsinh)r   asinhr   r0   s    r'   r   r     s    ^ 
(A6	77r)   c                  t        j                  t        d|        }t        j                  |       t        j                  |j                  t        j                        r,t        t        |      dk  t        j                  |      |      }|S )a  Calculate element-wise inverse of hyperbolic cosine of input.

  JAX implementation of :obj:`numpy.arccosh`.

  The inverse of hyperbolic cosine is defined by:

  .. math::

    arccosh(x) = \ln(x + \sqrt{x^2 - 1})

  Args:
    x: input array or scalar.

  Returns:
    An array of same shape as ``x`` containing the inverse of hyperbolic cosine
    of each element of ``x``, promoting to inexact dtype.

  Note:
    - ``jnp.arccosh`` returns ``nan`` for real-values in the range ``[-inf, 1)``.
    - ``jnp.arccosh`` follows the branch cut convention of :obj:`numpy.arccosh`
      for complex inputs.

  See also:
    - :func:`jax.numpy.cosh`: Computes the element-wise hyperbolic cosine of the
      input.
    - :func:`jax.numpy.arcsinh`: Computes the element-wise inverse of hyperbolic
      sine of the input.
    - :func:`jax.numpy.arctanh`: Computes the element-wise inverse of hyperbolic
      tangent of the input.

  Examples:
    >>> x = jnp.array([[1, 3, -4],
    ...                [-5, 2, 7]])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arccosh(x)
    Array([[0.   , 1.763,   nan],
           [  nan, 1.317, 2.634]], dtype=float32)

    For complex-valued input:

    >>> x1 = jnp.array([-jnp.inf+0j, 1+2j, -5+0j])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arccosh(x1)
    Array([  inf+3.142j, 1.529+1.144j, 2.292+3.142j], dtype=complex64)
  arccoshr   )r   acoshr   rr   rs   r   rS   r"   r#   rT   r   r.   ra   )r%   results     r'   r   r     sg    d 99*9a89&f%v||R%7%78DL1$cggfov>F	-r)   c               :    t        j                  t        d|        S )a'  Calculate element-wise hyperbolic tangent of input.

  JAX implementation of :obj:`numpy.tanh`.

  The hyperbolic tangent is defined by:

  .. math::

    tanh(x) = \frac{sinh(x)}{cosh(x)} = \frac{e^x - e^{-x}}{e^x + e^{-x}}

  Args:
    x: input array or scalar.

  Returns:
    An array containing the hyperbolic tangent of each element of ``x``, promoting
    to inexact dtype.

  Note:
    ``jnp.tanh`` is equivalent to computing ``-1j * jnp.tan(1j * x)``.

  See also:
    - :func:`jax.numpy.sinh`: Computes the element-wise hyperbolic sine of the input.
    - :func:`jax.numpy.cosh`: Computes the element-wise hyperbolic cosine of the
      input.
    - :func:`jax.numpy.arctanh`:  Computes the element-wise inverse of hyperbolic
      tangent of the input.

  Examples:
    >>> x = jnp.array([[-1, 0, 1],
    ...                [3, -2, 5]])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.tanh(x)
    Array([[-0.762,  0.   ,  0.762],
           [ 0.995, -0.964,  1.   ]], dtype=float32)
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   -1j * jnp.tan(1j * x)
    Array([[-0.762+0.j,  0.   -0.j,  0.762-0.j],
           [ 0.995-0.j, -0.964+0.j,  1.   -0.j]],      dtype=complex64, weak_type=True)

    For complex-valued input:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.tanh(2-5j)
    Array(1.031+0.021j, dtype=complex64, weak_type=True)
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   -1j * jnp.tan(1j * (2-5j))
    Array(1.031+0.021j, dtype=complex64, weak_type=True)
  tanh)r   r   r   r0   s    r'   r   r     r   r)   c               h    t        j                  t        d|        }t        j                  |       |S )a  Calculate element-wise inverse of hyperbolic tangent of input.

  JAX implementation of :obj:`numpy.arctanh`.

  The inverse of hyperbolic tangent is defined by:

  .. math::

    arctanh(x) = \frac{1}{2} [\ln(1 + x) - \ln(1 - x)]

  Args:
    x: input array or scalar.

  Returns:
    An array of same shape as ``x`` containing the inverse of hyperbolic tangent
    of each element of ``x``, promoting to inexact dtype.

  Note:
    - ``jnp.arctanh`` returns ``nan`` for real-values outside the range ``[-1, 1]``.
    - ``jnp.arctanh`` follows the branch cut convention of :obj:`numpy.arctanh`
      for complex inputs.

  See also:
    - :func:`jax.numpy.tanh`: Computes the element-wise hyperbolic tangent of the
      input.
    - :func:`jax.numpy.arcsinh`: Computes the element-wise inverse of hyperbolic
      sine of the input.
    - :func:`jax.numpy.arccosh`: Computes the element-wise inverse of hyperbolic
      cosine of the input.

  Examples:
    >>> x = jnp.array([-2, -1, -0.5, 0, 0.5, 1, 2])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arctanh(x)
    Array([   nan,   -inf, -0.549,  0.   ,  0.549,    inf,    nan], dtype=float32)

    For complex-valued input:

    >>> x1 = jnp.array([-2+0j, 3+0j, 4-1j])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.arctanh(x1)
    Array([-0.549+1.571j,  0.347+1.571j,  0.239-1.509j], dtype=complex64)
  arctanh)r   atanhr   rr   rs   rt   s     r'   r   r   ;  s.    \ 			'	156#c"	*r)   c               h    t        j                  t        d|        }t        j                  |       |S )as  Calculates element-wise non-negative square root of the input array.

  JAX implementation of :obj:`numpy.sqrt`.

  Args:
    x: input array or scalar.

  Returns:
    An array containing the non-negative square root of the elements of ``x``.

  Note:
    - For real-valued negative inputs, ``jnp.sqrt`` produces a ``nan`` output.
    - For complex-valued negative inputs, ``jnp.sqrt`` produces a ``complex`` output.

  See also:
    - :func:`jax.numpy.square`: Calculates the element-wise square of the input.
    - :func:`jax.numpy.power`: Calculates the element-wise base ``x1`` exponential
      of ``x2``.

  Examples:
    >>> x = jnp.array([-8-6j, 1j, 4])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.sqrt(x)
    Array([1.   -3.j   , 0.707+0.707j, 2.   +0.j   ], dtype=complex64)
    >>> jnp.sqrt(-1)
    Array(nan, dtype=float32, weak_type=True)
  sqrt)r   r   r   rr   rs   rt   s     r'   r   r   n  s-    < 	&vq12#c"	*r)   c               :    t        j                  t        d|        S )a  Calculates element-wise cube root of the input array.

  JAX implementation of :obj:`numpy.cbrt`.

  Args:
    x: input array or scalar. ``complex`` dtypes are not supported.

  Returns:
    An array containing the cube root of the elements of ``x``.

  See also:
    - :func:`jax.numpy.sqrt`: Calculates the element-wise non-negative square root
      of the input.
    - :func:`jax.numpy.square`: Calculates the element-wise square of the input.

  Examples:
    >>> x = jnp.array([[216, 125, 64],
    ...                [-27, -8, -1]])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.cbrt(x)
    Array([[ 6.,  5.,  4.],
           [-3., -2., -1.]], dtype=float32)
  cbrt)r   r   r   r0   s    r'   r   r     s    4 
'2	33r)   c                :   | j                   t        k(  rk| j                  d      } t        j                  |t              j                  d      }| j
                  |   j                  |      j                  t              S | j
                  |   j                  |      S )zImplementation of jnp.add.at.int32)r"   r3   astyper   convert_element_typerJ   addaindicesbs      r'   _add_atr     su    WW_	A  D)009A44=Q&&t,,	
g		1	r)   )rG   rH   rI   rJ   c                   t        d| |      \  } }| j                  t        k(  rt        j                  | |      S t        j
                  | |      }t        j                  |       |S )a  Add two arrays element-wise.

  JAX implementation of :obj:`numpy.add`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.
  This function provides the implementation of the ``+`` operator for
  JAX arrays.

  Args:
    x, y: arrays to add. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise addition.

  Examples:
    Calling ``add`` explicitly:

    >>> x = jnp.arange(4)
    >>> jnp.add(x, 10)
    Array([10, 11, 12, 13], dtype=int32)

    Calling ``add`` via the ``+`` operator:

    >>> x + 10
    Array([10, 11, 12, 13], dtype=int32)
  r   )r   r"   r3   r   
bitwise_orr   rr   rs   r%   yru   s      r'   r   r     sT    6 
eQ	"$!QWW_>>!Q1#c"	*r)   c                :   | j                   t        k(  rk| j                  d      } t        j                  |t              j                  d      }| j
                  |   j                  |      j                  t              S | j
                  |   j                  |      S )z"Implementation of jnp.multiply.at.r   )r"   r3   r   r   r   rJ   mulr   s      r'   _multiply_atr     su    WW_	A  D)009A44=Q&&t,,44=Qr)   r:   c                   t        d| |      \  } }| j                  t        k7  rt        j                  | |      S t        j
                  | |      S )a  Multiply two arrays element-wise.

  JAX implementation of :obj:`numpy.multiply`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.
  This function provides the implementation of the ``*`` operator for
  JAX arrays.

  Args:
    x, y: arrays to multiply. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise multiplication.

  Examples:
    Calling ``multiply`` explicitly:

    >>> x = jnp.arange(4)
    >>> jnp.multiply(x, 10)
    Array([ 0, 10, 20, 30], dtype=int32)

    Calling ``multiply`` via the ``*`` operator:

    >>> x * 10
    Array([ 0, 10, 20, 30], dtype=int32)
  multiply)r   r"   r3   r   r   bitwise_andr%   r   s     r'   r   r     s@    6 
j!Q	'$!Q''T/ADsq!/DDr)   )rG   rH   c               <    t        j                  t        d| |       S )a  Compute the bitwise AND operation elementwise.

  JAX implementation of :obj:`numpy.bitwise_and`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.
  This function provides the implementation of the ``&`` operator for
  JAX arrays.

  Args:
    x, y: integer or boolean arrays. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise bitwise AND.

  Examples:
    Calling ``bitwise_and`` explicitly:

    >>> x = jnp.arange(4)
    >>> jnp.bitwise_and(x, 1)
    Array([0, 1, 0, 1], dtype=int32)

    Calling ``bitwise_and`` via the ``&`` operator:

    >>> x & 1
    Array([0, 1, 0, 1], dtype=int32)
  r   )r   r   r   r   s     r'   r   r         6 
,}a;	<<r)   c               <    t        j                  t        d| |       S )a  Compute the bitwise OR operation elementwise.

  JAX implementation of :obj:`numpy.bitwise_or`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.
  This function provides the implementation of the ``|`` operator for
  JAX arrays.

  Args:
    x, y: integer or boolean arrays. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise bitwise OR.

  Examples:
    Calling ``bitwise_or`` explicitly:

    >>> x = jnp.arange(4)
    >>> jnp.bitwise_or(x, 1)
    Array([1, 1, 3, 3], dtype=int32)

    Calling ``bitwise_or`` via the ``|`` operator:

    >>> x | 1
    Array([1, 1, 3, 3], dtype=int32)
  r   )r   r   r   r   s     r'   r   r   !  s    6 
lAq9	::r)   c               <    t        j                  t        d| |       S )a  Compute the bitwise XOR operation elementwise.

  JAX implementation of :obj:`numpy.bitwise_xor`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.
  This function provides the implementation of the ``^`` operator for
  JAX arrays.

  Args:
    x, y: integer or boolean arrays. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise bitwise XOR.

  Examples:
    Calling ``bitwise_xor`` explicitly:

    >>> x = jnp.arange(4)
    >>> jnp.bitwise_xor(x, 1)
    Array([1, 0, 3, 2], dtype=int32)

    Calling ``bitwise_xor`` via the ``^`` operator:

    >>> x ^ 1
    Array([1, 0, 3, 2], dtype=int32)
  bitwise_xor)r   r   r   r   s     r'   r   r   ?  r   r)   c               <    t        j                  t        d| |       S )aU  Shift bits of ``x`` to left by the amount specified in ``y``, element-wise.

  JAX implementation of :obj:`numpy.left_shift`.

  Args:
    x: Input array, must be integer-typed.
    y: The amount of bits to shift each element in ``x`` to the left, only accepts
      integer subtypes. ``x`` and ``y`` must either have same shape or be broadcast
      compatible.

  Returns:
    An array containing the left shifted elements of ``x`` by the amount specified
    in ``y``, with the same shape as the broadcasted shape of ``x`` and ``y``.

  Note:
    Left shifting ``x`` by ``y`` is equivalent to ``x * (2**y)`` within the
    bounds of the dtypes involved.

  See also:
    - :func:`jax.numpy.right_shift`: and :func:`jax.numpy.bitwise_right_shift`:
      Shifts the bits of ``x1`` to right by the amount specified in ``x2``,
      element-wise.
    - :func:`jax.numpy.bitwise_left_shift`: Alias of :func:`jax.left_shift`.

  Examples:
    >>> def print_binary(x):
    ...   return [bin(int(val)) for val in x]

    >>> x1 = jnp.arange(5)
    >>> x1
    Array([0, 1, 2, 3, 4], dtype=int32)
    >>> print_binary(x1)
    ['0b0', '0b1', '0b10', '0b11', '0b100']
    >>> x2 = 1
    >>> result = jnp.left_shift(x1, x2)
    >>> result
    Array([0, 2, 4, 6, 8], dtype=int32)
    >>> print_binary(result)
    ['0b0', '0b10', '0b100', '0b110', '0b1000']

    >>> x3 = 4
    >>> print_binary([x3])
    ['0b100']
    >>> x4 = jnp.array([1, 2, 3, 4])
    >>> result1 = jnp.left_shift(x3, x4)
    >>> result1
    Array([ 8, 16, 32, 64], dtype=int32)
    >>> print_binary(result1)
    ['0b1000', '0b10000', '0b100000', '0b1000000']
  
left_shiftr   
shift_leftr   r   s     r'   r   r   ]  s    j 
-lAqA	BBr)   c               <    t        j                  t        d| |       S )z&Alias of :func:`jax.numpy.left_shift`.bitwise_left_shiftr   r   s     r'   r   r     s     
-.BAqI	JJr)   c               <    t        j                  t        d| |       S )a*  Returns element-wise truth value of ``x == y``.

  JAX implementation of :obj:`numpy.equal`. This function provides the implementation
  of the ``==`` operator for JAX arrays.

  Args:
    x: input array or scalar.
    y: input array or scalar. ``x`` and ``y`` should either have same shape or be
      broadcast compatible.

  Returns:
    A boolean array containing ``True`` where the elements of ``x == y`` and
    ``False`` otherwise.

  See also:
    - :func:`jax.numpy.not_equal`: Returns element-wise truth value of ``x != y``.
    - :func:`jax.numpy.greater_equal`: Returns element-wise truth value of
      ``x >= y``.
    - :func:`jax.numpy.less_equal`: Returns element-wise truth value of ``x <= y``.
    - :func:`jax.numpy.greater`: Returns element-wise truth value of ``x > y``.
    - :func:`jax.numpy.less`: Returns element-wise truth value of ``x < y``.

  Examples:
    >>> jnp.equal(0., -0.)
    Array(True, dtype=bool, weak_type=True)
    >>> jnp.equal(1, 1.)
    Array(True, dtype=bool, weak_type=True)
    >>> jnp.equal(5, jnp.array(5))
    Array(True, dtype=bool, weak_type=True)
    >>> jnp.equal(2, -2)
    Array(False, dtype=bool, weak_type=True)
    >>> x = jnp.array([[1, 2, 3],
    ...                [4, 5, 6],
    ...                [7, 8, 9]])
    >>> y = jnp.array([1, 5, 9])
    >>> jnp.equal(x, y)
    Array([[ True, False, False],
           [False,  True, False],
           [False, False,  True]], dtype=bool)
    >>> x == y
    Array([[ True, False, False],
           [False,  True, False],
           [False, False,  True]], dtype=bool)
  equal)r   eqr   r   s     r'   r   r     s    ^ 
gq!,	--r)   c               <    t        j                  t        d| |       S )a@  Returns element-wise truth value of ``x != y``.

  JAX implementation of :obj:`numpy.not_equal`. This function provides the
  implementation of the ``!=`` operator for JAX arrays.

  Args:
    x: input array or scalar.
    y: input array or scalar. ``x`` and ``y`` should either have same shape or be
      broadcast compatible.

  Returns:
    A boolean array containing ``True`` where the elements of ``x != y`` and
    ``False`` otherwise.

  See also:
    - :func:`jax.numpy.equal`: Returns element-wise truth value of ``x == y``.
    - :func:`jax.numpy.greater_equal`: Returns element-wise truth value of
      ``x >= y``.
    - :func:`jax.numpy.less_equal`: Returns element-wise truth value of ``x <= y``.
    - :func:`jax.numpy.greater`: Returns element-wise truth value of ``x > y``.
    - :func:`jax.numpy.less`: Returns element-wise truth value of ``x < y``.

  Examples:
    >>> jnp.not_equal(0., -0.)
    Array(False, dtype=bool, weak_type=True)
    >>> jnp.not_equal(-2, 2)
    Array(True, dtype=bool, weak_type=True)
    >>> jnp.not_equal(1, 1.)
    Array(False, dtype=bool, weak_type=True)
    >>> jnp.not_equal(5, jnp.array(5))
    Array(False, dtype=bool, weak_type=True)
    >>> x = jnp.array([[1, 2, 3],
    ...                [4, 5, 6],
    ...                [7, 8, 9]])
    >>> y = jnp.array([1, 5, 9])
    >>> jnp.not_equal(x, y)
    Array([[False,  True,  True],
           [ True, False,  True],
           [ True,  True, False]], dtype=bool)
    >>> x != y
    Array([[False,  True,  True],
           [ True, False,  True],
           [ True,  True, False]], dtype=bool)
  	not_equal)r   r4   r   r   s     r'   r   r     s    ^ 
k1a0	11r)   c                >    | j                   |   j                  |      S )z"Implementation of jnp.subtract.at.)rJ   subtractr   s      r'   _subtract_atr      s    	
g			""r)   )rG   rJ   c               j    t        j                  t        d| |       }t        j                  |       |S )a  Subtract two arrays element-wise.

  JAX implementation of :obj:`numpy.subtract`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.
  This function provides the implementation of the ``-`` operator for
  JAX arrays.

  Args:
    x, y: arrays to subtract. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise subtraction.

  Examples:
    Calling ``subtract`` explicitly:

    >>> x = jnp.arange(4)
    >>> jnp.subtract(x, 10)
    Array([-10,  -9,  -8,  -7], dtype=int32)

    Calling ``subtract`` via the ``-`` operator:

    >>> x - 10
    Array([-10,  -9,  -8,  -7], dtype=int32)
  r   )r   subr   rr   rs   r   s      r'   r   r     s.    6 	j!Q/0#c"	*r)   c               <    t        j                  t        d| |       S )a  Compute the arctangent of x1/x2, choosing the correct quadrant.

  JAX implementation of :func:`numpy.arctan2`

  Args:
    x1: numerator array.
    x2: denomniator array; should be broadcast-compatible with x1.

  Returns:
    The elementwise arctangent of x1 / x2, tracking the correct quadrant.

  See also:
    - :func:`jax.numpy.tan`: compute the tangent of an angle
    - :func:`jax.numpy.atan2`: the array API version of this function.

  Examples:
    Consider a sequence of angles in radians between 0 and :math:`2\pi`:

    >>> theta = jnp.linspace(-jnp.pi, jnp.pi, 9)
    >>> with jnp.printoptions(precision=2, suppress=True):
    ...   print(theta)
    [-3.14 -2.36 -1.57 -0.79  0.    0.79  1.57  2.36  3.14]

    These angles can equivalently be represented by ``(x, y)`` coordinates
    on a unit circle:

    >>> x, y = jnp.cos(theta), jnp.sin(theta)

    To reconstruct the input angle, we might be tempted to use the identity
    :math:`\tan(\theta) = y / x`, and compute :math:`\theta = \tan^{-1}(y/x)`.
    Unfortunately, this does not recover the input angle:

    >>> with jnp.printoptions(precision=2, suppress=True):
    ...   print(jnp.arctan(y / x))
    [-0.    0.79  1.57 -0.79  0.    0.79  1.57 -0.79  0.  ]

    The problem is that :math:`y/x` contains some ambiguity: although
    :math:`(y, x) = (-1, -1)` and :math:`(y, x) = (1, 1)` represent different points in
    Cartesian space, in both cases :math:`y / x = 1`, and so the simple arctan
    approach loses information about which quadrant the angle lies in. :func:`arctan2`
    is built to address this:

    >>> with jnp.printoptions(precision=2, suppress=True):
    ...  print(jnp.arctan2(y, x))
    [ 3.14 -2.36 -1.57 -0.79  0.    0.79  1.57  2.36 -3.14]

    The results match the input ``theta``, except at the endpoints where :math:`+\pi`
    and :math:`-\pi` represent indistinguishable points on the unit circle. By convention,
    :func:`arctan2` always returns values between :math:`-\pi` and :math:`+\pi` inclusive.
  arctan2)r   atan2r   x1x2s     r'   r   r   %  s    j 
(B;	<<r)   c               <    t        j                  t        d| |       S )a  Return element-wise minimum of the input arrays.

  JAX implementation of :obj:`numpy.minimum`.

  Args:
    x: input array or scalar.
    y: input array or scalar. Both ``x`` and ``y`` should either have same shape
      or be broadcast compatible.

  Returns:
    An array containing the element-wise minimum of ``x`` and ``y``.

  Note:
    For each pair of elements, ``jnp.minimum`` returns:
      - smaller of the two if both elements are finite numbers.
      - ``nan`` if one element is ``nan``.

  See also:
    - :func:`jax.numpy.maximum`: Returns element-wise maximum of the input arrays.
    - :func:`jax.numpy.fmin`: Returns element-wise minimum of the input arrays,
      ignoring NaNs.
    - :func:`jax.numpy.amin`: Returns the minimum of array elements along a given
      axis.
    - :func:`jax.numpy.nanmin`: Returns the minimum of the array elements along
      a given axis, ignoring NaNs.

  Examples:
    Inputs with ``x.shape == y.shape``:

    >>> x = jnp.array([2, 3, 5, 1])
    >>> y = jnp.array([-3, 6, -4, 7])
    >>> jnp.minimum(x, y)
    Array([-3,  3, -4,  1], dtype=int32)

    Inputs having broadcast compatibility:

    >>> x1 = jnp.array([[1, 5, 2],
    ...                 [-3, 4, 7]])
    >>> y1 = jnp.array([-2, 3, 6])
    >>> jnp.minimum(x1, y1)
    Array([[-2,  3,  2],
           [-3,  3,  6]], dtype=int32)

    Inputs with ``nan``:

    >>> nan = jnp.nan
    >>> x2 = jnp.array([[2.5, nan, -2],
    ...                 [nan, 5, 6],
    ...                 [-4, 3, 7]])
    >>> y2 = jnp.array([1, nan, 5])
    >>> jnp.minimum(x2, y2)
    Array([[ 1., nan, -2.],
           [nan, nan,  5.],
           [-4., nan,  5.]], dtype=float32)
  minimum)r   minr   r   s     r'   r   r   ]  s    r 
,y!Q/	00r)   c               <    t        j                  t        d| |       S )a`  Return element-wise maximum of the input arrays.

  JAX implementation of :obj:`numpy.maximum`.

  Args:
    x: input array or scalar.
    y: input array or scalar. Both ``x`` and ``y`` should either have same shape
      or be broadcast compatible.

  Returns:
    An array containing the element-wise maximum of ``x`` and ``y``.

  Note:
    For each pair of elements, ``jnp.maximum`` returns:
      - larger of the two if both elements are finite numbers.
      - ``nan`` if one element is ``nan``.

  See also:
    - :func:`jax.numpy.minimum`: Returns element-wise minimum of the input
      arrays.
    - :func:`jax.numpy.fmax`: Returns element-wise maximum of the input arrays,
      ignoring NaNs.
    - :func:`jax.numpy.amax`: Returns the maximum of array elements along a given
      axis.
    - :func:`jax.numpy.nanmax`: Returns the maximum of the array elements along
      a given axis, ignoring NaNs.

  Examples:
    Inputs with ``x.shape == y.shape``:

    >>> x = jnp.array([1, -5, 3, 2])
    >>> y = jnp.array([-2, 4, 7, -6])
    >>> jnp.maximum(x, y)
    Array([1, 4, 7, 2], dtype=int32)

    Inputs with broadcast compatibility:

    >>> x1 = jnp.array([[-2, 5, 7, 4],
    ...                 [1, -6, 3, 8]])
    >>> y1 = jnp.array([-5, 3, 6, 9])
    >>> jnp.maximum(x1, y1)
    Array([[-2,  5,  7,  9],
           [ 1,  3,  6,  9]], dtype=int32)

    Inputs having ``nan``:

    >>> nan = jnp.nan
    >>> x2 = jnp.array([nan, -3, 9])
    >>> y2 = jnp.array([[4, -2, nan],
    ...                 [-3, -5, 10]])
    >>> jnp.maximum(x2, y2)
    Array([[nan, -2., nan],
          [nan, -3., 10.]], dtype=float32)
  maximum)r   maxr   r   s     r'   r   r     s    p 
,y!Q/	00r)   c               j    t        j                  t        d| |       }t        j                  |       |S )a  Calculate element-wise base ``x`` exponential of ``y``.

  JAX implementation of :obj:`numpy.float_power`.

  Args:
    x: scalar or array. Specifies the bases.
    y: scalar or array. Specifies the exponents. ``x`` and ``y`` should either
      have same shape or be broadcast compatible.

  Returns:
    An array containing the base ``x`` exponentials of ``y``, promoting to the
    inexact dtype.

  See also:
    - :func:`jax.numpy.exp`: Calculates element-wise exponential of the input.
    - :func:`jax.numpy.exp2`: Calculates base-2 exponential of each element of
      the input.

  Examples:
    Inputs with same shape:

    >>> x = jnp.array([3, 1, -5])
    >>> y = jnp.array([2, 4, -1])
    >>> jnp.float_power(x, y)
    Array([ 9. ,  1. , -0.2], dtype=float32)

    Inputs with broadcast compatibility:

    >>> x1 = jnp.array([[2, -4, 1],
    ...                 [-1, 2, 3]])
    >>> y1 = jnp.array([-2, 1, 4])
    >>> jnp.float_power(x1, y1)
    Array([[ 0.25, -4.  ,  1.  ],
           [ 1.  ,  2.  , 81.  ]], dtype=float32)

    ``jnp.float_power`` produces ``nan`` for negative values raised to a non-integer
    values.

    >>> jnp.float_power(-3, 1.7)
    Array(nan, dtype=float32, weak_type=True)
  float_power)r   powr   rr   rs   r   s      r'   r   r     s0    X 	%mQ:;#c"	*r)   c               <    t        j                  t        d| |       S )a  Return element-wise next floating point value after ``x`` towards ``y``.

  JAX implementation of :obj:`numpy.nextafter`.

  Args:
    x: scalar or array. Specifies the value after which the next number is found.
    y: scalar or array. Specifies the direction towards which the next number is
      found. ``x`` and ``y`` should either have same shape or be broadcast
      compatible.

  Returns:
    An array containing the next representable number of ``x`` in the direction
    of ``y``.

  Examples:
    >>> jnp.nextafter(2, 1)  # doctest: +SKIP
    Array(1.9999999, dtype=float32, weak_type=True)
    >>> x = jnp.array([3, -2, 1])
    >>> y = jnp.array([2, -1, 2])
    >>> jnp.nextafter(x, y)  # doctest: +SKIP
    Array([ 2.9999998, -1.9999999,  1.0000001], dtype=float32)
  	nextafter)r   r   r   r   s     r'   r   r     s    2 
,[!Q?	@@r)   c                  t        d|       \  }t        j                  |j                  d      rt	        d      t        |t        j                        }t        j                  |j                        j                  }|j                  dk(  rt        j                  ||      |z
  S t        j                  |t        ||            |z
  }t        |dk(  t        ||      |      S )a=  Return the spacing between ``x`` and the next adjacent number.

  JAX implementation of :func:`numpy.spacing`.

  Args:
    x: real-valued array. Integer or boolean types will be cast to float.

  Returns:
    Array of same shape as ``x`` containing spacing between each entry of
    ``x`` and its closest adjacent value.

  See also:
    - :func:`jax.numpy.nextafter`: find the next representable value.

  Examples:
    >>> x = jnp.array([0.0, 0.25, 0.5, 0.75, 1.0], dtype='float32')
    >>> jnp.spacing(x)
    Array([1.4012985e-45, 2.9802322e-08, 5.9604645e-08, 5.9604645e-08,
          1.1920929e-07], dtype=float32)

    For ``x = 1``, the spacing is equal to the ``eps`` value given by
    :class:`jax.numpy.finfo`:

    >>> x = jnp.float32(1)
    >>> jnp.spacing(x) == jnp.finfo(x.dtype).eps
    Array(True, dtype=bool)
  spacingzcomplex floatingz.jnp.spacing is not defined for complex inputs.float16r   )r   r   rk   r"   
ValueErrorr5   r#   inffinfosmallest_subnormalr   r   copysignr   )r%   arrr   r   r   s        r'   r   r   !  s    < 
i	+$#^^CII12
E
FF3#||CII.AA 	YY)==c"S((]]3c 23c9F&A+x(:C@&IIr)   c          
     X    t        j                  t        t        t	        d| |             S )a  Compute the logical AND operation elementwise.

  JAX implementation of :obj:`numpy.logical_and`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.

  Args:
    x, y: input arrays. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise logical AND.

  Examples:
    >>> x = jnp.arange(4)
    >>> jnp.logical_and(x, 1)
    Array([False,  True,  True,  True], dtype=bool)
  logical_and)r   r   mapr6   r   r   s     r'   r   r   N  #    $ 
#h]Aq(IJ	KKr)   Fc          
     X    t        j                  t        t        t	        d| |             S )a  Compute the logical OR operation elementwise.

  JAX implementation of :obj:`numpy.logical_or`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.

  Args:
    x, y: input arrays. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise logical OR.

  Examples:
    >>> x = jnp.arange(4)
    >>> jnp.logical_or(x, 1)
    Array([ True,  True,  True,  True], dtype=bool)
  
logical_or)r   r   r   r6   r   r   s     r'   r   r   c  s#    $ 
X|L!Q'GH	IIr)   c          
     X    t        j                  t        t        t	        d| |             S )a  Compute the logical XOR operation elementwise.

  JAX implementation of :obj:`numpy.logical_xor`. This is a universal function,
  and supports the additional APIs described at :class:`jax.numpy.ufunc`.

  Args:
    x, y: input arrays. Must be broadcastable to a common shape.

  Returns:
    Array containing the result of the element-wise logical XOR.

  Examples:
    >>> x = jnp.arange(4)
    >>> jnp.logical_xor(x, 1)
    Array([ True, False, False, False], dtype=bool)
  logical_xor)r   r   r   r6   r   r   s     r'   r   r   x  r   r)   c          	     V    t        j                  t        t        t	        d|              S )a\  Compute NOT bool(x) element-wise.

  JAX implementation of :func:`numpy.logical_not`.

  Args:
    x: input array of any dtype.

  Returns:
    A boolean array that computes NOT bool(x) element-wise

  See also:
    - :func:`jax.numpy.invert` or :func:`jax.numpy.bitwise_invert`: bitwise NOT operation

  Examples:
    Compute NOT x element-wise on a boolean array:

    >>> x = jnp.array([True, False, True])
    >>> jnp.logical_not(x)
    Array([False,  True, False], dtype=bool)

    For boolean input, this is equivalent to :func:`~jax.numpy.invert`, which implements
    the unary ``~`` operator:

    >>> ~x
    Array([False,  True, False], dtype=bool)

    For non-boolean input, the input of :func:`logical_not` is implicitly cast to boolean:

    >>> x = jnp.array([-1, 0, 1])
    >>> jnp.logical_not(x)
    Array([False,  True, False], dtype=bool)
  logical_not)r   r[   r   r6   r   r0   s    r'   r   r     s"    F 
#h]A(FG	HHr)   c                Z   t        j                  |j                  t        j                        rut        j                  t        j                  |j                  |j                         | |j                  |j                         | |j                  |j                              S  | ||      S r+   )
r   rS   r"   r#   rT   r   r,   r   r.   imag)lax_opr%   r   s      r'   _complex_comparisonr     st    qww 2 23::cffQVVQVV,QVVQVV,QVVQVV,. . 
1r)   c               L    t        t        j                  gt        d| |       S )a  Return element-wise truth value of ``x >= y``.

  JAX implementation of :obj:`numpy.greater_equal`.

  Args:
    x: input array or scalar.
    y: input array or scalar. ``x`` and ``y`` must either have same shape or be
      broadcast compatible.

  Returns:
    An array containing boolean values. ``True`` if the elements of ``x >= y``,
    and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.less_equal`: Returns element-wise truth value of ``x <= y``.
    - :func:`jax.numpy.greater`: Returns element-wise truth value of ``x > y``.
    - :func:`jax.numpy.less`: Returns element-wise truth value of ``x < y``.

  Examples:
    Scalar inputs:

    >>> jnp.greater_equal(4, 7)
    Array(False, dtype=bool, weak_type=True)

    Inputs with same shape:

    >>> x = jnp.array([2, 5, -1])
    >>> y = jnp.array([-6, 4, 3])
    >>> jnp.greater_equal(x, y)
    Array([ True,  True, False], dtype=bool)

    Inputs with broadcast compatibility:

    >>> x1 = jnp.array([[3, -1, 4],
    ...                 [5, 9, -6]])
    >>> y1 = jnp.array([-1, 4, 2])
    >>> jnp.greater_equal(x1, y1)
    Array([[ True, False,  True],
           [ True,  True, False]], dtype=bool)
  greater_equal)r   r   ger   r   s     r'   r   r     s"    V 
SVV	Jl?Aq&I	JJr)   c               L    t        t        j                  gt        d| |       S )a  Return element-wise truth value of ``x > y``.

  JAX implementation of :obj:`numpy.greater`.

  Args:
    x: input array or scalar.
    y: input array or scalar. ``x`` and ``y`` must either have same shape or be
      broadcast compatible.

  Returns:
    An array containing boolean values. ``True`` if the elements of ``x > y``,
    and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.less`: Returns element-wise truth value of ``x < y``.
    - :func:`jax.numpy.greater_equal`: Returns element-wise truth value of
      ``x >= y``.
    - :func:`jax.numpy.less_equal`: Returns element-wise truth value of ``x <= y``.

  Examples:
    Scalar inputs:

    >>> jnp.greater(5, 2)
    Array(True, dtype=bool, weak_type=True)

    Inputs with same shape:

    >>> x = jnp.array([5, 9, -2])
    >>> y = jnp.array([4, -1, 6])
    >>> jnp.greater(x, y)
    Array([ True,  True, False], dtype=bool)

    Inputs with broadcast compatibility:

    >>> x1 = jnp.array([[5, -6, 7],
    ...                 [-2, 5, 9]])
    >>> y1 = jnp.array([-4, 3, 10])
    >>> jnp.greater(x1, y1)
    Array([[ True, False, False],
           [ True,  True, False]], dtype=bool)
  greater)r   r   gtr   r   s     r'   r   r     s"    X 
SVV	Dl9a&C	DDr)   c               L    t        t        j                  gt        d| |       S )a  Return element-wise truth value of ``x <= y``.

  JAX implementation of :obj:`numpy.less_equal`.

  Args:
    x: input array or scalar.
    y: input array or scalar. ``x`` and ``y`` must have either same shape or be
      broadcast compatible.

  Returns:
    An array containing the boolean values. ``True`` if the elements of ``x <= y``,
    and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.greater_equal`: Returns element-wise truth value of
      ``x >= y``.
    - :func:`jax.numpy.greater`: Returns element-wise truth value of ``x > y``.
    - :func:`jax.numpy.less`: Returns element-wise truth value of ``x < y``.

  Examples:
    Scalar inputs:

    >>> jnp.less_equal(6, -2)
    Array(False, dtype=bool, weak_type=True)

    Inputs with same shape:

    >>> x = jnp.array([-4, 1, 7])
    >>> y = jnp.array([2, -3, 8])
    >>> jnp.less_equal(x, y)
    Array([ True, False,  True], dtype=bool)

    Inputs with broadcast compatibility:

    >>> x1 = jnp.array([2, -5, 9])
    >>> y1 = jnp.array([[1, -6, 5],
    ...                 [-2, 4, -6]])
    >>> jnp.less_equal(x1, y1)
    Array([[False, False, False],
           [False,  True, False]], dtype=bool)
  
less_equal)r   r   ler   r   s     r'   r   r     s"    X 
SVV	Gl<A&F	GGr)   c               L    t        t        j                  gt        d| |       S )a  Return element-wise truth value of ``x < y``.

  JAX implementation of :obj:`numpy.less`.

  Args:
    x: input array or scalar.
    y: input array or scalar. ``x`` and ``y`` must either have same shape or be
      broadcast compatible.

  Returns:
    An array containing boolean values. ``True`` if the elements of ``x < y``,
    and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.greater`: Returns element-wise truth value of ``x > y``.
    - :func:`jax.numpy.greater_equal`: Returns element-wise truth value of
      ``x >= y``.
    - :func:`jax.numpy.less_equal`: Returns element-wise truth value of ``x <= y``.

  Examples:
    Scalar inputs:

    >>> jnp.less(3, 7)
    Array(True, dtype=bool, weak_type=True)

    Inputs with same shape:

    >>> x = jnp.array([5, 9, -3])
    >>> y = jnp.array([1, 6, 4])
    >>> jnp.less(x, y)
    Array([False, False,  True], dtype=bool)

    Inputs with broadcast compatibility:

    >>> x1 = jnp.array([[2, -4, 6, -8],
    ...                 [-1, 5, -3, 7]])
    >>> y1 = jnp.array([0, 3, -5, 9])
    >>> jnp.less(x1, y1)
    Array([[False,  True, False,  True],
           [ True, False, False,  True]], dtype=bool)
  less)r   r   ltr   r   s     r'   r   r   H  s"    X 
SVV	Al61a&@	AAr)   c               &    t        t        d|        S )z!Alias of :func:`jax.numpy.arccos`r   )r   r   r0   s    r'   r   r   x       
fa(	))r)   c               &    t        t        d|        S )z"Alias of :func:`jax.numpy.arccosh`r   )r   r   r0   s    r'   r   r          
,w*	++r)   c               &    t        t        d|        S )z!Alias of :func:`jax.numpy.arcsin`r   )r   r   r0   s    r'   r   r     r   r)   c               &    t        t        d|        S )z"Alias of :func:`jax.numpy.arcsinh`r   )r   r   r0   s    r'   r   r     r  r)   c               &    t        t        d|        S )z!Alias of :func:`jax.numpy.arctan`r   )r   r   r0   s    r'   r   r     r   r)   c               &    t        t        d|        S )z"Alias of :func:`jax.numpy.arctanh`r   )r   r   r0   s    r'   r   r     r  r)   c               (    t        t        d| |       S )z"Alias of :func:`jax.numpy.arctan2`r   )r   r   r   s     r'   r   r     s     
,wB/	00r)   c               x    t        d|       \  } t        j                  t        |             j	                  d      S )a  Counts the number of 1 bits in the binary representation of the absolute value
  of each element of ``x``.

  JAX implementation of :obj:`numpy.bitwise_count`.

  Args:
    x: Input array, only accepts integer subtypes

  Returns:
    An array-like object containing the binary 1 bit counts of the absolute value of
    each element in ``x``, with the same shape as ``x`` of dtype uint8.

  Examples:
    >>> x1 = jnp.array([64, 32, 31, 20])
    >>> # 64 = 0b1000000, 32 = 0b100000, 31 = 0b11111, 20 = 0b10100
    >>> jnp.bitwise_count(x1)
    Array([1, 1, 5, 2], dtype=uint8)

    >>> x2 = jnp.array([-16, -7, 7])
    >>> # |-16| = 0b10000, |-7| = 0b111, 7 = 0b111
    >>> jnp.bitwise_count(x2)
    Array([1, 3, 3], dtype=uint8)

    >>> x3 = jnp.array([[2, -7],[-9, 7]])
    >>> # 2 = 0b10, |-7| = 0b111, |-9| = 0b1001, 7 = 0b111
    >>> jnp.bitwise_count(x3)
    Array([[1, 3],
           [2, 3]], dtype=uint8)
  bitwise_countuint8)r   r   population_countrV   r   r0   s    r'   r  r    s3    @ OQ/"!			c!f	%	,	,W	55r)   c                   t        t        j                  j                  | |      \  } }t        j                  | j
                  t        j                        rt        j                  nt        j                  } || |      S )aI  Right shift the bits of ``x1`` to the amount specified in ``x2``.

  JAX implementation of :obj:`numpy.right_shift`.

  Args:
    x1: Input array, only accepts unsigned integer subtypes
    x2: The amount of bits to shift each element in ``x1`` to the right, only accepts
      integer subtypes

  Returns:
    An array-like object containing the right shifted elements of ``x1`` by the
    amount specified in ``x2``, with the same shape as the broadcasted shape of
    ``x1`` and ``x2``.

  Note:
    If ``x1.shape != x2.shape``, they must be compatible for broadcasting to a
    shared shape, this shared shape will also be the shape of the output. Right shifting
    a scalar x1 by scalar x2 is equivalent to ``x1 // 2**x2``.

  Examples:
    >>> def print_binary(x):
    ...   return [bin(int(val)) for val in x]

    >>> x1 = jnp.array([1, 2, 4, 8])
    >>> print_binary(x1)
    ['0b1', '0b10', '0b100', '0b1000']
    >>> x2 = 1
    >>> result = jnp.right_shift(x1, x2)
    >>> result
    Array([0, 1, 2, 4], dtype=int32)
    >>> print_binary(result)
    ['0b0', '0b1', '0b10', '0b100']

    >>> x1 = 16
    >>> print_binary([x1])
    ['0b10000']
    >>> x2 = jnp.array([1, 2, 3, 4])
    >>> result = jnp.right_shift(x1, x2)
    >>> result
    Array([8, 4, 2, 1], dtype=int32)
    >>> print_binary(result)
    ['0b1000', '0b100', '0b10', '0b1']
  )
r   r#   right_shiftr@   rS   r"   unsignedintegerr   shift_right_logicalshift_right_arithmetic)r   r   lax_fns      r'   r  r    s^    \   7 7R@&"bMM"((B../ ""585O5O 		Br)   c                   t        | |      S )z'Alias of :func:`jax.numpy.right_shift`.)r  r   s     r'   bitwise_right_shiftr  	  s     
R	r)   c                  t        d|       } t        j                  |       }|t        j                  k(  s$t        j
                  |t        j                        rt        j                  |       S t        j                  |       S )a  Calculate the absolute value element-wise.

  JAX implementation of :obj:`numpy.absolute`.

  This is the same function as :func:`jax.numpy.abs`.

  Args:
    x: Input array

  Returns:
    An array-like object containing the absolute value of each element in ``x``,
    with the same shape as ``x``. For complex valued input, :math:`a + ib`,
    the absolute value is :math:`\sqrt{a^2+b^2}`.

  Examples:
    >>> x1 = jnp.array([5, -2, 0, 12])
    >>> jnp.absolute(x1)
    Array([ 5,  2,  0, 12], dtype=int32)

    >>> x2 = jnp.array([[ 8, -3, 1],[ 0, 9, -6]])
    >>> jnp.absolute(x2)
    Array([[8, 3, 1],
           [0, 9, 6]], dtype=int32)

    >>> x3 = jnp.array([8 + 15j, 3 - 4j, -5 + 0j])
    >>> jnp.absolute(x3)
    Array([17.,  5.,  5.], dtype=float32)
  absolute)
r   r   r"   r#   bool_rS   r  r   rd   rV   )r%   dts     r'   r  r  		  s\    > z1%!||A">V->->r2CUCU-VQf\_\c\cde\ffr)   c                   t        |       S )z$Alias of :func:`jax.numpy.absolute`.)r  r0   s    r'   rV   rV   -	  s     
!r)   c               &   t        d|       } t        j                  |       }|t        k(  s$t        j                  |t
        j                        r$t        j                  | t        j                        S t        j                  |t
        j                        rNt        j                  t        t        j                  |             t        t        j                  |                   S t        j                  | t        j                   j"                        S )a  Rounds the elements of x to the nearest integer

  JAX implementation of :obj:`numpy.rint`.

  Args:
    x: Input array

  Returns:
    An array-like object containing the rounded elements of ``x``. Always promotes
    to inexact.

  Note:
    If an element of x is exactly half way, e.g. ``0.5`` or ``1.5``, rint will round
    to the nearest even integer.

  Examples:
    >>> x1 = jnp.array([5, 4, 7])
    >>> jnp.rint(x1)
    Array([5., 4., 7.], dtype=float32)

    >>> x2 = jnp.array([-2.5, -1.5, -0.5, 0.5, 1.5, 2.5, 3.5, 4.5])
    >>> jnp.rint(x2)
    Array([-2., -2., -0.,  0.,  2.,  2.,  4.,  4.], dtype=float32)

    >>> x3 = jnp.array([-2.5+3.5j, 4.5-0.5j])
    >>> jnp.rint(x3)
    Array([-2.+4.j,  4.-0.j], dtype=complex64)
  rint)r   r   r"   r3   rS   r#   integerr   r   float_rT   complexr  r.   r   roundRoundingMethodTO_NEAREST_EVENr%   r"   s     r'   r  r  4	  s    > vq!!
,,q/%
d]f''rzz:##Av}}55ub001;;tCHHQK($sxx{*;<<	1c((88	99r)   c               F   t        d| |      \  } }t        j                  t        j                  |       t        j
                        rt        d      t        t        |      j                  t              t        j                  |        t        j                  |             S )a  Copies the sign of each element in ``x2`` to the corresponding element in ``x1``.

  JAX implementation of :obj:`numpy.copysign`.

  Args:
    x1: Input array
    x2: The array whose elements will be used to determine the sign, must be
      broadcast-compatible with ``x1``

  Returns:
    An array object containing the potentially changed elements of ``x1``, always promotes
    to inexact dtype, and has a shape of ``jnp.broadcast_shapes(x1.shape, x2.shape)``

  Examples:
    >>> x1 = jnp.array([5, 2, 0])
    >>> x2 = -1
    >>> jnp.copysign(x1, x2)
    Array([-5., -2., -0.], dtype=float32)

    >>> x1 = jnp.array([6, 8, 0])
    >>> x2 = 2
    >>> jnp.copysign(x1, x2)
    Array([6., 8., 0.], dtype=float32)

    >>> x1 = jnp.array([2, -3])
    >>> x2 = jnp.array([[1],[-4], [5]])
    >>> jnp.copysign(x1, x2)
    Array([[ 2.,  3.],
           [-2., -3.],
           [ 2.,  3.]], dtype=float32)
  r   z/copysign does not support complex-valued inputs)r   r   rS   r"   r#   rT   rU   r   signbitr   r3   r   rV   r   s     r'   r   r   \	  sr    D  
B3&"bv||B'););<
E
FF	""4(3772;,	DDr)   c                   t        d| |      \  } }t        j                  |       t        j                  | |      }t        j
                  |       |S )a=  Calculates the division of x1 by x2 element-wise

  JAX implementation of :func:`numpy.true_divide`.

  Args:
    x1: Input array, the dividend
    x2: Input array, the divisor

  Returns:
    An array containing the elementwise quotients, will always use
    floating point division.

  Examples:
    >>> x1 = jnp.array([3, 4, 5])
    >>> x2 = 2
    >>> jnp.true_divide(x1, x2)
    Array([1.5, 2. , 2.5], dtype=float32)

    >>> x1 = 24
    >>> x2 = jnp.array([3, 4, 6j])
    >>> jnp.true_divide(x1, x2)
    Array([8.+0.j, 6.+0.j, 0.-4.j], dtype=complex64)

    >>> x1 = jnp.array([1j, 9+5j, -4+2j])
    >>> x2 = 3j
    >>> jnp.true_divide(x1, x2)
    Array([0.33333334+0.j       , 1.6666666 -3.j       ,
           0.6666667 +1.3333334j], dtype=complex64)

  See Also:
    :func:`jax.numpy.floor_divide` for integer division
  true_divide)r   rr   _set_error_if_divide_by_zeror   divrs   r   r   ru   s      r'   r$  r$  	  sG    F  r26&"b((,B#c"	*r)   c                   t        | |      S )z'Alias of :func:`jax.numpy.true_divide`.)r$  r   s     r'   divider)  	  s     
R	r)   c                  t        d| |      \  } }t        j                  |       t        j                  |       }t        j
                  |t        j                        rt        j                  | |      S t        j
                  |t        j                        rrt        j                  | |      }t        t        j                  |       t        j                  |      k7  t        j                  | |      dk7        }t        ||dz
  |      S t        j
                  |t        j                        rt!        d      t#        | |      d   S )aM  Calculates the floor division of x1 by x2 element-wise

  JAX implementation of :obj:`numpy.floor_divide`.

  Args:
    x1: Input array, the dividend
    x2: Input array, the divisor

  Returns:
    An array-like object containing each of the quotients rounded down
    to the nearest integer towards negative infinity. This is equivalent
    to ``x1 // x2`` in Python.

  Note:
    ``x1 // x2`` is equivalent to ``jnp.floor_divide(x1, x2)`` for arrays ``x1``
    and ``x2``

  See Also:
    :func:`jax.numpy.divide` and :func:`jax.numpy.true_divide` for floating point
    division.

  Examples:
    >>> x1 = jnp.array([10, 20, 30])
    >>> x2 = jnp.array([3, 4, 7])
    >>> jnp.floor_divide(x1, x2)
    Array([3, 5, 4], dtype=int32)

    >>> x1 = jnp.array([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5])
    >>> x2 = 3
    >>> jnp.floor_divide(x1, x2)
    Array([-2, -2, -1, -1, -1,  0,  0,  0,  1,  1,  1], dtype=int32)

    >>> x1 = jnp.array([6, 6, 6], dtype=jnp.int32)
    >>> x2 = jnp.array([2.0, 2.5, 3.0], dtype=jnp.float32)
    >>> jnp.floor_divide(x1, x2)
    Array([3., 2., 2.], dtype=float32)
  floor_divider   r:   z3floor_divide does not support complex-valued inputs)r   rr   r%  r   r"   rS   r#   r  r   r&  r  r   rf   remr   rT   rU   _float_divmod)r   r   r"   quotientr,   s        r'   r+  r+  	  s    P  B7&"b((,
,,r
%ub001772r?

+wwr2H""5swwr2!7KLF&(Q,11 2 23
I
JJR ##r)   c                  t        d| |      \  } }t        j                  t        j                  |       t        j
                        rt        | |      t        | |      fS t        j                  |       t        | |      S )a  Calculates the integer quotient and remainder of x1 by x2 element-wise

  JAX implementation of :obj:`numpy.divmod`.

  Args:
    x1: Input array, the dividend
    x2: Input array, the divisor

  Returns:
    A tuple of arrays ``(x1 // x2, x1 % x2)``.

  See Also:
    - :func:`jax.numpy.floor_divide`: floor division function
    - :func:`jax.numpy.remainder`: remainder function

  Examples:
    >>> x1 = jnp.array([10, 20, 30])
    >>> x2 = jnp.array([3, 4, 7])
    >>> jnp.divmod(x1, x2)
    (Array([3, 5, 4], dtype=int32), Array([1, 0, 2], dtype=int32))

    >>> x1 = jnp.array([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5])
    >>> x2 = 3
    >>> jnp.divmod(x1, x2)
    (Array([-2, -2, -1, -1, -1,  0,  0,  0,  1,  1,  1], dtype=int32),
     Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2], dtype=int32))

    >>> x1 = jnp.array([6, 6, 6], dtype=jnp.int32)
    >>> x2 = jnp.array([1.9, 2.5, 3.1], dtype=jnp.float32)
    >>> jnp.divmod(x1, x2)
    (Array([3., 2., 1.], dtype=float32),
     Array([0.30000007, 1.        , 2.9       ], dtype=float32))
  divmod)r   r   rS   r"   r#   r  r+  	remainderrr   r%  r-  r   s     r'   r0  r0  	  sh    H  "b1&"bv||B'4B2r!222**2.R  r)   c                   t        j                  | |      }t        j                  t        j                  | |      |      }t        j                  |dk7  t        j
                  |      t        j
                  |      k7        }t        j                  |||z   |      }t        j                  ||t        |d      z
  |      }t        j                  |      |fS )Nr   r:   )	r   r,  r&  r   r   rf   r,   r(   r  )r   r   modr&  inds        r'   r-  r-  
  s    B#C "%#q#((2,#((3-"?@#

3b#&#

3nS!44c:#	3	r)   c                  t        d| |       t        | d      r| j                         n| } t        |d      r|j                         n|}t        d| |       t	        j
                  |      r9	 t        j                  |      }t        |       \  } t        j                  | |      S t        | |      }t        j                  |       |S # t        $ r Y .w xY w)a  Calculate element-wise base ``x1`` exponential of ``x2``.

  JAX implementation of :obj:`numpy.power`.

  Args:
    x1: scalar or array. Specifies the bases.
    x2: scalar or array. Specifies the exponent. ``x1`` and ``x2`` should either
      have same shape or be broadcast compatible.

  Returns:
    An array containing the base ``x1`` exponentials of ``x2`` with same dtype
    as input.

  Note:
    - When ``x2`` is a concrete integer scalar, ``jnp.power`` lowers to
      :func:`jax.lax.integer_pow`.
    - When ``x2`` is a traced scalar or an array, ``jnp.power`` lowers to
      :func:`jax.lax.pow`.
    - ``jnp.power`` raises a ``TypeError`` for integer type raised to a concrete
      negative integer power. For a non-concrete power, the operation is invalid
      and the returned value is implementation-defined.
    - ``jnp.power`` returns ``nan`` for negative value raised to the power of
      non-integer values.

  See also:
    - :func:`jax.lax.pow`: Computes element-wise power, :math:`x^y`.
    - :func:`jax.lax.integer_pow`: Computes element-wise power :math:`x^y`, where
      :math:`y` is a fixed integer.
    - :func:`jax.numpy.float_power`: Computes the first array raised to the power
      of second array, element-wise, by promoting to the inexact dtype.
    - :func:`jax.numpy.pow`: Computes the first array raised to the power of second
      array, element-wise.

  Examples:
    Inputs with scalar integers:

    >>> jnp.power(4, 3)
    Array(64, dtype=int32, weak_type=True)

    Inputs with same shape:

    >>> x1 = jnp.array([2, 4, 5])
    >>> x2 = jnp.array([3, 0.5, 2])
    >>> jnp.power(x1, x2)
    Array([ 8.,  2., 25.], dtype=float32)

    Inputs with broadcast compatibility:

    >>> x3 = jnp.array([-2, 3, 1])
    >>> x4 = jnp.array([[4, 1, 6],
    ...                 [1.3, 3, 5]])
    >>> jnp.power(x3, x4)
    Array([[16.,  3.,  1.],
           [nan, 27.,  1.]], dtype=float32)
  power__jax_array__)r   hasattrr7  r   r   is_concreteoperatorindexr   r   integer_powrU   _powerrr   rs   r'  s      r'   r6  r6  $
  s    r '2r" %R9rr"$R9rr"7B#  
b%>>"b #2&cb__R$$ 	r2#c"	*  
s   -C 	CCc                   t        | |      S )z Alias of :func:`jax.numpy.power`)r6  r   s     r'   r   r   
  s     
r2r)   c                   t        d| |      \  } }t        d| |      \  }}t        j                  t        j                  |      t
        j                        s7t        j                  t        j                  |      t
        j                        rCt        j                  t        j                  |            j                  dk  sJ t        ||      S t        j                  |       t        j                  |      }}t        j                  |t
        j                        r:t        j                  |t
        j                        rt        j                  | |      S t        j                  ||      S )Nr6  r   )r   r   r   rS   r"   r#   r  r  iinfobits_pow_int_intinexactr   r   )r   r   x1_x2_d1d2s         r'   r=  r=  
  s    '2r*&"b "'2r2(#sS)2::6S)288488FLL%&++r111S!! <<V\\"-b"r2::&6+<+<R+L772r? 
c	r)   c           	        d}t        |d      }t        |d      }t        t        j                  t        j                  | |      t        j
                  ||            ||      }t        |      D ]c  }t        t        j                  ||      t        j                  ||       |      }t        j                  | |       } t        j                  ||      }e |S )N   r   r:   )	r(   r   r   r   r   r4   ranger   r  )r   r   rA  zerooneacc_s          r'   rB  rB  
  s    	
$	A	$r1#ssvvb$/D1ABD#N#; *a
S)3773+;S
AC	RB		 	 S	)B* 
*r)   c               N    t        d| |      \  } }t        j                  | |      S )a  Compute ``log(exp(x1) + exp(x2))`` avoiding overflow.

  JAX implementation of :obj:`numpy.logaddexp`

  Args:
    x1: input array
    x2: input array

  Returns:
    array containing the result.

  Examples:

  >>> x1 = jnp.array([1, 2, 3])
  >>> x2 = jnp.array([4, 5, 6])
  >>> result1 = jnp.logaddexp(x1, x2)
  >>> result2 = jnp.log(jnp.exp(x1) + jnp.exp(x2))
  >>> print(jnp.allclose(result1, result2))
  True
  	logaddexp)r   	lax_otherrP  r   s     r'   rP  rP  
  s)    ,  R4&"b			R	$$r)   c               N    t        d| |      \  } }t        j                  | |      S )aJ  Logarithm of the sum of exponentials of inputs in base-2 avoiding overflow.

  JAX implementation of :obj:`numpy.logaddexp2`.

  Args:
    x1: input array or scalar.
    x2: input array or scalar. ``x1`` and ``x2`` should either have same shape or
      be broadcast compatible.

  Returns:
    An array containing the result, :math:`log_2(2^{x1}+2^{x2})`, element-wise.

  See also:
    - :func:`jax.numpy.logaddexp`: Computes ``log(exp(x1) + exp(x2))``, element-wise.
    - :func:`jax.numpy.log2`: Calculates the base-2 logarithm of ``x`` element-wise.

  Examples:
    >>> x1 = jnp.array([[3, -1, 4],
    ...                 [8, 5, -2]])
    >>> x2 = jnp.array([2, 3, -5])
    >>> result1 = jnp.logaddexp2(x1, x2)
    >>> result2 = jnp.log2(jnp.exp2(x1) + jnp.exp2(x2))
    >>> jnp.allclose(result1, result2)
    Array(True, dtype=bool)
  
logaddexp2)r   rQ  rS  r   s     r'   rS  rS  
  s)    6  b"5&"b			b"	%%r)   c          	     l   t        d|       \  } t        j                  | j                  t        j
                        rt        j                  |       }t        j                  |      }t        j                  |      }t        j                  t        |d            }t        j                  t        j                  ||      t        j                  ||            S t        j                  t        j                  |       t        j                  t        | d                  }t        j                  |       |S )a~  Calculates the base-2 logarithm of ``x`` element-wise.

  JAX implementation of :obj:`numpy.log2`.

  Args:
    x: Input array

  Returns:
    An array containing the base-2 logarithm of each element in ``x``, promotes
    to inexact dtype.

  Examples:
    >>> x1 = jnp.array([0.25, 0.5, 1, 2, 4, 8])
    >>> jnp.log2(x1)
    Array([-2., -1.,  0.,  1.,  2.,  3.], dtype=float32)
  log2rF   r   r   rS   r"   r#   rT   r   rq   r.   r   r(   r  r&  rr   rs   )r%   rreimln2ru   s         r'   rU  rU  
  s    & FA&"!qww 2 23
A	!B	!B
''.Q'
(C;;swwr3'S)9::
CGGN1a$89:#c"	*r)   c          	     l   t        d|       \  } t        j                  | j                  t        j
                        rt        j                  |       }t        j                  |      }t        j                  |      }t        j                  t        |d            }t        j                  t        j                  ||      t        j                  ||            S t        j                  t        j                  |       t        j                  t        | d                  }t        j                  |       |S )a  Calculates the base-10 logarithm of x element-wise

  JAX implementation of :obj:`numpy.log10`.

  Args:
    x: Input array

  Returns:
    An array containing the base-10 logarithm of each element in ``x``, promotes
    to inexact dtype.

  Examples:
    >>> x1 = jnp.array([0.01, 0.1, 1, 10, 100, 1000])
    >>> with jnp.printoptions(precision=2, suppress=True):
    ...   print(jnp.log10(x1))
    [-2. -1.  0.  1.  2.  3.]
  log10
   rV  )r%   rW  rX  rY  ln10ru   s         r'   r\  r\    s    ( GQ'"!qww 2 23
A	!B	!B77>"b)*D;;swwr4(#''"d*;<<
CGGN1b$9:;#c"	*r)   c               H    t        d|       \  } t        j                  |       S )ac  Calculate element-wise base-2 exponential of input.

  JAX implementation of :obj:`numpy.exp2`.

  Args:
    x: input array or scalar

  Returns:
    An array containing the base-2 exponential of each element in ``x``, promotes
    to inexact dtype.

  See also:
    - :func:`jax.numpy.log2`: Calculates base-2 logarithm of each element of input.
    - :func:`jax.numpy.exp`: Calculates exponential of each element of the input.
    - :func:`jax.numpy.expm1`: Calculates :math:`e^x-1` of each element of the
      input.

  Examples:
    ``jnp.exp2`` follows the properties of the exponential such as :math:`2^{a+b}
    = 2^a * 2^b`.

    >>> x1 = jnp.array([2, -4, 3, -1])
    >>> x2 = jnp.array([-1, 3, -2, 3])
    >>> jnp.exp2(x1+x2)
    Array([2. , 0.5, 2. , 4. ], dtype=float32)
    >>> jnp.exp2(x1)*jnp.exp2(x2)
    Array([2. , 0.5, 2. , 4. ], dtype=float32)
  exp2)r   r   r`  r0   s    r'   r`  r`  !  s     > FA&"!	!r)   c                  t        d|       \  } t        j                  |       }t        j                  |t        j
                        r t        j                  | t        | d            S t        j                  |t        j                        r&t        j                  | dt        j                        S t        j                  |t        j                        st        d|z        t        j                  |      }|j                  t        vrt!        d      t        |j                     }t        j"                  | |      } t        j$                  | |j&                  |j(                  z   z	  t        j                        S )a  Return the sign bit of array elements.

  JAX implementation of :obj:`numpy.signbit`.

  Args:
    x: input array. Complex values are not supported.

  Returns:
    A boolean array of the same shape as ``x``, containing ``True``
    where the sign of ``x`` is negative, and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.sign`: return the mathematical sign of array elements,
      i.e. ``-1``, ``0``, or ``+1``.

  Examples:
    :func:`signbit` on boolean values is always ``False``:

    >>> x = jnp.array([True, False])
    >>> jnp.signbit(x)
    Array([False, False], dtype=bool)

    :func:`signbit` on integer values is equivalent to ``x < 0``:

    >>> x = jnp.array([-2, -1, 0, 1, 2])
    >>> jnp.signbit(x)
    Array([ True,  True, False, False, False], dtype=bool)

    :func:`signbit` on floating point values returns the value of the actual
    sign bit from the float representation, including signed zero:

    >>> x = jnp.array([-1.5, -0.0, 0.0, 1.5])
    >>> jnp.signbit(x)
    Array([ True, True, False, False], dtype=bool)

    This also returns the sign bit for special values such as signed NaN
    and signed infinity:

    >>> x = jnp.array([jnp.nan, -jnp.nan, jnp.inf, -jnp.inf])
    >>> jnp.signbit(x)
    Array([False,  True, False,  True], dtype=bool)
    r"  r   Fr!   z,jax.numpy.signbit is not well defined for %sz9jax.numpy.signbit only supports 16, 32, and 64-bit types.)r   r   r"   rS   r#   r  r   r   r(   r  	full_likefloatingr   r   rA  _INT_DTYPESNotImplementedErrorbitcast_convert_typer   nexpnmant)r%   r"   infoint_types       r'   r"  r"  D  s   Z Iq!"!
,,q/%ubjj)66!^Aq)**)==E22UBKK0
6>@ @ 
e	$	YYk!
CE E#(	q(+!		!	!!		DJJ(>"?	JJr)   c           	        t        j                  t        j                  |             }t        |j                     }t        j                  |       |j                  k  }t        || t        | d|j                  z        z  |       }t        | ||j                          |d            }t        j                  ||      |fS Nr:   r   )r   r   r"   rd  rA  r   rV   tinyr   r5   rh  rf  )r%   ri  rj  condr   r   s         r'   _normalize_floatro    s    	fll1o	&$#(	dii	$dA
1a4::o66:"dHdjj[)8A;7"		!	!"h	/	33r)   c                  t        d| |      \  } }t        j                  |       }t        j                  |      }t        j                  |t        j
                        s$t        j                  |t        j                        rt        d||f       t        d|       \  } t        j                  |t        j                  |             }t        |       \  }}|j                  |j                        |z   j                  | j                        }t        |dkD  |dz  |      }t        |dkD  |dz
  |      }|d|j                  |j                        z  z  }t        t        |       | dk(  z  | |      S )a  Compute x1 * 2 ** x2

  JAX implementation of :func:`numpy.ldexp`.

  Note that XLA does not provide an ``ldexp`` operation, so this
  is implemneted in JAX via a standard multiplication and
  exponentiation.

  Args:
    x1: real-valued input array.
    x2: integer input array. Must be broadcast-compatible with ``x1``.

  Returns:
    ``x1 * 2 ** x2`` computed element-wise.

  See also:
    - :func:`jax.numpy.frexp`: decompose values into mantissa and exponent.

  Examples:
    >>> x1 = jnp.arange(5.0)
    >>> x2 = 10
    >>> jnp.ldexp(x1, x2)
    Array([   0., 1024., 2048., 3072., 4096.], dtype=float32)

    ``ldexp`` can be used to reconstruct the input to ``frexp``:

    >>> x = jnp.array([2., 3., 5., 11.])
    >>> m, e = jnp.frexp(x)
    >>> m
    Array([0.5   , 0.75  , 0.625 , 0.6875], dtype=float32)
    >>> e
    Array([2, 2, 3, 4], dtype=int32)
    >>> jnp.ldexp(m, e)
    Array([ 2.,  3.,  5., 11.], dtype=float32)
  ldexpz$ldexp not supported for input types r   rF   r:   )r   r   r"   rS   r#   rT   rC  r   r   r   r   frexpr   r   isinf)r   r   x1_dtypex2_dtypemer%   s          r'   rq  rq    s:   L GR,&"b\\"(\\"(""4"45			8RZZ	0
;Xx<P;QR
SSWb)#"
FLL$45" 
r$!QxxB&&rxx0! QUAE1!QUAE1!1!!"!	b	R1W%r1	--r)   c                   t        d|       } t        |       \  } t        j                  | j                  t
        j                        rt        d      t        |       S )a  Split floating point values into mantissa and twos exponent.

  JAX implementation of :func:`numpy.frexp`.

  Args:
    x: real-valued array

  Returns:
    A tuple ``(mantissa, exponent)`` where ``mantissa`` is a floating point
    value between -1 and 1, and ``exponent`` is an integer such that
    ``x == mantissa * 2 ** exponent``.

  See also:
    - :func:`jax.numpy.ldexp`: compute the inverse of ``frexp``.

  Examples:
    Split values into mantissa and exponent:

    >>> x = jnp.array([1., 2., 3., 4., 5.])
    >>> m, e = jnp.frexp(x)
    >>> m
    Array([0.5  , 0.5  , 0.75 , 0.5  , 0.625], dtype=float32)
    >>> e
    Array([1, 2, 2, 3, 3], dtype=int32)

    Reconstruct the original array:

    >>> m * 2 ** e
    Array([1., 2., 3., 4., 5.], dtype=float32)
  rr  z,frexp does not support complex-valued inputs)	r   r   r   rS   r"   r#   rT   rU   _frexpr0   s    r'   rr  rr    sM    B w"!a "!qww 2 23
B
CC	r)   c                B   t        j                  |       }t        j                  |      }d|j                  z  dz
  }d|j                  z
  }t        |       \  }}|||j                  z	  |z  |z
  dz   z  }|||j                  z   z  }||dz
  |j                  z  z  }t        j                  ||      }t        |       t        |       z  | dk(  z  }t        |t        j                  |      |      }t        || |      t        j                  |t        j                        fS rl  )r   r"   r   rg  minexpro  rh  r   rf  rs  isnanr   r/   r   r#   r   )r%   r"   ri  maskbiasr   r   rn  s           r'   ry  ry    s   
,,q/%	e	$
tyy.A	$	
T[[$A&"b"


d	"d*Q.."$$**
"djj  "
E*"	qE!H	Q	'$dCJJrNB'"	a	c66r288D	DDr)   c                    | \  }|\  }t        |      \  }}|t        |j                  |j                               z  }t	        j
                  |j                  t        j                        }||f||ffS r+   )	rr  r`  r   r"   r#   emptyshaper   float0)primalstangentsr%   trv  rw  mdotedots           r'   
_frexp_jvpr    sg    "!"!	q$!Q	
T188AGG$$%	%$	!''6==	)$
Q$	r)   c          	        t        d| |      \  } }t        j                  |       t        | d      }t	        j
                  |j                  t        j                        r#t        |dk(  t        j                  |      |      }t        j                  | |      }t        j                  ||      }t        j                  t        j                  t        j                  ||      t        j                  ||            |      }t        j                   |t        j"                  ||      |      }t        j$                  |       |S )a  Returns element-wise remainder of the division.

  JAX implementation of :obj:`numpy.remainder`.

  Args:
    x1: scalar or array. Specifies the dividend.
    x2: scalar or array. Specifies the divisor. ``x1`` and ``x2`` should either
      have same shape or be broadcast compatible.

  Returns:
    An array containing the remainder of element-wise division of ``x1`` by
    ``x2`` with same sign as the elements of ``x2``.

  Note:
    The result of ``jnp.remainder`` is equivalent to ``x1 - x2 * jnp.floor(x1 / x2)``.

  See also:
    - :func:`jax.numpy.mod`: Returns the element-wise remainder of the division.
    - :func:`jax.numpy.fmod`: Calculates the element-wise floating-point modulo
      operation.
    - :func:`jax.numpy.divmod`: Calculates the integer quotient and remainder of
      ``x1`` by ``x2``, element-wise.

  Examples:
    >>> x1 = jnp.array([[3, -1, 4],
    ...                 [8, 5, -2]])
    >>> x2 = jnp.array([2, 3, -5])
    >>> jnp.remainder(x1, x2)
    Array([[ 1,  2, -1],
           [ 0,  2, -2]], dtype=int32)
    >>> x1 - x2 * jnp.floor(x1 / x2)
    Array([[ 1.,  2., -1.],
           [ 0.,  2., -2.]], dtype=float32)
  r1  r   )r   rr   r%  r(   r   rS   r"   r#   r  r   r   _onesr,  r4   r   r   r,   r   rs   )r   r   rK  	trunc_modtrunc_mod_not_zerodo_plusru   s          r'   r1  r1    s    J  R4&"b((,	A	$rxx,	a2	+Bggb"o)vvi.OO	ffSVVIt$cffR&679KM'

7CGGIr2I>#c"	*r)   c                   t        | |      S )z$Alias of :func:`jax.numpy.remainder`)r1  r   s     r'   r3  r3  >  s     
2r	r)   c               @   t        d| |      \  } }t        j                  t        j                  | |      t        j
                        r#t        |dk(  t        j                  |      |      }t        j                  t        d| |       }t        j                  |       |S )aZ  Calculate element-wise floating-point modulo operation.

  JAX implementation of :obj:`numpy.fmod`.

  Args:
    x1: scalar or array. Specifies the dividend.
    x2: scalar or array. Specifies the divisor. ``x1`` and ``x2`` should either
       have same shape or be broadcast compatible.

  Returns:
    An array containing the result of the element-wise floating-point modulo
    operation of ``x1`` and ``x2`` with same sign as the elements of ``x1``.

  Note:
    The result of ``jnp.fmod`` is equivalent to ``x1 - x2 * jnp.fix(x1 / x2)``.

  See also:
    - :func:`jax.numpy.mod` and :func:`jax.numpy.remainder`: Returns the element-wise
      remainder of the division.
    - :func:`jax.numpy.divmod`: Calculates the integer quotient and remainder of
      ``x1`` by ``x2``, element-wise.

  Examples:
    >>> x1 = jnp.array([[3, -1, 4],
    ...                 [8, 5, -2]])
    >>> x2 = jnp.array([2, 3, -5])
    >>> jnp.fmod(x1, x2)
    Array([[ 1, -1,  4],
           [ 0,  2, -2]], dtype=int32)
    >>> x1 - x2 * jnp.fix(x1 / x2)
    Array([[ 1., -1.,  4.],
           [ 0.,  2., -2.]], dtype=float32)
  fmodr   )r   r   rS   result_typer#   r  r   r   r  r,  r   rr   rs   r'  s      r'   r  r  D  s}    H FB+&"bv))"b12::>	a2	+B%fb"56#c"	*r)   c               ^    t        d|       } t        |       \  } t        j                  |       S )a  Calculate element-wise square of the input array.

  JAX implementation of :obj:`numpy.square`.

  Args:
    x: input array or scalar.

  Returns:
    An array containing the square of the elements of ``x``.

  Note:
    ``jnp.square`` is equivalent to computing ``jnp.power(x, 2)``.

  See also:
    - :func:`jax.numpy.sqrt`: Calculates the element-wise non-negative square root
      of the input array.
    - :func:`jax.numpy.power`: Calculates the element-wise base ``x1`` exponential
      of ``x2``.
    - :func:`jax.lax.integer_pow`: Computes element-wise power :math:`x^y`, where
      :math:`y` is a fixed integer.
    - :func:`jax.numpy.float_power`: Computes the first array raised to the power
      of second array, element-wise, by promoting to the inexact dtype.

  Examples:
    >>> x = jnp.array([3, -2, 5.3, 1])
    >>> jnp.square(x)
    Array([ 9.      ,  4.      , 28.090002,  1.      ], dtype=float32)
    >>> jnp.power(x, 2)
    Array([ 9.      ,  4.      , 28.090002,  1.      ], dtype=float32)

    For integer inputs:

    >>> x1 = jnp.array([2, 4, 5, 6])
    >>> jnp.square(x1)
    Array([ 4, 16, 25, 36], dtype=int32)

    For complex-valued inputs:

    >>> x2 = jnp.array([1-3j, -1j, 2])
    >>> jnp.square(x2)
    Array([-8.-6.j, -1.+0.j,  4.+0.j], dtype=complex64)
  square)r   r   r   r  r0   s    r'   r  r  p  s+    Z x#!a "!	Ar)   c                   t        d|       \  } t        j                  | t        | t        j
                  dz              S )a  Convert angles from degrees to radians.

  JAX implementation of :obj:`numpy.deg2rad`.

  The angle in degrees is converted to radians by:

  .. math::

     deg2rad(x) = x * \frac{pi}{180}

  Args:
    x: scalar or array. Specifies the angle in degrees.

  Returns:
    An array containing the angles in radians.

  See also:
    - :func:`jax.numpy.rad2deg` and :func:`jax.numpy.degrees`: Converts the angles
      from radians to degrees.
    - :func:`jax.numpy.radians`: Alias of ``deg2rad``.

  Examples:
    >>> x = jnp.array([60, 90, 120, 180])
    >>> jnp.deg2rad(x)
    Array([1.0471976, 1.5707964, 2.0943952, 3.1415927], dtype=float32)
    >>> x * jnp.pi / 180
    Array([1.0471976, 1.5707964, 2.0943952, 3.1415927],      dtype=float32, weak_type=True)
  deg2rad   r   r   r   r5   r#   pir0   s    r'   r  r    s2    > Iq)"!	Jq"%%#+.	//r)   c                   t        d|       \  } t        j                  | t        | dt        j
                  z              S )a  Convert angles from radians to degrees.

  JAX implementation of :obj:`numpy.rad2deg`.

  The angle in radians is converted to degrees by:

  .. math::

     rad2deg(x) = x * \frac{180}{pi}

  Args:
    x: scalar or array. Specifies the angle in radians.

  Returns:
    An array containing the angles in degrees.

  See also:
    - :func:`jax.numpy.deg2rad` and :func:`jax.numpy.radians`: Converts the angles
      from degrees to radians.
    - :func:`jax.numpy.degrees`: Alias of ``rad2deg``.

  Examples:
    >>> pi = jnp.pi
    >>> x = jnp.array([pi/4, pi/2, 2*pi/3])
    >>> jnp.rad2deg(x)
    Array([ 45.     ,  90.     , 120.00001], dtype=float32)
    >>> x * 180 / pi
    Array([ 45.,  90., 120.], dtype=float32)
  rad2degr  r  r0   s    r'   r  r    s3    @ Iq)"!	Jq#+.	//r)   c                   t        |       S )z"Alias of :func:`jax.numpy.rad2deg`)r  r0   s    r'   degreesr         
r)   c                   t        |       S )z"Alias of :func:`jax.numpy.deg2rad`)r  r0   s    r'   radiansr    r  r)   c                   t        d|       } t        j                  |       rt        j                  |       S t        j
                  |       S )aj  Return element-wise complex-conjugate of the input.

  JAX implementation of :obj:`numpy.conjugate`.

  Args:
    x: inpuat array or scalar.

  Returns:
    An array containing the complex-conjugate of ``x``.

  See also:
    - :func:`jax.numpy.real`: Returns the element-wise real part of the complex
      argument.
    - :func:`jax.numpy.imag`: Returns the element-wise imaginary part of the
      complex argument.

  Examples:
    >>> jnp.conjugate(3)
    Array(3, dtype=int32, weak_type=True)
    >>> x = jnp.array([2-1j, 3+5j, 7])
    >>> jnp.conjugate(x)
    Array([2.+1.j, 3.-5.j, 7.-0.j], dtype=complex64)
  	conjugate)r   r#   iscomplexobjr   conjrd   r0   s    r'   r  r    s6    4 {A&!*!>A>r)   c                   t        |       S )z$Alias of :func:`jax.numpy.conjugate`)r  r0   s    r'   r  r    s     
1r)   c                   t        d|       } t        j                  |       rt        j                  |       S t        j
                  | d      S )a  Return element-wise imaginary of part of the complex argument.

  JAX implementation of :obj:`numpy.imag`.

  Args:
    val: input array or scalar.

  Returns:
    An array containing the imaginary part of the elements of ``val``.

  See also:
    - :func:`jax.numpy.conjugate` and :func:`jax.numpy.conj`: Returns the element-wise
      complex-conjugate of the input.
    - :func:`jax.numpy.real`: Returns the element-wise real part of the complex
      argument.

  Examples:
    >>> jnp.imag(4)
    Array(0, dtype=int32, weak_type=True)
    >>> jnp.imag(5j)
    Array(5., dtype=float32, weak_type=True)
    >>> x = jnp.array([2+3j, 5-1j, -3])
    >>> jnp.imag(x)
    Array([ 3., -1.,  0.], dtype=float32)
  r   r   )r   r#   r  r   r   rb  vals    r'   r   r     s9    8 	%#//#.#ICMM#q4IIr)   c                   t        d|       } t        j                  |       rt        j                  |       S t        j
                  |       S )a  Return element-wise real part of the complex argument.

  JAX implementation of :obj:`numpy.real`.

  Args:
    val: input array or scalar.

  Returns:
    An array containing the real part of the elements of ``val``.

  See also:
    - :func:`jax.numpy.conjugate` and :func:`jax.numpy.conj`: Returns the element-wise
      complex-conjugate of the input.
    - :func:`jax.numpy.imag`: Returns the element-wise imaginary part of the
      complex argument.

  Examples:
    >>> jnp.real(5)
    Array(5, dtype=int32, weak_type=True)
    >>> jnp.real(2j)
    Array(0., dtype=float32, weak_type=True)
    >>> x = jnp.array([3-2j, 4+7j, -2j])
    >>> jnp.real(x)
    Array([ 3.,  4., -0.], dtype=float32)
  r.   )r   r#   r  r   r.   rd   r  s    r'   r.   r.   9  s7    8 	%#//#.#DCKK4DDr)   c                   t        d|       } t        |       \  } |t        d      t        t	        j
                  | t	        j                  |             t        |       t        |             }| |z
  |fS )a  Return element-wise fractional and integral parts of the input array.

  JAX implementation of :obj:`numpy.modf`.

  Args:
    x: input array or scalar.
    out: Not used by JAX.

  Returns:
    An array containing the fractional and integral parts of the elements of ``x``,
    promoting dtypes inexact.

  See also:
    - :func:`jax.numpy.divmod`: Calculates the integer quotient and remainder of
      ``x1`` by ``x2`` element-wise.

  Examples:
    >>> jnp.modf(4.8)
    (Array(0.8000002, dtype=float32, weak_type=True), Array(4., dtype=float32, weak_type=True))
    >>> x = jnp.array([-3.4, -5.7, 0.6, 1.5, 2.3])
    >>> jnp.modf(x)
    (Array([-0.4000001 , -0.6999998 ,  0.6       ,  0.5       ,  0.29999995],      dtype=float32), Array([-3., -5.,  0.,  1.,  2.], dtype=float32))
  modfz0The 'out' argument to jnp.modf is not supported.)	r   r   re  r   r   r   _zerorh   rm   )r%   ru   wholes      r'   r  r  Y  se    4 vq!!a "!_
P
QQ
399Q<(%(DG
<%	
UE	r)   c                  t        d|       } t        j                  |       }t        j                  |t        j
                        rt        j                  |       S t        j                  |t        j                        rNt        j                  t        j                  t        |             t        j                  t        |                   S t        j                  | dt        j                        S )a*  Return a boolean array indicating whether each element of input is finite.

  JAX implementation of :obj:`numpy.isfinite`.

  Args:
    x: input array or scalar.

  Returns:
    A boolean array of same shape as ``x`` containing ``True`` where ``x`` is
    not ``inf``, ``-inf``, or ``NaN``, and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.isinf`: Returns a boolean array indicating whether each
      element of input is either positive or negative infinity.
    - :func:`jax.numpy.isposinf`: Returns a boolean array indicating whether each
      element of input is positive infinity.
    - :func:`jax.numpy.isneginf`: Returns a boolean array indicating whether each
      element of input is negative infinity.
    - :func:`jax.numpy.isnan`: Returns a boolean array indicating whether each
      element of input is not a number (``NaN``).

  Examples:
    >>> x = jnp.array([-1, 3, jnp.inf, jnp.nan])
    >>> jnp.isfinite(x)
    Array([ True,  True, False, False], dtype=bool)
    >>> jnp.isfinite(3-4j)
    Array(True, dtype=bool, weak_type=True)
  isfiniteTr!   )r   r   r"   rS   r#   rc  r   	is_finiterT   r   r.   r   rb  r  r   s     r'   r  r  {  s    > z1%!
,,q/%ubkk*== 2 23??3==a13==a3IJJ==D11r)   c          
        t        d|       } t        j                  |       }t        j                  |t        j
                        rAt        j                  t        j                  |       t        | t        j                              S t        j                  |t        j                        rt        j                  |       }t        j                  |       }t        j                  t        j                  t        j                  |      t        |t        j                              t        j                  t        j                  |      t        |t        j                                    S t        j                  | dt        j                         S )a   Return a boolean array indicating whether each element of input is infinite.

  JAX implementation of :obj:`numpy.isinf`.

  Args:
    x: input array or scalar.

  Returns:
    A boolean array of same shape as ``x`` containing ``True`` where ``x`` is
    ``inf`` or ``-inf``, and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.isposinf`: Returns a boolean array indicating whether each
      element of input is positive infinity.
    - :func:`jax.numpy.isneginf`: Returns a boolean array indicating whether each
      element of input is negative infinity.
    - :func:`jax.numpy.isfinite`: Returns a boolean array indicating whether each
      element of input is finite.
    - :func:`jax.numpy.isnan`: Returns a boolean array indicating whether each
      element of input is not a number (``NaN``).

  Examples:
    >>> jnp.isinf(jnp.inf)
    Array(True, dtype=bool)
    >>> x = jnp.array([2+3j, -jnp.inf, 6, jnp.inf, jnp.nan])
    >>> jnp.isinf(x)
    Array([False,  True, False,  True, False], dtype=bool)
  rs  Fr!   )r   r   r"   rS   r#   rc  r   r   rV   r(   r   rT   r.   r   r   rb  r  )r%   r"   rX  rY  s       r'   rs  rs    s    > w"!
,,q/%ubkk*66#''!*nQ788 2 23	!B	!B>>#&&nR.HI&&nR.HIK K ==E22r)   c                x   |t        d      t        j                  |      }t        j                  |t        j
                        r t        j                  |t        ||             S t        j                  |t        j                        rt        d      t        j                  |dt        j                        S )Nz9The 'out' argument to isneginf/isposinf is not supported.z8isposinf/isneginf are not well defined for complex typesFr!   )re  r   r"   rS   r#   rc  r   r   r(   rT   r   rb  r  )infinityr%   ru   r"   s       r'   _isposneginfr    s    _
Y
ZZ
,,q/%ubkk*66!^Ax011 2 23
O
PP==E22r)   c               P    t        d|       } t        t        j                  | |      S )a4  
  Return boolean array indicating whether each element of input is positive infinite.

  JAX implementation of :obj:`numpy.isposinf`.

  Args:
    x: input array or scalar. ``complex`` dtype are not supported.

  Returns:
    A boolean array of same shape as ``x`` containing ``True`` where ``x`` is
    ``inf``, and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.isinf`: Returns a boolean array indicating whether each
      element of input is either positive or negative infinity.
    - :func:`jax.numpy.isneginf`: Returns a boolean array indicating whether each
      element of input is negative infinity.
    - :func:`jax.numpy.isfinite`: Returns a boolean array indicating whether each
      element of input is finite.
    - :func:`jax.numpy.isnan`: Returns a boolean array indicating whether each
      element of input is not a number (``NaN``).

  Examples:
    >>> jnp.isposinf(5)
    Array(False, dtype=bool)
    >>> x = jnp.array([-jnp.inf, 5, jnp.inf, jnp.nan, 1])
    >>> jnp.isposinf(x)
    Array([False, False,  True, False, False], dtype=bool)
  r-   r   r  r#   r   rt   s     r'   r-   r-     s#    > z1%!	bffa	%%r)   c               R    t        d|       } t        t        j                   | |      S )a;  
  Return boolean array indicating whether each element of input is negative infinite.

  JAX implementation of :obj:`numpy.isneginf`.

  Args:
    x: input array or scalar. ``complex`` dtype are not supported.

  Returns:
    A boolean array of same shape as ``x`` containing ``True`` where ``x`` is
    ``-inf``, and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.isinf`: Returns a boolean array indicating whether each
      element of input is either positive or negative infinity.
    - :func:`jax.numpy.isposinf`: Returns a boolean array indicating whether each
      element of input is positive infinity.
    - :func:`jax.numpy.isfinite`: Returns a boolean array indicating whether each
      element of input is finite.
    - :func:`jax.numpy.isnan`: Returns a boolean array indicating whether each
      element of input is not a number (``NaN``).

  Examples:
    >>> jnp.isneginf(jnp.inf)
    Array(False, dtype=bool)
    >>> x = jnp.array([-jnp.inf, 5, jnp.inf, jnp.nan, 1])
    >>> jnp.isneginf(x)
    Array([ True, False, False, False, False], dtype=bool)
  isneginfr  rt   s     r'   r  r    s%    > z1%!	rvvgq#	&&r)   c               F    t        d|       } t        j                  | |       S )a  Returns a boolean array indicating whether each element of input is ``NaN``.

  JAX implementation of :obj:`numpy.isnan`.

  Args:
    x: input array or scalar.

  Returns:
    A boolean array of same shape as ``x`` containing ``True`` where ``x`` is
    not a number (i.e. ``NaN``) and ``False`` otherwise.

  See also:
    - :func:`jax.numpy.isfinite`: Returns a boolean array indicating whether each
      element of input is finite.
    - :func:`jax.numpy.isinf`: Returns a boolean array indicating whether each
      element of input is either positive or negative infinity.
    - :func:`jax.numpy.isposinf`: Returns a boolean array indicating whether each
      element of input is positive infinity.
    - :func:`jax.numpy.isneginf`: Returns a boolean array indicating whether each
      element of input is negative infinity.

  Examples:
    >>> jnp.isnan(6)
    Array(False, dtype=bool, weak_type=True)
    >>> x = jnp.array([2, 1+4j, jnp.inf, jnp.nan])
    >>> jnp.isnan(x)
    Array([False, False, False,  True], dtype=bool)
  r|  )r   r   r4   r0   s    r'   r|  r|  "  s     > w"!	1r)   c                   t        d| |      \  } }t        | |      \  } }t        | d      }t        t	        j
                  | |      |t        t	        j                  | |      t        | d      |            S )at  Compute the heaviside step function.

  JAX implementation of :obj:`numpy.heaviside`.

  The heaviside step function is defined by:

  .. math::

    \mathrm{heaviside}(x1, x2) = \begin{cases}
      0,  & x1 < 0\\
      x2, & x1 = 0\\
      1,  & x1 > 0.
    \end{cases}

  Args:
    x1: input array or scalar. ``complex`` dtype are not supported.
    x2: scalar or array. Specifies the return values when ``x1`` is ``0``. ``complex``
      dtype are not supported. ``x1`` and ``x2`` must either have same shape or
      broadcast compatible.

  Returns:
    An array containing the heaviside step function of ``x1``, promoting to
    inexact dtype.

  Examples:
    >>> x1 = jnp.array([[-2, 0, 3],
    ...                 [5, -1, 0],
    ...                 [0, 7, -3]])
    >>> x2 = jnp.array([2, 0.5, 1])
    >>> jnp.heaviside(x1, x2)
    Array([[0. , 0.5, 1. ],
           [1. , 0. , 1. ],
           [2. , 1. , 0. ]], dtype=float32)
    >>> jnp.heaviside(x1, 0.5)
    Array([[0. , 0.5, 1. ],
           [1. , 0. , 0.5],
           [0.5, 1. , 0. ]], dtype=float32)
    >>> jnp.heaviside(-3, x2)
    Array([0., 0., 0.], dtype=float32)
  	heavisider   r:   )r   r   r5   r   r   r   r   )r   r   rK  s      r'   r  r  E  so    V KR0&"b!"b)&"b	B	$	r4 $svvb$'B):B?
A Ar)   c                  t        d| |      \  } }t        j                  | j                  t        j
                        rt        d      t        j                  |       t        j                  |      }} t        j                  t        |       t        |            }t        | |      t        | |      }} t        | dk(  | | t        j                  dt        j                  t        j                   |t        | dk(  t        j"                  |       |                   z         z        }t        |t%        |t        j&                        |      S )a9  
  Return element-wise hypotenuse for the given legs of a right angle triangle.

  JAX implementation of :obj:`numpy.hypot`.

  Args:
    x1: scalar or array. Specifies one of the legs of right angle triangle.
      ``complex`` dtype are not supported.
    x2: scalar or array. Specifies the other leg of right angle triangle.
      ``complex`` dtype are not supported. ``x1`` and ``x2`` must either have
      same shape or be broadcast compatible.

  Returns:
    An array containing the hypotenuse for the given given legs ``x1`` and ``x2``
    of a right angle triangle, promoting to inexact dtype.

  Note:
    ``jnp.hypot`` is a more numerically stable way of computing
    ``jnp.sqrt(x1 ** 2 + x2 **2)``.

  Examples:
    >>> jnp.hypot(3, 4)
    Array(5., dtype=float32, weak_type=True)
    >>> x1 = jnp.array([[3, -2, 5],
    ...                 [9, 1, -4]])
    >>> x2 = jnp.array([-5, 6, 8])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.hypot(x1, x2)
    Array([[ 5.831,  6.325,  9.434],
           [10.296,  6.083,  8.944]], dtype=float32)
  hypotzujnp.hypot is not well defined for complex-valued inputs. Please convert to real values first, such as by using abs(x)r   r:   )r   r   rS   r"   r#   rT   r   r   rV   r   r-   r   r   r   r   r  r&  r  r5   r   )r   r   idx_infr%   s       r'   r  r  w  s    D  R0&"b rxx!3!34
EF F 772;b"NN8B<"6'2r?GBOb"R1Wb"sxxCJJswwr6"PQ'SVS\S\]_S`bdCe7f,g(ghhi!	Arvv.	22r)   c               `    t        d|       } t        |       \  } t        j                  | d      S )a  Calculate element-wise reciprocal of the input.

  JAX implementation of :obj:`numpy.reciprocal`.

  The reciprocal is calculated by ``1/x``.

  Args:
    x: input array or scalar.

  Returns:
    An array of same shape as ``x`` containing the reciprocal of each element of
    ``x``.

  Note:
    For integer inputs, ``np.reciprocal`` returns rounded integer output, while
    ``jnp.reciprocal`` promotes integer inputs to floating point.

  Examples:
    >>> jnp.reciprocal(2)
    Array(0.5, dtype=float32, weak_type=True)
    >>> jnp.reciprocal(0.)
    Array(inf, dtype=float32, weak_type=True)
    >>> x = jnp.array([1, 5., 4.])
    >>> jnp.reciprocal(x)
    Array([1.  , 0.2 , 0.25], dtype=float32)
  
reciprocalr   )r   r   r   r<  r0   s    r'   r  r    s-    : |Q'!a "!	B	r)   c          	     z   t        d|       } t        |       \  } t        j                  | t	        | d            }t        j
                  t	        | t        j                        |       }t        |t	        | d      |      }t        |t        d|      t        j                  t        j                  |      |            S )aD  Calculate the normalized sinc function.

  JAX implementation of :func:`numpy.sinc`.

  The normalized sinc function is given by

  .. math::
     \mathrm{sinc}(x) = \frac{\sin({\pi x})}{\pi x}

  where ``sinc(0)`` returns the limit value of ``1``. The sinc function is
  smooth and infinitely differentiable.

  Args:
    x : input array; will be promoted to an inexact type.

  Returns:
    An array of the same shape as ``x`` containing the result.

  Examples:
    >>> x = jnp.array([-1, -0.5, 0, 0.5, 1])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.sinc(x)
    Array([-0.   ,  0.637,  1.   ,  0.637, -0.   ], dtype=float32)

    Compare this to the naive approach to computing the function, which is
    undefined at zero:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.sin(jnp.pi * x) / (jnp.pi * x)
    Array([-0.   ,  0.637,    nan,  0.637, -0.   ], dtype=float32)

    JAX defines a custom gradient rule for sinc to allow accurate evaluation
    of the gradient at zero even for higher-order derivatives:

    >>> f = jnp.sinc
    >>> for i in range(1, 6):
    ...   f = jax.grad(f)
    ...   print(f"(d/dx)^{i} f(0.0) = {f(0.0):.2f}")
    ...
    (d/dx)^1 f(0.0) = 0.00
    (d/dx)^2 f(0.0) = -3.29
    (d/dx)^3 f(0.0) = 0.00
    (d/dx)^4 f(0.0) = 19.48
    (d/dx)^5 f(0.0) = 0.00
  sincr   r:   )r   r   r   r   r5   r   r#   r  r   _sinc_maclaurinr&  r{   )r%   eq_zeropi_x	safe_pi_xs       r'   r  r    s    ` vq!!a "!FF1jA&''	Aruu%q	)$WjA.5)	D1	*I6
8 8r)   )r   )nondiff_argnumsc                R    | dz  r|dz  S |dz  t        |d| dz  z  | dz   z        z   S )NrF   r   r   r:   )r5   )kr%   s     r'   r  r    s<    
 Uq5Lq5:a"!q&!1QU!;<<<r)   c                P    ||c\  }\  }t        | |      t        | dz   |      |z  fS )Nr:   )r  )r  r  r  r%   r  s        r'   _sinc_maclaurin_jvpr    s3    *$1	A	Aq 9A =	==r)   )r%   r   rN   r   )r%   r   rN   r   )rA   zCallable[[ArrayLike], Array]rN   r   )NNNN)rG   r   rH   Callable[..., Any] | NonerI   r  rJ   r  rK   r  rN   z:Callable[[Callable[[ArrayLike, ArrayLike], Array]], ufunc])r   r   r   r   r   r   rN   r   )r%   r   r   r   rN   r   )r   r   r   r   rN   r   )r   rM   r%   r   r   r   )r   r   r   r   rN   tuple[Array, Array])r%   r   rN   r  )r  r   rN   r   r+   )r  floatr%   r   rN   r   )__doc__
__future__r   collections.abcr   	functoolsr   r:  typingr   numpyr#   jax._srcr   r   jax._src.apir	   jax._src.custom_derivativesr
   jax._src.laxr   r   rQ  jax._src.typingr   r   jax._src.numpyr   rr   r   jax._src.numpy.ufunc_apir   jax._src.numpy.utilr   r   r   r   r   r   r   r   r   r   jax._src.utilr   export_constr5   int16r   int64rd  r(   r1   r6   rC   rP   rR   rY   r[   r^   r`   rc   rf   rh   rm   ro   rq   rw   ry   r{   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   sumcumsumr   r   prodcumprodr   _reduce_bitwise_andr   _reduce_bitwise_orr   _reduce_bitwise_xorr   r   r   r   r   r   r   r   _reduce_minr   _reduce_maxr   r   r   r   _reduce_logical_andr   _reduce_logical_orr   _reduce_logical_xorr   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  rV   r  r   r$  r)  r+  r0  r-  r6  r   r=  rB  r   
_logsumexprP  _logsumexp2rS  rU  r\  r`  r"  ro  rq  rr  ry  defjvpr  r1  r3  r  r  r  r  r  r  r  r  r   r.   r  r  rs  r  r-   r  r|  r  r  r  r  r  r  rO   r)   r'   <module>r     s   # $        2  + , - % *- - - % 
K	 ZZ
 	hhhhhh09?K EI9=157;	6	.	 5	 A{	 T(3  (3V T=  =
 T:  :
 T+5  +5\ )/ )/X T,3  ,3^ T.,  .,b T"6  "6J T"4  "4J T%2  %2P T#  #L T(6  (6V T&  &R T  @ T  > T  > T'  'T T(  (V T$6  $6N T24  24j T14  14h T-8  -8` 4  4n T14  14h T.  .b T  B T4  46 qJ<M<MRYZ [D  qZ=O=OT`aE bE< r*"@"@A= B=: q!>!>?; @;: q!?!?@= A=: T3C  3Cl TK  K
 T-.  -.` T-2  -2`#
 t- .> T3=  3=l tJ$:$:;81 <81v tJ$:$:;71 <71t T,  ,^ TA  A4 T'J  'JV tJ$B$BCL DL( uZ%B%BCJ DJ( uZ%C%CDL EL( T!I  !IH %* T)K  )KX T*E  *EZ T*H  *HZ T*B  *B\ T*  *
 T,  ,
 T*  *
 T,  ,
 T*  *
 T,  ,
 T1  1
  6   6F T/  /d T  
 Tg  gD T  
 #:  #:L #E  #EL T%  %P  
 3$  3$l '!  '!T	 Z Zx   	T ( wz'<'<=% >%2 wz'='=>& ?&< T  : T  < T  B ;K  ;K|4 6.  6.r #  #J E E"   .  .b  
 '  'T T-  -` T0  0B T0  0D  
  
 T?  ?8  
 TJ  J< TE  E<   @ T$2  $2N '3  '3T	3 & &D ' 'D T  B -A  -A` ,3  ,3^ T    @ 48  48n 	T*= += > >r)   