Valarrays are created to allow the compiler to make a faster executable. However, these optimizations are achievable by other means, and varars are rarely used.
std :: valarray and auxiliary classes are defined as free from certain forms of anti-aliasing, which allows optimizing operations on these classes, similar to the effect of restricting a keyword in the programming language C. In addition, functions and operators that accept valarray arguments are allowed to return proxy objects so that the compiler can optimize the expression, such as v1 = av2 + v3; as a single cycle that executes v1 [i] = av2 [i] + v3 [i]; avoiding any temporary or multiple passes ......
In other words, valarrays are intended to be used in places where there are many values ββthat are passed mostly to simple expressions.
Rarely, only valars are optimized, such as Intel Parallel Studio.
Further information can be found at cppreference
Petar velev
source share