gugatr0n1c
gugatr0n1c

Reputation: 477

Julia - how to shuffle matrix

what is best way to shuffle given matrix in Julia (2d-array)?

Function shuffle() does not work.

What I mean is randomly shuffle rows (not all elements).

Upvotes: 7

Views: 6920

Answers (1)

isebarn
isebarn

Reputation: 3950

to shuffle all rows of matrix

a = a[shuffle(1:end), :]

for those who mean to shuffle a specific row,

function shuffle_row(mat, row)
    mat[row,:] = shuffle(mat[row,:])
end 

Upvotes: 11

Related Questions