cpowf
在头文件<math.h>中定义 | | |
---|---|---|
float complex cpowf( float complex x, float complex y ); | (1) | (since C99) |
double complex cpow( double complex x, double complex y ); | (2) | (since C99) |
long double complex cpowl( long double complex x, long double complex y ); | (3) | (since C99) |
Defined in header <tgmath.h> | | |
#define pow( x, y ) | (4) | (since C99) |
1-3)计算复数幂函数xy
,沿负实轴的第一个参数分支切割。
4)类型 - 通用宏:如果任何参数具有类型long
double
complex
,cpowl
则被调用。如果任何参数具有类型double
complex
,cpow
则被调用,如果任何参数具有类型float
complex
,cpowf
则调用它。如果参数是实数或整数,则宏调用相应的实函数(powf
,pow
,powl
)。如果有任何参数是虚构的,则调用相应的复数版本。
参数
x,y | - | 复杂的论点 |
---|
返回值
如果没有错误发生,复杂的权力xy
,返回。
错误和特殊情况的处理就像是通过执行操作一样cexp(y*clog(x))
,除了允许实现更仔细地处理特殊情况。
例
#include <stdio.h>
#include <complex.h>
int main(void)
{
double complex z = cpow(1.0+2.0*I, 2);
printf("(1+2i)^2 = %.1f%+.1fi\n", creal(z), cimag(z));
double complex z2 = cpow(-1, 0.5);
printf("(-1+0i)^0.5 = %.1f%+.1fi\n", creal(z2), cimag(z2));
double complex z3 = cpow(conj(-1), 0.5); // other side of the cut
printf("(-1-0i)^0.5 = %.1f%+.1fi\n", creal(z3), cimag(z3));
double complex z4 = cpow(I, I); // i^i = exp(-pi/2)
printf("i^i = %f%+fi\n", creal(z4), cimag(z4));
}
输出:
(1+2i)^2 = -3.0+4.0i
(-1+0i)^0.5 = 0.0+1.0i
(-1-0i)^0.5 = 0.0-1.0i
i^i = 0.207880+0.000000i
参考
- C11标准(ISO / IEC 9899:2011):
- 7.3.8.2 cpow函数(p:195-196)
- 7.25类型通用数学<tgmath.h>(p:373-375)
- G.6.4.1 cpow功能(p:544)
- G.7类型 - 通用数学<tgmath.h>(p:545)
- C99标准(ISO / IEC 9899:1999):
- 7.3.8.2 cpow函数(p:177)
- 7.22类型通用数学<tgmath.h>(p:335-337)
- G.6.4.1 cpow功能(p:479)
- G.7类型 - 通用数学<tgmath.h>(p:480)
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com