Namespaces
Variants
Views
Actions

std::complex

From cppreference.com
< cpp‎ | numeric
Revision as of 20:27, 14 October 2013 by Cubbi (Talk | contribs)

 
 
 
 
Defined in header <complex>
template< class T >
class complex;
(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 numbers.

The effect of instantiating the template complex for any other type is unspecified.

Contents

Member types

Member type Definition
value_type T

Member functions

constructs a complex number
(public member function)
assigns the contents
(public member function) [edit]
accesses the real part of the complex number
(public member function) [edit]
accesses the imaginary part of the complex number
(public member function) [edit]
compound assignment of two complex numbers or a complex and a scalar
(public member function) [edit]

Non-member functions

applies unary operators to complex numbers
(function template) [edit]
performs complex number arithmetic on two complex values or a complex and a scalar
(function template) [edit]
(removed in C++20)
compares two complex numbers or a complex and a scalar
(function template) [edit]
serializes and deserializes a complex number
(function template) [edit]
returns the real part
(function template) [edit]
returns the imaginary part
(function template) [edit]
returns the magnitude of a complex number
(function template) [edit]
returns the phase angle
(function template) [edit]
returns the squared magnitude
(function template) [edit]
returns the complex conjugate
(function template) [edit]
(C++11)
returns the projection onto the Riemann sphere
(function template) [edit]
constructs a complex number from magnitude and phase angle
(function template) [edit]
Exponential functions
complex base e exponential
(function template) [edit]
complex natural logarithm with the branch cuts along the negative real axis
(function template) [edit]
complex common logarithm with the branch cuts along the negative real axis
(function template) [edit]
Power functions
complex power, one or both arguments may be a complex number
(function template) [edit]
complex square root in the range of the right half-plane
(function template) [edit]
Trigonometric functions
computes sine of a complex number (sin(z))
(function template) [edit]
computes cosine of a complex number (cos(z))
(function template) [edit]
computes tangent of a complex number (tan(z))
(function template) [edit]
computes arc sine of a complex number (arcsin(z))
(function template) [edit]
computes arc cosine of a complex number (arccos(z))
(function template) [edit]
computes arc tangent of a complex number (arctan(z))
(function template) [edit]
Hyperbolic functions
computes hyperbolic sine of a complex number (sinh(z))
(function template) [edit]
computes hyperbolic cosine of a complex number (cosh(z))
(function template) [edit]
computes hyperbolic tangent of a complex number (tanh(z))
(function template) [edit]
computes area hyperbolic sine of a complex number (arsinh(z))
(function template) [edit]
computes area hyperbolic cosine of a complex number (arcosh(z))
(function template) [edit]
computes area hyperbolic tangent of a complex number (artanh(z))
(function template) [edit]

Non-static data members

For any complex number z, reinterpret_cast<T(&)[2]>(z)[0] is the real part of z and reinterpret_cast<T(&)[2]>(z)[1] is the imaginary part of z.

For any pointer to an element of an array of complex numbers p and any valid array index i, reinterpret_cast<T*>(p)[2*i] is the real part of the complex number p[i], and reinterpret_cast<T*>(p)[2*i + 1] is the imaginary part of the complex number p[i]

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.

(since C++11)

Literals

Defined in inline namespace std::literals::complex_literals
a std::complex literal representing purely imaginary number
(function) [edit]