Row major arrays?

I have to integrate with a C library that expects row-major 2D data. I could transpose/reshape an array before calling it but it seems awkward and not efficient.

What’s the best way to handle this? Maybe I could create a new array type that’s already row-major by design (unless something like this already exists)?

Transposing is generally a very cheap operation. I would do that and profile, and only think about optimizing it if it is a bottleneck.

However, if you find that you still want to do this, it is easy to create a wrapper type with row major storage. When defining methods, you can use LinearAlgebra.Transpose in v0.7 and build on existing methods without copying/transposing.

On master, maybe you could use PermuteDimsArray / permutedims.

3 Likes