std::log10(std::complex)

来自cppreference.com
< cpp‎ | numeric‎ | complex
 
 
 
 
在标头 <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 <iostream>
#include <cmath>
#include <complex>
 
int main()
{
    std::complex<double> z(0, 1); // // r = 0, θ = pi/2
    std::cout << "2*log10" << z << " = " << 2.*std::log10(z) << '\n';
 
    std::complex<double> z2(sqrt(2)/2, sqrt(2)/2); // r = 1, θ = pi/4
    std::cout << "4*log10" << z2 << " = " << 4.*std::log10(z2) << '\n';
 
    std::complex<double> z3(-100, 0); // r = 100, θ = pi
    std::cout << "log10" << z3 << " = " << std::log10(z3) << '\n';
    std::complex<double> z4(-100, -0.0); // 切割的另一侧
    std::cout << "log10" << z4 << " (the other side of the cut) = "
              << std::log10(z4) << '\n'
              << "(note: pi/log(10) = " << acos(-1)/log(10) << ")\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) (the other side of the cut) = (2,-1.36438)
(note: pi/log(10) = 1.36438)

参阅

沿负实轴切割的复自然对数
(函数模板)
(C++11)(C++11)
计算常用(以 10 为底)对数(log10(x)
(函数)
应用函数 std::log10 到 valarray 的每个元素
(函数模板)