Core 1.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
Complex Class Reference

Complex numbers. More...

#include <complex.h>

Public Member Functions

 Complex ()
 Empty, set complex to zero.
 
 Complex (const double &, const double &=0.0)
 Create a complex number. More...
 
constexpr double & operator[] (int)
 Overloaded. More...
 
constexpr const double & operator[] (int) const
 Overloaded.
 
Complex operator+ () const
 Overloaded.
 
Complex operator- () const
 Overloaded.
 
Complexoperator+= (const Complex &)
 Overloaded.
 
Complexoperator-= (const Complex &)
 Overloaded.
 
Complexoperator*= (const Complex &)
 Overloaded.
 
Complexoperator*= (const double &)
 Overloaded.
 
Complexoperator/= (const double &)
 Overloaded.
 
double Arg () const
 Returns the argument of a complex.
 
Complex Conj () const
 Computes the conjugate of a complex number.
 
int Escape (int=1024) const
 Compute the escape time in the Mandelbrot series. More...
 

Static Public Member Functions

static Complex Polar (const double &, const double &)
 Returns a complex given modulus and argument. More...
 

Protected Attributes

double y = 0.0
 Real and imaginary parts.
 

Friends

Complex operator+ (const Complex &, const Complex &)
 Adds two complex numbers.
 
Complex operator- (const Complex &, const Complex &)
 Subtract two complex numbers.
 
Complex operator* (const Complex &, const Complex &)
 Multiplies two complex numbers.
 
Complex operator* (const Complex &, const double &)
 Overloaded.
 
Complex operator* (const double &, const Complex &)
 Overloaded.
 
Complex operator/ (const Complex &, const double &)
 Overloaded.
 
Complex operator/ (const Complex &, const Complex &)
 Divide two complex numbers. More...
 
Complex operator/ (const double &, const Complex &)
 Compute the inverse of a complex number.
 
bool operator== (const Complex &, const Complex &)
 Overloaded.
 
bool operator!= (const Complex &, const Complex &)
 Overloaded.
 
double Norm (const Complex &)
 Returns the module of a complex.
 
void Normalize (Complex &)
 Normalize a complex. More...
 
Complex Sqrt (const Complex &)
 Computes the square root of a complex number. More...
 
std::ostream & operator<< (std::ostream &, const Complex &)
 Overloaded. More...
 

Detailed Description

Complex numbers.

All operators are overloaded to enable the writing of simple math expressions.

Constructor & Destructor Documentation

◆ Complex()

Complex::Complex ( const double &  a,
const double &  b = 0.0 
)
inlineexplicit

Create a complex number.

Parameters
a,bReal and imaginary parts.

Member Function Documentation

◆ Escape()

int Complex::Escape ( int  n = 1024) const

Compute the escape time in the Mandelbrot series.

Parameters
nMaximum number of iterations.

◆ operator[]()

constexpr double & Complex::operator[] ( int  i)
inlineconstexpr

Overloaded.

Returns either the real part or the imaginary part of a complex number.

◆ Polar()

Complex Complex::Polar ( const double &  r,
const double &  t 
)
inlinestatic

Returns a complex given modulus and argument.

Parameters
rModulus.
tArgument (in radian).

Friends And Related Function Documentation

◆ Normalize

void Normalize ( Complex z)
friend

Normalize a complex.

c/=Norm(c); // Equivalent
Complex numbers.
Definition: complex.h:11
friend double Norm(const Complex &)
Returns the module of a complex.
Definition: complex.h:207
Parameters
zComplex number.

◆ operator/

Complex operator/ ( const Complex u,
const Complex v 
)
friend

Divide two complex numbers.

Parameters
u,vArguments.

◆ operator<<

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

Overloaded.

Parameters
sStream.
complexThe complex.

◆ Sqrt

Complex Sqrt ( const Complex z)
friend

Computes the square root of a complex number.

Parameters
zComplex number.