Physical Units for Matrices: How Hard Can It Be?

Speaker: Daniel Withopf

Audience level: Intermediate | Advanced

This talk will present a comprehensive C++ solution how matrix types from a linear algebra library (Eigen, blaze, P1385) can be enriched with physical units (e.g. mpusz/units from P1935) to achieve more expressive and less error-prone code. In contrast to existing work on the topic, this approach works in all cases and not only when the units in a vector / matrix are uniform.

Furthermore, the solution also enables coordinate frame and quantity kind annotations for all matrix elements. E.g., it allows to distinguish between X- and Y-position and between X-position in coordinate frame A and X-Position in frame B.

The presented approach is being used in Bosch's self-driving car projects to create code that is more expressive, easier to understand and less likely to contain errors. This helps our C++ programmers to catch bugs as early as possible (at compile time). It also makes code reviews more efficient by preventing a large class of incorrect operations on vector and matrix types that cannot be detected when using a classical linear algebra library.