Skip to main content

Module jnp

Module jnp 

Source
Expand description

Functions following jax.numpy, with NumPy’s broadcasting.

Operands are anything that converts to an array (ArrayLike): arrays, scalars, and Rust values of the element type. At least one operand must be an array or a scalar, which fixes the backend.

Modules§

fft
Discrete Fourier transforms following jax.numpy.fft.
linalg
Linear algebra following jax.numpy.linalg (and NumPy’s semantics), on matrices and batches of matrices (see lax::linalg for the decompositions). The decompositions and solves (cholesky, solve, inv, qr, eigh, eigvalsh, svd, svdvals) take f32, f64, c64, and c128; det, slogdet, and norm take f32 and f64.

Structs§

AxisList
At most eight axes, stored without allocating.

Enums§

Axes
Axes of a reduction: all of them, or a list (negative values count from the end).

Constants§

ALL
Every axis.

Functions§

abs
|x| (unsigned values are returned unchanged; the magnitude of a complex number is real).
add
x + y.
all
Whether every element along axes is true.
angle
The arguments of complex numbers (atan2(imag, real)), in radians.
any
Whether any element along axes is true.
arange
0, 1, ..., n - 1.
arctan2
atan2(x, y).
argmax
The index (i32) of the largest element along axis.
argmin
The index (i32) of the smallest element along axis.
astype
Converts to another element type.
broadcast_to
Broadcasts to shape.
cbrt
Cube root.
ceil
Round up.
clip
Clamps to [lo, hi] (maximum then minimum, propagating NaN).
concatenate
Joins arrays along axis.
conj
The complex conjugates.
conjugate
The complex conjugates (jnp.conjugate, the same as conj).
cos
Cosine.
cumprod
The cumulative product along axis (of the flattened array for None), in the input type.
cumsum
The cumulative sum along axis (of the flattened array for None), in the input type.
divide
x / y.
equal
Whether two arrays are equal elementwise.
exp
e^x.
expand_dims
Inserts a dimension of size 1 at axis.
expm1
e^x - 1.
floor
Round down.
floor_divide
Integer division rounding toward negative infinity, computed as JAX does: div, minus one where the signs of x and y differ and the remainder is nonzero (so x // 0 is -2 for x != 0; unsigned integers only div).
fmod
The remainder of truncated division, with the sign of x (C’s fmod).
full
An array of shape filled with value.
imag
The imaginary parts of complex numbers.
isfinite
Whether each element is finite.
log
Natural logarithm.
log1p
log(1 + x).
logical_and
Logical and.
logical_not
Logical not.
logical_or
Logical or.
matmul
Matrix product with NumPy’s rules for vectors and matrices.
max
The maximum over axes.
maximum
The maximum, propagating NaN.
mean
Averages over axes, in the input type (16-bit floats in f32).
min
The minimum over axes.
minimum
The minimum, propagating NaN.
multiply
x * y.
negative
-x.
ones
An array of ones.
power
x^y.
real
The real parts of complex numbers.
remainder
The remainder with the sign of y (Python’s %, jnp.remainder): x - floor(x / y) * y, computed as JAX does (rem, adding y where the signs differ; an integer y of zero is replaced by one).
roll
x with the elements along axis moved by a static shift toward higher indices, wrapping around (jnp.roll(x, shift, axis)): element i goes to (i + shift) mod n. As in JAX, it is two slices and a concatenation.
round
Round, halfway cases to even (NumPy’s rounding).
round_with
Rounds with the given method (round with a method, for completeness).
sign
The sign (x / |x| for complex numbers).
sin
Sine.
sqrt
Square root.
square
x * x.
stack
Stacks arrays (or scalars) along a new dimension axis.
subtract
x - y.
sum
Sums over axes. 16-bit floats accumulate in f32, as in JAX.
take
The elements of x at indices along axis (jnp.take(x, indices, axis, mode="clip"), which is JAX’s indexing x[..., indices, ...]): the result has the shape of x with dimension axis replaced by the shape of indices. Negative indices count from the end, and indices out of bounds are clamped.
tan
Tangent.
tanh
Hyperbolic tangent.
where_
cond ? x : y elementwise, with broadcasting.
zeros
An array of zeros.