Theoretica
A C++ numerical and automatic mathematical library
|
Complex number in exponential form \(\rho e^{i \theta}\). More...
#include <phasor.h>
Public Member Functions | |
phasor () | |
Initialize as 0/0. | |
phasor (Type modulus, Type phase) | |
Initialize from two real numbers. | |
phasor (const phasor &other) | |
Initialize from another phasor. | |
template<typename T > | |
phasor (const complex< T > &z) | |
Construct a phasor from a complex number. | |
phasor (Type r) | |
Construct a phasor from a real number. | |
phasor & | operator= (const phasor &z) |
Assignment operator. | |
template<typename T > | |
phasor & | operator= (const std::array< T, 2 > &v) |
Assignment operator from a 2D array as {modulus, phase}. | |
Type | Re () const |
Get the real part of the complex number. | |
Type | Im () const |
Get the imaginary part of the complex number. | |
phasor | 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. | |
Type | inverse () const |
Compute the inverse of the complex number. | |
phasor & | invert () |
Invert the complex number. | |
Type | arg () const |
Get the argument of the complex number. | |
phasor | operator+ (const phasor &other) const |
Add two phasors. More... | |
phasor | operator- (const phasor &other) const |
Subtract two phasors. More... | |
phasor | operator* (const phasor &other) const |
Multiply two phasors. | |
template<typename T > | |
phasor | operator* (const complex< T > &other) const |
Multiply a complex number in algebraic form and a phasor. | |
phasor | operator/ (const phasor &other) const |
Divide two phasors. | |
phasor & | operator+= (const phasor &other) |
Add a phasor to this one. | |
phasor & | operator-= (const phasor &other) |
Subtract a phasor from this one. | |
phasor & | operator*= (const phasor &other) |
Multiply this phasor by another one. | |
phasor & | operator/= (const phasor &other) |
Divide this phasor by another one. | |
bool | operator== (const phasor &z) const |
Check whether two phasors are the same. | |
bool | operator!= (const phasor &z) const |
Check whether two phasors are not the same. | |
template<typename T = Type> | |
complex< T > | to_complex () const |
Transform a phasor to a complex number. | |
template<typename T > | |
operator complex< T > () | |
Cast to complex. | |
std::string | to_string (const std::string &separator=", ") const |
Convert the phasor to string representation. | |
operator std::string () | |
Convert the phasor to string representation. | |
Static Public Member Functions | |
static phasor | rotor (Type rad) |
Construct a phasor representing a rotation of <rad> radians in 2 dimensions. | |
static phasor | i () |
Imaginary unit in exponential form. | |
Public Attributes | |
Type | modulus |
Modulus of the complex number. | |
Type | phase |
Phase of the complex number. | |
Friends | |
Type | Re (const phasor &z) |
Extract the real part of the complex number. | |
Type | Im (const phasor &z) |
Extract the imaginary part of the complex number. | |
template<typename T > | |
phasor | operator* (const complex< T > &z, const phasor &w) |
Multiply a complex number in algebraic form and a phasor. | |
phasor | operator+ (Type r, const phasor &z) |
phasor | operator- (Type r, const phasor &z) |
phasor | operator* (Type r, const phasor &z) |
phasor | operator/ (Type r, const phasor &z) |
std::ostream & | operator<< (std::ostream &out, const phasor &obj) |
Stream the phasor in string representation to an output stream (std::ostream) | |
Complex number in exponential form \(\rho e^{i \theta}\).
|
inline |
Add two phasors.
|
inline |
Subtract two phasors.