Julia: consolidate ror/rol and circshift

Created on 7 Jan 2017  路  12Comments  路  Source: JuliaLang/julia

deprecation help wanted

Most helpful comment

How about calling these all rotate and rotate! instead of circshift?

All 12 comments

If I may, I'd like to specifically propose the following consolidation:

  • Deprecate ror(A, i) in favor of circshift(A, i)
  • Deprecate rol(A, i) in favor of circshift(A, -i)
  • Add a method circshift!(A, i) (currently we just have circshift!(A, B, i))
  • Similarly deprecate the in-place 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!.

Was this page helpful?
0 / 5 - 0 ratings