Please rotate your tablet to be horizontal.

You can dismiss this notice but please note that this experience has not been designed for mobile devices and so will be less than optimal

Back To Schedule

Taking Static Type-Safety to the Next Level

Physical Units for Matrices

07:45 - 08:45 Tuesday 13th September 2022 MDT Summit 6 & 7 / Online B
Intermediate
Advanced
Expert
Templates & Metaprogramming

If you are interested in achieving the ultimate goal in library interface design: "If it compiles, it works!", this talk is for you!

There are several existing C++ libraries to annotate scalars with their physical units.

This talk will present a full-blown solution for a related problem that has not been solved in C++ before: How can we put distinct physical unit types (e. g. meters, seconds, meter per second...) inside a single vector or matrix type from a linear algebra library?

The presented solution uses C++'s strong type system to provide these physical unit annotations for each matrix element. Furthermore, it also enables coordinate frame and quantity kind annotations (think X- and Y-position in coordinate frame A or B which have identical units but refer to different things).

We will learn what is the best way to represent these annotations, how they propagate through linear algebra operations, how they determine the subset of valid operations on each type and of course and most importantly, how this can be implemented efficiently in C++ (with a special on how C++20 is a game-changer here).

While developing the solution, we will also understand how this leads to code that is more expressive and less likely to contain errors because the majority of bugs can be caught at compile-time.

Applications that benefit from this include robotics, computer graphics, automated driving and any other domain that works with physical units, different coordinate frames and matrix operations.

Daniel Withopf

Staff Software EngineerRobert Bosch GmbH

Daniel Withopf has been working on solving real-world problems with C++ in robotics, computer vision and related fields for over 20 years. He is a Staff Software Engineer at the German car supplier Bosch where he wrote and maintains an object tracking framework for self-driving car projects. While doing that he discovered novel ways how to leverage C++'s type system to create linear algebra and tracking code that is more expressive, easier to understand and less likely to contain errors.