std::valarray< _Tp > Class Template Reference

Inheritance diagram for std::valarray< _Tp >:

Inheritance graph
List of all members.

Detailed Description

template<class _Tp>
class std::valarray< _Tp >

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 108 of file valarray.

Public Types

Public Member Functions

Friends


Constructor & Destructor Documentation

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

Construct an empty array.

Definition at line 550 of file valarray.

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

Construct an array with n elements.

Definition at line 554 of file valarray.

References std::__valarray_default_construct().

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

Construct an array with n elements initialized to t.

Definition at line 560 of file valarray.

References std::__valarray_fill_construct().

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

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

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

Copy constructor.

Definition at line 575 of file valarray.

References std::__valarray_copy_construct(), and std::valarray< _Tp >::_M_data.

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

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

Definition at line 582 of file valarray.

References std::__valarray_copy_construct(), std::slice_array< _Tp >::_M_array, std::slice_array< _Tp >::_M_stride, and std::slice_array< _Tp >::_M_sz.

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

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

Definition at line 591 of file valarray.

References std::__valarray_copy_construct(), std::gslice_array< _Tp >::_M_array, and std::gslice_array< _Tp >::_M_index.

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

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

Definition at line 602 of file valarray.

References std::__valarray_copy_construct(), std::mask_array< _Tp >::_M_array, and std::mask_array< _Tp >::_M_mask.

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

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

Definition at line 611 of file valarray.

References std::__valarray_copy_construct(), std::indirect_array< _Tp >::_M_array, and std::indirect_array< _Tp >::_M_index.


Member Function Documentation

template<class _Tp>
_Expr< _RefFunClos< _ValArray, _Tp >, _Tp > std::valarray< _Tp >::apply ( _Tp   func(const _Tp &)  )  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 has 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 905 of file valarray.

template<class _Tp>
_Expr< _ValFunClos< _ValArray, _Tp >, _Tp > std::valarray< _Tp >::apply ( _Tp   func(_Tp)  )  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 has the same size as this one.

Parameters:
func Function of Tp returning Tp to apply.
Returns:
New valarray with transformed elements.

Definition at line 897 of file valarray.

template<class _Tp>
valarray< _Tp > std::valarray< _Tp >::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 has 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 823 of file valarray.

References std::__valarray_copy_construct(), std::valarray< _Tp >::_M_data, std::valarray< _Tp >::_M_size, and __gnu_cxx::int.

Referenced by std::_Expr< _Clos, _Tp >::cshift().

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

Return the maximum element using operator<().

Definition at line 889 of file valarray.

References _GLIBCXX_DEBUG_ASSERT.

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

Return the minimum element using operator<().

Definition at line 881 of file valarray.

References _GLIBCXX_DEBUG_ASSERT.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator &= ( const valarray< _Tp > &   )  [inline]

Logical and corresponding elements of v with elements of array.

Definition at line 953 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator &= ( const _Tp &   )  [inline]

Set each element e of array to e & t.

Definition at line 953 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator *= ( const valarray< _Tp > &   )  [inline]

Multiply elements of array by corresponding elements of v.

Definition at line 949 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator *= ( const _Tp &   )  [inline]

Multiply each element of array by t.

Definition at line 949 of file valarray.

template<typename _Tp>
valarray< _Tp >::template _UnaryOp< __logical_not >::_Rt std::valarray< _Tp >::operator! (  )  const [inline]

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

Definition at line 924 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator%= ( const valarray< _Tp > &   )  [inline]

Modulo elements of array by corresponding elements of v.

Definition at line 951 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator%= ( const _Tp &   )  [inline]

Set each element e of array to e % t.

Definition at line 951 of file valarray.

template<typename _Tp>
valarray< _Tp >::template _UnaryOp< __unary_plus >::_Rt std::valarray< _Tp >::operator+ (  )  const [inline]

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

Definition at line 921 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator+= ( const valarray< _Tp > &   )  [inline]

Add corresponding elements of v to elements of array.

Definition at line 947 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator+= ( const _Tp &   )  [inline]

Add t to each element of array.

Definition at line 947 of file valarray.

template<typename _Tp>
valarray< _Tp >::template _UnaryOp< __negate >::_Rt std::valarray< _Tp >::operator- (  )  const [inline]

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

Definition at line 922 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator-= ( const valarray< _Tp > &   )  [inline]

Subtract corresponding elements of v from elements of array.

Definition at line 948 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator-= ( const _Tp &   )  [inline]

Subtract t to each element of array.

Definition at line 948 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator/= ( const valarray< _Tp > &   )  [inline]

Divide elements of array by corresponding elements of v.

Definition at line 950 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator/= ( const _Tp &   )  [inline]

Divide each element of array by t.

Definition at line 950 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator<<= ( const valarray< _Tp > &   )  [inline]

Left shift elements of array by corresponding elements of v.

Definition at line 955 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator<<= ( const _Tp &   )  [inline]

Left shift each element e of array by t bits.

Definition at line 955 of file valarray.

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

Assign elements to an array subset.

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

Parameters:
ia Array slice to get values from.

Definition at line 681 of file valarray.

References std::__valarray_copy(), _GLIBCXX_DEBUG_ASSERT, std::indirect_array< _Tp >::_M_array, std::indirect_array< _Tp >::_M_index, and std::indirect_array< _Tp >::_M_sz.

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

