#include <complex.h>
A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers and i is the imaginary unit, that satisfies the equation x2 = -1, that is, i2 = -1.[1] In this expression, a is the real part and b is the imaginary part of the complex number.
Complex numbers extend the concept of the one-dimensional number line to the two-dimensional complex plane by using the horizontal axis for the real part and the vertical axis for the imaginary part. The complex number a + bi can be identified with the point (a, b) in the complex plane. A complex number whose real part is zero is said to be purely imaginary, whereas a complex number whose imaginary part is zero is a real number. In this way, the complex numbers contain the ordinary real numbers while extending them in order to solve problems that cannot be solved with real numbers alone.
Examples for using complex numbers are the famous Mandelbrot set or the Fourier Transform of a signal. In the latter case the imaginary part stores the phase information.
Public Member Functions | |
Complex () | |
MAXON_IMPLICIT | Complex (const T real) |
MAXON_IMPLICIT | Complex (const T real, const T imag) |
const Complex & | operator+= (const Complex &c) |
const Complex & | operator-= (const Complex &c) |
const Complex & | operator*= (const Complex &c) |
Complex | operator+ (const Complex &c) const |
Complex | operator- (const Complex &c) const |
Complex | operator* (const Complex &c) const |
Complex | operator* (const T s) const |
void | SetLength (const T len) |
void | SetPhase (const T phase) |
void | SetPolar (const T len, const T phase) |
void | SetExp (const T x) |
T | GetSquaredLength () const |
T | GetLength () const |
T | GetPhase () const |
Complex | GetNormalized () const |
Complex | GetConjugate () const |
Complex | GetSqrt () const |
Result< Complex > | GetLog () const |
Result< Complex > | GetDivision (const Complex &divisor) const |
String | ToString (const FormatStatement *formatStatement=nullptr) const |
MAXON_OPERATOR_EQUALITY_HASHCODE (Complex, real, imag) | |
Static Public Member Functions | |
static Result< void > | DescribeIO (const DataSerializeInterface &stream) |
Public Attributes | |
T | real |
T | imag |
Friends | |
Complex | operator* (const T s, const Complex &c) |
Complex | ( | const T | real | ) |
Creates a Complex initialized with given real and default ( = 0.0) imaginary values.
Complex | ( | const T | real, |
const T | imag | ||
) |
Creates a Complex initialized with given real and imaginary values.
void SetLength | ( | const T | len | ) |
Set polar length (magnitude) in the Argand plane.
void SetPhase | ( | const T | phase | ) |
Set polar phase (angle) in the Argand plane.
void SetPolar | ( | const T | len, |
const T | phase | ||
) |
Initialize Complex number by given polar coordinates.
void SetExp | ( | const T | x | ) |
set Complex number according to e^(i*x)
T GetSquaredLength |
Computes the squared magnitude/length/norm in the Argand plane.
T GetLength | ( | void | ) | const |
Computes the magnitude/length/norm in the Argand plane.
T GetPhase |
Computes the angle of the complex vector in the Argand plane.
Complex< T > GetNormalized |
Get a complex vector with normalized length in the Argand plane.
Complex< T > GetConjugate |
Get the complex conjugate of a complex vector
Complex< T > GetSqrt |
Compute the square root.
Compute the natural logarithm.
Divides the complex value by another complex value.
[in] | divisor | divisor |
String ToString | ( | const FormatStatement * | formatStatement = nullptr | ) | const |
Returns a readable string of the content.
[in] | formatStatement | Nullptr or additional formatting instruction. See also Formatting Floating point values. |
|
static |
Describe all elements of this class for I/O operations.
[in] | stream | The stream that is used to register the class members. |
T real |
real part
T imag |
imaginary part