Source: http://eel.is/c++draft/template.valarray
Timestamp: 2019-04-23 04:56:11+00:00

Document:
The class template valarray<T> is a one-dimensional smart array, with elements numbered sequentially from zero.
It is a representation of the mathematical concept of an ordered set of values.
For convenience, an object of type valarray<T> is referred to as an “array” throughout the remainder of [numarray].
The intent is to specify an array template that has the minimum functionality necessary to address aliasing ambiguities and the proliferation of temporary objects.
Thus, the valarray template is neither a matrix class nor a field class.
However, it is a very useful building block for designing such classes.
Effects: Constructs a valarray that has length n.
Each element of the array is value-initialized.
Each element of the array is initialized with v.
Requires: p points to an array ([dcl.array]) of at least n elements.
Effects: Constructs a valarray that has the same length as v.
The elements are initialized with the values of the corresponding elements of v.
Effects: Equivalent to valarray(il.begin(), il.size()).
These conversion constructors convert one of the four reference templates to a valarray.
Effects: The destructor is applied to every element of *this; an implementation may return all allocated memory.
This default constructor is essential, since arrays of valarray may be useful.
After initialization, the length of an empty array can be increased with the resize member function.
This constructor is the preferred method for converting a C array to a valarray object.
This copy constructor creates a distinct array rather than an alias.
Implementations in which arrays share storage are permitted, but they would need to implement a copy-on-reference mechanism to ensure that arrays are conceptually distinct.
Effects: Each element of the *this array is assigned the value of the corresponding element of v.
If the length of v is not equal to the length of *this, resizes *this to make the two arrays the same length, as if by calling resize(v.size()), before performing the assignment.
Effects: *this obtains the value of v.
The value of v after the assignment is not specified.
Effects: Assigns v to each element of *this.
Requires: The length of the array to which the argument refers equals size().
The value of an element in the left-hand side of a valarray assignment operator does not depend on the value of another element in that left-hand side.
These operators allow the results of a generalized subscripting operation to be assigned directly to a valarray.
Returns: A reference to the corresponding element of the array.
The expression (a[i] = q, a[i]) == q evaluates to true for any non-constant valarray<T> a, any T q, and for any size_­t i such that the value of i is less than the length of a.
Remarks: The expression addressof(a[i+j]) == addressof(a[i]) + j evaluates to true for all size_­t i and size_­t j such that i+j < a.size().
The expression addressof(a[i]) != addressof(b[j]) evaluates to true for any two arrays a and b and for any size_­t i and size_­t j such that i < a.size() and j < b.size().
This property indicates an absence of aliasing and may be used to advantage by optimizing compilers.
Compilers may take advantage of inlining, constant propagation, loop fusion, tracking of pointers obtained from operator new, and other techniques to generate efficient valarrays.
The reference returned by the subscript operator for an array shall be valid until the member function resize(size_­t, T) is called for that array or until the lifetime of that array ends, whichever happens first.
The member operator is overloaded to provide several ways to select sequences of elements from among those controlled by *this.
Each of these operations returns a subset of the array.
The const-qualified versions return this subset as a new valarray object.
The non-const versions return a class template object which has reference semantics to the original array, working in conjunction with various overloads of operator= and other assigning operators to allow selective replacement (slicing) of the controlled sequence.
In each case the selected element(s) shall exist.
Returns: A valarray containing those elements of the controlled sequence designated by slicearr.
Returns: An object that holds references to elements of the controlled sequence selected by slicearr.
Returns: A valarray containing those elements of the controlled sequence designated by gslicearr.
Returns: An object that holds references to elements of the controlled sequence selected by gslicearr.
Returns: A valarray containing those elements of the controlled sequence designated by boolarr.
Returns: An object that holds references to elements of the controlled sequence selected by boolarr.
Returns: A valarray containing those elements of the controlled sequence designated by indarr.
Returns: An object that holds references to elements of the controlled sequence selected by indarr.
Requires: Each of these operators may only be instantiated for a type T to which the indicated operator can be applied and for which the indicated operator returns a value which is of type T (bool for operator!) or which may be unambiguously implicitly converted to type T (bool for operator!).
Returns: A valarray whose length is size().
Each element of the returned array is initialized with the result of applying the indicated operator to the corresponding element of the array.
Each of these operators may only be instantiated for a type T if the indicated operator can be applied to two operands of type T.
The value of an element in the left-hand side of a valarray compound assignment operator does not depend on the value of another element in that left hand side.
Effects: Each of these operators performs the indicated operation on each of the elements of *this and the corresponding element of v.
Remarks: The appearance of an array on the left-hand side of a compound assignment does not invalidate references or pointers.
Requires: Each of these operators may only be instantiated for a type T if the indicated operator can be applied to two operands of type T.
Effects: Each of these operators applies the indicated operation to each element of *this and v.
Remarks: The appearance of an array on the left-hand side of a compound assignment does not invalidate references or pointers to the elements of the array.
v obtains the value of *this.
Returns: The number of elements in the array.
This function may only be instantiated for a type T to which operator+= can be applied.
Returns: The sum of all the elements of the array.
If the array has length 1, returns the value of element 0.
Otherwise, the returned value is calculated by applying operator+= to a copy of an element of the array and all other elements of the array in an unspecified order.
Returns: The minimum value contained in *this.
For an array of length 1, the value of element 0 is returned.
For all other array lengths, the determination is made using operator<.
Returns: The maximum value contained in *this.
Returns: A valarray of length size(), each of whose elements I is (*this)[I + n] if I + n is non-negative and less than size(), otherwise T().
If element zero is taken as the leftmost element, a positive value of n shifts the elements left n places, with zero fill.
If the argument has the value -2, the first two elements of the result will be value-initialized; the third element of the result will be assigned the value of the first element of the argument; etc.
Returns: A valarray of length size() that is a circular shift of *this.
If element zero is taken as the leftmost element, a non-negative value of n shifts the elements circularly left n places and a negative value of n shifts the elements circularly right −n places.
Each element of the returned array is assigned the value returned by applying the argument function to the corresponding element of *this.
Effects: Changes the length of the *this array to sz and then assigns to each element the value of the second argument.
Resizing invalidates all pointers and references to elements in the array.

References: v.

 v.

 v.

 v.

 v.

 v.

 v.