libstdc++: std::complex< _Tp > Class Template Reference

libstdc++

std::complex< _Tp > Class 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
constexpr complex | __rep () const
template<typename _Up>
| explicit (!requires(_Up __u) { _Tp{__u};}) const expr complex(const complex< _Up > &__z)
constexpr _Tp | imag () const
constexpr void | imag (_Tp __val)
constexpr complex< _Tp > & | operator*= (const _Tp &)
template<typename _Up>
constexpr complex< _Tp > & | operator*= (const complex< _Up > &)
constexpr complex< _Tp > & | operator+= (const _Tp &__t)
template<typename _Up>
constexpr complex< _Tp > & | operator+= (const complex< _Up > &)
constexpr complex< _Tp > & | operator-= (const _Tp &__t)
template<typename _Up>
constexpr complex< _Tp > & | operator-= (const complex< _Up > &)
constexpr complex< _Tp > & | operator/= (const _Tp &)
template<typename _Up>
constexpr complex< _Tp > & | operator/= (const complex< _Up > &)
constexpr complex< _Tp > & | operator= (const _Tp &)
constexpr complex & | operator= (const complex &)=default
template<typename _Up>
constexpr complex< _Tp > & | operator= (const complex< _Up > &)
constexpr _Tp | real () const
constexpr void | real (_Tp __val)

## Detailed Description

template<typename _Tp>
class 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 156 of file complex.

## Member Typedef Documentation

## ◆ value_type

template<typename _Tp>

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

Value typedef.

Definition at line 160 of file complex.

## Constructor & Destructor Documentation

## ◆ complex()

template<typename _Tp>

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

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

Definition at line 164 of file complex.

Referenced by operator*=(), operator*=(), operator+=(), operator-=(), operator/=(), operator/=(), operator=(), and operator=().

## Member Function Documentation

## ◆ __rep()

template<typename _Tp>

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

Definition at line 263 of file complex.

## ◆ explicit()

template<typename _Tp>
template<typename _Up>

std::complex< _Tp >::explicit | ( | !requires(_Up __u) { _Tp{__u};} |  | ) | const &
| inline

Converting constructor.

Definition at line 175 of file complex.

## ◆ imag() [1/2]

template<typename _Tp>

_Tp std::complex< _Tp >::imag | ( |  | ) | const
| inlineconstexpr

Definition at line 189 of file complex.

## ◆ imag() [2/2]

template<typename _Tp>

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

Definition at line 214 of file complex.

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

template<typename _Tp>

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

Multiply this complex number by a scalar.

References complex().

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

template<typename _Tp>
template<typename _Up>

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

Multiply this complex number by another.

References complex().

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

template<typename _Tp>

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

Add a scalar to this complex number.

Definition at line 222 of file complex.

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

template<typename _Tp>
template<typename _Up>

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

Add another complex number to this one.

References complex().

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

template<typename _Tp>

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

Subtract a scalar from this complex number.

Definition at line 231 of file complex.

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

template<typename _Tp>
template<typename _Up>

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

Subtract another complex number from this one.

References complex().

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

template<typename _Tp>

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

Divide this complex number by a scalar.

References complex().

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

template<typename _Tp>
template<typename _Up>

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

Divide this complex number by another.

References complex().

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

template<typename _Tp>

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

Assign a scalar to this complex number.

References complex().

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

template<typename _Tp>
template<typename _Up>

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

Assign another complex number to this one.

References complex().

## ◆ real() [1/2]

template<typename _Tp>

_Tp std::complex< _Tp >::real | ( |  | ) | const
| inlineconstexpr

Definition at line 185 of file complex.

## ◆ real() [2/2]

template<typename _Tp>

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

Definition at line 211 of file complex.

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

- complex