std::arg(std::complex)
STD::Arg%28 std::Complex%29
Defined in header | | |
---|---|---|
template< class T > T arg( const complex<T>& z | (1) | |
long double arg( long double z | (2) | (since C++11) |
template< class DoubleOrInteger > double arg( DoubleOrInteger z | (3) | (since C++11) |
float arg( float z | (4) | (since C++11) |
计算复数的相位角%28 in半径%29z
...
%28,因为C++11%提供了29附加过载float
,,,double
,,,long double
,以及所有整数类型,它们被视为零虚分量的复数。
参数
z | - | complex value |
---|
返回值
如果没有出现错误,则返回z
在区间为%28-π;π%为29。
错误和特殊情况的处理方式就像函数是按照std::atan2
(std::imag(z), std::real(z))
...
例
二次
#include <iostream>
#include <complex>
int main()
{
std::complex<double> z1(1, 0
std::cout << "phase angle of " << z1 << " is " << std::arg(z1) << '\n';
std::complex<double> z2(0, 1
std::cout << "phase angle of " << z2 << " is " << std::arg(z2) << '\n';
std::complex<double> z3(-1, 0
std::cout << "phase angle of " << z3 << " is " << std::arg(z3) << '\n';
std::complex<double> z4(-1, -0.0
std::cout << "phase angle of " << z4 << " (the other side of the cut) is "
<< std::arg(z4) << '\n';
}
二次
产出:
二次
phase angle of (1,0) is 0
phase angle of (0,1) is 1.5708
phase angle of (-1,0) is 3.14159
phase angle of (-1,-0) (the other side of the cut) is -3.14159
二次
另见
abs(std::complex) | returns the magnitude of a complex number (function template) |
---|---|
polar | constructs a complex number from magnitude and phase angle (function template) |
atan2 | arc tangent, using signs to determine quadrants (function) |
atan2(std::valarray) | applies the function std::atan2 to a valarray and a value (function template) |
c Carg文件
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。