xtensor-stack/xtensor
C++ tensors with broadcasting and lazy computing
What it solves
xtensor is a C++ library designed for numerical analysis using multi-dimensional array expressions. It brings NumPy-like functionality to C++, allowing developers to perform complex mathematical operations on arrays without the overhead of Python, while maintaining a familiar API for those coming from the Python ecosystem.
How it works
The library uses an extensible expression system that implements lazy broadcasting. Instead of computing results immediately, operations (like addition or sine functions) return an xexpression object. The actual values are only computed when the result is accessed or assigned to a container like xarray or xtensor.
It provides two primary container types:
xarray: A dynamic container that can be reshaped at runtime, similar to NumPy arrays.xtensor: A container with dimensions set at compile-time, which allows for stack allocation of shapes and strides for better performance.
Who it’s for
It is intended for C++ developers performing numerical analysis, data science, or high-performance computing who need multi-dimensional array manipulation and broadcasting capabilities.
Highlights
- NumPy-inspired API: Follows the idioms of the C++ standard library while mirroring NumPy's array programming model.
- Lazy Computing: Reduces unnecessary computations by only evaluating expressions at the point of access.
- Broadcasting: Supports element-wise operations on arrays of different shapes following NumPy-style rules.
- Interoperability: Can process NumPy, Julia, and R data structures in-place via adaptors.
- SIMD Acceleration: Integrates with
xsimdto leverage SSE, AVX, AVX512, and Neon instruction sets for performance.
Related
- Project
- Project
- Project
- Project