cargf, carg, cargl
From cppreference.com
| ヘッダー <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 The carg functions (p: 196)
- 7.25 型総称数学関数 <tgmath.h> (p: 373-375)
- G.7 Type-generic math <tgmath.h> (p: 545)
- C99標準 (ISO/IEC 9899:1999)
- 7.3.9.1 The carg functions (p: 178)
- 7.22 型総称数学関数 <tgmath.h> (p: 335-337)
- G.7 Type-generic math <tgmath.h> (p: 480)
[編集] 関連項目
| (C99)(C99)(C99) |
複素数の絶対値を計算する (関数) |
| (C99)(C99) |
象限を決定するために符号を使用してアークタンジェントを計算する (関数) |
| C++ ドキュメント (
arg) | |