cargf, carg, cargl

来自cppreference.com
< c‎ | numeric‎ | complex
在标头 <complex.h> 定义
float       cargf(floatcomplex z );
(1) (C99 起)
double      carg(doublecomplex z );
(2) (C99 起)
longdouble cargl(longdoublecomplex z );
(3) (C99 起)
在标头 <tgmath.h> 定义
#define carg( z )
(4) (C99 起)
1-3) 计算 z 的辐角(又称相位角),沿负实轴切割分支。
4) 泛型宏:若 z 拥有 longdoublecomplexlongdoubleimaginarylongdouble 类型,则调用 cargl。若 z 拥有 floatcomplexfloatimaginaryfloat 类型,则调用 cargf。若 z 拥有 doublecomplexdoubleimaginarydouble 或任何整数类型,则调用 carg

目录

[编辑]参数

z - 复参数

[编辑]返回值

若不出现错误,则返回 z[−π; π] 区间中的相位角。

如同函数实现为 atan2(cimag(z), creal(z)) 一般处理错误和特殊情况。

[编辑]示例

#include <stdio.h>#include <complex.h>   int main(void){doublecomplex z1 =1.0+0.0*I;printf("phase angle of %.1f%+.1fi is %f\n", creal(z1), cimag(z1), carg(z1));   doublecomplex z2 =0.0+1.0*I;printf("phase angle of %.1f%+.1fi is %f\n", creal(z2), cimag(z2), carg(z2));   doublecomplex z3 =-1.0+0.0*I;printf("phase angle of %.1f%+.1fi is %f\n", creal(z3), cimag(z3), carg(z3));   doublecomplex z4 =conj(z3);// 或 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 (第 196 页)
  • 7.25 Type-generic math <tgmath.h> (第 373-375 页)
  • G.7 Type-generic math <tgmath.h> (第 545 页)
  • C99 标准(ISO/IEC 9899:1999):
  • 7.3.9.1 The carg functions (第 178 页)
  • 7.22 Type-generic math <tgmath.h> (第 335-337 页)
  • G.7 Type-generic math <tgmath.h> (第 480 页)

[编辑]参阅

(C99)(C99)(C99)
计算复数的模(绝对值)
(函数)[编辑]
计算反正切,以符号确定象限
(函数)[编辑]
arg 的 C++ 文档
close