man std::valarray (Fonctions bibliothèques) - Smart array designed to support numeric processing.

NAME

std::valarray - Smart array designed to support numeric processing.

SYNOPSIS



Public Types

typedef Type value_type

Public Member Functions

valarray ()

Construct an empty array. valarray (size_t)

Construct an array with n elements. valarray (const Type &, size_t)

Construct an array with n elements initialized to t. valarray (const Type *__restrict__, size_t)

Construct an array initialized to the first n elements of t. valarray (const valarray &)

Copy constructor. valarray (const slice_array< Type > &)

Construct an array with the same size and values in sa. valarray (const gslice_array< Type > &)

Construct an array with the same size and values in ga. valarray (const mask_array< Type > &)

Construct an array with the same size and values in ma. valarray (const indirect_array< Type > &)

Construct an array with the same size and values in ia. template<class Dom> valarray (const Expr< Dom, Type > &__e)

~valarray ()

valarray< Type > & operator= (const valarray< Type > &)

Assign elements to an array. valarray< Type > & operator= (const Type &)

Assign elements to a value. valarray< Type > & operator= (const slice_array< Type > &)

Assign elements to an array subset. valarray< Type > & operator= (const gslice_array< Type > &)

Assign elements to an array subset. valarray< Type > & operator= (const mask_array< Type > &)

Assign elements to an array subset. valarray< Type > & operator= (const indirect_array< Type > &)

Assign elements to an array subset. template<class Dom> valarray< Type > & operator= (const Expr< Dom, Type > &)

Type & operator[] (size_t)

const Type & operator[] (size_t) const

Expr< SClos< ValArray, Type >, Type > operator[] (slice) const

Return an array subset. slice_array< Type > operator[] (slice)

Return a reference to an array subset. Expr< GClos< ValArray, Type >, Type > operator[] (const gslice &) const

Return an array subset. gslice_array< Type > operator[] (const gslice &)

Return a reference to an array subset. valarray< Type > operator[] (const valarray< bool > &) const

Return an array subset. mask_array< Type > operator[] (const valarray< bool > &)

Return a reference to an array subset. Expr< IClos< ValArray, Type >, Type > operator[] (const valarray< size_t > &) const

Return an array subset. indirect_array< Type > operator[] (const valarray< size_t > &)

Return a reference to an array subset. UnaryOp< __unary_plus >::Rt operator+ () const

Return a new valarray by applying unary + to each element. UnaryOp< negate >::Rt operator- () const

Return a new valarray by applying unary - to each element. UnaryOp< __bitwise_not >::Rt operator~ () const

Return a new valarray by applying unary ~ to each element. UnaryOp< __logical_not >::Rt operator! () const

Return a new valarray by applying unary ! to each element. valarray< Type > & operator *= (const Type &)

Multiply each element of array by t. valarray< Type > & operator/= (const Type &)

Divide each element of array by t. valarray< Type > & operator%= (const Type &)

Set each element e of array to e % t. valarray< Type > & operator+= (const Type &)

Add t to each element of array. valarray< Type > & operator-= (const Type &)

Subtract t to each element of array. valarray< Type > & operator^= (const Type &)

Set each element e of array to e ^ t. valarray< Type > & operator &= (const Type &)

Set each element e of array to e & t. valarray< Type > & operator|= (const Type &)

Set each element e of array to e | t. valarray< Type > & operator<<= (const Type &)

Left shift each element e of array by t bits. valarray< Type > & operator>>= (const Type &)

Right shift each element e of array by t bits. valarray< Type > & operator *= (const valarray< Type > &)

Multiply elements of array by corresponding elements of v. valarray< Type > & operator/= (const valarray< Type > &)

Divide elements of array by corresponding elements of v. valarray< Type > & operator%= (const valarray< Type > &)

Modulo elements of array by corresponding elements of v. valarray< Type > & operator+= (const valarray< Type > &)

