Skip to contents

Row-bind mlx arrays

Usage

# S3 method for class 'mlx'
rbind(..., deparse.level = 1)

Arguments

...

Objects to bind. mlx arrays are kept in MLX; other inputs are coerced via as_mlx().

deparse.level

Compatibility argument accepted for S3 dispatch; ignored.

Value

An mlx array stacked along the first axis.

Details

Unlike base R's rbind(), this function supports arrays with more than 2 dimensions and preserves all dimensions except the first (which is summed across inputs). Base R's rbind() flattens higher-dimensional arrays to matrices before binding.

Examples

x <- as_mlx(matrix(1:4, 2, 2))
y <- as_mlx(matrix(5:8, 2, 2))
rbind(x, y)
#> mlx array [4 x 2]
#>   dtype: float32
#>   device: gpu
#>   values:
#>      [,1] [,2]
#> [1,]    1    3
#> [2,]    2    4
#> [3,]    5    7
#> [4,]    6    8