Assign elements to an array subset.

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

Parameters:
ma Array slice to get values from.

Definition at line 671 of file valarray.

References std::__valarray_copy(), _GLIBCXX_DEBUG_ASSERT, std::mask_array< _Tp >::_M_array, std::mask_array< _Tp >::_M_mask, and std::mask_array< _Tp >::_M_sz.

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

Assign elements to an array subset.

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

Parameters:
ga Array slice to get values from.

Definition at line 661 of file valarray.

References std::__valarray_copy(), _GLIBCXX_DEBUG_ASSERT, std::gslice_array< _Tp >::_M_array, std::gslice_array< _Tp >::_M_index, and std::valarray< _Tp >::size().

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

Assign elements to an array subset.

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

Parameters:
sa Array slice to get values from.

Definition at line 651 of file valarray.

References std::__valarray_copy(), _GLIBCXX_DEBUG_ASSERT, std::slice_array< _Tp >::_M_array, std::slice_array< _Tp >::_M_stride, and std::slice_array< _Tp >::_M_sz.

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

Assign elements to a value.

Assign all elements of array to t.

Parameters:
t Value for elements.

Definition at line 643 of file valarray.

References std::__valarray_fill().

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

Assign elements to an array.

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

Parameters:
v Valarray to get values from.

Definition at line 634 of file valarray.

References std::__valarray_copy(), _GLIBCXX_DEBUG_ASSERT, std::valarray< _Tp >::_M_data, and std::valarray< _Tp >::_M_size.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator>>= ( const valarray< _Tp > &   )  [inline]

Right shift elements of array by corresponding elements of v.

Definition at line 956 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator>>= ( const _Tp &   )  [inline]

Right shift each element e of array by t bits.

Definition at line 956 of file valarray.

template<typename _Tp>
indirect_array< _Tp > std::valarray< _Tp >::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 761 of file valarray.

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

template<typename _Tp>
_Expr< _IClos< _ValArray, _Tp >, _Tp > std::valarray< _Tp >::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 753 of file valarray.

template<typename _Tp>
mask_array< _Tp > std::valarray< _Tp >::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 742 of file valarray.

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

template<typename _Tp>
valarray< _Tp > std::valarray< _Tp >::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 730 of file valarray.

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

template<typename _Tp>
gslice_array< _Tp > std::valarray< _Tp >::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 has the same size as the input gslice.

See also:
gslice.
Parameters:
s The source gslice.
Returns:
New valarray containing elements in s.

Definition at line 722 of file valarray.

References std::gslice::_M_index.

template<typename _Tp>
_Expr< _GClos< _ValArray, _Tp >, _Tp > std::valarray< _Tp >::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 713 of file valarray.

References std::gslice::_M_index.

template<typename _Tp>
slice_array< _Tp > std::valarray< _Tp >::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 has the same size as the input slice.

See also:
slice.
Parameters:
s The source slice.
Returns:
New valarray containing elements in s.

Definition at line 708 of file valarray.

template<typename _Tp>
_Expr< _SClos< _ValArray, _Tp >, _Tp > std::valarray< _Tp >::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 has the same size as the input slice.

See also:
slice.
Parameters:
s The source slice.
Returns:
New valarray containing elements in s.

Definition at line 700 of file valarray.

template<typename _Tp>
_Tp & std::valarray< _Tp >::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 531 of file valarray.

References __glibcxx_requires_subscript.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator^= ( const valarray< _Tp > &   )  [inline]

Logical xor corresponding elements of v with elements of array.

Definition at line 952 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator^= ( const _Tp &   )  [inline]

Set each element e of array to e ^ t.

Definition at line 952 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator|= ( const valarray< _Tp > &   )  [inline]

Logical or corresponding elements of v with elements of array.

Definition at line 954 of file valarray.

template<class _Tp>
valarray< _Tp > & std::valarray< _Tp >::operator|= ( const _Tp &   )  [inline]

Set each element e of array to e | t.

Definition at line 954 of file valarray.

template<typename _Tp>
valarray< _Tp >::template _UnaryOp< __bitwise_not >::_Rt std::valarray< _Tp >::operator~ (  )  const [inline]

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

Definition at line 923 of file valarray.

template<class _Tp>
void std::valarray< _Tp >::resize ( size_t  __size,
_Tp  __c = _Tp() 
) [inline]

Resize array.

Resize this array to 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 864 of file valarray.

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

template<class _Tp>
valarray< _Tp > std::valarray< _Tp >::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 has the same size as the current one. New elements without a value are set to 0. Elements whose 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 782 of file valarray.

References std::__valarray_copy_construct(), std::__valarray_default_construct(), std::valarray< _Tp >::_M_data, std::valarray< _Tp >::_M_size, and __gnu_cxx::int.

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

Return the number of elements in array.

Definition at line 769 of file valarray.

Referenced by std::valarray< _Tp >::operator=(), std::gslice_array< _Tp >::operator=(), and std::valarray< _Tp >::operator[]().

template<class _Tp>
_Tp std::valarray< _Tp >::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 774 of file valarray.

References std::__valarray_sum(), and _GLIBCXX_DEBUG_ASSERT.


The documentation for this class was generated from the following file:
Generated on Wed Mar 26 00:44:52 2008 for libstdc++ by  doxygen 1.5.1