Generate random permutations on mlx arrays
mlx_rand_permutation.RdGenerate a random permutation of integers or permute the entries of an array along a specified axis.
Usage
mlx_rand_permutation(x, axis = 0L, device = mlx_default_device())Arguments
- x
- Either an integer n (to generate a permutation of 0:(n-1)), or an mlx array or matrix to permute. 
- axis
- The axis along which to permute when x is an array. Default is 0 (permute rows). 
- device
- Execution target: supply - "gpu",- "cpu", or an- mlx_streamcreated via- mlx_new_stream(). Default:- mlx_default_device().
Details
When x is an integer, the result is created on the specified
device or stream; otherwise the permutation follows the input array's
device.
Examples
# Generate a random permutation of 0:9
perm <- mlx_rand_permutation(10)
# Permute the rows of a matrix
mat <- matrix(1:12, 4, 3)
perm_mat <- mlx_rand_permutation(mat)
# Permute columns instead
perm_cols <- mlx_rand_permutation(mat, axis = 1)