
    ukix                     p   d dl Z d dlZd dlmZmZ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 d d
lmZ d dlmZ d dlmZmZ d dlmZmZmZm Z  d dl!m"Z"m#Z#  e#d      Z$d<dede%de
jL                  fdZ'e$d=ddddede dz  dejP                  ez  dz  deez  dz  def
d       Z)e$d=ddddede dz  dejP                  ez  dz  deez  dz  def
d       Z*e$d=ddddede dz  dejP                  ez  dz  deez  dz  def
d       Z+de%dz  fdZ,e$	 d=dddedede dz  dejP                  ez  dz  def
d       Z-e$	 	 d>ddddeez  de dz  dedejP                  ez  dz  deez  dz  defd        Z.e$	 	 d>ddddeez  de dz  dedejP                  ez  dz  deez  dz  defd!       Z/e$	 	 d>ddd"eez  de dz  dedejP                  ez  dz  def
d#       Z0e$	 	 d>dddeez  dede dz  dedejP                  ez  dz  defd$       Z1e	 	 	 	 d?ddd'ed(ed)e2d*e3d+ed&   de dz  d,e2dejP                  ez  dz  defd-       Z4e	 	 d@ddd'ed(ed)e2d*e3d+ed%   de dz  d,e2dejP                  ez  dz  de5eef   fd.       Z4e	 	 dAdd dd/d'ed(ed)e2d*e3d+ed%   de dz  d,e2dejP                  ez  dz  de5eef   fd0       Z4e	 	 	 	 d?ddd'ed(ed)e2d*e3d+e3de dz  d,e2dejP                  ez  dz  dee5eef   z  fd1       Z4e$	 	 	 	 d?ddd'ed(ed)e2d*e3d+e3de dz  d,e2dejP                  ez  dz  dee5eef   z  fd2       Z4 e	jl                  d34      	 	 	 	 d?ddd'ed(ed)e2d*e3d+e3de dz  d,e2dejP                  ez  dz  dee5eef   z  fd5       Z7e$	 	 	 dBd'ed(ed)e2d*e3d6ede dz  d,e2defd7       Z8 e	jl                  d84      	 	 	 dBd'ed(ed)e2d*e3d6ede dz  d,e2defd9       Z9e$	 	 dCd'ed(ed)e2d*e3de dz  d,e2defd:       Z: e	jl                  d84      	 	 dCd'ed(ed)e2d*e3de dz  d,e2defd;       Z;y)D    N)AnyLiteraloverload)api)core)dtypes)lax)
xla_client)asarray)ufuncs)util)Sharding)NamedShardingPartitionSpec)Array	ArrayLikeDuckTypedArray	DTypeLike)canonicalize_axis
set_modulez	jax.numpyshapecontextreturnc                     t        | t        t        f      s?t        | dd       dk(  st	        j
                  |       dk(  rt        j                  | f|      S t        j                  | |      S )Nndimr   )
isinstancetuplelistgetattrnpr   r   canonicalize_shape)r   r   s     X/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jax/_src/numpy/array_creation.pyr!   r!   (   sX    
UUDM
*ufd#q(BGGENa,?""E8W55""5'22    deviceout_shardingdtyper%   r&   c                2   t        | t        j                        rt        d      t	        d| |      x}rt        |      t        j                  |t        n|d      }t        |       } t        j                  ||d      }t        j                  | d||      S )a  Create an array full of zeros.

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

  Args:
    shape: int or sequence of ints specifying the shape of the created array.
    dtype: optional dtype for the created array; defaults to float32 or float64
      depending on the X64 configuration (see :ref:`default-dtypes`).
    device: (optional) :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed. This argument exists for
      compatibility with the :ref:`python-array-api`.
    out_sharding: (optional) :class:`~jax.sharding.PartitionSpec` or :class:`~jax.NamedSharding`
      representing the sharding of the created array (see `explicit sharding`_ for more details).
      This argument exists for consistency with other array creation routines across JAX.
      Specifying both ``out_sharding`` and ``device`` will result in an error.

  Returns:
    Array of the specified shape and dtype, with the given device/sharding if specified.

  See also:
    - :func:`jax.numpy.zeros_like`
    - :func:`jax.numpy.empty`
    - :func:`jax.numpy.ones`
    - :func:`jax.numpy.full`

  Examples:
    >>> jnp.zeros(4)
    Array([0., 0., 0., 0.], dtype=float32)
    >>> jnp.zeros((2, 3), dtype=bool)
    Array([[False, False, False],
           [False, False, False]], dtype=bool)

  .. _explicit sharding: https://docs.jax.dev/en/latest/notebooks/explicit-sharding.html
  :expected sequence object with len >= 0 or a single integerzerosz	jnp.zerosr   sharding)r   typesGeneratorType	TypeError_check_forgot_shape_tupler   !check_and_canonicalize_user_dtypefloatr!   r   choose_device_or_out_shardingr	   fullr   r'   r%   r&   mr,   s         r"   r*   r*   0   s    L u**+
