Class Complex to represent complex numbers as a field.
More...

 Complex (double x=0.f, double y=0.f, bool is_polar=false) 
 Complex Constructor which initialises our complex number.


 Complex (const Complex &other) 
 Copy Constructor.


double  real () const 
 Member function to get real value of our complex number. Member function (getter) to access the class' re value.


double  imag () const 
 Member function to get imaginary value of our complex number. Member function (getter) to access the class' im value.


double  abs () const 
 Member function to give the modulus of our complex number. Member function to which gives the absolute value (modulus) of our complex number.


double  arg () const 
 Member function to give the argument of our complex number.


Complex  operator+ (const Complex &other) 
 Operator overload of '+' on Complex class. Operator overload to be able to add two complex numbers.


Complex  operator (const Complex &other) 
 Operator overload of '' on Complex class. Operator overload to be able to subtract two complex numbers.


Complex  operator* (const Complex &other) 
 Operator overload of '*' on Complex class. Operator overload to be able to multiple two complex numbers.


Complex  operator~ () const 
 Operator overload of '~' on Complex class. Operator overload of the BITWISE NOT which gives us the conjugate of our complex number. NOTE: This is overloading the BITWISE operator but its not a BITWISE operation in this definition.


Complex  operator/ (const Complex &other) 
 Operator overload of '/' on Complex class. Operator overload to be able to divide two complex numbers. This function would throw an exception if the other number is zero.


const Complex &  operator= (const Complex &other) 
 Operator overload of '=' on Complex class. Operator overload to be able to copy RHS instance of Complex to LHS instance of Complex.


Class Complex to represent complex numbers as a field.
◆ Complex() [1/2]
Complex::Complex 
( 
double  x = 0.f, 


double  y = 0.f, 


bool  is_polar = false ) 

inlineexplicit 
Complex Constructor which initialises our complex number.
Complex Constructor which initialises the complex number which takes three arguments.
 Parameters

x  If the third parameter is 'true' then this x is the absolute value of the complex number, if the third parameter is 'false' then this x is the real value of the complex number (optional). 
y  If the third parameter is 'true' then this y is the argument of the complex number, if the third parameter is 'false' then this y is the imaginary value of the complex number (optional). 
is_polar  'false' by default. If we want to initialise our complex number using polar form then set this to true, otherwise set it to false to use initialiser which initialises real and imaginary values using the first two parameters (optional). 
43 {
44 if (!is_polar) {
45 re = x;
46 im = y;
47 return;
48 }
49
52 }
◆ Complex() [2/2]
Complex::Complex 
( 
const Complex &  other  ) 


inline 
Copy Constructor.
 Parameters

other  The other number to equate our number to. 
58: re(other.
real()), im(other.
imag()) {}
double real() const
Member function to get real value of our complex number. Member function (getter) to access the class...
Definition complex_numbers.cpp:64
double imag() const
Member function to get imaginary value of our complex number. Member function (getter) to access the ...
Definition complex_numbers.cpp:70
◆ abs()
double Complex::abs 
( 
 ) 
const 

inline 
Member function to give the modulus of our complex number. Member function to which gives the absolute value (modulus) of our complex number.
 Returns
 \( \sqrt{z \bar{z}} \) where \( z \) is our complex number.
79 {
80 return std::sqrt(this>re * this>re + this>im * this>im);
81 }
◆ arg()
double Complex::arg 
( 
 ) 
const 

inline 
Member function to give the argument of our complex number.
 Returns
 Argument of our Complex number in radians.
◆ imag()
double Complex::imag 
( 
 ) 
const 

inline 
Member function to get imaginary value of our complex number. Member function (getter) to access the class' im value.
◆ operator*()
Operator overload of '*' on Complex class. Operator overload to be able to multiple two complex numbers.
 Parameters

other  The other number to multiply the current number to. 
 Returns
 result current number times other number.
117 {
119 this>re * other.im + this>im * other.re);
121 }
Class Complex to represent complex numbers as a field.
Definition complex_numbers.cpp:20
uint64_t result(uint64_t n)
Definition fibonacci_sum.cpp:76
◆ operator+()
Operator overload of '+' on Complex class. Operator overload to be able to add two complex numbers.
 Parameters

other  The other number that is added to the current number. 
 Returns
 result current number plus other number
◆ operator()
Operator overload of '' on Complex class. Operator overload to be able to subtract two complex numbers.
 Parameters

other  The other number being subtracted from the current number. 
 Returns
 result current number subtract other number
◆ operator/()
Operator overload of '/' on Complex class. Operator overload to be able to divide two complex numbers. This function would throw an exception if the other number is zero.
 Parameters

other  The other number we divide our number by. 
 Returns
 result Current number divided by other number.
142 {
144 double denominator =
146 if (denominator != 0) {
148 result.imag() / denominator);
150 } else {
152 }
153 }
Complex(double x=0.f, double y=0.f, bool is_polar=false)
Complex Constructor which initialises our complex number.
Definition complex_numbers.cpp:43
◆ operator=()
Operator overload of '=' on Complex class. Operator overload to be able to copy RHS instance of Complex to LHS instance of Complex.
160 {
161 this>re = other.
real();
162 this>im = other.
imag();
163 return *this;
164 }
◆ operator~()
Complex Complex::operator~ 
( 
 ) 
const 

inline 
Operator overload of '~' on Complex class. Operator overload of the BITWISE NOT which gives us the conjugate of our complex number. NOTE: This is overloading the BITWISE operator but its not a BITWISE operation in this definition.
 Returns
 result The conjugate of our complex number.
◆ real()
double Complex::real 
( 
 ) 
const 

inline 
Member function to get real value of our complex number. Member function (getter) to access the class' re value.
The documentation for this class was generated from the following file: