©
本文档使用
php中文网手册 发布
在头文件<math.h>中定义 | ||
|---|---|---|
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浮点运算,
考虑到虚部的符号,该功能在分支切割上是连续的
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θ
#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.141593i4*log(sqrt(2)/2+sqrt(2)i/2) = 0.0+3.141593ilog(-1+0i) = 0.0+3.141593ilog(-1-0i) (the other side of the cut) = 0.0-3.141593i
C11标准(ISO / IEC 9899:2011):
7.3.7.2堵塞功能(p:195)
7.25类型通用数学<tgmath.h>(p:373-375)
G.6.3.2堵塞功能(p:543-544)
G.7类型 - 通用数学<tgmath.h>(p:545)
C99标准(ISO / IEC 9899:1999):
7.3.7.2堵塞功能(p:176-177)
7.22类型通用数学<tgmath.h>(p:335-337)
G.6.3.2堵塞功能(p:478-479)
G.7类型 - 通用数学<tgmath.h>(p:480)