Add corresponding elements of v to elements of array. valarray< Type > & operator-= (const valarray< Type > &)

Subtract corresponding elements of v from elements of array. valarray< Type > & operator^= (const valarray< Type > &)

Logical xor corresponding elements of v with elements of array. valarray< Type > & operator|= (const valarray< Type > &)

Logical or corresponding elements of v with elements of array. valarray< Type > & operator &= (const valarray< Type > &)

Logical and corresponding elements of v with elements of array. valarray< Type > & operator<<= (const valarray< Type > &)

Left shift elements of array by corresponding elements of v. valarray< Type > & operator>>= (const valarray< Type > &)

Right shift elements of array by corresponding elements of v. size_t size () const

Return the number of elements in array. Type sum () const

Return the sum of all elements in the array. Type min () const

Return the minimum element using operator<(). Type max () const

Return the maximum element using operator<(). valarray< Type > shift (int) const

Return a shifted array. valarray< Type > cshift (int) const

Return a rotated array. Expr< ValFunClos< ValArray, Type >, Type > apply (Type func(Type)) const

Apply a function to the array. Expr< RefFunClos< ValArray, Type >, Type > apply (Type func(const Type &)) const

Apply a function to the array. void resize (size_t size, Type c=Type())

Resize array. template<typename Type> valarray (const Type *__restrict__ __p, size_t n)

template<typename Type> valarray (const valarray< Type > &__v)

Private Attributes

size_t M_size

Type *__restrict__ M_data

Friends

class Array< Type >

Classes

struct UnaryOp

Detailed Description

template<class Type> class std::valarray< Type >

Smart array designed to support numeric processing.

A valarray is an array that provides constraints intended to allow for effective optimization of numeric array processing by reducing the aliasing that can result from pointer representations. It represents a one-dimensional array from which different multidimensional subsets can be accessed and modified.

Parameters: Tp Type of object in the array.

Definition at line 110 of file valarray.

Constructor & Destructor Documentation

template<typename Type> std::valarray< Type >::valarray () [inline]

Construct an empty array.

Definition at line 556 of file valarray.

template<typename Type> std::valarray< Type >::valarray (size_t) [inline, explicit]

Construct an array with n elements.

Definition at line 560 of file valarray.

References std::__valarray_default_construct().

template<typename Type> std::valarray< Type >::valarray (const Type &, size_t) [inline]

Construct an array with n elements initialized to t.

Definition at line 566 of file valarray.

References std::__valarray_fill_construct().

template<class Type> std::valarray< Type >::valarray (const Type * __restrict__, size_t)

Construct an array initialized to the first n elements of t.

template<class Type> std::valarray< Type >::valarray (const valarray< Type > &)

Copy constructor.

template<typename Type> std::valarray< Type >::valarray (const slice_array< Type > &) [inline]

Construct an array with the same size and values in sa.

Definition at line 587 of file valarray.

template<typename Type> std::valarray< Type >::valarray (const gslice_array< Type > &) [inline]

Construct an array with the same size and values in ga.

Definition at line 596 of file valarray.

template<typename Type> std::valarray< Type >::valarray (const mask_array< Type > &) [inline]

Construct an array with the same size and values in ma.

Definition at line 607 of file valarray.

template<typename Type> std::valarray< Type >::valarray (const indirect_array< Type > &) [inline]

Construct an array with the same size and values in ia.

Definition at line 616 of file valarray.

Member Function Documentation

template<class Type> Expr< RefFunClos< ValArray, Type >, Type > std::valarray< Type >::apply (Type func(const Type &)) const [inline]

Apply a function to the array.

Returns a new valarray with elements assigned to the result of applying func to the corresponding element of this array. The new array is the same size as this one.

Parameters: func Function of const Tp& returning Tp to apply.

Returns: New valarray with transformed elements.

Definition at line 886 of file valarray.

