名前空間
変種
操作

conjf, conj, conjl

提供: cppreference.com
< c‎ | numeric‎ | complex
ヘッダ <complex.h> で定義
floatcomplex       conjf(floatcomplex z );
(1) (C99以上)
doublecomplex      conj(doublecomplex z );
(2) (C99以上)
longdoublecomplex conjl(longdoublecomplex z );
(3) (C99以上)
ヘッダ <tgmath.h> で定義
#define conj( z )
(4) (C99以上)
1-3) 虚部の符号を反転することによって、 z複素共役を計算します。
4) 型総称マクロ。 zlongdoublecomplexlongdoubleimaginary または longdouble の場合は conjl が呼ばれます。 zfloatcomplexfloatimaginary または float の場合は conjf が呼ばれます。 zdoublecomplexdoubleimaginarydouble または任意の整数型の場合は conj が呼ばれます。

目次

[編集]引数

z - 複素数の引数

[編集]戻り値

z の複素共役。

[編集]ノート

I_Imaginary_I として実装しない C99 処理系では、負のゼロを虚部に持つ複素数を取得するために conj が使用されることがあります。 C11 ではマクロ CMPLX がこの目的に使用されます。

[編集]

#include <stdio.h>#include <complex.h>   int main(void){doublecomplex z =1.0+2.0*I;doublecomplex 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)

[編集]関連項目

close