Row-major order vs column-major order: Samuel's tutorial

Опубликовано: 22 Март 2026
на канале: Samuel Albanie
9,920
254

Samuel's tutorial on row-major and column-major order and their relevance for multi-dimensional arrays.

Timestamps:
00:00 - Row-major vs column-major: Samuel's guide
02:00 - Why storage order is important (caching)
06:59 - Memory address formulas
08:36 - Higher dimensions
10:03 - Conventions in different languages

Detailed description:
Row-major order and column-major order are two widely strategies for storing multi-dimensional arrays. For matrices, row-major (or lexicographic) order traverses elements along its rows, while column-major (colexicographic) order traverses along its columns.

The video describes how storage order has implications for performance because of how computer processors use caching that relies on the assumption of spatial locality.

It also describes the formulas used to compute storage addresses for matrices and higher dimensional arrays.

Finally, the ordering dimensions of different languages (C, FORTRAN, Julia etc.) and libraries (e.g. PyTorch) are described.

Topics: #row-major #column-major #programming

Slides (pdf): https://samuelalbanie.com/files/diges...

References for papers mentioned in the video can be found at
http://samuelalbanie.com/digests/2022...

Recommended further reading:
https://eli.thegreenplace.net/2015/me...
https://onestepcode.com/array-referen...

Music credit: spacedust by airtone (c) copyright 2022 Licensed under a Creative Commons Attribution (3.0) license. http://dig.ccmixter.org/files/airtone...