template<class Type> Expr< ValFunClos< ValArray, Type >, Type > std::valarray< Type >::apply (Type func(Type)) const [inline]

Apply a function to the array.

Returns a new valarray with elements assigned to the result of applying func to the corresponding element of this array. The new array is the same size as this one.

Parameters: func Function of Tp returning Tp to apply.

Returns: New valarray with transformed elements.

Definition at line 878 of file valarray.

template<class Type> valarray< Type > std::valarray< Type >::cshift (int) const [inline]

Return a rotated array.

A new valarray is constructed as a copy of this array with elements in shifted positions. For an element with index i, the new position is (i - n) % size(). The new valarray is the same size as the current one. Elements that are shifted beyond the array bounds are shifted into the other end of the array. No elements are lost.

Positive arguments shift toward index 0, wrapping around the top. Negative arguments shift towards the top, wrapping around to 0.

Parameters: n Number of element positions to rotate.

Returns: New valarray with elements in shifted positions.

Definition at line 822 of file valarray.

References std::__valarray_copy_construct().

template<typename Type> Type std::valarray< Type >::max () const [inline]

Return the maximum element using operator<().

Definition at line 870 of file valarray.

References std::max_element().

template<typename Type> Type std::valarray< Type >::min () const [inline]

Return the minimum element using operator<().

Definition at line 862 of file valarray.

References std::min_element().

template<class Type> valarray<Type>& std::valarray< Type >::operator &= (const valarray< Type > &)

Logical and corresponding elements of v with elements of array.

template<class Type> valarray<Type>& std::valarray< Type >::operator &= (const Type &)

Set each element e of array to e & t.

template<class Type> valarray<Type>& std::valarray< Type >::operator *= (const valarray< Type > &)

Multiply elements of array by corresponding elements of v.

template<class Type> valarray<Type>& std::valarray< Type >::operator *= (const Type &)

Multiply each element of array by t.

template<class Type> UnaryOp<__logical_not>::Rt std::valarray< Type >::operator! () const

Return a new valarray by applying unary ! to each element.

template<class Type> valarray<Type>& std::valarray< Type >::operator%= (const valarray< Type > &)

Modulo elements of array by corresponding elements of v.

template<class Type> valarray<Type>& std::valarray< Type >::operator%= (const Type &)

Set each element e of array to e % t.

template<class Type> UnaryOp<__unary_plus>::Rt std::valarray< Type >::operator+ () const

Return a new valarray by applying unary + to each element.

template<class Type> valarray<Type>& std::valarray< Type >::operator+= (const valarray< Type > &)

Add corresponding elements of v to elements of array.

template<class Type> valarray<Type>& std::valarray< Type >::operator+= (const Type &)

Add t to each element of array.

template<class Type> UnaryOp<negate>::Rt std::valarray< Type >::operator- () const

Return a new valarray by applying unary - to each element.

template<class Type> valarray<Type>& std::valarray< Type >::operator-= (const valarray< Type > &)

Subtract corresponding elements of v from elements of array.

template<class Type> valarray<Type>& std::valarray< Type >::operator-= (const Type &)

Subtract t to each element of array.

template<class Type> valarray<Type>& std::valarray< Type >::operator/= (const valarray< Type > &)

Divide elements of array by corresponding elements of v.

template<class Type> valarray<Type>& std::valarray< Type >::operator/= (const Type &)

Divide each element of array by t.

template<class Type> valarray<Type>& std::valarray< Type >::operator<<= (const valarray< Type > &)

Left shift elements of array by corresponding elements of v.

template<class Type> valarray<Type>& std::valarray< Type >::operator<<= (const Type &)

Left shift each element e of array by t bits.

template<typename Type> valarray< Type > & std::valarray< Type >::operator= (const indirect_array< Type > &) [inline]

Assign elements to an array subset.

Assign elements of array to values in ia. Results are undefined if ia is not the same size as this array.

