TBTK
Need a break? Support the development by playing Polarity Puzzles
TBTK::Complex Class Reference

Complex number. More...

#include <Complex.h>

Inheritance diagram for TBTK::Complex:
TBTK::PseudoSerializable

Public Member Functions

 Complex ()
 
constexpr Complex (std::complex< double > value)
 
constexpr Complex (Real real, Real imag)
 
constexpr Complex (double value)
 
 Complex (const std::string &serialization, Serializable::Mode mode)
 
constexpr operator std::complex< double > () const
 
Complexoperator= (const std::complex< double > &rhs)
 
Complexoperator+= (const Complex &rhs)
 
Complexoperator-= (const Complex &rhs)
 
Complex operator- (const Complex &rhs) const
 
Complex operator- () const
 
Complexoperator*= (const Complex &rhs)
 
Complexoperator/= (const Complex &rhs)
 
Boolean operator== (const Complex &rhs) const
 
Boolean operator!= (const Complex &rhs) const
 
std::string serialize (Serializable::Mode mode) const
 

Friends

std::complex< double > & operator+= (std::complex< double > &lhs, const Complex &rhs)
 
Complex operator+ (const Complex &lhs, const double &rhs)
 
Complex operator+ (const double &lhs, const Complex &rhs)
 
Complex operator- (const Complex &lhs, const double &rhs)
 
Complex operator- (const double &lhs, const Complex &rhs)
 
Complex operator* (const Complex &lhs, const double &rhs)
 
Complex operator* (const double &lhs, const Complex &rhs)
 
Complex operator/ (const Complex &lhs, const double &rhs)
 
std::ostream & operator<< (std::ostream &os, const Complex &complex)
 
std::istream & operator>> (std::istream &is, Complex &complex)
 
constexpr friend Real real (const Complex &complex)
 
constexpr friend Real imag (const Complex &complex)
 
Complex conj (const Complex &complex)
 
Real abs (const Complex &complex)
 

Detailed Description

Complex number.

Constructor & Destructor Documentation

◆ Complex() [1/5]

TBTK::Complex::Complex ( )
inline

Constructor.

◆ Complex() [2/5]

constexpr TBTK::Complex::Complex ( std::complex< double >  value)
inlineconstexpr

Constructor.

Parameters
valueThe value to initilize the Complex with.

◆ Complex() [3/5]

constexpr TBTK::Complex::Complex ( Real  real,
Real  imag 
)
inlineconstexpr

Constructor.

Parameters
valueThe value to initilize the Complex with.

◆ Complex() [4/5]

constexpr TBTK::Complex::Complex ( double  value)
inlineconstexpr

Constructor.

Parameters
valueThe value to initilize the Complex with.

◆ Complex() [5/5]

TBTK::Complex::Complex ( const std::string &  serialization,
Serializable::Mode  mode 
)
inline

Constructs an Index from a serialization string.

Parameters
serializationSerialization string from which to construct the Complex.
modeMode with which the string has been serialized.

Member Function Documentation

◆ operator std::complex< double >()

constexpr TBTK::Complex::operator std::complex< double > ( ) const
inlineconstexpr

Type conversion operator.

◆ operator!=()

Boolean TBTK::Complex::operator!= ( const Complex rhs) const
inline

Not equal operator.

Parameters
rhsThe right hand side.
Returns
False if the two Complex numbers are equal, otherwise true.

◆ operator*=()

Complex& TBTK::Complex::operator*= ( const Complex rhs)
inline

Multiplication assignment operator.

Parameters
rhsThe right hand side.
Returns
The Complex after the multiplication has occured.

◆ operator+=()

Complex& TBTK::Complex::operator+= ( const Complex rhs)
inline

Addition assignment operator.

Parameters
rhsThe right hand side.
Returns
The Complex after the addition has occured.

◆ operator-() [1/2]

Complex TBTK::Complex::operator- ( ) const
inline

Unary minus operator.

Returns
The negative of the Complex number.

◆ operator-() [2/2]

Complex TBTK::Complex::operator- ( const Complex rhs) const
inline

Subtraction operator.

