How px4/eigen works
Purpose and consumption model
Eigen is a C++ template library for dense and sparse linear algebra, decompositions, solvers, geometry, and related numerical algorithms. It is primarily header-based: downstream C++ projects include module entry headers rather than call a standalone service or executable. Public module entry points include Eigen/Core, Eigen/Dense, Eigen/Sparse, and Eigen/Eigen.
Build and distribution boundary
CMake configures installation, optional targets, test integration, and package discovery from CMakeLists.txt; consumers can integrate through generated CMake package config or pkg-config metadata (cmake/Eigen3Config.cmake.in, eigen3.pc.in). The core library has no required runtime infrastructure. Build-time optional backends and supported integrations are discovered by CMake, including BLAS/LAPACK, SuiteSparse-family solvers, MKL, CUDA, and SYCL.
Core expression and storage system
The foundational data model is templated matrices, arrays, views, maps, storage, and expression templates. Public Eigen/Core forwards into implementations such as Eigen/src/Core/Matrix.h, Eigen/src/Core/Array.h, and Eigen/src/Core/AssignEvaluator.h. User operations construct typed expression trees; assignment evaluators decide when and how to materialize results into dense storage. Map and Ref form an important boundary for non-owning access to externally allocated memory.
Evaluation and performance layer
Expression evaluation routes arithmetic and products through generic evaluators and specialized kernels. Matrix products are implemented under Eigen/src/Core/products/GeneralMatrixMatrix.h and parallel scheduling support is in Eigen/src/Core/products/Parallelizer.h. SIMD packet implementations are selected at compile time by platform/compiler capabilities, with architecture-specific paths such as Eigen/src/Core/arch/SSE/PacketMath.h, Eigen/src/Core/arch/AVX/PacketMath.h, and Eigen/src/Core/arch/CUDA/PacketMath.h. This layer is performance-critical and separates user-facing algebra syntax from CPU/GPU-specific execution.
Dense algebra modules
Higher-level dense operations are exposed through module headers and specialized implementations: factorizations in Eigen/Cholesky, Eigen/LU, and Eigen/QR; spectral methods in Eigen/Eigenvalues; and singular-value decomposition in Eigen/SVD. Representative algorithms include Eigen/src/Cholesky/LDLT.h, Eigen/src/LU/FullPivLU.h, and Eigen/src/SVD/BDCSVD.h. The usual flow is dense matrix/expression input → decomposition object/factorization → solve, inverse-related, rank, or spectral result.
Sparse algebra and external solver adapters
Sparse matrix storage and lazy sparse operations are centered on Eigen/SparseCore and Eigen/src/SparseCore/SparseMatrix.h; solvers build on this through Eigen/SparseCholesky, Eigen/SparseLU, and Eigen/SparseQR. Optional adapter modules bridge Eigen sparse types to external native libraries: Eigen/CholmodSupport, Eigen/SuperLUSupport, and Eigen/UmfPackSupport (also KLU, PaStiX, Pardiso, SPQR, and Metis). These are compile-time integration boundaries rather than remotely accessed services.
Extended and experimental functionality
Stable geometry types and transformations are exposed by Eigen/Geometry with implementation in Eigen/src/Geometry/Transform.h and Eigen/src/Geometry/Quaternion.h. Experimental/unsupported features are isolated under unsupported/Eigen, including tensor execution (unsupported/Eigen/CXX11/Tensor, unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h) and thread-pool support (unsupported/Eigen/CXX11/src/ThreadPool/ThreadPoolInterface.h). CUDA and SYCL tensor device paths are present but remain within this unsupported boundary.
Validation and performance artifacts
CMake-driven validation is organized from test/CMakeLists.txt, while compile-failure cases enforce template API constraints in failtest/CMakeLists.txt. Benchmarks measure kernels, solvers, sparse paths, and accelerator tensor operations under bench/ and bench/tensors/. These are development targets, not library runtime entry points.
Main entry points: Matrix.h Matrix, Array, views, storage · Eigen Public module headers · CMakeLists.txt CMake build and install · SparseMatrix.h Sparse storage and expressions
Components 19
Distribution
- CMake build and install · Configures installation, optional integrations, and development targets.
CMakeLists.txt - CMake package config
cmake/Eigen3Config.cmake.in - pkg-config metadata
eigen3.pc.in
Core evaluation
- Matrix, Array, views, storage · Typed dense objects and expression nodes.
Eigen/src/Core/Matrix.h - Map and Ref · Non-owning access to externally allocated memory.
Eigen/Core - Assignment evaluators · Materializes expression trees into dense storage.
Eigen/src/Core/AssignEvaluator.h - Matrix product kernels · Generic and specialized matrix multiplication evaluation.
Eigen/src/Core/products/GeneralMatrixMatrix.h - SIMD and parallel execution · Compile-time packet selection and product scheduling.
Eigen/src/Core/products/Parallelizer.h
Dense algebra
- Dense decompositions · Cholesky, LU, QR, eigenvalue, and SVD algorithms.
Eigen/Cholesky - Dense factorization algorithms · Produce solves, ranks, inverses, and spectral results.
Eigen/src/Cholesky/LDLT.h
Sparse algebra
- Sparse storage and expressions
Eigen/src/SparseCore/SparseMatrix.h - Sparse solvers · Sparse Cholesky, LU, and QR solvers.
Eigen/SparseCholesky - External sparse adapters · Compile-time bridges to SuiteSparse-family and other solvers.
Eigen/CholmodSupport
Extended features
- Geometry transforms · Transform and quaternion types.
Eigen/src/Geometry/Transform.h - Unsupported tensor execution · Tensor execution with optional CUDA and SYCL device paths.
unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
Development targets
- Tests and compile-fail checks · CMake-driven API and template constraint validation.
test/CMakeLists.txt - Benchmarks · Measures kernels, solvers, sparse, and tensor paths.
Other components
- Downstream C++ project · Includes Eigen headers and instantiates templates.
- Public module headers · Core, Dense, Sparse, and umbrella entry points.
Eigen/Eigen
Connections 22
- Downstream C++ project → Public module headers: includes
- CMake build and install → CMake package config: generates
- CMake build and install → pkg-config metadata: generates
- CMake package config → Downstream C++ project: package discovery
- pkg-config metadata → Downstream C++ project: package discovery
- Public module headers → Matrix, Array, views, storage: exposes
- Public module headers → Map and Ref: exposes
- Public module headers → Dense decompositions: includes
- Public module headers → Sparse storage and expressions: includes
- Matrix, Array, views, storage → Assignment evaluators: expression assignment
- Map and Ref → Matrix, Array, views, storage: views external memory as
- Assignment evaluators → Matrix product kernels: dispatches products
- Matrix product kernels → SIMD and parallel execution: uses
- Matrix, Array, views, storage → Dense factorization algorithms: dense input
- Dense decompositions → Dense factorization algorithms: selects
- Matrix, Array, views, storage → Sparse storage and expressions: interoperates
- Sparse storage and expressions → Sparse solvers: solver input
- Sparse solvers → External sparse adapters: optionally delegates to
- Matrix, Array, views, storage → Geometry transforms: supports
- Matrix, Array, views, storage → Unsupported tensor execution: extends
- CMake build and install → Tests and compile-fail checks: configures
- CMake build and install → Benchmarks: configures