Base Framework
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Related Functions | List of all members
Complex< TYPE > Class Template Reference

Complex number. More...

#include <base/math/Complex.h>

Classes

class  Imaginary
 
class  Polar
 

Public Types

typedef TYPE Type
 

Public Member Functions

 Complex () noexcept
 
 Complex (Type real) noexcept
 
 Complex (Type real, Type imaginary) noexcept
 
 Complex (const Polar &polar) noexcept
 
 Complex (const Complex &copy) noexcept
 
Complexoperator= (const Complex &assign) noexcept
 
Complexoperator= (Type real) noexcept
 
Type getReal () const noexcept
 
Type getImaginary () const noexcept
 
void setReal (const Type value) noexcept
 
void setImaginary (const Type value) noexcept
 
Type getSqrModulus () const noexcept
 
Polar getPolar () const noexcept
 
Type getModulus () const noexcept
 
Type getAngle () const noexcept
 
Complex plus () const noexcept
 
Complex minus () const noexcept
 
Complex negate () const noexcept
 
Complex conjugate () const noexcept
 
Complex invert () const noexcept
 
bool operator== (const Complex &value) const noexcept
 
bool operator!= (const Complex &value) const noexcept
 
Complexoperator+= (const Complex &value) noexcept
 
Complexoperator+= (const Imaginary) noexcept
 
Complexoperator-= (const Complex &value) noexcept
 
Complexoperator-= (const Imaginary) noexcept
 
Complexoperator*= (const Complex &value) noexcept
 
Complexoperator*= (Type value) noexcept
 
Complexoperator*= (const Imaginary) noexcept
 
Complexoperator/= (Type divisor) noexcept
 
Complexoperator/= (const Complex &divisor) noexcept
 
Complexoperator/= (const Imaginary) noexcept
 
Complex operator+ () const noexcept
 
Complex operator- () const noexcept
 

Static Public Member Functions

static Complex sqrt (const Complex &x) noexcept
 
static Complex exp (const Complex &x) noexcept
 
static Complex ln (const Complex &x) noexcept
 
static Complex pow (const Type x, const Complex &y) noexcept
 
static Complex sin (const Complex &x) noexcept
 
static Complex asin (const Complex &x) noexcept
 
static Complex cos (const Complex &x) noexcept
 
static Complex acos (const Complex &x) noexcept
 
static Complex tan (const Complex &x) noexcept
 
static Complex atan (const Complex &x) noexcept
 
static Complex sinh (const Complex &x) noexcept
 
static Complex asinh (const Complex &x) noexcept
 
static Complex cosh (const Complex &x) noexcept
 
static Complex acosh (const Complex &x) noexcept
 
static Complex tanh (const Complex &x) noexcept
 
static Complex atanh (const Complex &x) noexcept
 

Public Attributes

Type real = 0
 
TYPE imaginary = 0
 

Static Public Attributes

static const Imaginary I
 
static const Complex ZERO
 
static const Complex ONE
 
static const Complex MINUS_ONE
 
static const Complex II
 
static constexpr Type _ONE = 1
 

Related Functions

(Note that these are not member functions.)

template<typename TYPE >
FormatOutputStreamoperator<< (FormatOutputStream &stream, const Complex< TYPE > &value)
 

Detailed Description

template<typename TYPE>
class Complex< TYPE >

Complex number.

Complex number represented by real and imaginary parts.

Constructor & Destructor Documentation

◆ Complex() [1/4]

template<typename TYPE >
Complex< TYPE >::Complex ( )
inlinenoexcept

Initializes complex number as (0, 0).

◆ Complex() [2/4]

template<typename TYPE >
Complex< TYPE >::Complex ( Type  real)
inlinenoexcept

Initializes complex number with the specified real part. The imaginary part is initialized to zero.

Parameters
realThe real part.

◆ Complex() [3/4]

template<typename TYPE >
Complex< TYPE >::Complex ( Type  real,
Type  imaginary 
)
inlinenoexcept

Initializes complex number of the specified real and imaginary parts.

Parameters
realThe desired real part.
imaginaryThe desired imaginary part.

◆ Complex() [4/4]

template<typename TYPE >
Complex< TYPE >::Complex ( const Complex< TYPE > &  copy)
inlinenoexcept

Initializes complex number of other complex number.

Member Function Documentation

◆ conjugate()

template<typename TYPE >
Complex Complex< TYPE >::conjugate ( ) const
inlinenoexcept

Conjugates this number.

◆ getAngle()

template<typename TYPE >
Type Complex< TYPE >::getAngle ( ) const
inlinenoexcept

Returns the angle of the complex number.

◆ getImaginary()

template<typename TYPE >
Type Complex< TYPE >::getImaginary ( ) const
inlinenoexcept

Returns the imaginary part of the complex number.

◆ getModulus()

template<typename TYPE >
Type Complex< TYPE >::getModulus ( ) const
inlinenoexcept

Returns the modulus of the complex number.

◆ getReal()

template<typename TYPE >
Type Complex< TYPE >::getReal ( ) const
inlinenoexcept

Returns the real part of the complex number.

◆ getSqrModulus()

template<typename TYPE >
Type Complex< TYPE >::getSqrModulus ( ) const
inlinenoexcept

Returns the square of the modulus of the complex number.

◆ invert()

template<typename TYPE >
Complex Complex< TYPE >::invert ( ) const
inlinenoexcept

Inverts this number.

◆ minus()

template<typename TYPE >
Complex Complex< TYPE >::minus ( ) const
inlinenoexcept

Unary minus.

◆ negate()

template<typename TYPE >
Complex Complex< TYPE >::negate ( ) const
inlinenoexcept

Negates this number.

◆ operator*=() [1/3]

template<typename TYPE >
Complex& Complex< TYPE >::operator*= ( const Complex< TYPE > &  value)
inlinenoexcept

Multiplies this number with the specified value.

Parameters
valueThe multiplicator.

◆ operator*=() [2/3]

template<typename TYPE >
Complex& Complex< TYPE >::operator*= ( const  Imaginary)
inlinenoexcept

Multiplies this number with the specified value.

Parameters
valueThe multiplicator.

◆ operator*=() [3/3]

template<typename TYPE >
Complex& Complex< TYPE >::operator*= ( Type  value)
inlinenoexcept

Multiplies this number with the specified value.

Parameters
valueThe multiplicator.

◆ operator+()

template<typename TYPE >
Complex Complex< TYPE >::operator+ ( ) const
inlinenoexcept

Unary plus.

◆ operator+=() [1/2]

template<typename TYPE >
Complex& Complex< TYPE >::operator+= ( const Complex< TYPE > &  value)
inlinenoexcept

Adds the specified number to this number.

Parameters
valueThe value to be added.

◆ operator+=() [2/2]

template<typename TYPE >
Complex& Complex< TYPE >::operator+= ( const  Imaginary)
inlinenoexcept

Adds the specified number to this number.

Parameters
valueThe value to be added.

◆ operator-()

template<typename TYPE >
Complex Complex< TYPE >::operator- ( ) const
inlinenoexcept

Unary minus.

◆ operator-=() [1/2]

template<typename TYPE >
Complex& Complex< TYPE >::operator-= ( const Complex< TYPE > &  value)
inlinenoexcept

Subtracts the specified complex from this number.

Parameters
valueThe value to be subtracted.

◆ operator-=() [2/2]

template<typename TYPE >
Complex& Complex< TYPE >::operator-= ( const  Imaginary)
inlinenoexcept

Subtracts the specified complex from this number.

Parameters
valueThe value to be subtracted.

◆ operator/=() [1/2]

template<typename TYPE >
Complex& Complex< TYPE >::operator/= ( const Complex< TYPE > &  divisor)
inlinenoexcept

Divides this number with the specified value.

Parameters
valueThe divisor.

◆ operator/=() [2/2]

template<typename TYPE >
Complex& Complex< TYPE >::operator/= ( Type  divisor)
inlinenoexcept

Divides this number with the specified value.

Parameters
valueThe divisor.

◆ operator=() [1/2]

template<typename TYPE >
Complex& Complex< TYPE >::operator= ( const Complex< TYPE > &  assign)
inlinenoexcept

Assignment of complex number by complex number.

◆ operator=() [2/2]

template<typename TYPE >
Complex& Complex< TYPE >::operator= ( Type  real)
inlinenoexcept

Assignment of complex number by real number.

◆ operator==()

template<typename TYPE >
bool Complex< TYPE >::operator== ( const Complex< TYPE > &  value) const
inlinenoexcept

Returns true if the numbers are equal.

Parameters
valueComplex number to be compared.

◆ plus()

template<typename TYPE >
Complex Complex< TYPE >::plus ( ) const
inlinenoexcept

Unary plus.

◆ setImaginary()

template<typename TYPE >
void Complex< TYPE >::setImaginary ( const Type  value)
inlinenoexcept

Sets the imaginary part of the complex number.

◆ setReal()

template<typename TYPE >
void Complex< TYPE >::setReal ( const Type  value)
inlinenoexcept

Sets the real part of the complex number.

Friends And Related Function Documentation

◆ operator<<()

template<typename TYPE >
FormatOutputStream & operator<< ( FormatOutputStream stream,
const Complex< TYPE > &  value 
)
related

Writes a string representation of the complex number to a format stream "(real[+-]imaginaryi)".

Member Data Documentation

◆ I

template<typename TYPE >
const Imaginary Complex< TYPE >::I
static

Imaginary symbol. Use for faster math operations.

◆ II

template<typename TYPE >
const Complex Complex< TYPE >::II
static

Complex number 1i.

◆ imaginary

template<typename TYPE >
TYPE Complex< TYPE >::imaginary = 0

The imaginary part the complex number.

◆ MINUS_ONE

template<typename TYPE >
const Complex Complex< TYPE >::MINUS_ONE
static

Complex number -1.

◆ ONE

template<typename TYPE >
const Complex Complex< TYPE >::ONE
static

Complex number 1.

◆ real

template<typename TYPE >
Type Complex< TYPE >::real = 0

The real part of the complex number.

◆ ZERO

template<typename TYPE >
const Complex Complex< TYPE >::ZERO
static

Complex number 0.