On Tuesday, 13 March 2018 at 16:40:13 UTC, 9il wrote:
On Tuesday, 13 March 2018 at 14:13:02 UTC, jmh530 wrote:
I'm not sure I understand what your syntax solution does...
matrix(j, i) == matrix[i, j] (reversed order)
Hopefully, I made the issue more clean in my response to Martin.
The issue with row/column major order is one-part performance and
one-part interoperability with other Matrix libraries.
Perhaps most importantly for that syntax is to imagine how
confusing a new user would find that syntax... A free-standing
function, such as the simple one below, might be less confusing.
Also, this is a solution for the Matrix type, but not so much the
auto reverseIndex(T)(T x, size_t i, size_t j)
The reverseIndex function is convenient, but you are looping
through each element of the second column. Is there any
performance advantage to using the reverseIndex function to do
so? I suspect not. This is because you still have to jump around
in memory because the underlying storage is row-major. You may
not notice this effect when the CPU is able to pre-fetch the
whole matrix and put it in cache, but as the matrix gets larger,
then you can't fit it all in cache and it starts to matter more.
Also, you might break vector operations.
Personally, while I think it's important to think about, I also
don't think it's a hugely pressing issue so long as the API is
flexible enough that you can add the functionality in the future.