shiandow
4 months ago
I don't think there's any mathematical reason to lay out the elements in memory that way. Sure given no context I would probably use i = row + n col as index, but it doesn't really matter much me.
If I had to pick between a matrix being a row of vectors or a column of covectors, I'd pick the latter. And M[i][j] should be the element in row i column j, which is nonnegotiable.
SR2Z
4 months ago
I think the fundamental reason it's laid out like this is because it results in elements with the same major index being close to each other for caching. The assumption is that users will change their minor index much more often than the major one while accessing data, which means that cache prefetching will just work.
Obviously there are situations where this breaks down, but if you have to pick one way to do it I think this makes more sense.
larodi
4 months ago
He lost me at
> Well, if we neglect the translation part (the bottom row), then the pure rotation part simply describes the new location of the points on the cube:
Even though im very good at visual with say complex graphs. I really didn’t get where the ‘simply’ part really comes from..
mwkaufma
4 months ago
This was answered in the article.
>> It is often fortunate that the OpenGL matrix array is laid out the way it is because it results in those three elements being consecutive in memory.
inamberclad
4 months ago
Matlab deliberately notes that its matrices are laid out like this since most matrix operations occur on columns, a whole column can be loaded on a cache line.