P
QQ$WeU;;a;IaL>P

2
2}e%2%
U
#%//lK)(	%EH	55r#   c                2   t        | t        j                        rt        d      t	        d| |      x}rt        |      t        |       } t        j                  |t        n|d      }t        j                  ||d      }t        j                  | d||      S )a  Create an array full of ones.

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

  Args:
    shape: int or sequence of ints specifying the shape of the created array.
    dtype: optional dtype for the created array; defaults to float32 or float64
      depending on the X64 configuration (see :ref:`default-dtypes`).
    device: (optional) :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed. This argument exists for
      compatibility with the :ref:`python-array-api`.
    out_sharding: (optional) :class:`~jax.sharding.PartitionSpec` or :class:`~jax.NamedSharding`
      representing the sharding of the created array (see `explicit sharding`_ for more details).
      This argument exists for consistency with other array creation routines across JAX.
      Specifying both ``out_sharding`` and ``device`` will result in an error.

  Returns:
    Array of the specified shape and dtype, with the given device/sharding if specified.

  See also:
    - :func:`jax.numpy.ones_like`
    - :func:`jax.numpy.empty`
    - :func:`jax.numpy.zeros`
    - :func:`jax.numpy.full`

  Examples:
    >>> jnp.ones(4)
    Array([1., 1., 1., 1.], dtype=float32)
    >>> jnp.ones((2, 3), dtype=bool)
    Array([[ True,  True,  True],
           [ True,  True,  True]], dtype=bool)

  .. _explicit sharding: https://docs.jax.dev/en/latest/notebooks/explicit-sharding.html
  r)   oneszjnp.ones   r+   )r   r-   r.   r/   r0   r!   r   r1   r2   r   r3   r	   r4   r5   s         r"   r8   r8   a   s    L u**+
P
QQ$VUE::a:9Q<=O
U
#%

2
2}e%1%//lJ((	%EH	55r#   c                    t        d| |      x}rt        |      t        j                  |t        n|d      }t        | |||      S )a  Create an empty array.

  JAX implementation of :func:`numpy.empty`. Because XLA cannot create an
  un-initialized array, :func:`jax.numpy.empty` will always return an array
  full of zeros.

  Args:
    shape: int or sequence of ints specifying the shape of the created array.
    dtype: optional dtype for the created array; defaults to float32 or float64
      depending on the X64 configuration (see :ref:`default-dtypes`).
    device: (optional) :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed. This argument exists for
      compatibility with the :ref:`python-array-api`.
    out_sharding: (optional) :class:`~jax.sharding.PartitionSpec` or :class:`~jax.NamedSharding`
      representing the sharding of the created array (see `explicit sharding`_ for more details).
      This argument exists for consistency with other array creation routines across JAX.
      Specifying both ``out_sharding`` and ``device`` will result in an error.

  Returns:
    Array of the specified shape and dtype, with the given device/sharding if specified.

  See also:
    - :func:`jax.numpy.empty_like`
    - :func:`jax.numpy.zeros`
    - :func:`jax.numpy.ones`
    - :func:`jax.numpy.full`

  Examples:
    >>> jnp.empty(4)
    Array([0., 0., 0., 0.], dtype=float32)
    >>> jnp.empty((2, 3), dtype=bool)
    Array([[False, False, False],
           [False, False, False]], dtype=bool)

  .. _explicit sharding: https://docs.jax.dev/en/latest/notebooks/explicit-sharding.html
  emptyr$   )r0   r/   r   r1   r2   r*   )r   r'   r%   r&   r6   s        r"   r;   r;      sN    P %WeU;;a;IaL>P

