ejmahler / transpose

Utility for transposing multi-dimensional data
Apache License 2.0
16 stars 7 forks source link

More efficient inplace transpose #4

Open preiter93 opened 2 years ago

preiter93 commented 2 years ago

Hi,

I was looking for multidimensional transpositions and implemented some myself.

The out-of place transposes are very similar to yours (I pretty much copy-pasted the recursive one), and the performance is almost the same: perf_oop

("this" is my implementation and "ej" is yours)

For the inplace transposition, however, I have implemented a method that is described in

F. Gustavson and D. Walker - Algorithms for in-place matrix transposition (2018)

which is about 10x faster than your current implementation, although still slower than the out-of-place variant: perf_ip

My code is at https://github.com/preiter93/transpose. Let me know if you are interested, we could include the in-place variant in your library. I think an efficient inplace algorithm with variable scratch space can be quite useful for some people.

Best regards

ejmahler commented 2 years ago

That's great! I'd be thrilled to have a faster in-place transpose. I'll take look in the next few days.