mlx_meshgrid() mirrors mlx.core.meshgrid(),
returning coordinate arrays suitable for vectorised evaluation on MLX devices.
Usage
mlx_meshgrid(..., sparse = FALSE, indexing = c("xy", "ij"), device = NULL)Arguments
- ...
One or more arrays (or a single list) convertible via
as_mlx()representing coordinate vectors.- sparse
Logical flag producing broadcast-friendly outputs when
TRUE.- indexing
Either
"xy"(Cartesian) or"ij"(matrix) indexing.- device
Execution target: supply
"gpu","cpu", or anmlx_streamcreated viamlx_new_stream(). Defaults to the currentmlx_default_device()unless noted otherwise (helpers that act on an existing array typically reuse that array's device or stream).
Examples
xs <- as_mlx(1:3)
ys <- as_mlx(1:2)
mlx_meshgrid(xs, ys, indexing = "xy")
#> [[1]]
#> mlx array [2 x 3]
#> dtype: float32
#> device: gpu
#> values:
#> [,1] [,2] [,3]
#> [1,] 1 2 3
#> [2,] 1 2 3
#>
#> [[2]]
#> mlx array [2 x 3]
#> dtype: float32
#> device: gpu
#> values:
#> [,1] [,2] [,3]
#> [1,] 1 1 1
#> [2,] 2 2 2
#>