std::complex

From Cppreference

Jump to: navigation, search
Defined in header <complex>

template<class T>
class complex; //not defined
(1)
template<> class complex<float>;
(2)
template<> class complex<double>;
(3)
template<> class complex<long double>;
(4)

The specializations std::complex<float>, std::complex<double>, and std::complex<long double> are literal types for representing and manipulating complex number. The effect of instantiating the template complex for any other type is unspecified.

[edit] Member types

Member type Definition
value_type T

[edit] Member functions

(constructor)
constructs a complex number
(public member function)
real
gets/sets real part of the complex number
(public member function)
imag
gets/sets imaginary part of the complex number
(public member function)
operator=
replaces the complex number with another
(public member function)
operator+=
operator-=
operator/=
operator*=
compound assignment of two complex numbers or a complex and a scalar
(public member function)

[edit] Non-member functions

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)
real
returns the real component
(function template)
imag
returns the imaginary component
(function template)
abs(std::complex)
returns the magnitude of a complex number
(function template)
arg
returns the phase angle
(function template)
norm
returns the squared magnitude
(function template)
conj
returns the complex conjugate
(function template)
proj
returns the projection onto the Riemann sphere
(function template)
polar
constructs a complex number from magnitude and phase angle
(function template)
sin(std::complex)
computes sine of a complex argument (sin(z))
(function template)
cos(std::complex)
computes cosine of a complex argument (cos(z))
(function template)
tan(std::complex)
computes tangent of a complex argument (tan(z))
(function template)
asin(std::complex)
computes arc sine of a complex argument (arcsin(z))
(function template)
acos(std::complex)
computes arc cosine of a complex argument (arccos(z))
(function template)
atan(std::complex)
computes arc tangent of a complex argument (arctan(z))
(function template)
sinh(std::complex)
computes hyperbolic sine of a complex argument (sh(z))
(function template)
cosh(std::complex)
computes hyperbolic cosine of a complex argument (ch(z))
(function template)
tanh(std::complex)
computes hyperbolic tangent of a complex argument
(function template)
asinh(std::complex) (C++11)
computes hyperbolic arc sine of a complex argument
(function template)
acosh(std::complex) (C++11)
computes hyperbolic arc cosine of a complex argument
(function template)
atanh(std::complex) (C++11)
computes hyperbolic arc tangent of a complex argument
(function template)
exp(std::complex)
complex base e exponential
(function template)
log(std::complex)
complex natural logarithm with the branch cuts along the negative real axis
(function template)
log10(std::complex)
complex common logarithm with the branch cuts along the negative real axis
(function template)
pow(std::complex)
complex power, one or both arguments may be a complex number
(function template)
sqrt(std::complex)
complex square root in the range of the right half-plane
(function template)