2
2}e%2%	ueF	FFr#   c                 v    t        |t              r)t        |t              rd| d|  d| d| d|  d| d| dS y y )NzCannot interpret 'z9' as a data type.

Did you accidentally write `jax.numpy.(z, z)` when you meant `jax.numpy.z((z5))`, i.e. with a single tuple argument for the shape?)r   int)namer   r'   s      r"   r0   r0      s`    s
5# 6  (qr% 1))-br% A:: ; !7r#   r%   
fill_valuec                f   |t        j                  |d      }t        j                  d|       t	        j
                  |      dk(  r7t        |       } t        j                  | ||t        j                  |            S t        j                  t        j                  t        ||      |       |      S )aT  Create an array full of a specified value.

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

  Args:
    shape: int or sequence of ints specifying the shape of the created array.
    fill_value: scalar or array with which to fill the created array.
    dtype: optional dtype for the created array; defaults to the dtype of the
      fill value.
    device: (optional) :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed.

  Returns:
    Array of the specified shape and dtype, on the specified device if specified.

  See also:
    - :func:`jax.numpy.full_like`
    - :func:`jax.numpy.empty`
    - :func:`jax.numpy.zeros`
    - :func:`jax.numpy.ones`

  Examples:
    >>> jnp.full(4, 2, dtype=float)
    Array([2., 2., 2., 2.], dtype=float32)
    >>> jnp.full((2, 3), 0, dtype=bool)
    Array([[False, False, False],
           [False, False, False]], dtype=bool)

    `fill_value` may also be an array that is broadcast to the specified shape:

    >>> jnp.full((2, 3), fill_value=jnp.arange(3))
    Array([[0, 1, 2],
           [0, 1, 2]], dtype=int32)
  r4   r   r+   r'   )r   r1   r   check_arrayliker    r   r!   r	   r4   canonicalize_device_to_shardingr   
device_put_broadcast_tor   )r   rA   r'   r%   s       r"   r4   r4      s    L 44UFCEvz*WWZAu%E88E:u!AA&IK K >>7:U;UCVM Mr#   ac                B   t        | d      rt        | d      s2t        | d      r| j                         } t        j                  d|        |t	        j
                  |d      }|t        |      }t        j                  ||d      }t        j                  | d|||      S )a  Create an array full of zeros with the same shape and dtype as an array.

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

  Args:
    a: Array-like object with ``shape`` and ``dtype`` attributes.
    shape: optionally override the shape of the created array.
    dtype: optionally override the dtype of the created array.
    device: (optional) :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed.

  Returns:
    Array of the specified shape and dtype, on the specified device if specified.

  See also:
    - :func:`jax.numpy.zeros`
    - :func:`jax.numpy.empty_like`
    - :func:`jax.numpy.ones_like`
    - :func:`jax.numpy.full_like`

  Examples:
    >>> x = jnp.arange(4)
    >>> jnp.zeros_like(x)
    Array([0, 0, 0, 0], dtype=int32)
    >>> jnp.zeros_like(x, dtype=bool)
    Array([False, False, False, False], dtype=bool)
    >>> jnp.zeros_like(x, shape=(2, 3))
    Array([[0, 0, 0],
           [0, 0, 0]], dtype=int32)
  r'   r   __jax_array__
