| | |
template<class T>
std::valarray<T> operator+(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator-(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator*(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator/(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator%(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator&(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator|(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator^(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator<<(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator>>(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T> std::valarray<bool> operator&&(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); template<class T>
std::valarray<bool> operator||(conststd::valarray<T>& lhs,conststd::valarray<T>& rhs); | (1) | |
template<class T>
std::valarray<T> operator+(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator-(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator*(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator/(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator%(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator&(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator|(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator^(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator<<(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<T> operator>>(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<bool> operator&&(consttypenamestd::valarray<T>::value_type& val, conststd::valarray<T>& rhs); template<class T> std::valarray<bool> operator||(consttypenamestd::valarray<T>::value_type& val,
conststd::valarray<T>& rhs); | (2) | |
template<class T>
std::valarray<T> operator+(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator-(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator*(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator/(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator%(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator&(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator|(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator^(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator<<(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<T> operator>>(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<bool> operator&&(conststd::valarray<T>& lhs, consttypenamestd::valarray<T>::value_type& val); template<class T> std::valarray<bool> operator||(conststd::valarray<T>& lhs,
consttypenamestd::valarray<T>::value_type& val); | (3) | |
| | |
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 a valarray 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.
[edit]Parameters
rhs | - | a numeric array |
lhs | - | a numeric array |
val | - | a value of typeT |
[edit]Return value
A valarray with the same size as the parameter.
The behaviour is undefined when the two arguments are valarrays with different sizes.
The function can be implemented with the return type different fromstd::valarray. In this case, the replacement type has the following properties:
[edit]Example
Finds real roots of multipleQuadratic equations.
Output:
quadratic equation: root 1: root 2: b: c:1·x² + 1·x + -1 = 0 -1.618034 0.618034 1 -11·x² + 2·x + -2 = 0 -2.732051 0.732051 2 -21·x² + 3·x + -3 = 0 -3.791288 0.791288 3 -31·x² + 4·x + -4 = 0 -4.828427 0.828427 4 -41·x² + 5·x + -5 = 0 -5.854102 0.854102 5 -51·x² + 6·x + -6 = 0 -6.872983 0.872983 6 -61·x² + 7·x + -7 = 0 -7.887482 0.887482 7 -71·x² + 8·x + -8 = 0 -8.898979 0.898979 8 -8
[edit]Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|
LWG 3074 | C++98 | T is deduced from both the scalar and thevalarray for(2,3), disallowing mixed-type calls | only deduceT from thevalarray |
[edit]See also
| applies a unary arithmetic operator to each element of the valarray (public member function)[edit] |
| applies compound assignment operator to each element of the valarray (public member function)[edit] |