TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Class Complex to represent complex numbers as a field. More...
Public Member Functions | |
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. | |
Private Attributes | |
double | re |
double | im |
Class Complex to represent complex numbers as a field.
Definition at line 20 of file complex_numbers.cpp.
|
inlineexplicit |
Complex Constructor which initialises our complex number.
Complex Constructor which initialises the complex number which takes three arguments.
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). |
Definition at line 43 of file complex_numbers.cpp.
|
inline |
Copy Constructor.
other | The other number to equate our number to. |
Definition at line 58 of file complex_numbers.cpp.
|
inline |
Member function to give the modulus of our complex number. Member function to which gives the absolute value (modulus) of our complex number.
Definition at line 79 of file complex_numbers.cpp.
|
inline |
Member function to give the argument of our complex number.
Definition at line 87 of file complex_numbers.cpp.
|
inline |
Member function to get imaginary value of our complex number. Member function (getter) to access the class' im value.
Definition at line 70 of file complex_numbers.cpp.
Operator overload of '*' on Complex class. Operator overload to be able to multiple two complex numbers.
other | The other number to multiply the current number to. |
Definition at line 117 of file complex_numbers.cpp.
Operator overload of '+' on Complex class. Operator overload to be able to add two complex numbers.
other | The other number that is added to the current number. |
Definition at line 95 of file complex_numbers.cpp.
Operator overload of '-' on Complex class. Operator overload to be able to subtract two complex numbers.
other | The other number being subtracted from the current number. |
Definition at line 106 of file complex_numbers.cpp.
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.
other | The other number we divide our number by. |
Definition at line 142 of file complex_numbers.cpp.
|
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.
Definition at line 130 of file complex_numbers.cpp.
|
inline |
Member function to get real value of our complex number. Member function (getter) to access the class' re value.
Definition at line 64 of file complex_numbers.cpp.
|
private |
Definition at line 24 of file complex_numbers.cpp.
|
private |
Definition at line 22 of file complex_numbers.cpp.