在线文档教程
C++
数字 | Numerics

std::pow(std::complex)

STD::POW%28 std::Complex%29

Defined in header
template< class T > complex<T> pow( const complex<T>& x, const complex<T>& y
template< class T > complex<T> pow( const complex<T>& x, const T& y
template< class T > complex<T> pow( const T& x, const complex<T>& y
template< class T, class U > complex</*Promoted*/> pow( const complex<T>& x, const complex<U>& y(since C++11)
template< class T, class U > complex</*Promoted*/> pow( const complex<T>& x, const U& y(since C++11)
template< class T, class U > complex</*Promoted*/> pow( const T& x, const complex<U>& y(since C++11)

计算复杂x上升到一个复杂的力量y在第一个参数的负实轴上有一个分支。

%28因为所有算术类型都提供了C++11%29加法过载,因此。

  • 如果任何一个论点是long double或std::complex<longdouble>,则两个参数都转换为std::complex<longdouble>2.否则,如果任何一个论点是double,,,std::complex<double>或整数类型,则将两个参数转换为std::complex<double>3.否则,如果任何一个论点是float或std::complex<float>,则两个参数都转换为std::complex<float>

参数

x-base as a complex value
y-exponent as a complex value

返回值

如果没有出现错误,则复幂xy

,被归还。

处理错误和特殊情况时,就好像操作是由std::exp(y*std::log(x))...

结果std::pow(0, 0)是实现定义的。

二次

#include <iostream> #include <complex> int main() { std::cout << std::fixed; std::complex<double> z(1, 2 std::cout << "(1,2)^2 = " << std::pow(z, 2) << '\n'; std::complex<double> z2(-1, 0 // square root of -1 std::cout << "-1^0.5 = " << std::pow(z2, 0.5) << '\n'; std::complex<double> z3(-1, -0.0 // other side of the cut std::cout << "(-1, -0)^0.5 = " << std::pow(z3, 0.5) << '\n'; std::complex<double> i(0, 1 // 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)

二次

另见

sqrt(std::complex)complex square root in the range of the right half-plane (function template)
powraises a number to the given power (xy) (function)
pow(std::valarray)applies the function std::pow to two valarrays or a valarray and a value (function template)

c cpow文件

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/数值/复合/pow