# **[](https://en.cppreference.com/w/cpp/header/valarray)** provides `std::valarray`, a vector-like container optimized for mathematical operations: elementwise operations, slicing, and masking. Most scientific code uses Eigen or NumPy instead. `valarray` has an odd API and is rarely used in practice. ## Example This example performs elementwise addition on two valarrays, demonstrating the vectorized operations this container provides. ```cpp // compile: g++ -std=c++11 -o valarrayexample valarrayexample.cpp // run: ./valarrayexample // description: elementwise valarray operations #include #include int main() { std::valarray a{1, 2, 3}; std::valarray b{4, 5, 6}; std::valarray c = a + b; std::cout << "sum: "; for (int x : c) std::cout << x << " "; std::cout << "\n"; return 0; } ```