code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def unstack(x: ArrayLike, /, *, axis: int = 0) -> tuple[Array, ...]:
"""Unstack an array along an axis.
JAX implementation of :func:`array_api.unstack`.
Args:
x: array to unstack. Must have ``x.ndim >= 1``.
axis: integer axis along which to unstack. Must satisfy
``-x.ndim <= axis < x.ndim``.
Re... | Unstack an array along an axis.
JAX implementation of :func:`array_api.unstack`.
Args:
x: array to unstack. Must have ``x.ndim >= 1``.
axis: integer axis along which to unstack. Must satisfy
``-x.ndim <= axis < x.ndim``.
Returns:
tuple of unstacked arrays.
See also:
- :func:`jax.numpy.... | unstack | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def tile(A: ArrayLike, reps: DimSize | Sequence[DimSize]) -> Array:
"""Construct an array by repeating ``A`` along specified dimensions.
JAX implementation of :func:`numpy.tile`.
If ``A`` is an array of shape ``(d1, d2, ..., dn)`` and ``reps`` is a sequence of integers,
the resulting array will have a shape o... | Construct an array by repeating ``A`` along specified dimensions.
JAX implementation of :func:`numpy.tile`.
If ``A`` is an array of shape ``(d1, d2, ..., dn)`` and ``reps`` is a sequence of integers,
the resulting array will have a shape of ``(reps[0] * d1, reps[1] * d2, ..., reps[n] * dn)``,
with ``A`` tiled... | tile | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def concatenate(arrays: np.ndarray | Array | Sequence[ArrayLike],
axis: int | None = 0, dtype: DTypeLike | None = None) -> Array:
"""Join arrays along an existing axis.
JAX implementation of :func:`numpy.concatenate`.
Args:
arrays: a sequence of arrays to concatenate; each must have the same... | Join arrays along an existing axis.
JAX implementation of :func:`numpy.concatenate`.
Args:
arrays: a sequence of arrays to concatenate; each must have the same shape
except along the specified axis. If a single array is given it will be
treated equivalently to `arrays = unstack(arrays)`, but the i... | concatenate | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def concat(arrays: Sequence[ArrayLike], /, *, axis: int | None = 0) -> Array:
"""Join arrays along an existing axis.
JAX implementation of :func:`array_api.concat`.
Args:
arrays: a sequence of arrays to concatenate; each must have the same shape
except along the specified axis. If a single array is gi... | Join arrays along an existing axis.
JAX implementation of :func:`array_api.concat`.
Args:
arrays: a sequence of arrays to concatenate; each must have the same shape
except along the specified axis. If a single array is given it will be
treated equivalently to `arrays = unstack(arrays)`, but the im... | concat | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def vstack(tup: np.ndarray | Array | Sequence[ArrayLike],
dtype: DTypeLike | None = None) -> Array:
"""Vertically stack arrays.
JAX implementation of :func:`numpy.vstack`.
For arrays of two or more dimensions, this is equivalent to
:func:`jax.numpy.concatenate` with ``axis=0``.
Args:
tup: a ... | Vertically stack arrays.
JAX implementation of :func:`numpy.vstack`.
For arrays of two or more dimensions, this is equivalent to
:func:`jax.numpy.concatenate` with ``axis=0``.
Args:
tup: a sequence of arrays to stack; each must have the same shape along all
but the first axis. If a single array is ... | vstack | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def hstack(tup: np.ndarray | Array | Sequence[ArrayLike],
dtype: DTypeLike | None = None) -> Array:
"""Horizontally stack arrays.
JAX implementation of :func:`numpy.hstack`.
For arrays of one or more dimensions, this is equivalent to
:func:`jax.numpy.concatenate` with ``axis=1``.
Args:
tup: ... | Horizontally stack arrays.
JAX implementation of :func:`numpy.hstack`.
For arrays of one or more dimensions, this is equivalent to
:func:`jax.numpy.concatenate` with ``axis=1``.
Args:
tup: a sequence of arrays to stack; each must have the same shape along all
but the second axis. Input arrays will ... | hstack | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def dstack(tup: np.ndarray | Array | Sequence[ArrayLike],
dtype: DTypeLike | None = None) -> Array:
"""Stack arrays depth-wise.
JAX implementation of :func:`numpy.dstack`.
For arrays of three or more dimensions, this is equivalent to
:func:`jax.numpy.concatenate` with ``axis=2``.
Args:
tup: ... | Stack arrays depth-wise.
JAX implementation of :func:`numpy.dstack`.
For arrays of three or more dimensions, this is equivalent to
:func:`jax.numpy.concatenate` with ``axis=2``.
Args:
tup: a sequence of arrays to stack; each must have the same shape along all
but the third axis. Input arrays will b... | dstack | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def column_stack(tup: np.ndarray | Array | Sequence[ArrayLike]) -> Array:
"""Stack arrays column-wise.
JAX implementation of :func:`numpy.column_stack`.
For arrays of two or more dimensions, this is equivalent to
:func:`jax.numpy.concatenate` with ``axis=1``.
Args:
tup: a sequence of arrays to stack; e... | Stack arrays column-wise.
JAX implementation of :func:`numpy.column_stack`.
For arrays of two or more dimensions, this is equivalent to
:func:`jax.numpy.concatenate` with ``axis=1``.
Args:
tup: a sequence of arrays to stack; each must have the same leading dimension.
Input arrays will be promoted t... | column_stack | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def choose(a: ArrayLike, choices: Array | np.ndarray | Sequence[ArrayLike],
out: None = None, mode: str = 'raise') -> Array:
"""Construct an array by stacking slices of choice arrays.
JAX implementation of :func:`numpy.choose`.
The semantics of this function can be confusing, but in the simplest case... | Construct an array by stacking slices of choice arrays.
JAX implementation of :func:`numpy.choose`.
The semantics of this function can be confusing, but in the simplest case where
``a`` is a one-dimensional array, ``choices`` is a two-dimensional array, and
all entries of ``a`` are in-bounds (i.e. ``0 <= a_i ... | choose | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def atleast_1d(*arys: ArrayLike) -> Array | list[Array]:
"""Convert inputs to arrays with at least 1 dimension.
JAX implementation of :func:`numpy.atleast_1d`.
Args:
zero or more arraylike arguments.
Returns:
an array or list of arrays corresponding to the input values. Arrays
of shape ``()`` are... | Convert inputs to arrays with at least 1 dimension.
JAX implementation of :func:`numpy.atleast_1d`.
Args:
zero or more arraylike arguments.
Returns:
an array or list of arrays corresponding to the input values. Arrays
of shape ``()`` are converted to shape ``(1,)``, and arrays with other
shapes... | atleast_1d | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def atleast_2d(*arys: ArrayLike) -> Array | list[Array]:
"""Convert inputs to arrays with at least 2 dimensions.
JAX implementation of :func:`numpy.atleast_2d`.
Args:
zero or more arraylike arguments.
Returns:
an array or list of arrays corresponding to the input values. Arrays
of shape ``()`` ar... | Convert inputs to arrays with at least 2 dimensions.
JAX implementation of :func:`numpy.atleast_2d`.
Args:
zero or more arraylike arguments.
Returns:
an array or list of arrays corresponding to the input values. Arrays
of shape ``()`` are converted to shape ``(1, 1)``, 1D arrays of shape
``(N,)... | atleast_2d | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def atleast_3d(*arys: ArrayLike) -> Array | list[Array]:
"""Convert inputs to arrays with at least 3 dimensions.
JAX implementation of :func:`numpy.atleast_3d`.
Args:
zero or more arraylike arguments.
Returns:
an array or list of arrays corresponding to the input values. Arrays
of shape ``()`` ar... | Convert inputs to arrays with at least 3 dimensions.
JAX implementation of :func:`numpy.atleast_3d`.
Args:
zero or more arraylike arguments.
Returns:
an array or list of arrays corresponding to the input values. Arrays
of shape ``()`` are converted to shape ``(1, 1, 1)``, 1D arrays of
shape ``(... | atleast_3d | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def copy(a: ArrayLike, order: str | None = None) -> Array:
"""Return a copy of the array.
JAX implementation of :func:`numpy.copy`.
Args:
a: arraylike object to copy
order: not implemented in JAX
Returns:
a copy of the input array ``a``.
See Also:
- :func:`jax.numpy.array`: create an array... | Return a copy of the array.
JAX implementation of :func:`numpy.copy`.
Args:
a: arraylike object to copy
order: not implemented in JAX
Returns:
a copy of the input array ``a``.
See Also:
- :func:`jax.numpy.array`: create an array with or without a copy.
- :meth:`jax.Array.copy`: same func... | copy | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def array_equal(a1: ArrayLike, a2: ArrayLike, equal_nan: bool = False) -> Array:
"""Check if two arrays are element-wise equal.
JAX implementation of :func:`numpy.array_equal`.
Args:
a1: first input array to compare.
a2: second input array to compare.
equal_nan: Boolean. If ``True``, NaNs in ``a1`` ... | Check if two arrays are element-wise equal.
JAX implementation of :func:`numpy.array_equal`.
Args:
a1: first input array to compare.
a2: second input array to compare.
equal_nan: Boolean. If ``True``, NaNs in ``a1`` will be considered
equal to NaNs in ``a2``. Default is ``False``.
Returns:
... | array_equal | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def array_equiv(a1: ArrayLike, a2: ArrayLike) -> Array:
"""Check if two arrays are element-wise equal.
JAX implementation of :func:`numpy.array_equiv`.
This function will return ``False`` if the input arrays cannot be broadcasted
to the same shape.
Args:
a1: first input array to compare.
a2: second... | Check if two arrays are element-wise equal.
JAX implementation of :func:`numpy.array_equiv`.
This function will return ``False`` if the input arrays cannot be broadcasted
to the same shape.
Args:
a1: first input array to compare.
a2: second input array to compare.
Returns:
Boolean scalar array... | array_equiv | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def frombuffer(buffer: bytes | Any, dtype: DTypeLike = float,
count: int = -1, offset: int = 0) -> Array:
r"""Convert a buffer into a 1-D JAX array.
JAX implementation of :func:`numpy.frombuffer`.
Args:
buffer: an object containing the data. It must be either a bytes object with
a lengt... | Convert a buffer into a 1-D JAX array.
JAX implementation of :func:`numpy.frombuffer`.
Args:
buffer: an object containing the data. It must be either a bytes object with
a length that is an integer multiple of the dtype element size, or
it must be an object exporting the `Python buffer interface`_... | frombuffer | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def fromfile(*args, **kwargs):
"""Unimplemented JAX wrapper for jnp.fromfile.
This function is left deliberately unimplemented because it may be non-pure and thus
unsafe for use with JIT and other JAX transformations. Consider using
``jnp.asarray(np.fromfile(...))`` instead, although care should be taken if ``... | Unimplemented JAX wrapper for jnp.fromfile.
This function is left deliberately unimplemented because it may be non-pure and thus
unsafe for use with JIT and other JAX transformations. Consider using
``jnp.asarray(np.fromfile(...))`` instead, although care should be taken if ``np.fromfile``
is used within jax t... | fromfile | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def fromfunction(function: Callable[..., Array], shape: Any,
*, dtype: DTypeLike = float, **kwargs) -> Array:
"""Create an array from a function applied over indices.
JAX implementation of :func:`numpy.fromfunction`. The JAX implementation
differs in that it dispatches via :func:`jax.vmap`, and ... | Create an array from a function applied over indices.
JAX implementation of :func:`numpy.fromfunction`. The JAX implementation
differs in that it dispatches via :func:`jax.vmap`, and so unlike in NumPy
the function logically operates on scalar inputs, and need not explicitly
handle broadcasted inputs (See *Exa... | fromfunction | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def identity(n: DimSize, dtype: DTypeLike | None = None) -> Array:
"""Create a square identity matrix
JAX implementation of :func:`numpy.identity`.
Args:
n: integer specifying the size of each array dimension.
dtype: optional dtype; defaults to floating point.
Returns:
Identity array of shape ``(... | Create a square identity matrix
JAX implementation of :func:`numpy.identity`.
Args:
n: integer specifying the size of each array dimension.
dtype: optional dtype; defaults to floating point.
Returns:
Identity array of shape ``(n, n)``.
See also:
:func:`jax.numpy.eye`: non-square and/or offse... | identity | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def meshgrid(*xi: ArrayLike, copy: bool = True, sparse: bool = False,
indexing: str = 'xy') -> list[Array]:
"""Construct N-dimensional grid arrays from N 1-dimensional vectors.
JAX implementation of :func:`numpy.meshgrid`.
Args:
xi: N arrays to convert to a grid.
copy: whether to copy the i... | Construct N-dimensional grid arrays from N 1-dimensional vectors.
JAX implementation of :func:`numpy.meshgrid`.
Args:
xi: N arrays to convert to a grid.
copy: whether to copy the input arrays. JAX supports only ``copy=True``,
though under JIT compilation the compiler may opt to avoid copies.
spa... | meshgrid | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def i0(x: ArrayLike) -> Array:
r"""Calculate modified Bessel function of first kind, zeroth order.
JAX implementation of :func:`numpy.i0`.
Modified Bessel function of first kind, zeroth order is defined by:
.. math::
\mathrm{i0}(x) = I_0(x) = \sum_{k=0}^{\infty} \frac{(x^2/4)^k}{(k!)^2}
Args:
x:... | Calculate modified Bessel function of first kind, zeroth order.
JAX implementation of :func:`numpy.i0`.
Modified Bessel function of first kind, zeroth order is defined by:
.. math::
\mathrm{i0}(x) = I_0(x) = \sum_{k=0}^{\infty} \frac{(x^2/4)^k}{(k!)^2}
Args:
x: scalar or array. Specifies the argum... | i0 | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def ix_(*args: ArrayLike) -> tuple[Array, ...]:
"""Return a multi-dimensional grid (open mesh) from N one-dimensional sequences.
JAX implementation of :func:`numpy.ix_`.
Args:
*args: N one-dimensional arrays
Returns:
Tuple of Jax arrays forming an open mesh, each with N dimensions.
See Also:
-... | Return a multi-dimensional grid (open mesh) from N one-dimensional sequences.
JAX implementation of :func:`numpy.ix_`.
Args:
*args: N one-dimensional arrays
Returns:
Tuple of Jax arrays forming an open mesh, each with N dimensions.
See Also:
- :obj:`jax.numpy.ogrid`
- :obj:`jax.numpy.mgrid`
... | ix_ | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def indices(dimensions: Sequence[int], dtype: DTypeLike | None = None,
sparse: bool = False) -> Array | tuple[Array, ...]:
"""Generate arrays of grid indices.
JAX implementation of :func:`numpy.indices`.
Args:
dimensions: the shape of the grid.
dtype: the dtype of the indices (defaults to in... | Generate arrays of grid indices.
JAX implementation of :func:`numpy.indices`.
Args:
dimensions: the shape of the grid.
dtype: the dtype of the indices (defaults to integer).
sparse: if True, then return sparse indices. Default is False, which
returns dense indices.
Returns:
An array of sh... | indices | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def repeat(a: ArrayLike, repeats: ArrayLike, axis: int | None = None, *,
total_repeat_length: int | None = None,
out_sharding: NamedSharding | P | None = None) -> Array:
"""Construct an array from repeated elements.
JAX implementation of :func:`numpy.repeat`.
Args:
a: N-dimensional arr... | Construct an array from repeated elements.
JAX implementation of :func:`numpy.repeat`.
Args:
a: N-dimensional array
repeats: 1D integer array specifying the number of repeats. Must match the
length of the repeated axis.
axis: integer specifying the axis of ``a`` along which to construct the
... | repeat | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def trapezoid(y: ArrayLike, x: ArrayLike | None = None, dx: ArrayLike = 1.0,
axis: int = -1) -> Array:
r"""
Integrate along the given axis using the composite trapezoidal rule.
JAX implementation of :func:`numpy.trapezoid`
The trapezoidal rule approximates the integral under a curve by summing t... |
Integrate along the given axis using the composite trapezoidal rule.
JAX implementation of :func:`numpy.trapezoid`
The trapezoidal rule approximates the integral under a curve by summing the
areas of trapezoids formed between adjacent data points.
Args:
y: array of data to integrate.
x: optional a... | trapezoid | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def tri(N: int, M: int | None = None, k: int = 0, dtype: DTypeLike | None = None) -> Array:
r"""Return an array with ones on and below the diagonal and zeros elsewhere.
JAX implementation of :func:`numpy.tri`
Args:
N: int. Dimension of the rows of the returned array.
M: optional, int. Dimension of the c... | Return an array with ones on and below the diagonal and zeros elsewhere.
JAX implementation of :func:`numpy.tri`
Args:
N: int. Dimension of the rows of the returned array.
M: optional, int. Dimension of the columns of the returned array. If not
specified, then ``M = N``.
k: optional, int, defaul... | tri | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def tril(m: ArrayLike, k: int = 0) -> Array:
r"""Return lower triangle of an array.
JAX implementation of :func:`numpy.tril`
Args:
m: input array. Must have ``m.ndim >= 2``.
k: k: optional, int, default=0. Specifies the sub-diagonal above which the
elements of the array are set to zero. ``k=0`` re... | Return lower triangle of an array.
JAX implementation of :func:`numpy.tril`
Args:
m: input array. Must have ``m.ndim >= 2``.
k: k: optional, int, default=0. Specifies the sub-diagonal above which the
elements of the array are set to zero. ``k=0`` refers to main diagonal,
``k<0`` refers to sub-... | tril | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def triu(m: ArrayLike, k: int = 0) -> Array:
r"""Return upper triangle of an array.
JAX implementation of :func:`numpy.triu`
Args:
m: input array. Must have ``m.ndim >= 2``.
k: optional, int, default=0. Specifies the sub-diagonal below which the
elements of the array are set to zero. ``k=0`` refer... | Return upper triangle of an array.
JAX implementation of :func:`numpy.triu`
Args:
m: input array. Must have ``m.ndim >= 2``.
k: optional, int, default=0. Specifies the sub-diagonal below which the
elements of the array are set to zero. ``k=0`` refers to main diagonal,
``k<0`` refers to sub-dia... | triu | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def trace(a: ArrayLike, offset: int | ArrayLike = 0, axis1: int = 0, axis2: int = 1,
dtype: DTypeLike | None = None, out: None = None) -> Array:
"""Calculate sum of the diagonal of input along the given axes.
JAX implementation of :func:`numpy.trace`.
Args:
a: input array. Must have ``a.ndim >= 2`... | Calculate sum of the diagonal of input along the given axes.
JAX implementation of :func:`numpy.trace`.
Args:
a: input array. Must have ``a.ndim >= 2``.
offset: optional, int, default=0. Diagonal offset from the main diagonal.
Can be positive or negative.
axis1: optional, default=0. The first ax... | trace | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def mask_indices(n: int,
mask_func: Callable[[ArrayLike, int], Array],
k: int = 0, *, size: int | None = None) -> tuple[Array, Array]:
"""Return indices of a mask of an (n, n) array.
Args:
n: static integer array dimension.
mask_func: a function that takes a shape ``(n, n)... | Return indices of a mask of an (n, n) array.
Args:
n: static integer array dimension.
mask_func: a function that takes a shape ``(n, n)`` array and
an optional offset ``k``, and returns a shape ``(n, n)`` mask.
Examples of functions with this signature are
:func:`~jax.numpy.triu` and :func:... | mask_indices | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def triu_indices(n: int, k: int = 0, m: int | None = None) -> tuple[Array, Array]:
"""Return the indices of upper triangle of an array of size ``(n, m)``.
JAX implementation of :func:`numpy.triu_indices`.
Args:
n: int. Number of rows of the array for which the indices are returned.
k: optional, int, def... | Return the indices of upper triangle of an array of size ``(n, m)``.
JAX implementation of :func:`numpy.triu_indices`.
Args:
n: int. Number of rows of the array for which the indices are returned.
k: optional, int, default=0. Specifies the sub-diagonal on and above which
the indices of upper triangl... | triu_indices | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def tril_indices(n: int, k: int = 0, m: int | None = None) -> tuple[Array, Array]:
"""Return the indices of lower triangle of an array of size ``(n, m)``.
JAX implementation of :func:`numpy.tril_indices`.
Args:
n: int. Number of rows of the array for which the indices are returned.
k: optional, int, def... | Return the indices of lower triangle of an array of size ``(n, m)``.
JAX implementation of :func:`numpy.tril_indices`.
Args:
n: int. Number of rows of the array for which the indices are returned.
k: optional, int, default=0. Specifies the sub-diagonal on and below which
the indices of lower triangl... | tril_indices | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def triu_indices_from(arr: ArrayLike | SupportsShape, k: int = 0) -> tuple[Array, Array]:
"""Return the indices of upper triangle of a given array.
JAX implementation of :func:`numpy.triu_indices_from`.
Args:
arr: input array. Must have ``arr.ndim == 2``.
k: optional, int, default=0. Specifies the sub-d... | Return the indices of upper triangle of a given array.
JAX implementation of :func:`numpy.triu_indices_from`.
Args:
arr: input array. Must have ``arr.ndim == 2``.
k: optional, int, default=0. Specifies the sub-diagonal on and above which
the indices of upper triangle are returned. ``k=0`` refers to ... | triu_indices_from | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def tril_indices_from(arr: ArrayLike | SupportsShape, k: int = 0) -> tuple[Array, Array]:
"""Return the indices of lower triangle of a given array.
JAX implementation of :func:`numpy.tril_indices_from`.
Args:
arr: input array. Must have ``arr.ndim == 2``.
k: optional, int, default=0. Specifies the sub-d... | Return the indices of lower triangle of a given array.
JAX implementation of :func:`numpy.tril_indices_from`.
Args:
arr: input array. Must have ``arr.ndim == 2``.
k: optional, int, default=0. Specifies the sub-diagonal on and below which
the indices of upper triangle are returned. ``k=0`` refers to ... | tril_indices_from | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def fill_diagonal(a: ArrayLike, val: ArrayLike, wrap: bool = False, *,
inplace: bool = True) -> Array:
"""Return a copy of the array with the diagonal overwritten.
JAX implementation of :func:`numpy.fill_diagonal`.
The semantics of :func:`numpy.fill_diagonal` are to modify arrays in-place, whi... | Return a copy of the array with the diagonal overwritten.
JAX implementation of :func:`numpy.fill_diagonal`.
The semantics of :func:`numpy.fill_diagonal` are to modify arrays in-place, which
is not possible for JAX's immutable arrays. The JAX version returns a modified
copy of the input, and adds the ``inplac... | fill_diagonal | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def diag_indices(n: int, ndim: int = 2) -> tuple[Array, ...]:
"""Return indices for accessing the main diagonal of a multidimensional array.
JAX implementation of :func:`numpy.diag_indices`.
Args:
n: int. The size of each dimension of the square array.
ndim: optional, int, default=2. The number of dimen... | Return indices for accessing the main diagonal of a multidimensional array.
JAX implementation of :func:`numpy.diag_indices`.
Args:
n: int. The size of each dimension of the square array.
ndim: optional, int, default=2. The number of dimensions of the array.
Returns:
A tuple of arrays, each of leng... | diag_indices | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def diag_indices_from(arr: ArrayLike) -> tuple[Array, ...]:
"""Return indices for accessing the main diagonal of a given array.
JAX implementation of :func:`numpy.diag_indices_from`.
Args:
arr: Input array. Must be at least 2-dimensional and have equal length along
all dimensions.
Returns:
A tu... | Return indices for accessing the main diagonal of a given array.
JAX implementation of :func:`numpy.diag_indices_from`.
Args:
arr: Input array. Must be at least 2-dimensional and have equal length along
all dimensions.
Returns:
A tuple of arrays containing the indices to access the main diagonal ... | diag_indices_from | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def diagonal(a: ArrayLike, offset: int = 0, axis1: int = 0,
axis2: int = 1) -> Array:
"""Returns the specified diagonal of an array.
JAX implementation of :func:`numpy.diagonal`.
The JAX version always returns a copy of the input, although if this is used
within a JIT compilation, the compiler ma... | Returns the specified diagonal of an array.
JAX implementation of :func:`numpy.diagonal`.
The JAX version always returns a copy of the input, although if this is used
within a JIT compilation, the compiler may avoid the copy.
Args:
a: Input array. Must be at least 2-dimensional.
offset: optional, def... | diagonal | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def diag(v: ArrayLike, k: int = 0) -> Array:
"""Returns the specified diagonal or constructs a diagonal array.
JAX implementation of :func:`numpy.diag`.
The JAX version always returns a copy of the input, although if this is used
within a JIT compilation, the compiler may avoid the copy.
Args:
v: Input... | Returns the specified diagonal or constructs a diagonal array.
JAX implementation of :func:`numpy.diag`.
The JAX version always returns a copy of the input, although if this is used
within a JIT compilation, the compiler may avoid the copy.
Args:
v: Input array. Can be a 1-D array to create a diagonal ma... | diag | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def diagflat(v: ArrayLike, k: int = 0) -> Array:
"""Return a 2-D array with the flattened input array laid out on the diagonal.
JAX implementation of :func:`numpy.diagflat`.
This differs from `np.diagflat` for some scalar values of `v`. JAX always returns
a two-dimensional array, whereas NumPy may return a sc... | Return a 2-D array with the flattened input array laid out on the diagonal.
JAX implementation of :func:`numpy.diagflat`.
This differs from `np.diagflat` for some scalar values of `v`. JAX always returns
a two-dimensional array, whereas NumPy may return a scalar depending on the type
of `v`.
Args:
v: I... | diagflat | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def trim_zeros(filt: ArrayLike, trim: str ='fb') -> Array:
"""Trim leading and/or trailing zeros of the input array.
JAX implementation of :func:`numpy.trim_zeros`.
Args:
filt: input array. Must have ``filt.ndim == 1``.
trim: string, optional, default = ``fb``. Specifies from which end the input
i... | Trim leading and/or trailing zeros of the input array.
JAX implementation of :func:`numpy.trim_zeros`.
Args:
filt: input array. Must have ``filt.ndim == 1``.
trim: string, optional, default = ``fb``. Specifies from which end the input
is trimmed.
- ``f`` - trims only the leading zeros.
... | trim_zeros | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def append(
arr: ArrayLike, values: ArrayLike, axis: int | None = None
) -> Array:
"""Return a new array with values appended to the end of the original array.
JAX implementation of :func:`numpy.append`.
Args:
arr: original array.
values: values to be appended to the array. The ``values`` must have
... | Return a new array with values appended to the end of the original array.
JAX implementation of :func:`numpy.append`.
Args:
arr: original array.
values: values to be appended to the array. The ``values`` must have
the same number of dimensions as ``arr``, and all dimensions must
match except i... | append | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def delete(
arr: ArrayLike,
obj: ArrayLike | slice,
axis: int | None = None,
*,
assume_unique_indices: bool = False,
) -> Array:
"""Delete entry or entries from an array.
JAX implementation of :func:`numpy.delete`.
Args:
arr: array from which entries will be deleted.
obj: index, indi... | Delete entry or entries from an array.
JAX implementation of :func:`numpy.delete`.
Args:
arr: array from which entries will be deleted.
obj: index, indices, or slice to be deleted.
axis: axis along which entries will be deleted.
assume_unique_indices: In case of array-like integer (not boolean) in... | delete | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def insert(arr: ArrayLike, obj: ArrayLike | slice, values: ArrayLike,
axis: int | None = None) -> Array:
"""Insert entries into an array at specified indices.
JAX implementation of :func:`numpy.insert`.
Args:
arr: array object into which values will be inserted.
obj: slice or array of indices... | Insert entries into an array at specified indices.
JAX implementation of :func:`numpy.insert`.
Args:
arr: array object into which values will be inserted.
obj: slice or array of indices specifying insertion locations.
values: array of values to be inserted.
axis: specify the insertion axis in the ... | insert | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def apply_along_axis(
func1d: Callable, axis: int, arr: ArrayLike, *args, **kwargs
) -> Array:
"""Apply a function to 1D array slices along an axis.
JAX implementation of :func:`numpy.apply_along_axis`. While NumPy implements
this iteratively, JAX implements this via :func:`jax.vmap`, and so ``func1d``
mus... | Apply a function to 1D array slices along an axis.
JAX implementation of :func:`numpy.apply_along_axis`. While NumPy implements
this iteratively, JAX implements this via :func:`jax.vmap`, and so ``func1d``
must be compatible with ``vmap``.
Args:
func1d: a callable function with signature ``func1d(arr, /, ... | apply_along_axis | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def apply_over_axes(func: Callable[[ArrayLike, int], Array], a: ArrayLike,
axes: Sequence[int]) -> Array:
"""Apply a function repeatedly over specified axes.
JAX implementation of :func:`numpy.apply_over_axes`.
Args:
func: the function to apply, with signature ``func(Array, int) -> Array... | Apply a function repeatedly over specified axes.
JAX implementation of :func:`numpy.apply_over_axes`.
Args:
func: the function to apply, with signature ``func(Array, int) -> Array``, and
where ``y = func(x, axis)`` must satisfy ``y.ndim in [x.ndim, x.ndim - 1]``.
a: N-dimensional array over which to... | apply_over_axes | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def cross(a, b, axisa: int = -1, axisb: int = -1, axisc: int = -1,
axis: int | None = None):
r"""Compute the (batched) cross product of two arrays.
JAX implementation of :func:`numpy.cross`.
This computes the 2-dimensional or 3-dimensional cross product,
.. math::
c = a \times b
In 3 dimen... | Compute the (batched) cross product of two arrays.
JAX implementation of :func:`numpy.cross`.
This computes the 2-dimensional or 3-dimensional cross product,
.. math::
c = a \times b
In 3 dimensions, ``c`` is a length-3 array. In 2 dimensions, ``c`` is
a scalar.
Args:
a: N-dimensional array. ... | cross | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def kron(a: ArrayLike, b: ArrayLike) -> Array:
"""Compute the Kronecker product of two input arrays.
JAX implementation of :func:`numpy.kron`.
The Kronecker product is an operation on two matrices of arbitrary size that
produces a block matrix. Each element of the first matrix ``a`` is multiplied by
the ent... | Compute the Kronecker product of two input arrays.
JAX implementation of :func:`numpy.kron`.
The Kronecker product is an operation on two matrices of arbitrary size that
produces a block matrix. Each element of the first matrix ``a`` is multiplied by
the entire second matrix ``b``. If ``a`` has shape (m, n) a... | kron | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def vander(
x: ArrayLike, N: int | None = None, increasing: bool = False
) -> Array:
"""Generate a Vandermonde matrix.
JAX implementation of :func:`numpy.vander`.
Args:
x: input array. Must have ``x.ndim == 1``.
N: int, optional, default=None. Specifies the number of the columns the
output mat... | Generate a Vandermonde matrix.
JAX implementation of :func:`numpy.vander`.
Args:
x: input array. Must have ``x.ndim == 1``.
N: int, optional, default=None. Specifies the number of the columns the
output matrix. If not specified, ``N = len(x)``.
increasing: bool, optional, default=False. Specifie... | vander | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def argwhere(
a: ArrayLike,
*,
size: int | None = None,
fill_value: ArrayLike | None = None,
) -> Array:
"""Find the indices of nonzero array elements
JAX implementation of :func:`numpy.argwhere`.
``jnp.argwhere(x)`` is essentially equivalent to ``jnp.column_stack(jnp.nonzero(x))``
with specia... | Find the indices of nonzero array elements
JAX implementation of :func:`numpy.argwhere`.
``jnp.argwhere(x)`` is essentially equivalent to ``jnp.column_stack(jnp.nonzero(x))``
with special handling for zero-dimensional (i.e. scalar) inputs.
Because the size of the output of ``argwhere`` is data-dependent, the... | argwhere | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def argmax(a: ArrayLike, axis: int | None = None, out: None = None,
keepdims: bool | None = None) -> Array:
"""Return the index of the maximum value of an array.
JAX implementation of :func:`numpy.argmax`.
Args:
a: input array
axis: optional integer specifying the axis along which to find the... | Return the index of the maximum value of an array.
JAX implementation of :func:`numpy.argmax`.
Args:
a: input array
axis: optional integer specifying the axis along which to find the maximum
value. If ``axis`` is not specified, ``a`` will be flattened.
out: unused by JAX
keepdims: if True, t... | argmax | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def argmin(a: ArrayLike, axis: int | None = None, out: None = None,
keepdims: bool | None = None) -> Array:
"""Return the index of the minimum value of an array.
JAX implementation of :func:`numpy.argmin`.
Args:
a: input array
axis: optional integer specifying the axis along which to find the... | Return the index of the minimum value of an array.
JAX implementation of :func:`numpy.argmin`.
Args:
a: input array
axis: optional integer specifying the axis along which to find the minimum
value. If ``axis`` is not specified, ``a`` will be flattened.
out: unused by JAX
keepdims: if True, t... | argmin | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def nanargmax(
a: ArrayLike,
axis: int | None = None,
out: None = None,
keepdims: bool | None = None,
) -> Array:
"""Return the index of the maximum value of an array, ignoring NaNs.
JAX implementation of :func:`numpy.nanargmax`.
Args:
a: input array
axis: optional integer specifying the... | Return the index of the maximum value of an array, ignoring NaNs.
JAX implementation of :func:`numpy.nanargmax`.
Args:
a: input array
axis: optional integer specifying the axis along which to find the maximum
value. If ``axis`` is not specified, ``a`` will be flattened.
out: unused by JAX
ke... | nanargmax | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def nanargmin(
a: ArrayLike,
axis: int | None = None,
out: None = None,
keepdims: bool | None = None,
) -> Array:
"""Return the index of the minimum value of an array, ignoring NaNs.
JAX implementation of :func:`numpy.nanargmin`.
Args:
a: input array
axis: optional integer specifying th... | Return the index of the minimum value of an array, ignoring NaNs.
JAX implementation of :func:`numpy.nanargmin`.
Args:
a: input array
axis: optional integer specifying the axis along which to find the maximum
value. If ``axis`` is not specified, ``a`` will be flattened.
out: unused by JAX
ke... | nanargmin | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def roll(a: ArrayLike, shift: ArrayLike | Sequence[int],
axis: int | Sequence[int] | None = None) -> Array:
"""Roll the elements of an array along a specified axis.
JAX implementation of :func:`numpy.roll`.
Args:
a: input array.
shift: the number of positions to shift the specified axis. If an ... | Roll the elements of an array along a specified axis.
JAX implementation of :func:`numpy.roll`.
Args:
a: input array.
shift: the number of positions to shift the specified axis. If an integer,
all axes are shifted by the same amount. If a tuple, the shift for each
axis is specified individuall... | roll | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def rollaxis(a: ArrayLike, axis: int, start: int = 0) -> Array:
"""Roll the specified axis to a given position.
JAX implementation of :func:`numpy.rollaxis`.
This function exists for compatibility with NumPy, but in most cases the newer
:func:`jax.numpy.moveaxis` instead, because the meaning of its arguments ... | Roll the specified axis to a given position.
JAX implementation of :func:`numpy.rollaxis`.
This function exists for compatibility with NumPy, but in most cases the newer
:func:`jax.numpy.moveaxis` instead, because the meaning of its arguments is
more intuitive.
Args:
a: input array.
axis: index of ... | rollaxis | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def packbits(a: ArrayLike, axis: int | None = None, bitorder: str = "big") -> Array:
"""Pack array of bits into a uint8 array.
JAX implementation of :func:`numpy.packbits`
Args:
a: N-dimensional array of bits to pack.
axis: optional axis along which to pack bits. If not specified, ``a`` will
be fl... | Pack array of bits into a uint8 array.
JAX implementation of :func:`numpy.packbits`
Args:
a: N-dimensional array of bits to pack.
axis: optional axis along which to pack bits. If not specified, ``a`` will
be flattened.
bitorder: ``"big"`` (default) or ``"little"``: specify whether the bit order
... | packbits | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def unpackbits(
a: ArrayLike,
axis: int | None = None,
count: int | None = None,
bitorder: str = "big",
) -> Array:
"""Unpack the bits in a uint8 array.
JAX implementation of :func:`numpy.unpackbits`.
Args:
a: N-dimensional array of type ``uint8``.
axis: optional axis along which to unpa... | Unpack the bits in a uint8 array.
JAX implementation of :func:`numpy.unpackbits`.
Args:
a: N-dimensional array of type ``uint8``.
axis: optional axis along which to unpack. If not specified, ``a`` will
be flattened
count: specify the number of bits to unpack (if positive) or the number
of ... | unpackbits | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def gcd(x1: ArrayLike, x2: ArrayLike) -> Array:
"""Compute the greatest common divisor of two arrays.
JAX implementation of :func:`numpy.gcd`.
Args:
x1: First input array. The elements must have integer dtype.
x2: Second input array. The elements must have integer dtype.
Returns:
An array contain... | Compute the greatest common divisor of two arrays.
JAX implementation of :func:`numpy.gcd`.
Args:
x1: First input array. The elements must have integer dtype.
x2: Second input array. The elements must have integer dtype.
Returns:
An array containing the greatest common divisors of the corresponding... | gcd | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def lcm(x1: ArrayLike, x2: ArrayLike) -> Array:
"""Compute the least common multiple of two arrays.
JAX implementation of :func:`numpy.lcm`.
Args:
x1: First input array. The elements must have integer dtype.
x2: Second input array. The elements must have integer dtype.
Returns:
An array containin... | Compute the least common multiple of two arrays.
JAX implementation of :func:`numpy.lcm`.
Args:
x1: First input array. The elements must have integer dtype.
x2: Second input array. The elements must have integer dtype.
Returns:
An array containing the least common multiple of the corresponding
... | lcm | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def extract(condition: ArrayLike, arr: ArrayLike,
*, size: int | None = None, fill_value: ArrayLike = 0) -> Array:
"""Return the elements of an array that satisfy a condition.
JAX implementation of :func:`numpy.extract`.
Args:
condition: array of conditions. Will be converted to boolean and flat... | Return the elements of an array that satisfy a condition.
JAX implementation of :func:`numpy.extract`.
Args:
condition: array of conditions. Will be converted to boolean and flattened to 1D.
arr: array of values to extract. Will be flattened to 1D.
size: optional static size for output. Must be specif... | extract | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def compress(condition: ArrayLike, a: ArrayLike, axis: int | None = None,
*, size: int | None = None, fill_value: ArrayLike = 0, out: None = None) -> Array:
"""Compress an array along a given axis using a boolean condition.
JAX implementation of :func:`numpy.compress`.
Args:
condition: 1-dimens... | Compress an array along a given axis using a boolean condition.
JAX implementation of :func:`numpy.compress`.
Args:
condition: 1-dimensional array of conditions. Will be converted to boolean.
a: N-dimensional array of values.
axis: axis along which to compress. If None (default) then ``a`` will be
... | compress | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def cov(m: ArrayLike, y: ArrayLike | None = None, rowvar: bool = True,
bias: bool = False, ddof: int | None = None,
fweights: ArrayLike | None = None,
aweights: ArrayLike | None = None) -> Array:
r"""Estimate the weighted sample covariance.
JAX implementation of :func:`numpy.cov`.
The co... | Estimate the weighted sample covariance.
JAX implementation of :func:`numpy.cov`.
The covariance :math:`C_{ij}` between variable *i* and variable *j* is defined
as
.. math::
cov[X_i, X_j] = E[(X_i - E[X_i])(X_j - E[X_j])]
Given an array of *N* observations of the variables :math:`X_i` and :math:`X_j... | cov | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def corrcoef(x: ArrayLike, y: ArrayLike | None = None, rowvar: bool = True) -> Array:
r"""Compute the Pearson correlation coefficients.
JAX implementation of :func:`numpy.corrcoef`.
This is a normalized version of the sample covariance computed by :func:`jax.numpy.cov`.
For a sample covariance :math:`C_{ij}`,... | Compute the Pearson correlation coefficients.
JAX implementation of :func:`numpy.corrcoef`.
This is a normalized version of the sample covariance computed by :func:`jax.numpy.cov`.
For a sample covariance :math:`C_{ij}`, the correlation coefficients are
.. math::
R_{ij} = \frac{C_{ij}}{\sqrt{C_{ii}C_{j... | corrcoef | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def searchsorted(a: ArrayLike, v: ArrayLike, side: str = 'left',
sorter: ArrayLike | None = None, *, method: str = 'scan') -> Array:
"""Perform a binary search within a sorted array.
JAX implementation of :func:`numpy.searchsorted`.
This will return the indices within a sorted array ``a`` where... | Perform a binary search within a sorted array.
JAX implementation of :func:`numpy.searchsorted`.
This will return the indices within a sorted array ``a`` where values in ``v``
can be inserted to maintain its sort order.
Args:
a: one-dimensional array, assumed to be in sorted order unless ``sorter`` is sp... | searchsorted | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def digitize(x: ArrayLike, bins: ArrayLike, right: bool = False,
*, method: str | None = None) -> Array:
"""Convert an array to bin indices.
JAX implementation of :func:`numpy.digitize`.
Args:
x: array of values to digitize.
bins: 1D array of bin edges. Must be monotonically increasing or d... | Convert an array to bin indices.
JAX implementation of :func:`numpy.digitize`.
Args:
x: array of values to digitize.
bins: 1D array of bin edges. Must be monotonically increasing or decreasing.
right: if true, the intervals include the right bin edges. If false (default)
the intervals include th... | digitize | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def piecewise(x: ArrayLike, condlist: Array | Sequence[ArrayLike],
funclist: list[ArrayLike | Callable[..., Array]],
*args, **kw) -> Array:
"""Evaluate a function defined piecewise across the domain.
JAX implementation of :func:`numpy.piecewise`, in terms of :func:`jax.lax.switch`.
N... | Evaluate a function defined piecewise across the domain.
JAX implementation of :func:`numpy.piecewise`, in terms of :func:`jax.lax.switch`.
Note:
Unlike :func:`numpy.piecewise`, :func:`jax.numpy.piecewise` requires functions
in ``funclist`` to be traceable by JAX, as it is implemented via
:func:`jax.l... | piecewise | python | jax-ml/jax | jax/_src/numpy/lax_numpy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/lax_numpy.py | Apache-2.0 |
def matrix_power(a: ArrayLike, n: int) -> Array:
"""Raise a square matrix to an integer power.
JAX implementation of :func:`numpy.linalg.matrix_power`, implemented via
repeated squarings.
Args:
a: array of shape ``(..., M, M)`` to be raised to the power `n`.
n: the integer exponent to which the matrix... | Raise a square matrix to an integer power.
JAX implementation of :func:`numpy.linalg.matrix_power`, implemented via
repeated squarings.
Args:
a: array of shape ``(..., M, M)`` to be raised to the power `n`.
n: the integer exponent to which the matrix should be raised.
Returns:
Array of shape ``(.... | matrix_power | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def matrix_rank(
M: ArrayLike, rtol: ArrayLike | None = None, *,
tol: ArrayLike | DeprecatedArg | None = DeprecatedArg()) -> Array:
"""Compute the rank of a matrix.
JAX implementation of :func:`numpy.linalg.matrix_rank`.
The rank is calculated via the Singular Value Decomposition (SVD), and determined
by ... | Compute the rank of a matrix.
JAX implementation of :func:`numpy.linalg.matrix_rank`.
The rank is calculated via the Singular Value Decomposition (SVD), and determined
by the number of singular values greater than the specified tolerance.
Args:
M: array of shape ``(..., N, K)`` whose rank is to be comput... | matrix_rank | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def _cofactor_solve(a: ArrayLike, b: ArrayLike) -> tuple[Array, Array]:
"""Equivalent to det(a)*solve(a, b) for nonsingular mat.
Intermediate function used for jvp and vjp of det.
This function borrows heavily from jax.numpy.linalg.solve and
jax.numpy.linalg.slogdet to compute the gradient of the determinant
... | Equivalent to det(a)*solve(a, b) for nonsingular mat.
Intermediate function used for jvp and vjp of det.
This function borrows heavily from jax.numpy.linalg.solve and
jax.numpy.linalg.slogdet to compute the gradient of the determinant
in a way that is well defined even for low rank matrices.
This function h... | _cofactor_solve | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def det(a: ArrayLike) -> Array:
"""
Compute the determinant of an array.
JAX implementation of :func:`numpy.linalg.det`.
Args:
a: array of shape ``(..., M, M)`` for which to compute the determinant.
Returns:
An array of determinants of shape ``a.shape[:-2]``.
See also:
:func:`jax.scipy.linal... |
Compute the determinant of an array.
JAX implementation of :func:`numpy.linalg.det`.
Args:
a: array of shape ``(..., M, M)`` for which to compute the determinant.
Returns:
An array of determinants of shape ``a.shape[:-2]``.
See also:
:func:`jax.scipy.linalg.det`: Scipy-style API for determina... | det | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def inv(a: ArrayLike) -> Array:
"""Return the inverse of a square matrix
JAX implementation of :func:`numpy.linalg.inv`.
Args:
a: array of shape ``(..., N, N)`` specifying square array(s) to be inverted.
Returns:
Array of shape ``(..., N, N)`` containing the inverse of the input.
Notes:
In mos... | Return the inverse of a square matrix
JAX implementation of :func:`numpy.linalg.inv`.
Args:
a: array of shape ``(..., N, N)`` specifying square array(s) to be inverted.
Returns:
Array of shape ``(..., N, N)`` containing the inverse of the input.
Notes:
In most cases, explicitly computing the inv... | inv | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def norm(x: ArrayLike, ord: int | str | None = None,
axis: None | tuple[int, ...] | int = None,
keepdims: bool = False) -> Array:
"""Compute the norm of a matrix or vector.
JAX implementation of :func:`numpy.linalg.norm`.
Args:
x: N-dimensional array for which the norm will be computed.
... | Compute the norm of a matrix or vector.
JAX implementation of :func:`numpy.linalg.norm`.
Args:
x: N-dimensional array for which the norm will be computed.
ord: specify the kind of norm to take. Default is Frobenius norm for matrices,
and the 2-norm for vectors. For other options, see Notes below.
... | norm | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def qr(a: ArrayLike, mode: str = "reduced") -> Array | QRResult:
"""Compute the QR decomposition of an array
JAX implementation of :func:`numpy.linalg.qr`.
The QR decomposition of a matrix `A` is given by
.. math::
A = QR
Where `Q` is a unitary matrix (i.e. :math:`Q^HQ=I`) and `R` is an upper-triang... | Compute the QR decomposition of an array
JAX implementation of :func:`numpy.linalg.qr`.
The QR decomposition of a matrix `A` is given by
.. math::
A = QR
Where `Q` is a unitary matrix (i.e. :math:`Q^HQ=I`) and `R` is an upper-triangular
matrix.
Args:
a: array of shape (..., M, N)
mode: Co... | qr | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def solve(a: ArrayLike, b: ArrayLike) -> Array:
"""Solve a linear system of equations.
JAX implementation of :func:`numpy.linalg.solve`.
This solves a (batched) linear system of equations ``a @ x = b``
for ``x`` given ``a`` and ``b``.
If ``a`` is singular, this will return ``nan`` or ``inf`` values.
Arg... | Solve a linear system of equations.
JAX implementation of :func:`numpy.linalg.solve`.
This solves a (batched) linear system of equations ``a @ x = b``
for ``x`` given ``a`` and ``b``.
If ``a`` is singular, this will return ``nan`` or ``inf`` values.
Args:
a: array of shape ``(..., N, N)``.
b: arra... | solve | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def lstsq(a: ArrayLike, b: ArrayLike, rcond: float | None = None, *,
numpy_resid: bool = False) -> tuple[Array, Array, Array, Array]:
"""
Return the least-squares solution to a linear equation.
JAX implementation of :func:`numpy.linalg.lstsq`.
Args:
a: array of shape ``(M, N)`` representing the ... |
Return the least-squares solution to a linear equation.
JAX implementation of :func:`numpy.linalg.lstsq`.
Args:
a: array of shape ``(M, N)`` representing the coefficient matrix.
b: array of shape ``(M,)`` or ``(M, K)`` representing the right-hand side.
rcond: Cut-off ratio for small singular values... | lstsq | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def cross(x1: ArrayLike, x2: ArrayLike, /, *, axis=-1):
r"""Compute the cross-product of two 3D vectors
JAX implementation of :func:`numpy.linalg.cross`
Args:
x1: N-dimensional array, with ``x1.shape[axis] == 3``
x2: N-dimensional array, with ``x2.shape[axis] == 3``, and other axes
broadcast-compa... | Compute the cross-product of two 3D vectors
JAX implementation of :func:`numpy.linalg.cross`
Args:
x1: N-dimensional array, with ``x1.shape[axis] == 3``
x2: N-dimensional array, with ``x2.shape[axis] == 3``, and other axes
broadcast-compatible with ``x1``.
axis: axis along which to take the cros... | cross | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def outer(x1: ArrayLike, x2: ArrayLike, /) -> Array:
"""Compute the outer product of two 1-dimensional arrays.
JAX implementation of :func:`numpy.linalg.outer`.
Args:
x1: array
x2: array
Returns:
array containing the outer product of ``x1`` and ``x2``
See also:
:func:`jax.numpy.outer`: sim... | Compute the outer product of two 1-dimensional arrays.
JAX implementation of :func:`numpy.linalg.outer`.
Args:
x1: array
x2: array
Returns:
array containing the outer product of ``x1`` and ``x2``
See also:
:func:`jax.numpy.outer`: similar function in the main :mod:`jax.numpy` module.
Exam... | outer | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def matrix_norm(x: ArrayLike, /, *, keepdims: bool = False, ord: str | int = 'fro') -> Array:
"""Compute the norm of a matrix or stack of matrices.
JAX implementation of :func:`numpy.linalg.matrix_norm`
Args:
x: array of shape ``(..., M, N)`` for which to take the norm.
keepdims: if True, keep the reduc... | Compute the norm of a matrix or stack of matrices.
JAX implementation of :func:`numpy.linalg.matrix_norm`
Args:
x: array of shape ``(..., M, N)`` for which to take the norm.
keepdims: if True, keep the reduced dimensions in the output.
ord: A string or int specifying the type of norm; default is the F... | matrix_norm | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def matrix_transpose(x: ArrayLike, /) -> Array:
"""Transpose a matrix or stack of matrices.
JAX implementation of :func:`numpy.linalg.matrix_transpose`.
Args:
x: array of shape ``(..., M, N)``
Returns:
array of shape ``(..., N, M)`` containing the matrix transpose of ``x``.
See also:
:func:`ja... | Transpose a matrix or stack of matrices.
JAX implementation of :func:`numpy.linalg.matrix_transpose`.
Args:
x: array of shape ``(..., M, N)``
Returns:
array of shape ``(..., N, M)`` containing the matrix transpose of ``x``.
See also:
:func:`jax.numpy.transpose`: more general transpose operation.... | matrix_transpose | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def vector_norm(x: ArrayLike, /, *, axis: int | tuple[int, ...] | None = None, keepdims: bool = False,
ord: int | str = 2) -> Array:
"""Compute the vector norm of a vector or batch of vectors.
JAX implementation of :func:`numpy.linalg.vector_norm`.
Args:
x: N-dimensional array for which to t... | Compute the vector norm of a vector or batch of vectors.
JAX implementation of :func:`numpy.linalg.vector_norm`.
Args:
x: N-dimensional array for which to take the norm.
axis: optional axis along which to compute the vector norm. If None (default)
then ``x`` is flattened and the norm is taken over a... | vector_norm | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def vecdot(x1: ArrayLike, x2: ArrayLike, /, *, axis: int = -1,
precision: PrecisionLike = None,
preferred_element_type: DTypeLike | None = None) -> Array:
"""Compute the (batched) vector conjugate dot product of two arrays.
JAX implementation of :func:`numpy.linalg.vecdot`.
Args:
x1: l... | Compute the (batched) vector conjugate dot product of two arrays.
JAX implementation of :func:`numpy.linalg.vecdot`.
Args:
x1: left-hand side array.
x2: right-hand side array. Size of ``x2[axis]`` must match size of ``x1[axis]``,
and remaining dimensions must be broadcast-compatible.
axis: axis ... | vecdot | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def matmul(x1: ArrayLike, x2: ArrayLike, /, *,
precision: PrecisionLike = None,
preferred_element_type: DTypeLike | None = None) -> Array:
"""Perform a matrix multiplication.
JAX implementation of :func:`numpy.linalg.matmul`.
Args:
x1: first input array, of shape ``(..., N)``.
x2: ... | Perform a matrix multiplication.
JAX implementation of :func:`numpy.linalg.matmul`.
Args:
x1: first input array, of shape ``(..., N)``.
x2: second input array. Must have shape ``(N,)`` or ``(..., N, M)``.
In the multi-dimensional case, leading dimensions must be broadcast-compatible
with the l... | matmul | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def tensordot(x1: ArrayLike, x2: ArrayLike, /, *,
axes: int | tuple[Sequence[int], Sequence[int]] = 2,
precision: PrecisionLike = None,
preferred_element_type: DTypeLike | None = None) -> Array:
"""Compute the tensor dot product of two N-dimensional arrays.
JAX implementat... | Compute the tensor dot product of two N-dimensional arrays.
JAX implementation of :func:`numpy.linalg.tensordot`.
Args:
x1: N-dimensional array
x2: M-dimensional array
axes: integer or tuple of sequences of integers. If an integer `k`, then
sum over the last `k` axes of ``x1`` and the first `k` ... | tensordot | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def svdvals(x: ArrayLike, /) -> Array:
"""Compute the singular values of a matrix.
JAX implementation of :func:`numpy.linalg.svdvals`.
Args:
x: array of shape ``(..., M, N)`` for which singular values will be computed.
Returns:
array of singular values of shape ``(..., K)`` with ``K = min(M, N)``.
... | Compute the singular values of a matrix.
JAX implementation of :func:`numpy.linalg.svdvals`.
Args:
x: array of shape ``(..., M, N)`` for which singular values will be computed.
Returns:
array of singular values of shape ``(..., K)`` with ``K = min(M, N)``.
See also:
:func:`jax.numpy.linalg.svd`:... | svdvals | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def diagonal(x: ArrayLike, /, *, offset: int = 0) -> Array:
"""Extract the diagonal of an matrix or stack of matrices.
JAX implementation of :func:`numpy.linalg.diagonal`.
Args:
x: array of shape ``(..., M, N)`` from which the diagonal will be extracted.
offset: positive or negative offset from the main... | Extract the diagonal of an matrix or stack of matrices.
JAX implementation of :func:`numpy.linalg.diagonal`.
Args:
x: array of shape ``(..., M, N)`` from which the diagonal will be extracted.
offset: positive or negative offset from the main diagonal.
Returns:
Array of shape ``(..., K)`` where ``K`... | diagonal | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def tensorinv(a: ArrayLike, ind: int = 2) -> Array:
"""Compute the tensor inverse of an array.
JAX implementation of :func:`numpy.linalg.tensorinv`.
This computes the inverse of the :func:`~jax.numpy.linalg.tensordot`
operation with the same ``ind`` value.
Args:
a: array to be inverted. Must have ``pro... | Compute the tensor inverse of an array.
JAX implementation of :func:`numpy.linalg.tensorinv`.
This computes the inverse of the :func:`~jax.numpy.linalg.tensordot`
operation with the same ``ind`` value.
Args:
a: array to be inverted. Must have ``prod(a.shape[:ind]) == prod(a.shape[ind:])``
ind: positi... | tensorinv | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def tensorsolve(a: ArrayLike, b: ArrayLike, axes: tuple[int, ...] | None = None) -> Array:
"""Solve the tensor equation a x = b for x.
JAX implementation of :func:`numpy.linalg.tensorsolve`.
Args:
a: input array. After reordering via ``axes`` (see below), shape must be
``(*b.shape, *x.shape)``.
b:... | Solve the tensor equation a x = b for x.
JAX implementation of :func:`numpy.linalg.tensorsolve`.
Args:
a: input array. After reordering via ``axes`` (see below), shape must be
``(*b.shape, *x.shape)``.
b: right-hand-side array.
axes: optional tuple specifying axes of ``a`` that should be moved t... | tensorsolve | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def multi_dot(arrays: Sequence[ArrayLike], *, precision: PrecisionLike = None) -> Array:
"""Efficiently compute matrix products between a sequence of arrays.
JAX implementation of :func:`numpy.linalg.multi_dot`.
JAX internally uses the opt_einsum library to compute the most efficient
operation order.
Args:... | Efficiently compute matrix products between a sequence of arrays.
JAX implementation of :func:`numpy.linalg.multi_dot`.
JAX internally uses the opt_einsum library to compute the most efficient
operation order.
Args:
arrays: sequence of arrays. All must be two-dimensional, except the first
and last ... | multi_dot | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def cond(x: ArrayLike, p=None):
"""Compute the condition number of a matrix.
JAX implementation of :func:`numpy.linalg.cond`.
The condition number is defined as ``norm(x, p) * norm(inv(x), p)``. For ``p = 2``
(the default), the condition number is the ratio of the largest to the smallest
singular value.
... | Compute the condition number of a matrix.
JAX implementation of :func:`numpy.linalg.cond`.
The condition number is defined as ``norm(x, p) * norm(inv(x), p)``. For ``p = 2``
(the default), the condition number is the ratio of the largest to the smallest
singular value.
Args:
x: array of shape ``(..., M... | cond | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def trace(x: ArrayLike, /, *,
offset: int = 0, dtype: DTypeLike | None = None) -> Array:
"""Compute the trace of a matrix.
JAX implementation of :func:`numpy.linalg.trace`.
Args:
x: array of shape ``(..., M, N)`` and whose innermost two
dimensions form MxN matrices for which to take the trac... | Compute the trace of a matrix.
JAX implementation of :func:`numpy.linalg.trace`.
Args:
x: array of shape ``(..., M, N)`` and whose innermost two
dimensions form MxN matrices for which to take the trace.
offset: positive or negative offset from the main diagonal
(default: 0).
dtype: data ty... | trace | python | jax-ml/jax | jax/_src/numpy/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/linalg.py | Apache-2.0 |
def roots(p: ArrayLike, *, strip_zeros: bool = True) -> Array:
r"""Returns the roots of a polynomial given the coefficients ``p``.
JAX implementations of :func:`numpy.roots`.
Args:
p: Array of polynomial coefficients having rank-1.
strip_zeros : bool, default=True. If True, then leading zeros in the
... | Returns the roots of a polynomial given the coefficients ``p``.
JAX implementations of :func:`numpy.roots`.
Args:
p: Array of polynomial coefficients having rank-1.
strip_zeros : bool, default=True. If True, then leading zeros in the
coefficients will be stripped, similar to :func:`numpy.roots`. If ... | roots | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
def polyfit(x: ArrayLike, y: ArrayLike, deg: int, rcond: float | None = None,
full: bool = False, w: ArrayLike | None = None, cov: bool = False
) -> Array | tuple[Array, ...]:
r"""Least squares polynomial fit to data.
Jax implementation of :func:`numpy.polyfit`.
Given a set of data point... | Least squares polynomial fit to data.
Jax implementation of :func:`numpy.polyfit`.
Given a set of data points ``(x, y)`` and degree of polynomial ``deg``, the
function finds a polynomial equation of the form:
.. math::
y = p(x) = p[0] x^{deg} + p[1] x^{deg - 1} + ... + p[deg]
Args:
x: Array of da... | polyfit | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
def poly(seq_of_zeros: ArrayLike) -> Array:
r"""Returns the coefficients of a polynomial for the given sequence of roots.
JAX implementation of :func:`numpy.poly`.
Args:
seq_of_zeros: A scalar or an array of roots of the polynomial of shape ``(M,)``
or ``(M, M)``.
Returns:
An array containing t... | Returns the coefficients of a polynomial for the given sequence of roots.
JAX implementation of :func:`numpy.poly`.
Args:
seq_of_zeros: A scalar or an array of roots of the polynomial of shape ``(M,)``
or ``(M, M)``.
Returns:
An array containing the coefficients of the polynomial. The dtype of th... | poly | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
def polyval(p: ArrayLike, x: ArrayLike, *, unroll: int = 16) -> Array:
r"""Evaluates the polynomial at specific values.
JAX implementations of :func:`numpy.polyval`.
For the 1D-polynomial coefficients ``p`` of length ``M``, the function returns
the value:
.. math::
p_0 x^{M - 1} + p_1 x^{M - 2} + ... ... | Evaluates the polynomial at specific values.
JAX implementations of :func:`numpy.polyval`.
For the 1D-polynomial coefficients ``p`` of length ``M``, the function returns
the value:
.. math::
p_0 x^{M - 1} + p_1 x^{M - 2} + ... + p_{M - 1}
Args:
p: An array of polynomial coefficients of shape ``(M... | polyval | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
def polyadd(a1: ArrayLike, a2: ArrayLike) -> Array:
r"""Returns the sum of the two polynomials.
JAX implementation of :func:`numpy.polyadd`.
Args:
a1: Array of polynomial coefficients.
a2: Array of polynomial coefficients.
Returns:
An array containing the coefficients of the sum of input polynomi... | Returns the sum of the two polynomials.
JAX implementation of :func:`numpy.polyadd`.
Args:
a1: Array of polynomial coefficients.
a2: Array of polynomial coefficients.
Returns:
An array containing the coefficients of the sum of input polynomials.
Note:
:func:`jax.numpy.polyadd` only accepts a... | polyadd | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
def polyint(p: ArrayLike, m: int = 1, k: int | ArrayLike | None = None) -> Array:
r"""Returns the coefficients of the integration of specified order of a polynomial.
JAX implementation of :func:`numpy.polyint`.
Args:
p: An array of polynomial coefficients.
m: Order of integration. Default is 1. It must ... | Returns the coefficients of the integration of specified order of a polynomial.
JAX implementation of :func:`numpy.polyint`.
Args:
p: An array of polynomial coefficients.
m: Order of integration. Default is 1. It must be specified statically.
k: Scalar or array of ``m`` integration constant (s).
Re... | polyint | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
def polyder(p: ArrayLike, m: int = 1) -> Array:
r"""Returns the coefficients of the derivative of specified order of a polynomial.
JAX implementation of :func:`numpy.polyder`.
Args:
p: Array of polynomials coefficients.
m: Order of differentiation (positive integer). Default is 1. It must be
speci... | Returns the coefficients of the derivative of specified order of a polynomial.
JAX implementation of :func:`numpy.polyder`.
Args:
p: Array of polynomials coefficients.
m: Order of differentiation (positive integer). Default is 1. It must be
specified statically.
Returns:
An array of polynomia... | polyder | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
def polymul(a1: ArrayLike, a2: ArrayLike, *, trim_leading_zeros: bool = False) -> Array:
r"""Returns the product of two polynomials.
JAX implementation of :func:`numpy.polymul`.
Args:
a1: 1D array of polynomial coefficients.
a2: 1D array of polynomial coefficients.
trim_leading_zeros: Default is ``F... | Returns the product of two polynomials.
JAX implementation of :func:`numpy.polymul`.
Args:
a1: 1D array of polynomial coefficients.
a2: 1D array of polynomial coefficients.
trim_leading_zeros: Default is ``False``. If ``True`` removes the leading
zeros in the return value to match the result of ... | polymul | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
def polydiv(u: ArrayLike, v: ArrayLike, *, trim_leading_zeros: bool = False) -> tuple[Array, Array]:
r"""Returns the quotient and remainder of polynomial division.
JAX implementation of :func:`numpy.polydiv`.
Args:
u: Array of dividend polynomial coefficients.
v: Array of divisor polynomial coefficients... | Returns the quotient and remainder of polynomial division.
JAX implementation of :func:`numpy.polydiv`.
Args:
u: Array of dividend polynomial coefficients.
v: Array of divisor polynomial coefficients.
trim_leading_zeros: Default is ``False``. If ``True`` removes the leading
zeros in the return v... | polydiv | python | jax-ml/jax | jax/_src/numpy/polynomial.py | https://github.com/jax-ml/jax/blob/master/jax/_src/numpy/polynomial.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.