std::arg(std::complex)
| 在标头 <complex> 定义
|
||
| template< class T > T arg( const std::complex<T>& z ); |
(1) | |
| 额外重载 (C++11 起) |
||
| 在标头 <complex> 定义
|
||
| (A) | ||
float arg( float f ); double arg( double f ); |
(C++23 前) | |
| template< class FloatingPoint > FloatingPoint |
(C++23 起) | |
| template< class Integer > double arg( Integer i ); |
(B) | |
|
A,B) 为所有整数和浮点类型提供额外重载,它们被处理为拥有零虚部的复数。
|
(C++11 起) |
目录 |
[编辑] 参数
| z | - | 复数值 |
| f | - | 浮点值 |
| i | - | 整数值 |
[编辑] 返回值
[编辑] 注解
额外重载不需要严格以 (A,B) 的形式提供。它们只需要能够对它们的实参 num 满足以下要求即可:
- 如果 num 具有标准(C++23 前)浮点类型
T,那么 std::arg(num) 和 std::arg(std::complex<T>(num)) 的效果相同。 - 否则,如果 num 具有整数类型,那么 std::arg(num) 和 std::arg(std::complex<double>(num)) 的效果相同。
[编辑] 示例
#include <complex> #include <iostream> int main() { std::complex<double> z1(1, 0); std::complex<double> z2(0, 0); std::complex<double> z3(0, 1); std::complex<double> z4(-1, 0); std::complex<double> z5(-1, -0.0); double f = 1.; int i = -1; std::cout << "phase angle of " << z1 << " is " << std::arg(z1) << '\n' << "phase angle of " << z2 << " is " << std::arg(z2) << '\n' << "phase angle of " << z3 << " is " << std::arg(z3) << '\n' << "phase angle of " << z4 << " is " << std::arg(z4) << '\n' << "phase angle of " << z5 << " is " << std::arg(z5) << " " "(the other side of the cut)\n" << "phase angle of " << f << " is " << std::arg(f) << '\n' << "phase angle of " << i << " is " << std::arg(i) << '\n'; }
输出:
(1,0) 的幅角是 0 (0,0) 的幅角是 0 (0,1) 的幅角是 1.5708 (-1,0) 的幅角是 3.14159 (-1,-0) 的幅角是 -3.14159(切面的另一侧) 1 的幅角是 0 -1 的幅角是 3.14159
[编辑] 参阅
| 返回复数的模 (函数模板) | |
| 从模和辐角构造复数 (函数模板) | |
| (C++11)(C++11) |
反正切,用符号确定象限 (函数) |
| 应用函数 std::atan2 到一个 valarray 和一个值 (函数模板) | |
| carg 的 C 文档
| |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
