Complex Numbers
Numerics
Collaboration diagram for Complex Numbers:

## Classes

struct | std::complex< _Tp >
struct | std::complex< double >
struct | std::complex< float >
struct | std::complex< long double >

## Functions

constexpr | std::complex< float >::complex (const complex< double > &)
constexpr | std::complex< float >::complex (const complex< long double > &)
constexpr | std::complex< double >::complex (const complex< long double > &)
template<typename _Tp >
_Tp | std::__complex_abs (const complex< _Tp > &__z)
template<typename _Tp >
std::complex< _Tp > | std::tr1::__complex_acosh (const std::complex< _Tp > &__z)
template<typename _Tp >
_Tp | std::__complex_arg (const complex< _Tp > &__z)
template<typename _Tp >
std::complex< _Tp > | std::tr1::__complex_asinh (const std::complex< _Tp > &__z)
template<typename _Tp >
std::complex< _Tp > | std::tr1::__complex_atanh (const std::complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_cos (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_cosh (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_exp (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_log (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_pow (const complex< _Tp > &__x, const complex< _Tp > &__y)
template<typename _Tp >
complex< _Tp > | std::__complex_sin (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_sinh (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_sqrt (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_tan (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::__complex_tanh (const complex< _Tp > &__z)
template<typename _Tp >
_Tp | std::abs (const complex< _Tp > &)
template<typename _Tp >
std::complex< _Tp > | std::tr1::acosh (const std::complex< _Tp > &__z)
template<typename _Tp >
_Tp | std::arg (const complex< _Tp > &)
template<typename _Tp >
std::complex< _Tp > | std::tr1::asinh (const std::complex< _Tp > &__z)
template<typename _Tp >
std::complex< _Tp > | std::tr1::atanh (const std::complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::conj (const complex< _Tp > &)
template<typename _Tp >
std::complex< _Tp > | std::tr1::conj (const std::complex< _Tp > &__z)
template<typename _Tp >
std::complex< typename __gnu_cxx::__promote< _Tp > ::__type > | std::tr1::conj (_Tp __x)
template<typename _Tp >
complex< _Tp > | std::cos (const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::cosh (const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::exp (const complex< _Tp > &)
template<typename _Tp >
std::complex< _Tp > | std::tr1::fabs (const std::complex< _Tp > &__z)
template<typename _Tp >
constexpr _Tp | std::imag (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::log (const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::log10 (const complex< _Tp > &)
template<typename _Tp >
_Tp | std::norm (const complex< _Tp > &)
complex< _Tp > & | std::complex< _Tp >::operator*= (const _Tp &)
template<typename _Up >
complex< _Tp > & | std::complex< _Tp >::operator*= (const complex< _Up > &)
template<typename _Tp >
complex< _Tp > | std::operator+ (const complex< _Tp > &__x)
template<typename _Up >
complex< _Tp > & | std::complex< _Tp >::operator+= (const complex< _Up > &)
template<typename _Tp >
complex< _Tp > | std::operator- (const complex< _Tp > &__x)
template<typename _Up >
complex< _Tp > & | std::complex< _Tp >::operator-= (const complex< _Up > &)
complex< _Tp > & | std::complex< _Tp >::operator/= (const _Tp &)
template<typename _Up >
complex< _Tp > & | std::complex< _Tp >::operator/= (const complex< _Up > &)
template<typename _Tp , typename _CharT , class _Traits >
basic_ostream< _CharT, _Traits > & | std::operator<< (basic_ostream< _CharT, _Traits > &__os, const complex< _Tp > &__x)
complex< _Tp > & | std::complex< _Tp >::operator= (const _Tp &)
template<typename _Up >
complex< _Tp > & | std::complex< _Tp >::operator= (const complex< _Up > &)
template<typename _Tp , typename _CharT , class _Traits >
basic_istream< _CharT, _Traits > & | std::operator>> (basic_istream< _CharT, _Traits > &__is, complex< _Tp > &__x)
template<typename _Tp >
complex< _Tp > | std::polar (const _Tp &, const _Tp &=0)
template<typename _Tp , typename _Up >
std::complex< typename __gnu_cxx::__promote_2< _Tp, _Up >::__type > | std::tr1::polar (const _Tp &__rho, const _Up &__theta)
template<typename _Tp >
complex< _Tp > | std::pow (const complex< _Tp > &, const _Tp &)
template<typename _Tp >
complex< _Tp > | std::pow (const complex< _Tp > &, const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::pow (const _Tp &, const complex< _Tp > &)
template<typename _Tp , typename _Up >
std::complex< typename __gnu_cxx::__promote_2< _Tp, _Up >::__type > | std::tr1::pow (const std::complex< _Tp > &__x, const _Up &__y)
template<typename _Tp , typename _Up >
std::complex< typename __gnu_cxx::__promote_2< _Tp, _Up >::__type > | std::tr1::pow (const _Tp &__x, const std::complex< _Up > &__y)
template<typename _Tp , typename _Up >
std::complex< typename __gnu_cxx::__promote_2< _Tp, _Up >::__type > | std::tr1::pow (const std::complex< _Tp > &__x, const std::complex< _Up > &__y)
template<typename _Tp >
std::complex< _Tp > | std::tr1::pow (const std::complex< _Tp > &__x, const _Tp &__y)
template<typename _Tp >
std::complex< _Tp > | std::tr1::pow (const _Tp &__x, const std::complex< _Tp > &__y)
template<typename _Tp >
std::complex< _Tp > | std::tr1::pow (const std::complex< _Tp > &__x, const std::complex< _Tp > &__y)
template<typename _Tp >
constexpr _Tp | std::real (const complex< _Tp > &__z)
template<typename _Tp >
complex< _Tp > | std::sin (const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::sinh (const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::sqrt (const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::tan (const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::tanh (const complex< _Tp > &)
template<typename _Tp >
complex< _Tp > | std::operator+ (const complex< _Tp > &__x, const complex< _Tp > &__y)
template<typename _Tp >
complex< _Tp > | std::operator+ (const complex< _Tp > &__x, const _Tp &__y)
template<typename _Tp >
complex< _Tp > | std::operator+ (const _Tp &__x, const complex< _Tp > &__y)
template<typename _Tp >
complex< _Tp > | std::operator- (const complex< _Tp > &__x, const complex< _Tp > &__y)
template<typename _Tp >
complex< _Tp > | std::operator- (const complex< _Tp > &__x, const _Tp &__y)
template<typename _Tp >
complex< _Tp > | std::operator- (const _Tp &__x, const complex< _Tp > &__y)
template<typename _Tp >
complex< _Tp > | std::operator* (const complex< _Tp > &__x, const complex< _Tp > &__y)
template<typename _Tp >
complex< _Tp > | std::operator* (const complex< _Tp > &__x, const _Tp &__y)
template<typename _Tp >
complex< _Tp > | std::operator* (const _Tp &__x, const complex< _Tp > &__y)
template<typename _Tp >
complex< _Tp > | std::operator/ (const complex< _Tp > &__x, const complex< _Tp > &__y)
template<typename _Tp >
complex< _Tp > | std::operator/ (const complex< _Tp > &__x, const _Tp &__y)
template<typename _Tp >
complex< _Tp > | std::operator/ (const _Tp &__x, const complex< _Tp > &__y)
template<typename _Tp >
constexpr bool | std::operator== (const complex< _Tp > &__x, const complex< _Tp > &__y)
template<typename _Tp >
constexpr bool | std::operator== (const complex< _Tp > &__x, const _Tp &__y)
template<typename _Tp >
constexpr bool | std::operator== (const _Tp &__x, const complex< _Tp > &__y)
template<typename _Tp >
constexpr bool | std::operator!= (const complex< _Tp > &__x, const complex< _Tp > &__y)
template<typename _Tp >
constexpr bool | std::operator!= (const complex< _Tp > &__x, const _Tp &__y)
template<typename _Tp >
constexpr bool | std::operator!= (const _Tp &__x, const complex< _Tp > &__y)

## Detailed Description

Classes and functions for complex numbers.

## Function Documentation

template<typename _Tp >

_Tp std::abs | ( | const complex< _Tp > & | __z | ) |

inline

Return magnitude of z.

Definition at line 599 of file complex.

Referenced by std::tr1::fabs(), std::fabs(), std::poisson_distribution< _IntType >::operator()(), and std::binomial_distribution< _IntType >::operator()().

template<typename _Tp >

std::complex< _Tp > std::tr1::acosh | ( | const std::complex< _Tp > & | __z | ) |

inline

acosh(__z) [8.1.5].

Definition at line 215 of file tr1/complex.

template<typename _Tp >

_Tp std::arg | ( | const complex< _Tp > & | __z | ) |

inline

Return phase angle of z.

Definition at line 626 of file complex.

Referenced by std::arg().

template<typename _Tp >

std::complex< _Tp > std::tr1::asinh | ( | const std::complex< _Tp > & | __z | ) |

inline

asinh(__z) [8.1.6].

Definition at line 254 of file tr1/complex.

template<typename _Tp >

std::complex< _Tp > std::tr1::atanh | ( | const std::complex< _Tp > & | __z | ) |

inline

atanh(__z) [8.1.7].

Definition at line 298 of file tr1/complex.

template<typename _Tp >

complex< _Tp > std::conj | ( | const complex< _Tp > & | __z | ) |

inline

Return complex conjugate of z.

Definition at line 672 of file complex.

template<typename _Tp >

complex< _Tp > std::cos | ( | const complex< _Tp > & | __z | ) |

inline

Return complex cosine of z.

Definition at line 704 of file complex.

Referenced by std::polar().

template<typename _Tp >

complex< _Tp > std::cosh | ( | const complex< _Tp > & | __z | ) |

inline

Return complex hyperbolic cosine of z.

Definition at line 734 of file complex.

template<typename _Tp >

complex< _Tp > std::exp | ( | const complex< _Tp > & | __z | ) |

inline

Return complex base e exponential of z.

Definition at line 760 of file complex.

Referenced by std::pow().

template<typename _Tp >

std::complex< _Tp > std::tr1::fabs | ( | const std::complex< _Tp > & | __z | ) |

inline

fabs(__z) [8.1.8].

Definition at line 307 of file tr1/complex.

References std::abs().

template<typename _Tp >

complex< _Tp > std::log | ( | const complex< _Tp > & | __z | ) |

inline

Return complex natural logarithm of z.

Definition at line 787 of file complex.

Referenced by std::generate_canonical(), std::log10(), std::poisson_distribution< _IntType >::operator()(), std::binomial_distribution< _IntType >::operator()(), std::normal_distribution< _RealType >::operator()(), std::gamma_distribution< _RealType >::operator()(), and std::pow().

template<typename _Tp >

complex< _Tp > std::log10 | ( | const complex< _Tp > & | __z | ) |

inline

Return complex base 10 logarithm of z.

Definition at line 792 of file complex.

References std::log().

template<typename _Tp >

_Tp std::norm | ( | const complex< _Tp > & | __z | ) |

inline

Return z magnitude squared.

Definition at line 659 of file complex.

Referenced by std::complex< _Tp >::operator/=().

template<typename _Tp >

constexpr bool std::operator!= | ( | const complex< _Tp > & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return false if x is equal to y.

Definition at line 474 of file complex.

template<typename _Tp >

constexpr bool std::operator!= | ( | const complex< _Tp > & | __x,
|  | const _Tp & | __y
| ) |  |

inline

Return false if x is equal to y.

Definition at line 479 of file complex.

template<typename _Tp >

constexpr bool std::operator!= | ( | const _Tp & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return false if x is equal to y.

Definition at line 484 of file complex.

template<typename _Tp >

complex<_Tp> std::operator* | ( | const complex< _Tp > & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return new complex value x times y.

Definition at line 384 of file complex.

template<typename _Tp >

complex<_Tp> std::operator* | ( | const complex< _Tp > & | __x,
|  | const _Tp & | __y
| ) |  |

inline

Return new complex value x times y.

Definition at line 393 of file complex.

template<typename _Tp >

complex<_Tp> std::operator* | ( | const _Tp & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return new complex value x times y.

Definition at line 402 of file complex.

template<typename _Tp >

complex< _Tp > & std::complex< _Tp >::operator*= | ( | const _Tp & | __t | ) |

Multiply this complex number by t.

Definition at line 243 of file complex.

template<typename _Tp >
template<typename _Up >

complex< _Tp > & std::complex< _Tp >::operator*= | ( | const complex< _Up > & | __z | ) |

Multiply this complex number by z.

Definition at line 297 of file complex.

template<typename _Tp >

complex<_Tp> std::operator+ | ( | const complex< _Tp > & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return new complex value x plus y.

Definition at line 324 of file complex.

template<typename _Tp >

complex<_Tp> std::operator+ | ( | const complex< _Tp > & | __x,
|  | const _Tp & | __y
| ) |  |

inline

Return new complex value x plus y.

Definition at line 333 of file complex.

template<typename _Tp >

complex<_Tp> std::operator+ | ( | const _Tp & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return new complex value x plus y.

Definition at line 342 of file complex.

template<typename _Tp >

complex<_Tp> std::operator+ | ( | const complex< _Tp > & | __x | ) |

inline

Return x.

Definition at line 443 of file complex.

template<typename _Tp >
template<typename _Up >

complex< _Tp > & std::complex< _Tp >::operator+= | ( | const complex< _Up > & | __z | ) |

Add z to this complex number.

Definition at line 274 of file complex.

template<typename _Tp >

complex<_Tp> std::operator- | ( | const complex< _Tp > & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return new complex value x minus y.

Definition at line 354 of file complex.

template<typename _Tp >

complex<_Tp> std::operator- | ( | const complex< _Tp > & | __x,
|  | const _Tp & | __y
| ) |  |

inline

Return new complex value x minus y.

Definition at line 363 of file complex.

template<typename _Tp >

complex<_Tp> std::operator- | ( | const _Tp & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return new complex value x minus y.

Definition at line 372 of file complex.

template<typename _Tp >

complex<_Tp> std::operator- | ( | const complex< _Tp > & | __x | ) |

inline

Return complex negation of x.

Definition at line 449 of file complex.

template<typename _Tp >
template<typename _Up >

complex< _Tp > & std::complex< _Tp >::operator-= | ( | const complex< _Up > & | __z | ) |

Subtract z from this complex number.

Definition at line 285 of file complex.

template<typename _Tp >

complex<_Tp> std::operator/ | ( | const complex< _Tp > & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return new complex value x divided by y.

Definition at line 414 of file complex.

template<typename _Tp >

complex<_Tp> std::operator/ | ( | const complex< _Tp > & | __x,
|  | const _Tp & | __y
| ) |  |

inline

Return new complex value x divided by y.

Definition at line 423 of file complex.

template<typename _Tp >

complex<_Tp> std::operator/ | ( | const _Tp & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return new complex value x divided by y.

Definition at line 432 of file complex.

template<typename _Tp >

complex< _Tp > & std::complex< _Tp >::operator/= | ( | const _Tp & | __t | ) |

Divide this complex number by t.

Definition at line 253 of file complex.

template<typename _Tp >
template<typename _Up >

complex< _Tp > & std::complex< _Tp >::operator/= | ( | const complex< _Up > & | __z | ) |

Divide this complex number by z.

Definition at line 310 of file complex.

References std::norm().

template<typename _Tp , typename _CharT , class _Traits >

basic_ostream<_CharT, _Traits>& std::operator<< | ( | basic_ostream< _CharT, _Traits > & | __os,
|  | const complex< _Tp > & | __x
| ) |  |

Insertion operator for complex values.

Definition at line 524 of file complex.

References std::ios_base::flags(), std::basic_ios< _CharT, _Traits >::imbue(), std::ios_base::precision(), and std::basic_ostringstream< _CharT, _Traits, _Alloc >::str().

template<typename _Tp >

complex< _Tp > & std::complex< _Tp >::operator= | ( | const _Tp & | __t | ) |

Assign this complex number to scalar t.

Definition at line 233 of file complex.

template<typename _Tp >
template<typename _Up >

complex< _Tp > & std::complex< _Tp >::operator= | ( | const complex< _Up > & | __z | ) |

Assign this complex number to complex z.

Definition at line 263 of file complex.

template<typename _Tp >

constexpr bool std::operator== | ( | const complex< _Tp > & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return true if x is equal to y.

Definition at line 456 of file complex.

template<typename _Tp >

constexpr bool std::operator== | ( | const complex< _Tp > & | __x,
|  | const _Tp & | __y
| ) |  |

inline

Return true if x is equal to y.

Definition at line 461 of file complex.

template<typename _Tp >

constexpr bool std::operator== | ( | const _Tp & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return true if x is equal to y.

Definition at line 466 of file complex.

template<typename _Tp , typename _CharT , class _Traits >

basic_istream<_CharT, _Traits>& std::operator>> | ( | basic_istream< _CharT, _Traits > & | __is,
|  | complex< _Tp > & | __x
| ) |  |

Extraction operator for complex values.

Definition at line 491 of file complex.

References std::ios_base::failbit, std::basic_istream< _CharT, _Traits >::putback(), and std::basic_ios< _CharT, _Traits >::setstate().

template<typename _Tp >

complex< _Tp > std::polar | ( | const _Tp & | __rho,
|  | const _Tp & | __theta = `0`
| ) |  |

inline

Return complex with magnitude rho and angle theta.

Definition at line 667 of file complex.

References std::cos(), and std::sin().

Referenced by std::pow().

template<typename _Tp >

complex< _Tp > std::pow | ( | const complex< _Tp > & | __x,
|  | const _Tp & | __y
| ) |  |

Return x to the y'th power.

Definition at line 989 of file complex.

References std::exp(), std::log(), and std::polar().

Referenced by std::gamma_distribution< _RealType >::operator()(), std::pow(), and std::tr1::pow().

template<typename _Tp >

complex< _Tp > std::pow | ( | const complex< _Tp > & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return x to the y'th power.

Definition at line 1028 of file complex.

template<typename _Tp >

complex< _Tp > std::pow | ( | const _Tp & | __x,
|  | const complex< _Tp > & | __y
| ) |  |

inline

Return x to the y'th power.

Definition at line 1034 of file complex.

References std::log(), std::polar(), and std::pow().

template<typename _Tp , typename _Up >

std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type> std::tr1::pow | ( | const std::complex< _Tp > & | __x,
|  | const _Up & | __y
| ) |  |

inline

Additional overloads [8.1.9].

Definition at line 348 of file tr1/complex.

References std::pow().

template<typename _Tp >

complex< _Tp > std::sin | ( | const complex< _Tp > & | __z | ) |

inline

Return complex sine of z.

Definition at line 822 of file complex.

Referenced by std::polar().

template<typename _Tp >

complex< _Tp > std::sinh | ( | const complex< _Tp > & | __z | ) |

inline

Return complex hyperbolic sine of z.

Definition at line 852 of file complex.

template<typename _Tp >

complex< _Tp > std::sqrt | ( | const complex< _Tp > & | __z | ) |

inline

Return complex square root of z.

Definition at line 896 of file complex.

Referenced by std::normal_distribution< _RealType >::operator()(), and std::student_t_distribution< _RealType >::operator()().

template<typename _Tp >

complex< _Tp > std::tan | ( | const complex< _Tp > & | __z | ) |

inline

Return complex tangent of z.

Definition at line 923 of file complex.

template<typename _Tp >

complex< _Tp > std::tanh | ( | const complex< _Tp > & | __z | ) |

inline

Return complex hyperbolic tangent of z.

Definition at line 951 of file complex.