Skip to contents

Column-bind mlx arrays

Usage

# S3 method for class 'mlx'
cbind(..., 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 second axis.

Details

Unlike base R's cbind(), this function supports arrays with more than 2 dimensions and preserves all dimensions except the second (which is summed across inputs). Base R's cbind() 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))
cbind(x, y)
#> mlx array [2 x 4]
#>   dtype: float32
#>   device: gpu
#>   values:
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    3    5    7
#> [2,]    2    4    6    8