Taking Static Type-safety to the Next Level: Physical Units for Matrices
summary
Presents a full C++ library that encodes per-element physical units and coordinate frames into matrix types, implemented as a thin Eigen binding with row and column index lists that derive units by exponent arithmetic and enforce valid linear algebra only at compile time. Uses C++20 features and C++20 concepts to get readable errors, adds lvalue/rvalue overloads to block dangling-expression bugs, and demonstrates ~15% compile-time overhead versus raw Eigen while preventing out-of-bounds and unit/frame mismatches.
AI-written summary · about
chapters (21)
- 0:00Intro
- 0:49What's in it for you? Physical units in vectors and matrices
- 2:28Terminology Physical units
- 4:17Combining linear algebra with physical units
- 5:53A slightly more complex example • Let's try to track a vehicle in 1 dimension
- 7:34Unit structure in a matrix
- 8:30Element access with classical linear algebra libraries
- 12:18Named index structs
- 14:22One type for almost everything
- 16:30Creating a vector and access to elements
- 20:11More ways to create a vector/matrix
- 23:18Matrix element access
- 26:08Taxonomy of vector and matrix types
- 29:44Matrix multiplication
- 31:43What operator+ looks like
- 33:56Compiler error messages
- 35:46Compiler error message with C++20 concepts
- 38:08Uniform matrices vs. Index-oriented design (Type Safe Matrix)
- 42:42Expression templates and auto variables
- 46:13How to prevent usage of Matrix Expression
- 48:36What we have achieved
related talks
01h 03mTaking Static Type-Safety to the Next Level - Physical Units for Matrices
01h 31mImplementing Physical Units Library for C++
01h 30mEnhancing Safety in C++ Code With Modern C++ Quantities and Units Library
01h 08mA Physical Units Library For the Next C++
01h 00mIntroducing a matrix class to the C++ standard library
51mThe C++ Type System is your Friend
01h 02mA Physical Units Library For C++
01h 40mUsing Units, Qantities, and Dimensions in C++14
