Condividi tramite


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.

For a list of all members of this type, see valarray Members.

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.

Requirements

Header: <valarray>

Namespace: std

See Also

Concepts

valarray Members

<valarray> Members

Thread Safety in the Standard C++ Library