Circular shift on a Matrix

Viewed 200

Is there a circshift() version that works on a Matrix? Or should I convert it back and forward?

julia> circshift([1, 2, 3], 1) # works
3-element Vector{Int64}:
 3
 1
 2

julia> circshift([1 2 3], 1) # doesn't work
1×3 Matrix{Int64}:
 1  2  3
1 Answers

A matrix is a 2D object that can shift in two directions. The example in the question shifts the matrix in the first dimension, which doesn't really do anything for an 1xN matrix. Providing circshift a tuple solves this.

julia> circshift([1 2 3], (0,1))
1×3 Matrix{Int64}:
 3  1  2
Related