名前空間
変種
操作

csqrtf, csqrt, csqrtl

提供: cppreference.com
< c‎ | numeric‎ | complex
ヘッダ <complex.h> で定義
floatcomplex       csqrtf(floatcomplex z );
(1) (C99以上)
doublecomplex      csqrt(doublecomplex z );
(2) (C99以上)
longdoublecomplex csqrtl(longdoublecomplex z );
(3) (C99以上)
ヘッダ <tgmath.h> で定義
#define sqrt( z )
(4) (C99以上)
1-3) 負の実軸に沿った分岐切断を持つ、 z の複素平方根を計算します。
4) 型総称マクロ。 zlongdoublecomplex の場合は csqrtl が呼ばれ、 zdoublecomplex 型の場合は csqrt が呼ばれ、 zfloatcomplex 型の場合は csqrtf が呼ばれます。 z が実数または整数の場合、このマクロは対応する実数の関数 (sqrtfsqrtsqrtl) を呼びます。 z が虚数の場合は、対応する複素数版が呼ばれます。

目次

[編集]引数

z - 複素数の引数

[編集]戻り値

エラーが発生しなければ、 z の平方根を返します。 戻り値は虚軸を含む右半平面 (実部が [0; +∞) で虚部が (−∞; +∞)) の範囲内になります。

[編集]エラー処理および特殊な値

エラーは math_errhandling と一貫性があるように報告されます。

処理系が IEEE 浮動小数点算術をサポートしている場合、

  • この関数は虚部の符号を考慮すれば分岐切断上で連続的です。
  • csqrt(conj(z))==conj(csqrt(z)) です。
  • z±0+0i であれば、結果は +0+0i です。
  • zx+∞i (x が NaN の場合も含む) であれば、結果は +∞+∞i です。
  • zx+NaNi (x が ±∞ の場合は除く) であれば、結果は NaN+NaNi であり、 FE_INVALID が発生するかもしれません。
  • z-∞+yi (ただし y は有限な正の値) であれば、結果は +0+∞i です。
  • z+∞+yi (ただし y は有限な正の値) であれば、結果は +∞+0i) です。
  • z-∞+NaNi であれば、結果は NaN±∞i (虚部の符号は未規定) です。
  • z+∞+NaNi であれば、結果は +∞+NaNi です。
  • zNaN+yi であれば、結果は NaN+NaNi であり、 FE_INVALID が発生するかもしれません。
  • zNaN+NaNi であれば、結果は NaN+NaNi です。

[編集]

#include <stdio.h>#include <complex.h>   int main(void){doublecomplex z1 = csqrt(-4);printf("Square root of -4 is %.1f%+.1fi\n", creal(z1), cimag(z1));   doublecomplex z2 = csqrt(conj(-4));// or, in C11, CMPLX(-4, -0.0)printf("Square root of -4-0i, the other side of the cut, is ""%.1f%+.1fi\n", creal(z2), cimag(z2));}

出力:

Square root of -4 is 0.0+2.0i Square root of -4-0i, the other side of the cut, is 0.0-2.0i

[編集]参考文献

  • C11 standard (ISO/IEC 9899:2011):
  • 7.3.8.3 The csqrt functions (p: 196)
  • 7.25 Type-generic math <tgmath.h> (p: 373-375)
  • G.6.4.2 The csqrt functions (p: 544)
  • G.7 Type-generic math <tgmath.h> (p: 545)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.3.8.3 The csqrt functions (p: 178)
  • 7.22 Type-generic math <tgmath.h> (p: 335-337)
  • G.6.4.2 The csqrt functions (p: 479)
  • G.7 Type-generic math <tgmath.h> (p: 480)

[編集]関連項目

(C99)(C99)(C99)
複素冪関数を計算します
(関数)[edit]
(C99)(C99)
平方根 (x) を計算します
(関数)[edit]
close