?
This document uses PHP Chinese website manual Release
在頭文件<math.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) |
Defined in header <tgmath.h> | ||
#define carg( z ) | (4) | (since C99) |
1-3)z
用沿著負(fù)實軸的分支來計算參數(shù)(也稱為相位角)。
4)式泛型宏:如果z
具有類型long
double
complex
,long
double
imaginary
或long double
,cargl
被調(diào)用。如果z
有類型float
complex
,float
imaginary
或者float
,cargf
被調(diào)用。如果z
有類型double
complex
,double
imaginary
,double
,或任何整數(shù)類型,carg
被調(diào)用。
z | - | 復(fù)雜的論點(diǎn) |
---|
如果沒有錯誤發(fā)生,則返回z
間隔(-π;π)的相位角。
處理錯誤和特殊情況,就像該函數(shù)被實現(xiàn)為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.000000phase angle of 0.0+1.0i is 1.570796phase angle of -1.0+0.0i is 3.141593phase angle of -1.0-0.0i (the other side of the cut) is -3.141593
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.3.9.1 carg函數(shù)(p:196)
7.25類型通用數(shù)學(xué)<tgmath.h>(p:373-375)
G.7類型 - 通用數(shù)學(xué)<tgmath.h>(p:545)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.3.9.1 carg函數(shù)(p:178)
7.22類型通用數(shù)學(xué)<tgmath.h>(p:335-337)
G.7類型 - 通用數(shù)學(xué)<tgmath.h>(p:480)