zeros_likezjnp.zeros_liker   r+   
hasattrrJ   r   rD   r   r1   r!   r3   r	   	full_likerH   r'   r   r%   r&   r,   s         r"   rK   rK      s    H !W
'!W"5q/"
//
aq)
44ULIE
u%E//l,.(	q!UEH	==r#   c                B   t        | d      rt        | d      s2t        | d      r| j                         } t        j                  d|        |t	        j
                  |d      }|t        |      }t        j                  ||d      }t        j                  | d|||      S )a  Create an array of ones with the same shape and dtype as an array.

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

  Args:
    a: Array-like object with ``shape`` and ``dtype`` attributes.
    shape: optionally override the shape of the created array.
    dtype: optionally override the dtype of the created array.
    device: (optional) :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed.

  Returns:
    Array of the specified shape and dtype, on the specified device if specified.

  See also:
    - :func:`jax.numpy.empty`
    - :func:`jax.numpy.zeros_like`
    - :func:`jax.numpy.ones_like`
    - :func:`jax.numpy.full_like`

  Examples:
    >>> x = jnp.arange(4)
    >>> jnp.ones_like(x)
    Array([1, 1, 1, 1], dtype=int32)
    >>> jnp.ones_like(x, dtype=bool)
    Array([ True,  True,  True,  True], dtype=bool)
    >>> jnp.ones_like(x, shape=(2, 3))
    Array([[1, 1, 1],
           [1, 1, 1]], dtype=int32)
  r'   r   rJ   	ones_likezjnp.ones_liker9   r+   rL   rO   s         r"   rQ   rQ   ,  s    H !W
'!W"5q/"
//
aa(
44UKHE
u%E//lO-(	q!UEH	==r#   	prototypec          	      :   t        | d      rt        | d      s2t        | d      r| j                         } t        j                  d|        |t	        j
                  |d      }|t        |      }t        j                  | d||t        j                  |            S )aN  Create an empty array with the same shape and dtype as an array.

  JAX implementation of :func:`numpy.empty_like`. Because XLA cannot create
  an un-initialized array, :func:`jax.numpy.empty` will always return an
  array full of zeros.

  Args:
    a: Array-like object with ``shape`` and ``dtype`` attributes.
    shape: optionally override the shape of the created array.
    dtype: optionally override the dtype of the created array.
    device: (optional) :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed.

  Returns:
    Array of the specified shape and dtype, on the specified device if specified.

  See also:
    - :func:`jax.numpy.empty`
    - :func:`jax.numpy.zeros_like`
    - :func:`jax.numpy.ones_like`
    - :func:`jax.numpy.full_like`

  Examples:
    >>> x = jnp.arange(4)
    >>> jnp.empty_like(x)
    Array([0, 0, 0, 0], dtype=int32)
    >>> jnp.empty_like(x, dtype=bool)
    Array([False, False, False, False], dtype=bool)
    >>> jnp.empty_like(x, shape=(2, 3))
    Array([[0, 0, 0],
           [0, 0, 0]], dtype=int32)
  r'   r   rJ   rQ   r   r+   )
