Namespaces
Variants
Views
Actions

operator+,-,*,/,%,&,|,<<,>>,^ std::valarray

From cppreference.com
< cpp‎ | numeric‎ | valarray
Revision as of 07:22, 5 December 2012 by Bazzy (Talk | contribs)

 
 
 
 

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <valarray>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td >
template <class T> std::valarray<T> operator+ (const std::valarray<T>& lhs, const std::valarray<T>& rhs);

template <class T> std::valarray<T> operator- (const std::valarray<T>& lhs, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator* (const std::valarray<T>& lhs, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator/ (const std::valarray<T>& lhs, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator% (const std::valarray<T>& lhs, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator& (const std::valarray<T>& lhs, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator| (const std::valarray<T>& lhs, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator^ (const std::valarray<T>& lhs, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator<< (const std::valarray<T>& lhs, const std::valarray<T>& rhs);

template <class T> std::valarray<T> operator>> (const std::valarray<T>& lhs, const std::valarray<T>& rhs);
</td>

<td > (1) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
template <class T> std::valarray<T> operator+ (const T& val, const std::valarray<T>& rhs);

template <class T> std::valarray<T> operator- (const T& val, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator* (const T& val, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator/ (const T& val, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator% (const T& val, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator& (const T& val, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator| (const T& val, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator^ (const T& val, const std::valarray<T>& rhs);
template <class T> std::valarray<T> operator<< (const T& val, const std::valarray<T>& rhs);

template <class T> std::valarray<T> operator>> (const T& val, const std::valarray<T>& rhs);
</td>

<td > (2) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
template <class T> std::valarray<T> operator+ (const std::valarray<T>& lhs, const T& rhs);

template <class T> std::valarray<T> operator- (const std::valarray<T>& lhs, const T& val);
template <class T> std::valarray<T> operator* (const std::valarray<T>& lhs, const T& val);
template <class T> std::valarray<T> operator/ (const std::valarray<T>& lhs, const T& val);
template <class T> std::valarray<T> operator% (const std::valarray<T>& lhs, const T& val);
template <class T> std::valarray<T> operator& (const std::valarray<T>& lhs, const T& val);
template <class T> std::valarray<T> operator| (const std::valarray<T>& lhs, const T& val);
template <class T> std::valarray<T> operator^ (const std::valarray<T>& lhs, const T& val);
template <class T> std::valarray<T> operator<< (const std::valarray<T>& lhs, const T& val);

template <class T> std::valarray<T> operator>> (const std::valarray<T>& lhs, const T& val);
</td>

<td > (3) </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

Apply binary operators to each element of two valarrays, or a valarray and a value.

1) The operators works on valarrays of the same size and returns avalarray with the same size as the parameters with the operation applied to every elements of the two arguments.
2,3) Applies the operator between each element of the valarray and the scalar.

Contents

Parameters

rhs - a numeric array
lhs - a numeric array
val - a value of type T

Return value

A valarray with the same size as the parameter.

Note

The behaviour is undefined when the two arguments are valarrays with different sizes.

The function can be implemented with the return type different from std::valarray. In this case, the replacement type has the following properties:

Example