std:: pow (std::complex)
|
定義先ヘッダ
<complex>
|
||
|
template
<
class
T
>
std:: complex < T > pow ( const std:: complex < T > & x, int y ) ; |
(1) | (C++11まで) |
|
template
<
class
T
>
std:: complex < T > pow ( const std:: complex < T > & x, const std:: complex < T > & y ) ; |
(2) | |
|
template
<
class
T
>
std:: complex < T > pow ( const std:: complex < T > & x, const T & y ) ; |
(3) | |
|
template
<
class
T
>
std:: complex < T > pow ( const T & x, const std:: complex < T > & y ) ; |
(4) | |
|
追加のオーバーロード
(C++11以降)
|
||
|
定義先ヘッダ
<complex>
|
||
| (A) | ||
|
template
<
class
T1,
class
T2
>
std::
complex
<
/* 共通型 */
>
|
(C++23まで) | |
|
template
<
class
T1,
class
T2
>
std::
complex
<
std::
common_type_t
<
T1, T2
>>
|
(C++23から) | |
| (B) | ||
|
template
<
class
T,
class
NonComplex
>
std::
complex
<
/* common-type */
>
|
(C++23まで) | |
|
template
<
class
T,
class
NonComplex
>
std::
complex
<
std::
common_type_t
<
T, NonComplex
>>
|
(C++23から) | |
| (C) | ||
|
template
<
class
T,
class
NonComplex
>
std::
complex
<
/* common-type */
>
|
(C++23まで) | |
|
template
<
class
T,
class
NonComplex
>
std::
complex
<
std::
common_type_t
<
T, NonComplex
>>
|
(C++23以降) | |
| (C++11以降) |
目次 |
パラメータ
| x | - | 基数 |
| y | - | 指数 |
戻り値
が返されます。
注記
オーバーロード (1) は、C++98において std::pow の追加オーバーロード (2) との整合性を保つために提供されていました。これらのオーバーロードは LWG issue 550 の解決により削除され、オーバーロード (1) は LWG issue 844 の解決により削除されました。
追加のオーバーロードは (A-C) と完全に同一である必要はありません。これらは、第一引数 base と第二引数 exponent に対して以下を保証するのに十分であればよいのです:
|
base および/または exponent が型 std:: complex < T > を持つ場合:
|
(C++23まで) |
|
一方の引数が型
std::
complex
<
T1
>
を持ち、もう一方の引数が型
std:: common_type_t < T1, T2 > が well-formed でない場合、プログラムは ill-formed である。 |
(C++23以降) |
例
#include <complex> #include <iostream> int main() { std::cout << std::fixed; std::complex<double> z(1.0, 2.0); std::cout << "(1,2)^2 = " << std::pow(z, 2) << '\n'; std::complex<double> z2(-1.0, 0.0); // -1の平方根 std::cout << "-1^0.5 = " << std::pow(z2, 0.5) << '\n'; std::complex<double> z3(-1.0, -0.0); // カットの反対側 std::cout << "(-1,-0)^0.5 = " << std::pow(z3, 0.5) << '\n'; std::complex<double> i(0.0, 1.0); // i^i = exp(-pi / 2) std::cout << "i^i = " << std::pow(i, i) << '\n'; }
出力:
(1,2)^2 = (-3.000000,4.000000) -1^0.5 = (0.000000,1.000000) (-1,-0)^0.5 = (0.000000,-1.000000) i^i = (0.207880,0.000000)
関連項目
|
右半平面の範囲における複素数の平方根
(関数テンプレート) |
|
|
(C++11)
(C++11)
|
数値を指定された累乗に引き上げる (
x
y
)
(関数) |
|
関数
std::pow
を2つのvalarray、またはvalarrayと値に適用する
(関数テンプレート) |
|
|
Cドキュメント
for
cpow
|
|