|
Theoretica
Mathematical Library
|
Complex number in algebraic form \(a + ib\). More...
#include <complex.h>
Public Member Functions | |
| complex () | |
| Default constructor, initializes the number to zero. | |
| complex (Type real_part, Type imag_part) | |
| Construct a complex number from its real and complex parts. | |
| complex (Type real_part) | |
| Construct a complex number from a real number, with zero imaginary part. | |
| complex (const complex &z) | |
| Copy constructor. | |
| complex & | operator= (const complex &z) |
| Assignment operator. | |
| template<typename T = Type> | |
| complex & | operator= (const std::array< T, 2 > &v) |
| Assignment operator from a 2D array. | |
| Type | Re () const |
| Get the real part of the complex number. | |
| Type & | Re () |
| Get the real part of the complex number. | |
| Type | Im () const |
| Get the imaginary part of the complex number. | |
| Type & | Im () |
| Get the imaginary part of the complex number. | |
| complex | conjugate () const |
| Compute the conjugate of the complex number. | |
| Type | sqr_norm () const |
| Compute the square norm of the complex number. | |
| Type | norm () const |
| Compute the norm of the complex number. | |
| complex | inverse () const |
| Compute the inverse of the complex number. | |
| complex & | invert () |
| Invert the complex number. | |
| Type | arg () const |
| Get the argument of the complex number. | |
| complex | operator+ () const |
| Identity (for consistency) | |
| complex | operator+ (const complex &z) const |
| Add two complex numbers. | |
| complex | operator- () const |
| Get the opposite of the complex number. | |
| complex | operator- (const complex &z) const |
| Subtract two complex numbers. | |
| complex | operator* (const complex &z) const |
| Multiply two complex numbers. | |
| complex | operator/ (const complex &z) const |
| Divide two complex numbers. | |
| complex & | operator+= (const complex &z) |
| Add a complex number to this one. | |
| complex & | operator-= (const complex &z) |
| Subtract a complex number from this one. | |
| complex & | operator*= (const complex &z) |
| Multiply the complex number by another. | |
| complex & | operator/= (const complex &z) |
| Divide the complex number by another. | |
| complex | operator+ (Type k) const |
| Add a real number to the complex number. | |
| complex | operator- (Type k) const |
| Subtract a real number from the complex number. | |
| complex | operator* (Type k) const |
| Multiply the complex number by a real number. | |
| complex | operator/ (Type k) const |
| Divide the complex number by a real number. | |
| complex & | operator+= (Type k) |
| Add a real number to the complex number. | |
| complex & | operator-= (Type k) |
| Subtract a real number from the complex number. | |
| complex & | operator*= (Type k) |
| Multiply the complex number by a real number. | |
| complex & | operator/= (Type k) |
| Divide the complex number by a real number. | |
| bool | operator== (const complex &z) const |
| Check whether two complex numbers are the same. | |
| bool | operator!= (const complex &z) const |
| Check whether two complex numbers are not the same. | |
| operator real () | |
| Narrowing cast to a real number. | |
| std::string | to_string () const |
| Convert the complex number to string representation. | |
| operator std::string () | |
| Convert the complex number to string representation. | |
Static Public Member Functions | |
| static complex | rotor (Type rad) |
| Construct a complex number representing a rotation of <rad> radians in 2 dimensions. | |
| static complex | i () |
| Imaginary unit. | |
Public Attributes | |
| Type | a |
| Real part. | |
| Type | b |
| Imaginary part. | |
Friends | |
| Type | Re (const complex &z) |
| Extract the real part of the complex number. | |
| Type & | Re (complex &z) |
| Extract the real part of the complex number. | |
| Type | Im (const complex &z) |
| Extract the imaginary part of the complex number. | |
| Type & | Im (complex &z) |
| Extract the imaginary part of the complex number. | |
| std::ostream & | operator<< (std::ostream &out, const complex &obj) |
| Stream the complex number in string representation to an output stream (std::ostream) | |
Complex number in algebraic form \(a + ib\).
|
inline |
Narrowing cast to a real number.
If the imaginary part is greater in module than the machine epsilon, NaN is returned.