?
本文檔使用 php中文網(wǎng)手冊(cè) 發(fā)布
在頭文件<math.h>中定義 | ||
---|---|---|
float complex conjf( float complex z ); | (1) | (since C99) |
double complex conj( double complex z ); | (2) | (since C99) |
long double complex conjl( long double complex z ); | (3) | (since C99) |
Defined in header <tgmath.h> | ||
#define conj( z ) | (4) | (since C99) |
1-3)計(jì)算復(fù)共軛的z
通過(guò)反轉(zhuǎn)虛部的符號(hào)。
4)式泛型宏:如果z
具有類(lèi)型long
double
complex
,long
double
imaginary
或long double
,conjl
被調(diào)用。如果z
有類(lèi)型float
complex
,float
imaginary
或者float
,conjf
被調(diào)用。如果z
有類(lèi)型double
complex
,double
imaginary
,double
,或任何整數(shù)類(lèi)型,conj
被調(diào)用。
z | - | 復(fù)雜的論點(diǎn) |
---|
復(fù)共軛的z
。
在不實(shí)施C99實(shí)現(xiàn)I
作為_Imaginary_I
,conj
可以使用具有負(fù)零虛數(shù)部分,以獲得復(fù)數(shù)。在C11中,宏CMPLX
被用于該目的。
#include <stdio.h>#include <complex.h> int main(void){ double complex z = 1.0 + 2.0*I; double complex z2 = conj(z); printf("The conjugate of %.1f%+.1fi is %.1f%+.1fi\n", creal(z), cimag(z), creal(z2), cimag(z2)); printf("Their product is %.1f%+.1fi\n", creal(z*z2), cimag(z*z2));}
輸出:
The conjugate of 1.0+2.0i is 1.0-2.0i Their product is 5.0+0.0i
C11 standard (ISO/IEC 9899:2011):
7.3.9.4 The conj functions (p: 198)
7.25 Type-generic math <tgmath.h> (p: 373-375)
G.7 Type-generic math <tgmath.h> (p: 545)
C99 standard (ISO/IEC 9899:1999):
7.3.9.3 The conj functions (p: 179)
7.22 Type-generic math <tgmath.h> (p: 335-337)
G.7 Type-generic math <tgmath.h> (p: 480)