Parameters: ia Array slice to get values from.

Definition at line 686 of file valarray.

template<typename Type> valarray< Type > & std::valarray< Type >::operator= (const mask_array< Type > &) [inline]

Assign elements to an array subset.

Assign elements of array to values in ma. Results are undefined if ma is not the same size as this array.

Parameters: ma Array slice to get values from.

Definition at line 676 of file valarray.

template<typename Type> valarray< Type > & std::valarray< Type >::operator= (const gslice_array< Type > &) [inline]

Assign elements to an array subset.

Assign elements of array to values in ga. Results are undefined if ga is not the same size as this array.

Parameters: ga Array slice to get values from.

Definition at line 666 of file valarray.

template<typename Type> valarray< Type > & std::valarray< Type >::operator= (const slice_array< Type > &) [inline]

Assign elements to an array subset.

Assign elements of array to values in sa. Results are undefined if sa is not the same size as this array.

Parameters: sa Array slice to get values from.

Definition at line 656 of file valarray.

template<typename Type> valarray< Type > & std::valarray< Type >::operator= (const Type &) [inline]

Assign elements to a value.

Assign all elements of array to t.

Parameters: t Value for elements.

Definition at line 648 of file valarray.

template<typename Type> valarray< Type > & std::valarray< Type >::operator= (const valarray< Type > &) [inline]

Assign elements to an array.

Assign elements of array to values in v. Results are undefined if v is not the same size as this array.

Parameters: v Valarray to get values from.

Definition at line 639 of file valarray.

template<class Type> valarray<Type>& std::valarray< Type >::operator>>= (const valarray< Type > &)

Right shift elements of array by corresponding elements of v.

template<class Type> valarray<Type>& std::valarray< Type >::operator>>= (const Type &)

Right shift each element e of array by t bits.

template<typename Type> indirect_array< Type > std::valarray< Type >::operator[] (const valarray< size_t > &) [inline]

Return a reference to an array subset.

Returns an indirect_array referencing the elements of the array indicated by the argument. The elements in the argument are interpreted as the indices of elements of this valarray to include in the subset. The returned indirect_array refers to these elements.

Parameters: i The valarray element index list.

Returns: Indirect_array referencing elements in i.

Definition at line 768 of file valarray.

References std::valarray< Type >::size().

template<typename Type> Expr< IClos< ValArray, Type >, Type > std::valarray< Type >::operator[] (const valarray< size_t > &) const [inline]

Return an array subset.

Returns a new valarray containing the elements of the array indicated by the argument. The elements in the argument are interpreted as the indices of elements of this valarray to copy to the return valarray.

Parameters: i The valarray element index list.

Returns: New valarray containing elements in s.

Definition at line 760 of file valarray.

template<typename Type> mask_array< Type > std::valarray< Type >::operator[] (const valarray< bool > &) [inline]

Return a reference to an array subset.

Returns a new mask_array referencing the elements of the array indicated by the argument. The input is a valarray of bool which represents a bitmask indicating which elements are part of the subset. Elements of the array are part of the subset if the corresponding element of the argument is true.

Parameters: m The valarray bitmask.

Returns: New valarray containing elements indicated by m.

Definition at line 749 of file valarray.

References std::valarray< Type >::size().

template<typename Type> valarray< Type > std::valarray< Type >::operator[] (const valarray< bool > &) const [inline]

Return an array subset.

Returns a new valarray containing the elements of the array indicated by the argument. The input is a valarray of bool which represents a bitmask indicating which elements should be copied into the new valarray. Each element of the array is added to the return valarray if the corresponding element of the argument is true.

Parameters: m The valarray bitmask.

Returns: New valarray containing elements indicated by m.

Definition at line 737 of file valarray.

References std::valarray< Type >::size().

template<typename Type> gslice_array< Type > std::valarray< Type >::operator[] (const gslice &) [inline]

Return a reference to an array subset.

