std::log10(std::complex)
來自 cppreference.com
定義於標頭檔案 <complex> |
||
template< class T > std::complex<T> log10( const std::complex<T>& z ); |
||
計算複數值 z 的複數常用(以 10 為底)對數,其分支切割沿負實軸。
此函式的行為等同於 std::log(z) / std::log(T(10))
。
目錄 |
[編輯] 引數
z | - | 複數型別的值 |
[編輯] 返回值
複數 z 的常用複對數。
[編輯] 示例
執行此程式碼
#include <cmath> #include <complex> #include <iostream> int main() { std::complex<double> z(0.0, 1.0); // r = 0, θ = pi / 2 std::cout << "2 * log10" << z << " = " << 2.0 * std::log10(z) << '\n'; std::complex<double> z2(sqrt(2.0) / 2, sqrt(2.0) / 2); // r = 1, θ = pi / 4 std::cout << "4 * log10" << z2 << " = " << 4.0 * std::log10(z2) << '\n'; std::complex<double> z3(-100.0, 0.0); // r = 100, θ = pi std::cout << "log10" << z3 << " = " << std::log10(z3) << '\n'; std::complex<double> z4(-100.0, -0.0); // the other side of the cut std::cout << "log10" << z4 << " = " << std::log10(z4) << " " "(the other side of the cut)\n" "(note: pi / log(10) = " << std::acos(-1.0) / std::log(10.0) << ")\n"; }
可能的輸出
2 * log10(0,1) = (0,1.36438) 4 * log10(0.707107,0.707107) = (0,1.36438) log10(-100,0) = (2,1.36438) log10(-100,-0) = (2,-1.36438) (the other side of the cut) (note: pi / log(10) = 1.36438)
[編輯] 參閱
具有沿負實軸分支割線的複數自然對數 (函式模板) | |
(C++11)(C++11) |
計算常用(以 10 為底)對數 (log10(x)) (函式) |
將函式 std::log10 應用於 valarray 的每個元素 (函式模板) |