NDArray Operations
Element-wise operations, reductions, and introspection for N-dimensional arrays.
abs
abs(a: NDArray) → r
abs(a: NDArray) → r
acos
acos(a: NDArray) → r
acos(a: NDArray) → r
add
Element-wise addition. Supports NDArray×NDArray and scalar broadcasting.
add(a: NDArray, b: NDArray) → r
alloc
Allocate an array with the given shape and dtype. Optionally fill with a value.
alloc(shape: Tuple, dt: String) → r
and
Element-wise logical AND of two boolean arrays.
and(a: NDArray, b: NDArray) → r
asin
asin(a: NDArray) → r
asin(a: NDArray) → r
atan
atan(a: NDArray) → r
atan(a: NDArray) → r
backend
Backend name where the array is allocated.
backend(a: NDArray) → r
ceil
ceil(a: NDArray) → r
ceil(a: NDArray) → r
cos
cos(a: NDArray) → r
cos(a: NDArray) → r
cosh
cosh(a: NDArray) → r
cosh(a: NDArray) → r
create
Create an uninitialized array with the given dtype.
create(dt: Type, n: Int64) → r
div
Element-wise division. Supports NDArray×NDArray and scalar broadcasting.
div(a: NDArray, b: NDArray) → r
dot
Dot product of two vectors.
dot(a: NDArray, b: NDArray) → r
dtype
Data type of the array elements as a string.
dtype(a: NDArray) → r
ediv
Element-wise division (./). Always element-wise regardless of shape.
ediv(a: NDArray, b: NDArray) → r
emul
Element-wise multiplication (.*). Always element-wise regardless of shape.
emul(a: NDArray, b: NDArray) → r
epow
Element-wise power (.^). Raises each element to the given power.
epow(a: NDArray, n: Int64) → r
eq
Element-wise equality. Supports scalar broadcasting.
eq(a: NDArray, b: NDArray) → r
exp
exp(a: NDArray) → r
exp(a: NDArray) → r
floor
floor(a: NDArray) → r
floor(a: NDArray) → r
free
Free the memory backing an array. The array becomes invalid after this call.
free(a: NDArray) → r
ge
Element-wise greater-than-or-equal. Supports scalar broadcasting.
ge(a: NDArray, b: NDArray) → r
gt
Element-wise greater-than. Supports scalar broadcasting.
gt(a: NDArray, b: NDArray) → r
le
Element-wise less-than-or-equal. Supports scalar broadcasting.
le(a: NDArray, b: NDArray) → r
length
Total number of elements in the array.
length(a: NDArray) → r
log
log(a: NDArray) → r
log(a: NDArray) → r
log10
log10(a: NDArray) → r
log10(a: NDArray) → r
log2
log2(a: NDArray) → r
log2(a: NDArray) → r
lt
Element-wise less-than. Supports scalar broadcasting.
lt(a: NDArray, b: NDArray) → r
matmul
Matrix multiplication.
matmul(a: NDArray, b: NDArray) → r
max
Maximum element. With dim, reduces along the given axis.
max(a: NDArray) → r
mean
Arithmetic mean of array elements. With dim, reduces along the given axis.
mean(a: NDArray) → r
min
Minimum element. With dim, reduces along the given axis.
min(a: NDArray) → r
mul
Linear algebra multiplication. For 2D matrices: matmul. For 2D×1D: mat-vec.
mul(a: NDArray, b: NDArray) → r
ndarray_ones
Create a vector or matrix of ones.
ndarray_ones(n: Int64) → r
ndarray_zeros
Create a vector or matrix of zeros.
ndarray_zeros(n: Int64) → r
ndims
Number of dimensions of the array.
ndims(a: NDArray) → r
neg
Element-wise negation.
neg(a: NDArray) → r
neq
Element-wise inequality. Supports scalar broadcasting.
neq(a: NDArray, b: NDArray) → r
norm
Euclidean norm (L2) of a vector.
norm(a: NDArray) → r
or
Element-wise logical OR of two boolean arrays.
or(a: NDArray, b: NDArray) → r
pointer
Raw memory pointer (byte offset) of the array data.
pointer(a: NDArray) → r
pow
Element-wise power. Raises each element of a to the integer power n.
pow(a: NDArray, n: Int64) → r
promote_dtype
Determine the common dtype when combining two dtypes (type promotion).
promote_dtype(a: String, b: String) → r
reshape
Reshape an array to the given dimensions. Total element count must match.
reshape(a: NDArray, n: Int64) → r
reverse
Reverse element order of a 1D array.
reverse(a: NDArray) → r
round
round(a: NDArray) → r
round(a: NDArray) → r
sign
sign(a: NDArray) → r
sign(a: NDArray) → r
sin
sin(a: NDArray) → r
sin(a: NDArray) → r
sinh
sinh(a: NDArray) → r
sinh(a: NDArray) → r
size
Shape of the array. With dim, returns the size along that axis.
size(a: NDArray) → r
sqrt
sqrt(a: NDArray) → r
sqrt(a: NDArray) → r
sub
Element-wise subtraction. Supports NDArray×NDArray and scalar broadcasting.
sub(a: NDArray, b: NDArray) → r
sum
Sum of array elements. With dim, reduces along the given axis.
sum(a: NDArray) → r
tan
tan(a: NDArray) → r
tan(a: NDArray) → r
tanh
tanh(a: NDArray) → r
tanh(a: NDArray) → r
to_dtype
Cast array elements to a different dtype.
to_dtype(a: NDArray, dt: String) → r
transfer
Transfer an array to a different backend (e.g. "wasm", "webgpu").
transfer(a: NDArray, target: String) → r
trunc
trunc(a: NDArray) → r
trunc(a: NDArray) → r