julia icon indicating copy to clipboard operation
julia copied to clipboard

`circshift!(x, n)` and `circshift(x, n)` shift in different directions

Open artemsolod opened this issue 3 years ago • 1 comments

circshift!(vec, n) rotation direction is inconsistent with copying circshift(vec, n) and mutating destination circshift!(dest, source, n) versions. Judging by https://github.com/JuliaLang/julia/issues/46016 it appears that in-place circshift!(vec, n) was introduced in 1.8 and implemented in https://github.com/JuliaLang/julia/pull/42678

julia> circshift(collect(1:3), 1)
3-element Vector{Int64}:
 3
 1
 2

julia> circshift!(collect(1:3), 1)
3-element Vector{Int64}:
 2
 3
 1

julia> circshift!(collect(1:3), collect(1:3), 1) # with destination and source
3-element Vector{Int64}:
 3
 1
 2
Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, ivybridge)

artemsolod avatar Aug 29 '22 11:08 artemsolod

yikes

Keno avatar Aug 29 '22 16:08 Keno

Thanks for taking care of this @fredrikekre.

Keno avatar Sep 27 '22 19:09 Keno