Matrices vs vectors of vectors performance

Matrices of structs are stored contiguously in memory, whereas vectors of vectors aren’t. If you’re working with numerical data, it will generally be more efficient to use a matrix instead of a vector of vectors, if all the vectors have the same length.

3 Likes