Extends base scale() to handle mlx inputs without moving data back to
base R. The computation delegates to MLX reductions and broadcasting. When
centering or scaling values are computed, the attributes "scaled:center"
and "scaled:scale" are stored as 1 x ncol(x) mlx arrays (user-supplied
numeric vectors are preserved as-is). These attributes remain MLX arrays even
after coercing with as.matrix(), so they stay lazily evaluated.
Usage
# S3 method for class 'mlx'
scale(x, center = TRUE, scale = TRUE)Arguments
- x
a numeric matrix(like object).
- center
either a logical value or numeric-alike vector of length equal to the number of columns of
x, where ‘numeric-alike’ means thatas.numeric(.)will be applied successfully ifis.numeric(.)is not true.- scale
either a logical value or a numeric-alike vector of length equal to the number of columns of
x.