You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Means that m is still column-major, so it's m[j][i] notation instead of m[i][j] as accepted in generic mathematics. We can test it like this :
uint8_t a[16] = // column-major
{
0x0, 0x1, 0x2, 0x3,
0x4, 0x5, 0x6, 0x7,
0x8, 0x9, 0xa, 0xb,
0xc, 0xd, 0xe, 0xf
};
typedef uint8_t column_t[4];
column_t * c = (column_t*)a;
printf("%x\n", c[2][1]); // prints 9, which means 2 is column, 1 is row
So would be nice to write down some comments in a lib saying this, and maybe introduce some _M(i, j) macro just so algorithms are written down in more mathematics friendly notation, which should enable less error-prone code.
The text was updated successfully, but these errors were encountered:
jimon
changed the title
Clarify column-major vs row-major
Clarify column-major vs row-major (docs)
Nov 20, 2016
I understand your concern but I don't think the operation/macro should be part of the library. I'm not going to close this issue as if others want this, I will reconsider it.
Reading gb_math.h source sometimes is really confusing.
Usual math notation for matrix is Aij where i is row and j is column:
Note that this notation is memory-layout free, this is just how matrices are written down on paper in generic science/engineering notation.
Considering this:
One can make an assumption that layout is column-major, awesome. But then reading something like this:
Means that
m
is still column-major, so it'sm[j][i]
notation instead ofm[i][j]
as accepted in generic mathematics. We can test it like this :So would be nice to write down some comments in a lib saying this, and maybe introduce some
_M(i, j)
macro just so algorithms are written down in more mathematics friendly notation, which should enable less error-prone code.The text was updated successfully, but these errors were encountered: