cpowf, cpow, cpowl
來自 cppreference.com
定義在標頭檔案 <complex.h> 中 |
||
(1) | (C99 起) | |
(2) | (C99 起) | |
(3) | (C99 起) | |
定義於標頭檔案 <tgmath.h> |
||
#define pow( x, y ) |
(4) | (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)
[編輯] 另請參閱
(C99)(C99)(C99) |
計算復平方根 (函式) |
(C99)(C99) |
計算給定冪的數字 (xy) (函式) |
C++ 文件 for pow
|