C
数值 | Numerics

conjf

conjf, conj, conjl

在头文件中定义
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 complexlong double imaginarylong doubleconjl被调用。如果z有类型float complexfloat imaginary或者floatconjf被调用。如果z有类型double complexdouble imaginarydouble,或任何整数类型,conj被调用。

参数

z-复杂的论点

返回值

复共轭的z

笔记

在不实施C99实现I作为_Imaginary_Iconj可以使用具有负零虚数部分,以获得复数。在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):