CppCon 2024 Guide to Linear Algebra With the Eigen C++ Library -- Daniel Hanson
Registration is now open for CppCon 2025! The conference starts on September 15 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from last year's conference. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2025!
Guide to Linear Algebra With the Eigen C++ Library
by Daniel Hanson
Summary of the talk:
Linear algebra is an essential part of scientific programming, particularly in domains such as quantitative finance, data science, physics, and medical research. It is also relevant to imaging in game development. As C++ did not have all the convenient built-in multidimensional array capabilities and supporting libraries that came with typical Fortran platforms, scientific programmers making the transition to C++ back in the late 1990’s and early 2000's often found themselves in an inconvenient situation with limited options. These included building up this functionality mostly from scratch, wrestling with interfaces to numerical Fortran libraries such as BLAS and LAPACK, or somehow convincing management to invest in a third-party commercial C++ linear algebra library.
The situation has improved substantially over the years with the development of several well-regarded open-source linear algebra libraries for C++. One in particular that has become popular, first released in 2006, is the Eigen library. It has been adopted for use within both the TensorFlow machine learning library and the Stan Math Library, as well as at CERN, and it can also be found in the implementation of high-performance quantitative trading strategies in C++.
In this talk, we will examine the setup and basics of the Eigen library, followed by a discussion of some of its more advanced features, including applications of matrix decompositions frequently used in quantitative work, as well as its compatibility with STL algorithms. It will conclude with an overview of how it can be used within the context of the C++26 BLAS interface proposal (P1673), via an interface with std::mdspan now available in C++23.