Parameters
rhsThe right hand side.
Returns
The result of the subtraction.

◆ operator-=()

Complex& TBTK::Complex::operator-= ( const Complex rhs)
inline

Subtraction assignment operator.

Parameters
rhsThe right hand side.
Returns
The Complex after the subtraction has occured.

◆ operator/=()

Complex& TBTK::Complex::operator/= ( const Complex rhs)
inline

Division assignment operator.

Parameters
rhsThe right hand side.
Returns
The Complex after the division has occured.

◆ operator=()

Complex& TBTK::Complex::operator= ( const std::complex< double > &  rhs)
inline

Assignment operator.

Parameters
valueThe value to assign the Complex.
Returns
The Complex after assignment has occured.

◆ operator==()

Boolean TBTK::Complex::operator== ( const Complex rhs) const
inline

Comparison operator.

Parameters
rhsThe right hand side.
Returns
True if the two Complex numbers are equal, otherwise false.

◆ serialize()

std::string TBTK::Complex::serialize ( Serializable::Mode  mode) const
inline

Serialize Complex. Note that Complex is PseudoSerializable rather than Serializable. This means that the Serializable interface is implemented non-virtually.

Parameters
modeSerialization mode.
Returns
Serialized string representation of the Complex.

Friends And Related Function Documentation

◆ abs

Real abs ( const Complex complex)
friend

Absolute value.

Parameters
complexThe Complex number.
Returns
The absolute value.

◆ conj

Complex conj ( const Complex complex)
friend

Complex conjugate.

Parameters
complexThe Complex number.
Returns
The complex conjugate.

◆ imag

constexpr friend Real imag ( const Complex complex)
friend

Get the imaginary part.

Parameters
complexThe Complex number.
Returns
The imaginary part.

◆ operator* [1/2]

Complex operator* ( const Complex lhs,
const double &  rhs 
)
friend

Multiplication operator.

Parameters
lhsThe left hand side.
rhsThe right hand side.
Returns
The result of the multiplication.

◆ operator* [2/2]

Complex operator* ( const double &  lhs,
const Complex rhs 
)
friend

Multiplication operator.

Parameters
lhsThe left hand side.
rhsThe right hand side.
Returns
The result of the multiplication.

◆ operator+ [1/2]

Complex operator+ ( const Complex lhs,
const double &  rhs 
)
friend

Addition operator.

Parameters
lhsThe left hand side.
rhsThe right hand side.
Returns
The result of the addition.

◆ operator+ [2/2]

Complex operator+ ( const double &  lhs,
const Complex rhs 
)
friend

Addition operator.

Parameters
lhsThe left hand side.
rhsThe right hand side.
Returns
The result of the addition.

◆ operator+=

std::complex<double>& operator+= ( std::complex< double > &  lhs,
const Complex rhs 
)
friend

Addition assignment operator.

Parameters
lhsThe left hand side.
rhsThe right hand side.
Returns
The left hand side after the addition has occured.

◆ operator- [1/2]

Complex operator- ( const Complex lhs,
const double &  rhs 
)
friend

Subtraction operator.

Parameters
lhsThe left hand side.
rhsThe right hand side.
Returns
The result of the subtraction.

◆ operator- [2/2]

Complex operator- ( const double &  lhs,
const Complex rhs 
)
friend

Subtraction operator.

Parameters
lhsThe left hand side.
rhsThe right hand side.
Returns
The result of the subtraction.

◆ operator/

Complex operator/ ( const Complex lhs,
const double &  rhs 
)
friend

Division operator.

Parameters
rhsThe right hand side.
Returns
The result of the division.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Complex complex 
)
friend

ostream operator.

Parameters
osThe ostream to write to.
complexThe Complex to write.
Returns
The ostream.

◆ operator>>

std::istream& operator>> ( std::istream &  is,
Complex complex 
)
friend

istream operator.

Parameters
isThe istream to read from.
complexThe Complex to read to.
Returns
The istream.

◆ real

constexpr friend Real real ( const Complex complex)
friend

Get the real part.

Parameters
complexThe Complex number.
Returns
The real part.

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