std::valarray (3) - Linux Man Pages

std::valarray: std::valarray

NAME

std::valarray - std::valarray

Synopsis


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.

Notes


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 keyword restrict in the C programming language. In addition, functions and operators that take valarray arguments are allowed to return proxy objects to make it possible for the compiler to optimize an expression such as v1 = a*v2 + v3; as a single loop that executes v1[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 on std::valarray (e.g. GNU libstdc++ and LLVM libc++). Only rarely are valarrays optimized any further, as in e.g. Intel_Integrated_Performance_Primitives.

Template parameters


T - the type of the elements. The type must meet the NumericType requirements

Member types


Member type Definition
value_type T

Member functions


              constructs new numeric array
constructor (public member function)
              destructs the numeric array
destructor (public member function)
              assigns the contents
operator= (public member function)
              get/set valarray element, slice, or mask
operator[] (public member function)


operator+ applies a unary arithmetic operator to each element of the valarray
operator- (public member function)
operator~
operator!


operator+=
operator-=
operator*=
operator/= applies compound assignment operator to each element of the valarray
operator%= (public member function)
operator&=
operator|=
operator^=
operator<<=
operator>>=
              swaps with another valarray
swap (public member function)
              returns the size of valarray
size (public member function)
              changes the size of valarray
resize (public member function)
              calculates the sum of all elements
sum (public member function)
              returns the smallest element
min (public member function)
              returns the largest element
max (public member function)
              zero-filling shift the elements of the valarray
shift (public member function)
              circular shift of the elements of the valarray
cshift (public member function)
              applies a function to every element of a valarray
apply (public member function)

Non-member functions


std::swap(std::valarray) specializes the std::swap() algorithm
                          (function template)
(C++11)


std::begin(std::valarray) specializes std::begin
                          (function template)
(C++11)


std::end(std::valarray) specializes std::end
                          (function template)
(C++11)


operator+
operator-
operator*
operator/
operator% applies binary operators to each element of two valarrays, or a valarray and a value
operator& (function template)
operator|
operator^
operator<<
operator>>
operator&&
operator||


operator==
operator!= compares two valarrays or a valarray with a value
operator< (function template)
operator<=
operator>
operator>=
                          applies the function std::abs to each element of valarray
abs(std::valarray) (function template)

Exponential functions


                          applies the function std::exp to each element of valarray
exp(std::valarray) (function template)
                          applies the function std::log to each element of valarray
log(std::valarray) (function template)
                          applies the function std::log10 to each element of valarray
log10(std::valarray) (function template)

Power functions


                          applies the function std::pow to two valarrays or a valarray and a value
pow(std::valarray) (function template)
                          applies the function std::sqrt to each element of valarray
sqrt(std::valarray) (function template)

Trigonometric functions


                          applies the function std::sin to each element of valarray
sin(std::valarray) (function template)
                          applies the function std::cos to each element of valarray
cos(std::valarray) (function template)
                          applies the function std::tan to each element of valarray
tan(std::valarray) (function template)
                          applies the function std::asin to each element of valarray
asin(std::valarray) (function template)
                          applies the function std::acos to each element of valarray
acos(std::valarray) (function template)
                          applies the function std::atan to each element of valarray
atan(std::valarray) (function template)
                          applies the function std::atan2 to a valarray and a value
atan2(std::valarray) (function template)

Hyperbolic functions


                          applies the function std::sinh to each element of valarray
sinh(std::valarray) (function template)
                          applies the function std::cosh to each element of valarray
cosh(std::valarray) (function template)
                          applies the function std::tanh to each element of valarray
tanh(std::valarray) (function template)

Helper classes


               BLAS-like slice of a valarray: starting index, length, stride
slice (class)
               proxy to a subset of a valarray after applying a slice
slice_array (class template)
               generalized slice of a valarray: starting index, set of lengths, set of strides
gslice (class)
               proxy to a subset of a valarray after applying a gslice
gslice_array (class template)
               proxy to a subset of a valarray after applying a boolean mask operator[]
mask_array (class template)
               proxy to a subset of a valarray after applying indirect operator[]
indirect_array (class template)


Deduction_guides(since C++17)