Returns a new valarray containing the elements of the array indicated by the gslice argument. The new valarray is the size of the input gslice.

See also: gslice.

Parameters: s The source gslice.

Returns: New valarray containing elements in s.

Definition at line 729 of file valarray.

template<typename Type> Expr< GClos< ValArray, Type >, Type > std::valarray< Type >::operator[] (const gslice &) const [inline]

Return an array subset.

Returns a slice_array referencing the elements of the array indicated by the slice argument.

See also: gslice.

Parameters: s The source slice.

Returns: Slice_array referencing elements indicated by s.

Definition at line 720 of file valarray.

template<typename Type> slice_array< Type > std::valarray< Type >::operator[] (slice) [inline]

Return a reference to an array subset.

Returns a new valarray containing the elements of the array indicated by the slice argument. The new valarray is the size of the input slice.

See also: slice.

Parameters: s The source slice.

Returns: New valarray containing elements in s.

Definition at line 713 of file valarray.

template<typename Type> Expr< SClos< ValArray, Type >, Type > std::valarray< Type >::operator[] (slice) const [inline]

Return an array subset.

Returns a new valarray containing the elements of the array indicated by the slice argument. The new valarray is the size of the input slice.

See also: slice.

Parameters: s The source slice.

Returns: New valarray containing elements in s.

Definition at line 705 of file valarray.

template<typename Type> Type & std::valarray< Type >::operator[] (size_t) [inline]

Return a reference to the i'th array element.

Parameters: i Index of element to return.

Returns: Reference to the i'th element.

Definition at line 536 of file valarray.

template<class Type> valarray<Type>& std::valarray< Type >::operator^= (const valarray< Type > &)

Logical xor corresponding elements of v with elements of array.

template<class Type> valarray<Type>& std::valarray< Type >::operator^= (const Type &)

Set each element e of array to e ^ t.

template<class Type> valarray<Type>& std::valarray< Type >::operator|= (const valarray< Type > &)

Logical or corresponding elements of v with elements of array.

template<class Type> valarray<Type>& std::valarray< Type >::operator|= (const Type &)

Set each element e of array to e | t.

template<class Type> UnaryOp<__bitwise_not>::Rt std::valarray< Type >::operator~ () const

Return a new valarray by applying unary ~ to each element.

template<class Type> void std::valarray< Type >::resize (size_t size, Type c = Type()) [inline]

Resize array.

Resize this array to be size and set all elements to c. All references and iterators are invalidated.

Parameters: size New array size.

c New value for all elements.

Definition at line 845 of file valarray.

References std::__valarray_destroy_elements(), std::__valarray_fill_construct(), and std::__valarray_release_memory().

template<class Type> valarray< Type > std::valarray< Type >::shift (int) const [inline]

Return a shifted array.

A new valarray is constructed as a copy of this array with elements in shifted positions. For an element with index i, the new position is i - n. The new valarray is the same size as the current one. New elements without a value are set to 0. Elements whos new position is outside the bounds of the array are discarded.

Positive arguments shift toward index 0, discarding elements [0, n). Negative arguments discard elements from the top of the array.

Parameters: n Number of element positions to shift.

Returns: New valarray with elements in shifted positions.

Definition at line 796 of file valarray.

References std::__valarray_copy_construct(), and std::__valarray_default_construct().

template<class Type> size_t std::valarray< Type >::size () const [inline]

Return the number of elements in array.

Definition at line 776 of file valarray.

Referenced by std::__gslice_to_index(), std::__valarray_product(), and std::valarray< Type >::operator[]().

template<class Type> Type std::valarray< Type >::sum () const [inline]

Return the sum of all elements in the array.

Accumulates the sum of all elements into a Tp using +=. The order of adding the elements is unspecified.

Definition at line 781 of file valarray.

References std::__valarray_sum().

Author

Generated automatically by Doxygen for libstdc++-v3 Source from the source code.