cargf, carg, cargl
来自 cppreference.cn
定义于头文件 <complex.h> |
||
float cargf( float complex z ); |
(1) | (since C99) |
double carg( double complex z ); |
(2) | (since C99) |
long double cargl( long double complex z ); |
(3) | (since C99) |
定义于头文件 <tgmath.h> |
||
#define carg( z ) |
(4) | (since 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 Type-generic math <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 Type-generic math <tgmath.h> (p: 335-337)
- G.7 Type-generic math <tgmath.h> (p: 480)
[编辑] 参见
(C99)(C99)(C99) |
计算复数的模 (函数) |
(C99)(C99) |
计算反正切,使用符号确定象限 (函数) |
C++ 文档 关于 arg
|