xtensor is a C++ library for numerical analysis with multi-dimensional arrays that provides lazy broadcasting and expression-based computation.
The library solves the problem of performing efficient numerical operations on multi-dimensional data in C++ by offering an expression system that delays computation until results are needed, enabling lazy evaluation and automatic broadcasting. It follows C++ standard library idioms and provides an API inspired by NumPy, making it familiar to developers accustomed to Python's array programming model. The tool includes adaptors that allow existing data structures to be integrated into its expression system, and it can process NumPy, Julia, and R arrays in-place through language bindings.
Developers should choose xtensor for projects requiring high-performance numerical computing in C++ where lazy evaluation and broadcasting semantics are valuable. It suits applications that need to interoperate with Python data structures or other scientific computing ecosystems. The library is available as a header-only installation through package managers including mamba, conda, and vcpkg, making integration straightforward. It depends on the xtl library and optionally on xsimd for SIMD acceleration, which can be enabled by defining a preprocessor macro before including headers.
The project maintains active development with regular updates to support newer C++ standards, progressing from C++14 through C++17 and C++20 across successive versions. The tool is documented with comprehensive reference materials and supports interactive exploration through Jupyter notebooks via the xeus-cling kernel, enabling a NumPy-like workflow directly in C++.