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

std::complex

STD::复杂

Defined in header
template< class T > class complex;(1)
template<> class complex<float>;(2)
template<> class complex<double>;(3)
template<> class complex<long double>;(4)

专门性std::complex<float>,,,std::complex<double>,和std::complex<long double>是LiteralType斯用于表示和操作复数...

模板实例化的效果complex对于任何其他类型都未指定。

成员类型

Member typeDefinition
value_typeT

成员函数

(constructor)constructs a complex number (public member function)
operator=assigns the contents (public member function)
realaccesses the real part of the complex number (public member function)
imagaccesses the imaginary part of the complex number (public member function)
operator+=operator-=operator/=operator*=compound assignment of two complex numbers or a complex and a scalar (public member function)

非会员职能

operator+operator-applies unary operators to complex numbers (function template)
operator+operator-operator*operator/performs complex number arithmetics on two complex values or a complex and a scalar (function template)
operator==operator!=compares two complex numbers or a complex and a scalar (function template)
operator<<operator>>serializes and deserializes a complex number (function template)
realreturns the real component (function template)
imagreturns the imaginary component (function template)
abs(std::complex)returns the magnitude of a complex number (function template)
argreturns the phase angle (function template)
normreturns the squared magnitude (function template)
conjreturns the complex conjugate (function template)
proj (C++11)returns the projection onto the Riemann sphere (function template)
polarconstructs a complex number from magnitude and phase angle (function template)

指数函数

Exp%28 std::复数%29复合碱基e指数%28功能模板%29

LOG%28 std::复数%29复自然对数与分支沿负实轴切割%28功能模板%29

LOG 10%28 std::复数%29复数共对数与分支沿负实轴切割%28函数模板%29

幂函数

POW%28 std::复数%29复幂,一个或两个参数可能是复数%28函数模板%29

sqrt%28 std::右半平面%28函数模板%29范围内的复数%29复平方根

三角函数

SIN%28 std::复数%29计算复数的正弦数%28 sin%28Z%29%29%28函数模板%29

COS%28 std::复数%29计算复数的余弦%28 cos%28Z%29%29%28函数模板%29

TAN%28 std::复数%29计算复数数%28 tan%28Z%29%29%28函数模板%29的切线

Asin%28std::复数%29%28C++11%29计算复数的弧正弦%28 arcsin%28Z%29%29%28函数模板%29

ACOS%28std::复数%29%28C++11%29计算复数的弧余弦%28 arccos%28Z%29%29%28函数模板%29

Atan%28std::复数%29%28C++11%29计算复数的弧切线%28arctan%28Z%29%29%28函数模板%29

双曲函数

辛氏%28 std::复数%29计算复数的双曲正弦数%28 sh%28Z%29%29%28函数模板%29

COSH%28 std::复数%29计算复数的双曲余弦值%28ch%28Z%29%29%28函数模板%29

TANK%28 std::复数%29计算复数数%28函数模板%29的双曲切线

Asinh%28 std::复数%29%28C++11%29计算复数的面积双曲正弦数%28函数模板%29

ACOSH%28 std::复数%29%28C++11%29计算复数数%28函数模板%29的面积双曲余弦

ATANH%28 std::复数%29%28C++11%29计算复数数%28函数模板%29的面积双曲切线

非静态数据成员

For any object z of type complex, reinterpret_cast(z)0 is the real part of z and reinterpret_cast(z)1 is the imaginary part of z. For any pointer to an element of an array of complex named p and any valid array index i, reinterpret_cast(p)2*i is the real part of the complex number pi, and reinterpret_cast(p)2*i + 1 is the imaginary part of the complex number pi These requirements essentially limit implementation of each of the three specializations of std::complex to declaring two and only two non-static data members, of type value_type, with the same member access, which hold the real and the imaginary components, respectively. The intent of this requirement is to preserve binary compatibility between the C++ library complex number types and the C language complex number types (and arrays thereof), which have an identical object representation requirement.(since C++11)

文字

定义在内联命名空间std::文本::Complex中[医]文字

*。

运算符“ifOperator”“iOperator”“il%28C++14%29A std:复数”表示纯虚数%28函数%29

二次

#include <iostream> #include <iomanip> #include <complex> #include <cmath> int main() { using namespace std::complex_literals; std::cout << std::fixed << std::setprecision(1 std::complex<double> z1 = 1i * 1i; // imaginary unit squared std::cout << "i * i = " << z1 << '\n'; std::complex<double> z2 = std::pow(1i, 2 // imaginary unit squared std::cout << "pow(i, 2) = " << z2 << '\n'; double PI = std::acos(-1 std::complex<double> z3 = std::exp(1i * PI // Euler's formula std::cout << "exp(i * pi) = " << z3 << '\n'; std::complex<double> z4 = 1. + 2i, z5 = 1. - 2i; // conjugates std::cout << "(1+2i)*(1-2i) = " << z4*z5 << '\n'; }

二次

产出:

二次

i * i = (-1.0,0.0) pow(i, 2) = (-1.0,0.0) exp(i * pi) = (-1.0,0.0) (1+2i)*(1-2i) = (5.0,0.0)

二次

另见

复数算法的C文档

*。

© cppreference.com

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

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