matrix
Differences
This shows you the differences between two versions of the page.
| matrix [June 11, 2026 at 09:43] – created - external edit 127.0.0.1 | matrix [June 11, 2026 at 09:57] (current) – Ivan Janevski | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| # Matrix | # Matrix | ||
| - | A **matrix** is a two-dimensional rectangular array of values organised in rows and columns. In C, a matrix is stored as a flat [[array]] in **row-major order**: all elements of row 0 come first, then row 1, and so on. The element at row `i`, column `j` of an `M × N` matrix sits at index `i * N + j` in the flat array. This layout makes row traversal cache-friendly (consecutive elements are adjacent in memory) and column traversal cache-unfriendly (stride N between elements). | + | A **matrix** is a two-dimensional rectangular array of values organised in rows and columns. |
| + | |||
| + | In C, a matrix is stored as a flat [[array]] in **row-major order**: all elements of row 0 come first, then row 1, and so on. The element at row `i`, column `j` of an `M × N` matrix sits at index `i * N + j` in the flat array. This layout makes row traversal cache-friendly (consecutive elements are adjacent in memory) and column traversal cache-unfriendly (stride N between elements). | ||
| ```c | ```c | ||
matrix.txt · Last modified: by Ivan Janevski
