Web Analytics Made
Easy - StatCounter

Today I remembered matrix layout in Eigen is column-major

I’m fooling around more with Eigen, and remembered that the storage order is column-major, but wanted to confirm. Yes, the default storage order is column-major – see the docs.

Why does this matter? From the docs:

Algorithms that traverse a matrix row by row will go faster when the matrix is stored in row-major order because of better data locality. Similarly, column-by-column traversal is faster for column-major matrices. It may be worthwhile to experiment a bit to find out what is faster for your particular application.

I usually walk through matrices in a row-major way, because that’s the way images are typically laid out. It is useful for me to remember that Eigen is in column-major, and to write the loops in a different way if I need to walk through Eigen matrices (which, really I try to avoid) to reduce run-time.

You can change the storage order to be row-major, and the docs have some good discussion about why you might or might not want to do that.

© Amy Tabb 2018 - 2021. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.