std::complex< _Tp > Struct Template Reference
Numerics » Complex Numbers

`#include <complex>`

## Public Types

typedef _Tp | value_type

## Public Member Functions

constexpr | complex (const _Tp &__r=_Tp(), const _Tp &__i=_Tp())
constexpr | complex (const complex &)=default
template<typename _Up >
constexpr | complex (const complex< _Up > &__z)
constexpr complex | __rep () const
_GLIBCXX_ABI_TAG_CXX11 constexpr _Tp | imag () const
_GLIBCXX20_CONSTEXPR void | imag (_Tp __val)
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator*= (const _Tp &)
template<typename _Up >
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator*= (const complex< _Up > &)
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator+= (const _Tp &__t)
template<typename _Up >
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator+= (const complex< _Up > &)
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator-= (const _Tp &__t)
template<typename _Up >
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator-= (const complex< _Up > &)
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator/= (const _Tp &)
template<typename _Up >
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator/= (const complex< _Up > &)
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator= (const _Tp &)
_GLIBCXX20_CONSTEXPR complex & | operator= (const complex &)=default
template<typename _Up >
_GLIBCXX20_CONSTEXPR complex< _Tp > & | operator= (const complex< _Up > &)
_GLIBCXX_ABI_TAG_CXX11 constexpr _Tp | real () const
_GLIBCXX20_CONSTEXPR void | real (_Tp __val)

## Detailed Description

template<typename _Tp>
struct std::complex< _Tp >

Template to represent complex numbers.

Specializations for float, double, and long double are part of the library. Results with any other type are not guaranteed.

Parameters

  Tp | Type of real and imaginary values.

Definition at line 127 of file complex.

## Member Typedef Documentation

## value_type

template<typename _Tp >

typedef _Tp std::complex< _Tp >::value_type

Value typedef.

Definition at line 130 of file complex.

## Constructor & Destructor Documentation

## complex() [1/2]

template<typename _Tp >

constexpr std::complex< _Tp >::complex | ( | const _Tp & | __r = `_Tp()`,
|  | const _Tp & | __i = `_Tp()`
| ) |  |

inline constexpr

Default constructor. First parameter is x, second parameter is y. Unspecified parameters default to 0.

Definition at line 134 of file complex.

## complex() [2/2]

template<typename _Tp >
template<typename _Up >

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

inline constexpr

Converting constructor.

Definition at line 144 of file complex.

## Member Function Documentation

## __rep()

template<typename _Tp >

constexpr complex std::complex< _Tp >::__rep | ( |  | ) | const

inline constexpr

Definition at line 230 of file complex.

## imag() [1/2]

template<typename _Tp >

_GLIBCXX_ABI_TAG_CXX11 constexpr _Tp std::complex< _Tp >::imag | ( |  | ) | const

inline constexpr

Definition at line 156 of file complex.

## imag() [2/2]

template<typename _Tp >

_GLIBCXX20_CONSTEXPR void std::complex< _Tp >::imag | ( | _Tp | __val | ) |

inline

Definition at line 181 of file complex.

## operator+=()

template<typename _Tp >

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

inline

Add a scalar to this complex number.

Definition at line 189 of file complex.

## operator-=()

template<typename _Tp >

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

inline

Subtract a scalar from this complex number.

Definition at line 198 of file complex.

## real() [1/2]

template<typename _Tp >

_GLIBCXX_ABI_TAG_CXX11 constexpr _Tp std::complex< _Tp >::real | ( |  | ) | const

inline constexpr

Definition at line 152 of file complex.

## real() [2/2]

template<typename _Tp >

_GLIBCXX20_CONSTEXPR void std::complex< _Tp >::real | ( | _Tp | __val | ) |

inline

Definition at line 178 of file complex.

The documentation for this struct was generated from the following file:

- complex