rM   rJ   r   rD   r   r1   r!   r	   rN   rE   )rR   r'   r   r%   s       r"   
empty_likerT   ]  s    J )W
%')W*Ey/*))+ii0
44UKHE
u%E	y!UE $ D DV L
N Nr#   c          	      j   t        | d      r$t        | d      rt        j                  dd|       n3t        j                  d| |       t        | d      r| j                         } |t	        j
                  |d      }|t        |      }t        j                  |      dk(  r-t        j                  | |||t        j                  |            S |t        j                  |       n|}|t	        j                  |       n|}t        j                  t        j                   t#        ||      |      |      S )a  Create an array full of a specified value with the same shape and dtype as an array.

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

  Args:
    a: Array-like object with ``shape`` and ``dtype`` attributes.
    fill_value: scalar or array with which to fill the created array.
    shape: optionally override the shape of the created array.
    dtype: optionally override the dtype of the created array.
    device: (optional) :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed.

  Returns:
    Array of the specified shape and dtype, on the specified device if specified.

  See also:
    - :func:`jax.numpy.full`
    - :func:`jax.numpy.empty_like`
    - :func:`jax.numpy.zeros_like`
    - :func:`jax.numpy.ones_like`

  Examples:
    >>> x = jnp.arange(4.0)
    >>> jnp.full_like(x, 2)
    Array([2., 2., 2., 2.], dtype=float32)
    >>> jnp.full_like(x, 0, shape=(2, 3))
    Array([[0., 0., 0.],
           [0., 0., 0.]], dtype=float32)

    `fill_value` may also be an array that is broadcast to the specified shape:

    >>> x = jnp.arange(6).reshape(2, 3)
    >>> jnp.full_like(x, fill_value=jnp.array([[1], [2]]))
    Array([[1, 1, 1],
           [2, 2, 2]], dtype=int32)
  r'   r   rN   r   rJ   r+   rC   )rM   r   rD   rJ   r   r1   r!   r    r   r	   rN   rE   r   result_typer   rF   rG   r   )rH   rA   r'   r   r%   s        r"   rN   rN     s   R QWQ0a4a4q/"
//
a
44UKHE
u%EWWZA==Ju"&"F"Fv"NP P !=BHHQKeE%*]Fq!E>>7:U;UCVM Mr#   TFstartstopnumendpointretstepaxisc                     y N rW   rX   rY   rZ   r[   r'   r\   r%   s           r"   linspacera     s	    
 GJr#   c                     y r^   r_   r`   s           r"   ra   ra     s	    
 UXr#   )r'   r\   r%   c                     y r^   r_   r`   s           r"   ra   ra     s	    
 RUr#   c                     y r^   r_   r`   s           r"   ra   ra     s	    
 ]`r#   c          
          t        j                  |d      }t        j                  t        j                  |d      }t        | |||||||      S )a;  Return evenly-spaced numbers within an interval.

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

  Args:
    start: scalar or array of starting values.
    stop: scalar or array of stop values.
    num: number of values to generate. Default: 50.
    endpoint: if True (default) then include the ``stop`` value in the result.
      If False, then exclude the ``stop`` value.
    retstep: If True, then return a ``(result, step)`` tuple, where ``step`` is the
      interval between adjacent values in ``result``.
    axis: integer axis along which to generate the linspace. Defaults to zero.
    device: optional :class:`~jax.Device` or :class:`~jax.sharding.Sharding`
      to which the created array will be committed.

  Returns:
    An array ``values``, or a tuple ``(values, step)`` if ``retstep`` is True, where:

    - ``values`` is an array of evenly-spaced values from ``start`` to ``stop``
    - ``step`` is the interval between adjacent values.

  See also:
    - :func:`jax.numpy.arange`: Generate ``N`` evenly-spaced values given a starting
      point and a step
    - :func:`jax.numpy.logspace`: Generate logarithmically-spaced values.
    - :func:`jax.numpy.geomspace`: Generate geometrically-spaced values.

  Examples:
    List of 5 values between 0 and 10:

    >>> jnp.linspace(0, 10, 5)
    Array([ 0. ,  2.5,  5. ,  7.5, 10. ], dtype=float32)

    List of 8 values between 0 and 10, excluding the endpoint:

    >>> jnp.linspace(0, 10, 8, endpoint=False)
    Array([0.  , 1.25, 2.5 , 3.75, 5.  , 6.25, 7.5 , 8.75], dtype=float32)

    List of values and the step size between them

    >>> vals, step = jnp.linspace(0, 10, 9, retstep=True)
    >>> vals
    Array([ 0.  ,  1.25,  2.5 ,  3.75,  5.  ,  6.25,  7.5 ,  8.75, 10.  ],      dtype=float32)
    >>> step
    Array(1.25, dtype=float32)

    Multi-dimensional linspace:

    >>> start = jnp.array([0, 5])
    >>> stop = jnp.array([5, 10])
    >>> jnp.linspace(start, stop, 5)
    Array([[ 0.  ,  5.  ],
           [ 1.25,  6.25],
           [ 2.5 ,  7.5 ],
           [ 3.75,  8.75],
           [ 5.  , 10.  ]], dtype=float32)
  z'num' argument of jnp.linspacez'axis' argument of jnp.linspacer@   )r   concrete_dim_or_errorconcrete_or_erroroperatorindex	_linspacer`   s           r"   ra   ra     sJ    @ 	""3(HI#			6W	X$	5$XwtF	SSr#   )rY   rZ   r[   r'   r\   r%   )static_argnamesc                d   |dk  rt        d| d      t        j                  d| |      \  } }|*t        j                  t        j
                  | |            }nt        j                  |d      }t        j                  |      }| j                  |      } |j                  |      }t        t        j                  t        j                  |       t        j                  |                  }	t        j                  | |	      }
