Common mathematical functions | |||||||||||||||||||||||||||||||
Mathematical special functions(C++17) | |||||||||||||||||||||||||||||||
Mathematical constants(C++20) | |||||||||||||||||||||||||||||||
Basic linear algebra algorithms(C++26) | |||||||||||||||||||||||||||||||
Data-parallel types (SIMD)(C++26) | |||||||||||||||||||||||||||||||
Floating-point environment(C++11) | |||||||||||||||||||||||||||||||
Complex numbers | |||||||||||||||||||||||||||||||
Numeric array (valarray ) | |||||||||||||||||||||||||||||||
Pseudo-random number generation | |||||||||||||||||||||||||||||||
Bit manipulation(C++20) | |||||||||||||||||||||||||||||||
Saturation arithmetic(C++26) | |||||||||||||||||||||||||||||||
Factor operations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Interpolations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Generic numeric operations | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
C-style checked integer arithmetic | |||||||||||||||||||||||||||||||
|
Defined in header <valarray> | ||
template<class T> class valarray; | ||
std::valarray
is the class for representing and manipulating arrays of values. It supports element-wise mathematical operations and various forms of generalized subscript operators, slicing and indirect access.
Contents |
std::valarray
and helper classes are defined to be free of certain forms of aliasing, thus allowing operations on these classes to be optimized similar to the effect of the keywordrestrict in the C programming language. In addition, functions and operators that takevalarray
arguments are allowed to return proxy objects to make it possible for the compiler to optimize an expression such asv1= a* v2+ v3; as a single loop that executesv1[i]= a* v2[i]+ v3[i]; avoiding any temporaries or multiple passes. However,expression templates make the same optimization technique available for any C++ container, and the majority of numeric libraries prefer expression templates to valarrays for flexibility. Some C++ standard library implementations use expression templates to implement efficient operations onstd::valarray
(e.g. GNU libstdc++ and LLVM libc++). Only rarely are valarrays optimized any further, as in e.g.Intel Integrated Performance Primitives.
T | - | the type of the elements. The type must meet theNumericType requirements |
Member type | Definition |
value_type | T |
constructs new numeric array (public member function)[edit] | |
destructs the numeric array (public member function)[edit] | |
assigns the contents (public member function)[edit] | |
get/set valarray element, slice, or mask (public member function)[edit] | |
applies a unary arithmetic operator to each element of the valarray (public member function)[edit] | |
applies compound assignment operator to each element of the valarray (public member function)[edit] | |
swaps with another valarray (public member function)[edit] | |
returns the size of valarray (public member function)[edit] | |
changes the size of valarray (public member function)[edit] | |
calculates the sum of all elements (public member function)[edit] | |
returns the smallest element (public member function)[edit] | |
returns the largest element (public member function)[edit] | |
zero-filling shift the elements of the valarray (public member function)[edit] | |
circular shift of the elements of the valarray (public member function)[edit] | |
applies a function to every element of a valarray (public member function)[edit] |
(C++11) | specializes thestd::swap algorithm (function template)[edit] |
(C++11) | overloadsstd::begin (function template)[edit] |
(C++11) | specializesstd::end (function template)[edit] |
applies binary operators to each element of two valarrays, or a valarray and a value (function template)[edit] | |
compares two valarrays or a valarray with a value (function template)[edit] | |
applies the functionabs to each element of valarray (function template)[edit] | |
Exponential functions | |
applies the functionstd::exp to each element of valarray (function template)[edit] | |
applies the functionstd::log to each element of valarray (function template)[edit] | |
applies the functionstd::log10 to each element of valarray (function template)[edit] | |
Power functions | |
applies the functionstd::pow to two valarrays or a valarray and a value (function template)[edit] | |
applies the functionstd::sqrt to each element of valarray (function template)[edit] | |
Trigonometric functions | |
applies the functionstd::sin to each element of valarray (function template)[edit] | |
applies the functionstd::cos to each element of valarray (function template)[edit] | |
applies the functionstd::tan to each element of valarray (function template)[edit] | |
applies the functionstd::asin to each element of valarray (function template)[edit] | |
applies the functionstd::acos to each element of valarray (function template)[edit] | |
applies the functionstd::atan to each element of valarray (function template)[edit] | |
applies the functionstd::atan2 to a valarray and a value (function template)[edit] | |
Hyperbolic functions | |
applies the functionstd::sinh to each element of valarray (function template)[edit] | |
applies the functionstd::cosh to each element of valarray (function template)[edit] | |
applies the functionstd::tanh to each element of valarray (function template)[edit] |
BLAS-like slice of a valarray: starting index, length, stride (class)[edit] | |
proxy to a subset of a valarray after applying a slice (class template)[edit] | |
generalized slice of a valarray: starting index, set of lengths, set of strides (class)[edit] | |
proxy to a subset of a valarray after applying a gslice (class template)[edit] | |
proxy to a subset of a valarray after applying a boolean maskoperator[] (class template)[edit] | |
proxy to a subset of a valarray after applying indirectoperator[] (class template)[edit] |
(C++26) | convenience alias template forbasic_simd that can specify its width(alias template)[edit] |
(C++26) | convenience alias template forbasic_simd_mask that can specify its width(alias template)[edit] |
(parallelism TS v2) | data-parallel vector type (class template)[edit] |
(parallelism TS v2) | data-parallel type with the element type bool (class template)[edit] |