valarray Class
The template class describes an object that controls a sequence of elements of type Type that are stored as an array, designed for performing high-speed mathematical operations, and optimized for computational performance.
Remarks
The class is a representation of the mathematical concept of an ordered set of values and the elements are numbered sequentially from zero. The class is described as a near container because it supports some, but not all, of the capabilities that first-class sequence containers, such as vector, support. It differs from template class vector in two important ways:
It defines numerous arithmetic operations between corresponding elements of valarray<Type> objects of the same type and length, such as xarr = cos(yarr) + sin(zarr).
It defines a variety of interesting ways to subscript a valarray<Type> object, by overloading operator[].
An object of class Type:
Has a public default constructor, destructor, copy constructor, and assignment operator, with conventional behavior.
Defines the arithmetic operators and math functions, as needed, that are defined for the floating-point types, with conventional behavior.
In particular, no subtle differences may exist between copy construction and default construction followed by assignment. None of the operations on objects of class Type may throw exceptions.
Constructors
Constructs a valarray of a specific size or with elements of a specific value or as a copy of another valarray or subset of another valarray. |
Typedefs
A type that represents the type of element stored in a valarray. |
Member Functions
Applies a specified function to each element of a valarray. |
|
Cyclically shifts all the elements in a valarray by a specified number of positions. |
|
Frees the memory used by the valarray. |
|
Finds the largest element in a valarray. |
|
Finds the smallest element in a valarray. |
|
Changes the number of elements in a valarray to a specified number, adding or removing elements as required. |
|
Shifts all the elements in a valarray by a specified number of positions. |
|
Finds the number of elements in a valarray. |
|
Determines the sum of all the elements in a valarray of nonzero length. |
|
Operators
A unary operator that obtains the logical NOT values of each element in a valarray. |
|
Obtains the remainder of dividing the elements of an array element-wise either by a specified valarray or by a value of the element type. |
|
Obtains the bitwise AND of elements in an array either with the corresponding elements in a specified valarray or with a value of the element type. |
|
Right-shifts the bits for each element of a valarray operand a specified number of positions or by an element-wise amount specified by a second valarray. |
|
Left-shifts the bits for each element of a valarray operand a specified number of positions or by an element-wise amount specified by a second valarray. |
|
Multiplies the elements of a specified valarray or a value of the element type, element-wise, to an operand valarray. |
|
A unary operator that applies a plus to each element in a valarray. |
|
Adds the elements of a specified valarray or a value of the element type, element-wise, to an operand valarray. |
|
A unary operator that applies a minus to each element in a valarray. |
|
Subtracts the elements of a specified valarray or a value of the element type, element-wise, from an operand valarray. |
|
Divides an operand valarray element-wise by the elements of a specified valarray or a value of the element type. |
|
Assigns elements to a valarray whose values are specified either directly or as part of some other valarray or by a slice_array, gslice_array, mask_array, or indirect_array. |
|
Returns a reference to an element or its value at specified index or a specified subset. |
|
Obtains the element-wise exclusive logical or operator (XOR) of an array with either a specified valarray or a value of the element type. |
|
Obtains the bitwise OR of elements in an array either with the corresponding elements in a specified valarray or with a value of the element type. |
|
A unary operator that obtains the bitwise NOT values of each element in a valarray. |
Requirements
Header: <valarray>
Namespace: std