t        j                  ||	      }|dk  rt        |	      |z   dz   n|}|	j                  |d       |r|dz
  n|}|dkD  rt        j                   || z
  |      t#        ||      z  }dgt        |	      z  }|||<   t        j$                  |      j&                  }t        j(                  ||      j+                  |      t#        ||      z  }|j                  |      }|
j+                  |	      d|z
  z  |j+                  |	      |z  z   }|rt        j,                  |t        j.                  ||f      gt1        ||j2                              }n|dk(  r4t#        |rt        j4                  n|| z
  |      }|
j+                  |	      }n~t        t        j                  t        j                  |       t        j                  |                  }|j                  |d       t7        dt        j4                  |      }t9        ||      }t        j:                  |t        j<                        rCt        j:                  |j&                  t        j<                        st        j>                  |      }t        j@                  |      }t        jB                  |||      }|r||fS |S )	zAImplementation of linspace differentiable in start and stop args.r   zNumber of samples, z, must be non-negative.ra   r9   rC   r_   r+   )"
ValueErrorr   ensure_arrayliker   to_inexact_dtyperV   r1   astyper   r	   broadcast_shapesr    r   rG   leninsertconvert_element_typer   finfor'   iotareshapeconcatenateexpand_dimsr   r   nanr4   r;   
issubdtypeintegerfloorrE   _convert_element_type)rW   rX   rY   rZ   r[   r'   r\   r%   computation_dtypebounds_shapebroadcast_startbroadcast_stopdivdelta
iota_shape
real_dtypestepoutempty_shaper,   results                        r"   rj   rj   &  s    	1W
*3%/FG
HH%%j%>+%
]##F$6$6ud$CDE44UJGE--e4
,,(
)%	&	'$c**288E?BHHTNKL,&&ul;/%%dL9.)-\	T	!A	%t$dAq3#1W++D5L:KLwWZbsOttEL))JJt /066J88J$,,Z873
;SSD;;()D""<0AH=\*T12C OOS#//.4'"JK-dCHH=?c axhBFFD5L@QRE

