close
名前空間
変種

cimagf, cimag, cimagl

提供: cppreference.com
<tbody> </tbody>
ヘッダ <complex.h> で定義
float cimagf( float complex z );
(1) (C99以上)
double cimag( double complex z );
(2) (C99以上)
long double cimagl( long double complex z );
(3) (C99以上)
ヘッダ <tgmath.h> で定義
#define cimag( z )
(4) (C99以上)
1-3) z の虚部を返します。
4) 型総称マクロ。 zlong double complexlong double imaginary または long double 型であれば、 cimagl が呼ばれます。 zfloat complexfloat imaginary または float 型であれば、 cimagf が呼ばれます。 zdouble complexdouble imaginarydouble または任意の整数型であれば、 cimag が呼ばれます。

引数

z - 複素数の引数

戻り値

z の虚部。

この関数はすべての有り得る入力に対して完全に規定されており、 math_errhandling に記載されているいかなるエラーの対象でもありません。

ノート

任意の複素数の変数 z について、 z == creal(z) + I*cimag(z) が成り立ちます。

#include <stdio.h>
#include <complex.h>

int main(void)
{    
    double complex z = 1.0 + 2.0*I;
    printf("%f%+fi\n", creal(z), cimag(z));
}

出力:

1.000000+2.000000i

参考文献

  • C11 standard (ISO/IEC 9899:2011):
  • 7.3.9.2 The cimag functions (p: 197)
  • 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.2 The cimag functions (p: 178-179)
  • 7.22 Type-generic math <tgmath.h> (p: 335-337)
  • G.7 Type-generic math <tgmath.h> (p: 480)

関連項目

(C99)(C99)(C99)
複素数の実部を計算します
(関数) [edit]