std::log(std::complex)
提供: cppreference.com
| ヘッダ <complex> で定義
|
||
| template< class T > complex<T> log( const complex<T>& z ); |
||
負の実軸に沿って分岐切断する、複素数の値 z の (e を底とする) 複素自然対数を計算します。
目次 |
[編集] 引数
| z | - | 複素数の値 |
[編集] 戻り値
エラーが発生しなければ、 z の複素自然対数が返されます。 戻り値は実部が数学的に非有界で虚部が区間 [−iπ, +iπ] 内の帯状の範囲内です。
[編集] エラー処理と特殊な値
Errors are reported consistent with math_errhandling
If the implementation supports IEEE floating-point arithmetic,
- The function is continuous onto the branch cut taking into account the sign of imaginary part
- std::log(std::conj(z)) == std::conj(std::log(z))
- If
zis(-0,+0), the result is(-∞,π)and FE_DIVBYZERO is raised - If
zis(+0,+0), the result is(-∞,+0)and FE_DIVBYZERO is raised - If
zis(x,+∞)(for any finite x), the result is(+∞,π/2) - If
zis(x,NaN)(for any finite x), the result is(NaN,NaN)and FE_INVALID may be raised - If
zis(-∞,y)(for any finite positive y), the result is(+∞,π) - If
zis(+∞,y)(for any finite positive y), the result is(+∞,+0) - If
zis(-∞,+∞), the result is(+∞,3π/4) - If
zis(+∞,+∞), the result is(+∞,π/4) - If
zis(±∞,NaN), the result is(+∞,NaN) - If
zis(NaN,y)(for any finite y), the result is(NaN,NaN)and FE_INVALID may be raised - If
zis(NaN,+∞), the result is(+∞,NaN) - If
zis(NaN,NaN), the result is(NaN,NaN)
[編集] ノート
極座標 (r,θ) を持つ複素数 z の自然対数は、 ln r + i(θ+2nπ) と等しくなります。 主値は ln r + iθ です。
この関数の意味論は C の関数 clog と一貫性を持つことが意図されています。
[編集] 欠陥報告
以下の動作変更欠陥報告は以前に発行された C++ 標準に遡って適用されました。
| DR | 適用先 | 発行時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 2597 | C++98 | specification mishandles signed zero imaginary parts | erroneous requirement removed |
[編集] 例
Run this code
#include <iostream> #include <cmath> #include <complex> int main() { std::complex<double> z(0, 1); // // r = 1, θ = pi/2 std::cout << "2*log" << z << " = " << 2.*std::log(z) << '\n'; std::complex<double> z2(sqrt(2)/2, sqrt(2)/2); // r = 1, θ = pi/4 std::cout << "4*log" << z2 << " = " << 4.*std::log(z2) << '\n'; std::complex<double> z3(-1, 0); // r = 1, θ = pi std::cout << "log" << z3 << " = " << std::log(z3) << '\n'; std::complex<double> z4(-1, -0.0); // the other side of the cut std::cout << "log" << z4 << " (the other side of the cut) = " << std::log(z4) << '\n'; }
出力:
2*log(0,1) = (0,3.14159) 4*log(0.707107,0.707107) = (0,3.14159) log(-1,0) = (0,3.14159) log(-1,-0) (the other side of the cut) = (0,-3.14159)
[編集] 関連項目
| 負の実軸に沿って分岐切断する複素常用対数 (関数テンプレート) | |
| e を底とする複素指数関数 (関数テンプレート) | |
| (C++11)(C++11) |
(e を底とする) 自然対数 (ln(x)) を計算します (関数) |
| valarray の各要素に関数 std::log を適用します (関数テンプレート) | |
| clog の C言語リファレンス
| |

