clogf, clog, clogl
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <complex.h> で定義
|
||
float complex clogf( float complex z ); |
(1) | (C99以上) |
double complex clog( double complex z ); |
(2) | (C99以上) |
long double complex clogl( long double complex z ); |
(3) | (C99以上) |
| ヘッダ <tgmath.h> で定義
|
||
#define log( z ) |
(4) | (C99以上) |
1-3) 負の実軸に沿った分岐切断を持つ、 (e を底とする)
z の複素自然対数を計算します。4) 型総称マクロ。
z が long double complex の場合は clogl が呼ばれ、 z が double complex 型の場合は clog が呼ばれ、 z が float complex 型の場合は clogf が呼ばれます。 z が実数または整数の場合は、このマクロは対応する実数の関数 (logf、 log、 logl) を呼びます。 z が虚数の場合は、対応する複素数版が呼ばれます。引数
| z | - | 複素数の引数 |
戻り値
エラーが発生しなければ、 z の複素自然対数が返されます。 戻り値は実部が数学的に非有界で虚部が区間 [−iπ, +iπ] 内の帯状の範囲内になります。
エラー処理および特殊な値
エラーは math_errhandling と一貫性があるように報告されます。
処理系が IEEE 浮動小数点算術をサポートしている場合、
- この関数は虚部の符号を考慮すれば分岐切断上で連続的です。
clog(conj(z)) == conj(clog(z))です。zが-0+0iであれば、結果は-∞+πiであり、 FE_DIVBYZERO が発生します。zが+0+0iであれば、結果は-∞+0iであり、 FE_DIVBYZERO が発生します。zがx+∞i(ただし x は任意の有限な値) であれば、結果は+∞+πi/2です。zがx+NaNi(ただし x は任意の有限な値) であれば、結果はNaN+NaNiであり、 FE_INVALID が発生するかもしれません。zが-∞+yi(ただし y は任意の有限な正の値) であれば、結果は+∞+πiです。zが+∞+yi(ただし y は任意の有限な正の値) であれば、結果は+∞+0iです。zが-∞+∞iであれば、結果は+∞+3πi/4です。zが+∞+∞iであれば、結果は+∞+πi/4です。zが±∞+NaNiであれば、結果は+∞+NaNiです。zがNaN+yi(ただし y は任意の有限な値) であれば、結果はNaN+NaNiであり、 FE_INVALID が発生するかもしれません。zがNaN+∞iであれば、結果は+∞+NaNiです。zがNaN+NaNiであれば、結果はNaN+NaNiです。
ノート
極座標 (r,θ) を持つ複素数 z の自然対数は、 ln r + i(θ+2nπ) と等しくなります。 主値は ln r + iθ です。
例
Run this code
#include <stdio.h>
#include <math.h>
#include <complex.h>
int main(void)
{
double complex z = clog(I); // r = 1, θ = pi/2
printf("2*log(i) = %.1f%+fi\n", creal(2*z), cimag(2*z));
double complex z2 = clog(sqrt(2)/2 + sqrt(2)/2*I); // r = 1, θ = pi/4
printf("4*log(sqrt(2)/2+sqrt(2)i/2) = %.1f%+fi\n", creal(4*z2), cimag(4*z2));
double complex z3 = clog(-1); // r = 1, θ = pi
printf("log(-1+0i) = %.1f%+fi\n", creal(z3), cimag(z3));
double complex z4 = clog(conj(-1)); // or clog(CMPLX(-1, -0.0)) in C11
printf("log(-1-0i) (the other side of the cut) = %.1f%+fi\n", creal(z4), cimag(z4));
}
出力:
2*log(i) = 0.0+3.141593i
4*log(sqrt(2)/2+sqrt(2)i/2) = 0.0+3.141593i
log(-1+0i) = 0.0+3.141593i
log(-1-0i) (the other side of the cut) = 0.0-3.141593i
参考文献
- C11 standard (ISO/IEC 9899:2011):
- 7.3.7.2 The clog functions (p: 195)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- G.6.3.2 The clog functions (p: 543-544)
- G.7 Type-generic math <tgmath.h> (p: 545)
- C99 standard (ISO/IEC 9899:1999):
- 7.3.7.2 The clog functions (p: 176-177)
- 7.22 Type-generic math <tgmath.h> (p: 335-337)
- G.6.3.2 The clog functions (p: 478-479)
- G.7 Type-generic math <tgmath.h> (p: 480)
関連項目
(C99)(C99)(C99) |
eを底とする複素指数関数を計算します (関数) |
(C99)(C99) |
自然対数 (ln(x)) を計算します (関数) |
log の C++リファレンス
| |