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 >
_Tp | std::__complex_arg (const 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_pow_unsigned (complex< _Tp > __x, unsigned __n)
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 >
_Tp | std::arg (const complex< _Tp > &)
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 > &, int)
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

## abs()

template<typename _Tp >

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

inline

Return magnitude of z.

Definition at line 622 of file complex.

References std::arg().

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

## arg()

template<typename _Tp >

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

inline

Return phase angle of z.

Definition at line 649 of file complex.

References std::abs().

Referenced by std::abs(), std::arg(), std::exp(), std::tr1::fabs(), and std::tr1::pow().

## conj()

template<typename _Tp >

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

inline

Return complex conjugate of z.

Definition at line 698 of file complex.

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

Referenced by std::arg(), and std::tr1::pow().

## cos()

template<typename _Tp >

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

inline

Return complex cosine of z.

Definition at line 730 of file complex.

References std::cosh(), std::sin(), and std::sinh().

Referenced by std::conj(), std::log10(), std::sin(), and std::sqrt().

## cosh()

template<typename _Tp >

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

inline

Return complex hyperbolic cosine of z.

Definition at line 760 of file complex.

References std::exp().

Referenced by std::conj(), std::cos(), std::log10(), std::sin(), and std::tan().

## exp()

template<typename _Tp >

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

inline

Return complex base e exponential of z.

Definition at line 786 of file complex.

References std::abs(), std::arg(), and std::log().

Referenced by std::cosh(), std::lognormal_distribution< _RealType >::operator()(), and std::pow().

## fabs()

template<typename _Tp >

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

inline

fabs(__z) [8.1.8].

Definition at line 309 of file tr1/complex.

References std::abs(), std::arg(), std::fabs(), and std::norm().

## log()

template<typename _Tp >

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

inline

Return complex natural logarithm of z.

Definition at line 813 of file complex.

Referenced by std::acosh(), std::asin(), std::asinh(), std::atan(), std::exp(), std::generate_canonical(), std::log10(), std::normal_distribution< result_type >::operator()(), std::gamma_distribution< result_type >::operator()(), std::binomial_distribution< _IntType >::operator()(), std::poisson_distribution< _IntType >::operator()(), std::exponential_distribution< _RealType >::operator()(), std::operator<<(), std::operator>>(), and std::pow().

## log10()

template<typename _Tp >

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

inline

Return complex base 10 logarithm of z.

Definition at line 818 of file complex.

References std::cos(), std::cosh(), std::log(), std::sin(), and std::sinh().

## norm()

template<typename _Tp >

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

inline

Return z magnitude squared.

Definition at line 682 of file complex.

Referenced by std::arg(), std::tr1::fabs(), std::complex< _Tp >::operator/=(), and std::tr1::pow().

## operator!=() [1/3]

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 476 of file complex.

## operator!=() [2/3]

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 481 of file complex.

## operator!=() [3/3]

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 486 of file complex.

## operator*() [1/3]

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 386 of file complex.

## operator*() [2/3]

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 395 of file complex.

## operator*() [3/3]

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 404 of file complex.

## operator*=() [1/2]

template<typename _Tp >

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

Multiply this complex number by a scalar.

Definition at line 245 of file complex.

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

## operator*=() [2/2]

template<typename _Tp >
template<typename _Up >

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

Multiply this complex number by another.

Definition at line 299 of file complex.

## operator+() [1/4]

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 326 of file complex.

Referenced by std::operator+().

## operator+() [2/4]

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 335 of file complex.

## operator+() [3/4]

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 344 of file complex.

## operator+() [4/4]

template<typename _Tp >

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

inline

Return x.

Definition at line 445 of file complex.

## operator+=()

template<typename _Tp >
template<typename _Up >

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

Add another complex number to this one.

Definition at line 276 of file complex.

## operator-() [1/4]

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 356 of file complex.

## operator-() [2/4]

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 365 of file complex.

## operator-() [3/4]

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 374 of file complex.

## operator-() [4/4]

template<typename _Tp >

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

inline

Return complex negation of x.

Definition at line 451 of file complex.

## operator-=()

template<typename _Tp >
template<typename _Up >

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

Subtract another complex number from this one.

Definition at line 287 of file complex.

## operator/() [1/3]

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 416 of file complex.

## operator/() [2/3]

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 425 of file complex.

## operator/() [3/3]

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 434 of file complex.

## operator/=() [1/2]

template<typename _Tp >

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

Divide this complex number by a scalar.

Definition at line 255 of file complex.

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

## operator/=() [2/2]

template<typename _Tp >
template<typename _Up >

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

Divide this complex number by another.

Definition at line 312 of file complex.

References std::norm().

## operator<<()

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 547 of file complex.

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

## operator=() [1/2]

template<typename _Tp >

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

Assign a scalar to this complex number.

Definition at line 235 of file complex.

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

## operator=() [2/2]

template<typename _Tp >
template<typename _Up >

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

Assign another complex number to this one.

Definition at line 265 of file complex.

## operator==() [1/3]

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 458 of file complex.

## operator==() [2/3]

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 463 of file complex.

## operator==() [3/3]

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 468 of file complex.

## operator>>()

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 493 of file complex.

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

## polar()

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 690 of file complex.

Referenced by std::tr1::pow().

## pow() [1/5]

template<typename _Tp >

complex< _Tp > std::pow | ( | const complex< _Tp > & | __z,
|  | int | __n
| ) |  |

inline

Return x to the y'th power.

Definition at line 1008 of file complex.

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

## pow() [2/5]

template<typename _Tp >

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

Return x to the y'th power.

Definition at line 1017 of file complex.

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

## pow() [3/5]

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 1056 of file complex.

## pow() [4/5]

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 1062 of file complex.

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

## pow() [5/5]

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 350 of file tr1/complex.

References std::arg(), std::conj(), std::norm(), std::polar(), and std::pow().

## sin()

template<typename _Tp >

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

inline

Return complex sine of z.

Definition at line 848 of file complex.

References std::cos(), std::cosh(), and std::sinh().

Referenced by std::conj(), std::cos(), std::log10(), and std::sqrt().

## sinh()

template<typename _Tp >

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

inline

Return complex hyperbolic sine of z.

Definition at line 878 of file complex.

References std::abs(), and std::sqrt().

Referenced by std::conj(), std::cos(), std::log10(), std::sin(), and std::tan().

## sqrt()

template<typename _Tp >

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

inline

Return complex square root of z.

Definition at line 922 of file complex.

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

Referenced by std::acosh(), std::atan(), std::normal_distribution< result_type >::operator()(), std::student_t_distribution< _RealType >::operator()(), std::operator<<(), and std::sinh().

## tan()

template<typename _Tp >

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

inline

Return complex tangent of z.

Definition at line 949 of file complex.

References std::cosh(), std::sinh(), and std::tanh().

Referenced by std::sqrt().

## tanh()

template<typename _Tp >

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

inline

Return complex hyperbolic tangent of z.

Definition at line 977 of file complex.

Referenced by std::tan().