clogl
clogf, clog, clogl
在头文件 | | |
---|---|---|
float complex clogf( float complex z | (1) | (since C99) |
double complex clog( double complex z | (2) | (since C99) |
long double complex clogl( long double complex z | (3) | (since C99) |
Defined in header <tgmath.h> | | |
#define log( z ) | (4) | (since C99) |
1-3)计算沿着负实轴的分支切割的复数自然(base
- 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浮点运算,
- 考虑到虚部的符号,该功能在分支切割上是连续的
笔记
具有极坐标分量(r,θ)的复数z的自然对数等于ln r + i(θ+2nπ),其中主值ln r +iθ
例
#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标准(ISO / IEC 9899:2011):