C参考手册
数值 | Numerics
conj
在头文件<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)计算复共轭的z通过反转虚部的符号。
4)式泛型宏:如果z具有类型long double complex,long double imaginary或long double,conjl被调用。如果z有类型float complex,float imaginary或者float,conjf被调用。如果z有类型double complex,double imaginary,double,或任何整数类型,conj被调用。
参数
z |
- |
复杂的论点 |
|---|
返回值
复共轭的z。
笔记
在不实施C99实现I作为_Imaginary_I,conj可以使用具有负零虚数部分,以获得复数。在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标准(ISO / IEC 9899:2011):
- 7.3.9.4连接函数(p:198)
- 7.25类型通用数学<tgmath.h>(p:373-375)
- G.7类型 - 通用数学<tgmath.h>(p:545)
- C99标准(ISO / IEC 9899:1999):
- 7.3.9.3连接函数(p:179)
- 7.22类型通用数学<tgmath.h>(p:335-337)
- G.7类型 - 通用数学<tgmath.h>(p:480)
加载中,请稍侯......