std::arg(std::complex) - cppreference.com
提供: cppreference.com
<tbody> </tbody>
| ヘッダ |
||
|
|
(1) | |
|
|
(2) | (C++11以上) |
|
|
(3) | (C++11以上) |
|
|
(4) | (C++11以上) |
複素数 z の偏角を (ラジアンで) 計算します。
|
|
(C++11以上) |
引数
戻り値
エラーが発生しなければ、 z の区間 [−π; π] 内の偏角を返します。
エラーおよび特殊なケースは、この関数が 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