?
本文檔使用 php中文網(wǎng)手冊 發(fā)布
在頭文件<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)計算復數(shù)冪函數(shù)xy
,沿負實軸的第一個參數(shù)分支切割。
4)類型 - 通用宏:如果任何參數(shù)具有類型long
double
complex
,cpowl
則被調(diào)用。如果任何參數(shù)具有類型double
complex
,cpow
則被調(diào)用,如果任何參數(shù)具有類型float
complex
,cpowf
則調(diào)用它。如果參數(shù)是實數(shù)或整數(shù),則宏調(diào)用相應的實函數(shù)(powf
,pow
,powl
)。如果有任何參數(shù)是虛構的,則調(diào)用相應的復數(shù)版本。
x,y | - | 復雜的論點 |
---|
如果沒有錯誤發(fā)生,復雜的權力xy
,返回。
錯誤和特殊情況的處理就像是通過執(zhí)行操作一樣cexp(y*clog(x))
,除了允許實現(xiàn)更仔細地處理特殊情況。
#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函數(shù)(p:195-196)
7.25類型通用數(shù)學<tgmath.h>(p:373-375)
G.6.4.1 cpow功能(p:544)
G.7類型 - 通用數(shù)學<tgmath.h>(p:545)
C99標準(ISO / IEC 9899:1999):
7.3.8.2 cpow函數(shù)(p:177)
7.22類型通用數(shù)學<tgmath.h>(p:335-337)
G.6.4.1 cpow功能(p:479)
G.7類型 - 通用數(shù)學<tgmath.h>(p:480)