std::pow(std::valarray)
| Defined in header <valarray> | ||
|---|---|---|
| template< class T > std::valarray<T> pow( const std::valarray<T>& base, const std::valarray<T>& exp ); | (1) | |
| template< class T > 
std::valarray<T> pow( const std::valarray<T>& base, 
                      const typename std::valarray<T>::value_type& vexp ); | (2) | |
| template< class T > 
std::valarray<T> pow( const typename std::valarray<T>::value_type& vbase,
                      const std::valarray<T>& exp ); | (3) | 
Raises a value to a power.
1) Computes the values of each element in the numeric array 
 base raised to the power specified by the corresponding element from the numeric array exp.The behavior is undefined if base.size() != exp.size().
2) Computes the values of each element in the numeric array 
 base raised to the power vexp.
3) Computes the values of 
 vbase raised to the power defined by the elements in the numeric array exp.Parameters
| base | - | numeric array containing the values of the base | 
| exp | - | numeric array containing the values of the exponent | 
| vbase | - | a value defining the base | 
| vexp | - | a value defining the exponent | 
Return value
A numeric array containing the results of exponentiation.
Notes
Unqualified function (pow) is used to perform the computation. If such function is not available, std::pow is used due to argument dependent lookup.
The function can be implemented with the return type different from std::valarray. In this case, the replacement type has the following properties:
-  All constmember functions ofstd::valarrayare provided.
-  std::valarray,std::slice_array,std::gslice_array,std::mask_arrayandstd::indirect_arraycan be constructed from the replacement type.
-  All functions accepting an argument of type const std::valarray&exceptbegin()andend()(since C++11) should also accept the replacement type.
-  All functions accepting two arguments of type const std::valarray&should accept every combination ofconst std::valarray&and the replacement type.
- The return type does not add more than two levels of template nesting over the most deeply-nested argument type.
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 | Tis deduced from both the scalar and thevalarrayfor (2-3), disallowing mixed-type calls | only deduce Tfrom thevalarray | 
Example
See also
| applies the function std::sqrtto each element of valarray(function template) | |
| (C++11)(C++11) | raises a number to the given power (xy) (function) | 
| complex power, one or both arguments may be a complex number (function template) | 
    © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
    http://en.cppreference.com/w/cpp/numeric/valarray/pow