!
!,
/Cs++BHHUORXXd^LMKtQRVV./E
U
#Cubjj)&2C2CCIIrzz2Z
))C.C11&9($$S%(C&#&%//r#   basec           	          t        j                  t        j                  |d      }t        j                  t        j                  |d      }t	        | ||||||      S )a  Generate logarithmically-spaced values.

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

  Args:
    start: scalar or array. Used to specify the start value. The start value is
      ``base ** start``.
    stop: scalar or array. Used to specify the stop value. The end value is
      ``base ** stop``.
    num: int, optional, default=50. Number of values to generate.
    endpoint: bool, optional, default=True. If True, then include the ``stop`` value
      in the result. If False, then exclude the ``stop`` value.
    base: scalar or array, optional, default=10. Specifies the base of the logarithm.
    dtype: optional. Specifies the dtype of the output.
    axis: int, optional, default=0. Axis along which to generate the logspace.

  Returns:
    An array of logarithm.

  See also:
    - :func:`jax.numpy.arange`: Generate ``N`` evenly-spaced values given a starting
      point and a step value.
    - :func:`jax.numpy.linspace`: Generate evenly-spaced values.
    - :func:`jax.numpy.geomspace`: Generate geometrically-spaced values.

  Examples:
    List 5 logarithmically spaced values between 1 (``10 ** 0``) and 100
    (``10 ** 2``):

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.logspace(0, 2, 5)
    Array([  1.   ,   3.162,  10.   ,  31.623, 100.   ], dtype=float32)

    List 5 logarithmically-spaced values between 1(``10 ** 0``) and 100
    (``10 ** 2``), excluding endpoint:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.logspace(0, 2, 5, endpoint=False)
    Array([ 1.   ,  2.512,  6.31 , 15.849, 39.811], dtype=float32)

    List 7 logarithmically-spaced values between 1 (``2 ** 0``) and 4 (``2 ** 2``)
    with base 2:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.logspace(0, 2, 7, base=2)
    Array([1.   , 1.26 , 1.587, 2.   , 2.52 , 3.175, 4.   ], dtype=float32)

    Multi-dimensional logspace:

    >>> start = jnp.array([0, 5])
    >>> stop = jnp.array([5, 0])
    >>> base = jnp.array([2, 3])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.logspace(start, stop, 5, base=base)
    Array([[  1.   , 243.   ],
           [  2.378,  61.547],
           [  5.657,  15.588],
           [ 13.454,   3.948],
           [ 32.   ,   1.   ]], dtype=float32)
  z'num' argument of jnp.logspacez'axis' argument of jnp.logspace)r   rg   rh   ri   	_logspace)rW   rX   rY   rZ   r   r'   r\   s          r"   logspacer   `  sN    @ 	x~~s4TU#			6W	X$	5$XtUD	AAr#   )rY   rZ   r'   r\   c           	         |*t        j                  t        j                  | |            }nt        j                  |d      }t        j                  |      }t	        j
                  d| |      \  } }| j                  |      } |j                  |      }t        | |||dd|      }t        j                  t        j                  ||      |      S )zAImplementation of logspace differentiable in start and stop args.Nr   F)rZ   r[   r'   r\   )r   ro   rV   r1   r   rn   rp   ra   r	   rt   r   power)	rW   rX   rY   rZ   r   r'   r\   r   lins	            r"   r   r     s    
 ]##F$6$6ud$CDE44UJGE--e4%%j%>+%
,,(
)%	&	'$c"ED	J#		!	!&,,tS"95	AAr#   c                     t        j                  t        j                  |d      }t        j                  t        j                  |d      }t	        | |||||      S )a  Generate geometrically-spaced values.

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

  Args:
    start: scalar or array. Specifies the starting values.
    stop: scalar or array. Specifies the stop values.
    num: int, optional, default=50. Number of values to generate.
    endpoint: bool, optional, default=True. If True, then include the ``stop`` value
      in the result. If False, then exclude the ``stop`` value.
    dtype: optional. Specifies the dtype of the output.
    axis: int, optional, default=0. Axis along which to generate the geomspace.

  Returns:
    An array containing the geometrically-spaced values.

  See also:
    - :func:`jax.numpy.arange`: Generate ``N`` evenly-spaced values given a starting
      point and a step value.
    - :func:`jax.numpy.linspace`: Generate evenly-spaced values.
    - :func:`jax.numpy.logspace`: Generate logarithmically-spaced values.

  Examples:
    List 5 geometrically-spaced values between 1 and 16:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.geomspace(1, 16, 5)
    Array([ 1.,  2.,  4.,  8., 16.], dtype=float32)

    List 4 geomtrically-spaced values between 1 and 16, with ``endpoint=False``:

    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.geomspace(1, 16, 4, endpoint=False)
    Array([1., 2., 4., 8.], dtype=float32)

    Multi-dimensional geomspace:

    >>> start = jnp.array([1, 1000])
    >>> stop = jnp.array([27, 1])
    >>> with jnp.printoptions(precision=3, suppress=True):
    ...   jnp.geomspace(start, stop, 4)
    Array([[   1., 1000.],
           [   3.,  100.],
           [   9.,   10.],
           [  27.,    1.]], dtype=float32)
  z'num' argument of jnp.geomspacez 'axis' argument of jnp.geomspace)r   rg   rh   ri   
