cargf, carg, cargl
From cppreference.net
|
ヘッダー
<complex.h>
で定義
|
||
|
float
cargf
(
float
complex
z
)
;
|
(1) | (C99以降) |
|
double
carg
(
double
complex
z
)
;
|
(2) | (C99以降) |
|
long
double
cargl
(
long
double
complex
z
)
;
|
(3) | (C99以降) |
|
ヘッダー
<tgmath.h>
で定義
|
||
|
#define carg( z )
|
(4) | (C99以降) |
1-3)
負の実軸に沿って分岐切断を行った
z
の偏角(位相角とも呼ばれる)を計算します。
4)
型ジェネリックマクロ:
z
の型が
long
double
complex
、
long
double
imaginary
または
long
double
の場合、
cargl
が呼び出される。
z
の型が
float
complex
、
float
imaginary
または
float
の場合、
cargf
が呼び出される。
z
の型が
double
complex
、
double
imaginary
、
double
または任意の整数型の場合、
carg
が呼び出される。
目次 |
パラメータ
| z | - | 複素引数 |
戻り値
エラーが発生しない場合、区間
[−π; π]
内の
z
の位相角を返します。
エラーおよび特殊ケースは、この関数が以下のように実装されているかのように処理されます。 atan2 ( cimag ( z ) , creal ( z ) )
例
このコードを実行
#include <stdio.h> #include <complex.h> int main(void) { double complex z1 = 1.0+0.0*I; printf("phase angle of %.1f%+.1fi is %f\n", creal(z1), cimag(z1), carg(z1)); double complex z2 = 0.0+1.0*I; printf("phase angle of %.1f%+.1fi is %f\n", creal(z2), cimag(z2), carg(z2)); double complex z3 = -1.0+0.0*I; printf("phase angle of %.1f%+.1fi is %f\n", creal(z3), cimag(z3), carg(z3)); double complex z4 = conj(z3); // or CMPLX(-1, -0.0) printf("phase angle of %.1f%+.1fi (the other side of the cut) is %f\n", creal(z4), cimag(z4), carg(z4)); }
出力:
phase angle of 1.0+0.0i is 0.000000 phase angle of 0.0+1.0i is 1.570796 phase angle of -1.0+0.0i is 3.141593 phase angle of -1.0-0.0i (the other side of the cut) is -3.141593
参考文献
- C11規格 (ISO/IEC 9899:2011):
-
- 7.3.9.1 carg関数群 (p: 196)
-
- 7.25 型総称数学 <tgmath.h> (p: 373-375)
-
- G.7 型総称数学 <tgmath.h> (p: 545)
- C99規格 (ISO/IEC 9899:1999):
-
- 7.3.9.1 carg関数群 (p: 178)
-
- 7.22 型総称数学 <tgmath.h> (p: 335-337)
-
- G.7 型総称数学 <tgmath.h> (p: 480)
関連項目
|
(C99)
(C99)
(C99)
|
複素数の絶対値を計算する
(関数) |
|
(C99)
(C99)
|
符号を使用して象限を決定しながら逆正接を計算する
(関数) |
|
C++ドキュメント
for
arg
|
|