conjf, conj, conjl
来自cppreference.com
| 在标头 <complex.h> 定义
|
||
| |
(1) | (C99 起) |
| |
(2) | (C99 起) |
| |
(3) | (C99 起) |
| 在标头 <tgmath.h> 定义
|
||
| |
(4) | (C99 起) |
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 的共轭复数。
注意
在不把 I 实现为 _Imaginary_I 的 C99 实现上,可用 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 The conj functions (第 198 页)
- 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.3 The conj functions (第 179 页)
- 7.22 Type-generic math <tgmath.h> (第 335-337 页)
- G.7 Type-generic math <tgmath.h> (第 480 页)
参阅
conj 的 C++ 文档
|