_geomspace)rW   rX   rY   rZ   r'   r\   s         r"   	geomspacer     sL    b 	x~~s4UV#			6X	Y$	E4ht	<<r#   c           
         |*t        j                  t        j                  | |            }nt        j                  |d      }t        j                  |      }t	        j
                  d| |      \  } }| j                  |      } |j                  |      }t        j                  |       }|t        t        j                  | |z        t        j                  ||z        ||d|d      z  }t        ||j                        }|dk7  rBt        j                  |g t        d|dz         dt        |dz   |j                              }t        j                   ||      S )zBImplementation of geomspace differentiable in start and stop args.r         $@r   )rZ   r   r'   r\   r9   )permutation)r   ro   rV   r1   r   rn   rp   r   signr   log10r   r   r	   	transposerangert   )	rW   rX   rY   rZ   r'   r\   r   r   ress	            r"   r   r     s2    ]##F$6$6ud$CDE44UKHE--e4%%k5$?+%
,,(
)%	&	'$	U	$xUT\2FLL4MhT/a9 	9# 
4	*$	QY
--)]5D1H+=)]q)]5PQSVS[S[C\)]
^C		!	!#u	--r#   ) r^   )NN)2   TFNr   )Nr   )r   T)r   Tr   Nr   )r   TNr   )<r-   rh   typingr   r   r   numpyr    jax._srcr   r   r   jax._src.laxr	   jax._src.libr
   xc!jax._src.numpy.array_constructorsr   jax._src.numpyr   r   jax._src.shardingr   jax._src.sharding_implsr   r   Pjax._src.typingr   r   r   r   jax._src.utilr   r   exportstrShaper!   Devicer*   r8   r;   r0   r4   rK   rQ   rT   rN   r>   boolra   r   jitrj   r   r   r   r   r_   r#   r"   <module>r      si	     ) )      ) 5 !  & E G G 7 
K	 
3c 3C 3tzz 3 -60437-6 -6Y- -6))h&--6%)D0-6<A-6 -6` -6/326-6 -6I, -6X%,-6$q(4/-6;@-6 -6` *G0437*G *GY- *G))h&-*G%)D0*G<A*G *GZ;S4Z ; #'/M/3/M /M /MD /MX%,/M8=/M /Md )- -> 6:8<	->)n, ->$&->-> yy8+d2-> +Q.5	-> BG	-> ->` (,-> 597;	->^+ ->%->-> ii(*T1-> *A-4	-> AF	-> ->` )- -N 6:-N)n4 -N$&-N-N yy8+d2-N ?D-N -N` ?C9M 599M^+ 9M#9M,5,<9M9M ii(*T19M >C9M 9Mv 
;=>C'+J 7;	JI JY JS JJ-4U^J$J J 		H,t3	J @E	J 
J
 
 (,X 7;	XI XY XS XX&-dmX$X X 		H,t3	X @EUE\?R	X 
X
 
;="U'+37	UI UY US UU07U$U U YY)D0	U =B%,<O	U 
U
 
;=49'+` 7;	`I `Y `S ``-1`$` ` 		H,t3	` @EuUTY\GZ?Z	` 
`
 ;=49'+AT 7;	ATI ATY ATS ATAT-1AT$AT AT 		H,t3	AT @EuUTY\GZ?Z	AT ATF 	RS<>5:(,60 8<	60Y 60i 60c 6060.260%60 60 X-4	60 AFeUZlH[@[	60 T60r ;=6:9:ABI ABY ABS ABAB*3AB$AB36AB?DAB ABF 	=><>7;:;BY Bi Bc BB+4B%B47B@EB ?B" QU:;2=Y 2=i 2=c 2=$ 2=%2=472=@E2= 2=h 	=>RV;<.i .y .s .4 .$&.58.AF. ?.r#   