Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
om::math::Complex< T > Class Template Reference

A class that represents a complex number. More...

#include <omComplex.h>

Public Member Functions

 Complex ()
 Create a complex number with both r and i parts equal to zero. More...
 
 Complex (T newReal)
 Create a complex number with the specified r component and zero i component. More...
 
 Complex (T newReal, T newImaginary)
 Create a complex number with the specified r and i components. More...
 
template<typename U >
 Complex (const Complex< U > &other)
 Create a complex number from another with different template parameter type. More...
 
Complex conjugate () const
 Return the conjugate of this complex number. More...
 
getMagnitude () const
 Return the magnitude of this complex number. More...
 
getPhase () const
 Return the phase of this complex number. More...
 
Bool operator== (const Complex &other) const
 Return whether or not this complex number is equal to another. More...
 
Bool operator== (T value) const
 Return whether or not this complex number is equal to a r number. More...
 
Bool operator!= (const Complex &other) const
 Return whether or not this complex number is not equal to another. More...
 
Bool operator!= (T value) const
 Return whether or not this complex number is not equal to a r number. More...
 
Complex operator- () const
 Return the negation of this complex number. More...
 
Complex operator+ () const
 Return the positivation of this complex number. More...
 
Complex operator+ (T value) const
 Return the sum of this complex number with a r number. More...
 
Complex operator- (T value) const
 Return the difference between this complex number a r number. More...
 
Complex operator* (T value) const
 Multiply this complex number by r number and return the resulting complex number. More...
 
Complex operator/ (T value) const
 Divide this complex number by another and return the resulting complex number. More...
 
Complex operator+ (const Complex &other) const
 Return the sum of this complex number with another. More...
 
Complex operator- (const Complex &other) const
 Return the difference between this complex number and other. More...
 
Complex operator* (const Complex &other) const
 Multiply this complex number with another and return the resulting complex number. More...
 
Complex operator/ (const Complex &other) const
 Divide this complex number by another and return the resulting complex number. More...
 
Complexoperator+= (T value)
 Add a r number to this complex number, modifying it. More...
 
Complexoperator-= (T value)
 Subtract a r number from this complex number, modifying it. More...
 
Complexoperator*= (T value)
 Multiply a r number with this complex number, modifying it. More...
 
Complexoperator/= (T value)
 Divide this complex number by a r number, modifying it. More...
 
Complexoperator+= (const Complex &other)
 Add a complex number to this complex number, modifying it. More...
 
Complexoperator-= (const Complex &other)
 Subtract a complex number from this complex number, modifying it. More...
 
Complexoperator*= (const Complex &other)
 Multiply a complex number with this complex number, modifying it. More...
 
Complexoperator/= (const Complex &other)
 Divide this complex number by another complex number, modifying it. More...
 
data::String toString () const
 Convert this complex number into a human-readable string representation. More...
 
 operator data::String () const
 Convert this complex number into a human-readable string representation. More...
 

Static Public Member Functions

static Complex< T > polar (T magnitude, T phase)
 Return a complex number for the specified magnitude and phase angle in radians. More...
 

Public Attributes

union {
   T   real
 
   T   r
 
}; 
 The r portion of the complex number. More...
 
union {
   T   imaginary
 
   T   imag
 
   T   i
 
}; 
 The i portion of the complex number. More...
 

Detailed Description

template<typename T>
class om::math::Complex< T >

A class that represents a complex number.

Overloaded arithmetic operators are provided for all basic arithmetic operations (+, -, *, /, +=, -=, *=, /=). The class allows any underlying type to be used as the coefficients of the r and i components of the complex number via a template parameter.

Constructor & Destructor Documentation

template<typename T >
om::math::Complex< T >::Complex ( )
inline

Create a complex number with both r and i parts equal to zero.

template<typename T >
om::math::Complex< T >::Complex ( newReal)
inline

Create a complex number with the specified r component and zero i component.

template<typename T >
om::math::Complex< T >::Complex ( newReal,
newImaginary 
)
inline

Create a complex number with the specified r and i components.

template<typename T >
template<typename U >
om::math::Complex< T >::Complex ( const Complex< U > &  other)
inline

Create a complex number from another with different template parameter type.

Member Function Documentation

