std::arg(std::complex)
提供: cppreference.com
ヘッダ <complex> で定義
|
||
template< class T > T arg( const complex<T>& z ); |
(1) | |
long double arg( long double z ); |
(2) | (C++11以上) |
template< class DoubleOrInteger > double arg( DoubleOrInteger z ); |
(3) | (C++11以上) |
float arg( float z ); |
(4) | (C++11以上) |
複素数 z
の偏角を (ラジアンで) 計算します。
float, double, long double およびすべての整数型に対する追加のオーバーロードが提供されます。 これらの型は虚部がゼロの複素数として扱われます。 |
(C++11以上) |
目次 |
[編集] 引数
z | - | 複素数の値 |
[編集] 戻り値
エラーが発生しなければ、 z
の区間 [−π; π] 内の偏角を返します。
エラーおよび特殊なケースは、この関数が std::atan2(std::imag(z), std::real(z)) として実装されているかの��うに処理されます。
[編集] 例
Run this code
#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
[編集] 関連項目
複素数の絶対値を返します (関数テンプレート) | |
絶対値と偏角から複素数を構築します (関数テンプレート) | |
(C++11)(C++11) |
象限を判断するために符号を使用して逆正接を計算します (関数) |
valarray と値に関数 std::atan2 を適用します (関数テンプレート) | |
carg の C言語リファレンス
|