http://stackoverflow.com/questions/41517318/rotate-non-bit-arrays-in-julia
These are basically the same functions.
If I may, I'd like to specifically propose the following consolidation:
ror(A, i)
in favor of circshift(A, i)
rol(A, i)
in favor of circshift(A, -i)
circshift!(A, i)
(currently we just have circshift!(A, B, i)
)ror!
and rol!
in favor of circshift!
That to me seems like a fairly straightforward change.
See also #16032 and #9822 regarding in-place circshift!(A, i)
.
How about calling these all rotate
and rotate!
instead of circshift
?
Note also that efficient implementations of these for various integer bits types would be useful. The various shenanigans we've layered on top of shift operators make it fairly hard to coax LLVM into generating actual rotate instructions. Using llvm_call
or intrinsics might be necessary.
@StefanKarpinski I am new to Julia and would like to work on this. By deprecating a function, do you mean removing it from the base source, documentation and imports/exports it is involved in? Is there anything else which should be done?
And also I did not understand your last comment about efficient implementation and llvm_call
. Please help me in getting this started.
Thanks
Ref https://github.com/JuliaLang/julia/issues/11592#issuecomment-109477848 No llvmcall
should be necessary.
+5 > efficient implementations of these for various integer bits types would be useful.
I assigned performance-optimization of in-place circshift!
, both of a 1d array and of all the rows of a matrix, in problem-set 1 of our 18.S096 course at MIT this January. The solutions compare several algorithms and might be informative here.
I've posted an n-dimensional circshift!
over at #20696. It is not optimised to the end (e.g. not-shifted axes could be left alone) but complicated enough already.
Tell me what you think.
The ror
and rol
functions do the exact same thing as circshift
on any other array type, so they should just be deprecated in favor of methods of circshift
. Any change of name or whatever else can be discussed separately.
Resolved: deprecate BitArray ror and rol to be methods of circshift.
I'm also fine with calling it rotate
and rotate!
.
Most helpful comment
How about calling these all
rotate
androtate!
instead ofcircshift
?