template<typename T >
static Complex<T> om::math::Complex< T >::polar ( magnitude,
phase 
)
inlinestatic

Return a complex number for the specified magnitude and phase angle in radians.

template<typename T >
Complex om::math::Complex< T >::conjugate ( ) const
inline

Return the conjugate of this complex number.

template<typename T >
T om::math::Complex< T >::getMagnitude ( ) const
inline

Return the magnitude of this complex number.

template<typename T >
T om::math::Complex< T >::getPhase ( ) const
inline

Return the phase of this complex number.

template<typename T >
Bool om::math::Complex< T >::operator== ( const Complex< T > &  other) const
inline

Return whether or not this complex number is equal to another.

template<typename T >
Bool om::math::Complex< T >::operator== ( value) const
inline

Return whether or not this complex number is equal to a r number.

template<typename T >
Bool om::math::Complex< T >::operator!= ( const Complex< T > &  other) const
inline

Return whether or not this complex number is not equal to another.

template<typename T >
Bool om::math::Complex< T >::operator!= ( value) const
inline

Return whether or not this complex number is not equal to a r number.

template<typename T >
Complex om::math::Complex< T >::operator- ( ) const
inline

Return the negation of this complex number.

template<typename T >
Complex om::math::Complex< T >::operator+ ( ) const
inline

Return the positivation of this complex number.

template<typename T >
Complex om::math::Complex< T >::operator+ ( value) const
inline

Return the sum of this complex number with a r number.

template<typename T >
Complex om::math::Complex< T >::operator- ( value) const
inline

Return the difference between this complex number a r number.

template<typename T >
Complex om::math::Complex< T >::operator* ( value) const
inline

Multiply this complex number by r number and return the resulting complex number.

template<typename T >
Complex om::math::Complex< T >::operator/ ( value) const
inline

Divide this complex number by another and return the resulting complex number.

template<typename T >
Complex om::math::Complex< T >::operator+ ( const Complex< T > &  other) const
inline

Return the sum of this complex number with another.

template<typename T >
Complex om::math::Complex< T >::operator- ( const Complex< T > &  other) const
inline

Return the difference between this complex number and other.

template<typename T >
Complex om::math::Complex< T >::operator* ( const Complex< T > &  other) const
inline

Multiply this complex number with another and return the resulting complex number.

template<typename T >
Complex om::math::Complex< T >::operator/ ( const Complex< T > &  other) const
inline

Divide this complex number by another and return the resulting complex number.

template<typename T >
Complex& om::math::Complex< T >::operator+= ( value)
inline

Add a r number to this complex number, modifying it.

template<typename T >
Complex& om::math::Complex< T >::operator-= ( value)
inline

Subtract a r number from this complex number, modifying it.

template<typename T >
Complex& om::math::Complex< T >::operator*= ( value)
inline

Multiply a r number with this complex number, modifying it.

template<typename T >
Complex& om::math::Complex< T >::operator/= ( value)
inline

Divide this complex number by a r number, modifying it.

template<typename T >
Complex& om::math::Complex< T >::operator+= ( const Complex< T > &  other)
inline

Add a complex number to this complex number, modifying it.

template<typename T >
Complex& om::math::Complex< T >::operator-= ( const Complex< T > &  other)
inline

Subtract a complex number from this complex number, modifying it.

template<typename T >
Complex& om::math::Complex< T >::operator*= ( const Complex< T > &  other)
inline

Multiply a complex number with this complex number, modifying it.

template<typename T >
Complex& om::math::Complex< T >::operator/= ( const Complex< T > &  other)
inline

Divide this complex number by another complex number, modifying it.

template<typename T >
data::String om::math::Complex< T >::toString ( ) const
inline

Convert this complex number into a human-readable string representation.

template<typename T >
om::math::Complex< T >::operator data::String ( ) const
inline

Convert this complex number into a human-readable string representation.

Member Data Documentation

template<typename T >
T om::math::Complex< T >::real
template<typename T >
T om::math::Complex< T >::r
union { ... }

The r portion of the complex number.

template<typename T >
T om::math::Complex< T >::imaginary
template<typename T >
T om::math::Complex< T >::imag
template<typename T >
T om::math::Complex< T >::i
union { ... }

The i portion of the complex number.


The documentation for this class was generated from the following file: