std::exp<div class="t-tr-text">(性病:: valarray的)<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">原文:</div><div class="t-tr-dropdown-orig">(std::valarray)</div><div class="t-tr-dropdown-notes">这段文字是通过 [http://translate.google.com Google Translate] 自动翻译生成的。<br/>您可以帮助我们检查、纠正翻译中的错误。详情请点击[http://en.cppreference.com/w/Cppreference:MachineTranslations 这里]。</div></div></div></div></div>
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <valarray> 中定义
|
||
template< class T > valarray<T> exp( const valarray<T>& va ); |
||
对于中的每个元素
va
计算 E提高的功率相等的元素的值.原文:
For each element in
va
computes e raised to the power equal to the value of the element.目录 |
[编辑] 参数
va | - | 值的数组的操作
原文: value array to apply the operation to |
[编辑] 返回值
值数组,包含“E”提出
va
中的值.原文:
Value array containing e raised by the values in
va
.[编辑] 注释
碎末功能(exp)是用来执行计算。如果这种功能是不可用的,std::exp由于参数依赖查找.
原文:
Unqualified function (exp) is used to perform the computation. If such function is not available, std::exp is used due to argument dependent lookup.
该功能可以实现从std::valarray不同的返回类型。在这种情况下,替换类型具有以下属性:
原文:
The function can be implemented with the return type different from std::valarray. In this case, the replacement type has the following properties:
- const提供的所有std::valarray成员函数.原文:All const member functions of std::valarray are provided.
- std::valarray,std::slice_array,std::gslice_array,std::mask_array和std::indirect_array可以由更换型.原文:std::valarray, std::slice_array, std::gslice_array, std::mask_array and std::indirect_array can be constructed from the replacement type.
- 所有的函数接受一个参数的类型const std::valarray&也应接受替换类型.原文:All functions accepting a arguments of type const std::valarray& should also accept the replacement type.
- 接受两个参数的类型const std::valarray&应该接受所有的功能const std::valarray&的每个组合和置换型.原文:All functions accepting two arguments of type const std::valarray& should accept every combination of const std::valarray& and the replacement type.
-
[编辑] 可能的实现
template< class T > valarray<T> exp( const valarray<T>& va ) { valarray<T> other = va; for (T &i : other) { i = exp(i); } return other; // proxy object may be returned } |
[编辑] 示例
这个例子演示了欧拉等式eiπ
= -1及相关指数.
= -1及相关指数.
原文:
This example demonstrates the Euler's identity eiπ
= -1 and the related exponents.
= -1 and the related exponents.
#include <iostream> #include <complex> #include <valarray> int main() { const double pi = std::acos(-1); std::valarray<std::complex<double>> v = { {0, 0}, {0, pi/2}, {0, pi}, {0, 3*pi/2}, {0, 2*pi} }; std::valarray<std::complex<double>> v2 = std::exp(v); for(auto n : v2) { std::cout << std::fixed << n << '\n'; } }
输出:
(1.000000,0.000000) (0.000000,1.000000) (-1.000000,0.000000) (-0.000000,-1.000000) (1.000000,-0.000000)
[编辑] 另请参阅
返回“E”提出的功率(ex) 原文: returns e raised to the given power (ex) (函数) | |
complex base e exponential (函数模板) |