This template union represents complex number.
You can find more information in comments below.
template<class TYPE>
union TComplex
{
struct
{
TYPE Re; // Real part
TYPE Im; // Imaginary part
};
TYPE Data[2]; // Real and imaginary parts
const TYPE &operator[](const int index) const; // Return const reference to the part specified by index. 0 and 1 can be used only
TYPE &operator[](const int index); // Return reference to the part specified by index. 0 and 1 can be used only
};
Additionally following comparison(available for non-float types only) and arithmetic(available for arithmetic types only) operators exists.
template<class TYPE>
bool operator==(const TComplex<TYPE> &a, const TComplex<TYPE> &b) // Strict comparison with another complex number for equality
template<class TYPE>
bool operator!=(const TComplex<TYPE> &a, const TComplex<TYPE> &b) // Strict comparison with another complex number for inequality
template<class TYPE>
TComplex<TYPE>operator+(const TComplex<TYPE> &a, const TYPE &value) // Add complex and real values
template<class TYPE>
TComplex<TYPE> operator-(const TComplex<TYPE> &a, const TYPE &value) // Subtract real value from complex
template<class TYPE>
TComplex<TYPE> operator*(const TComplex<TYPE> &a, const TYPE &value) // Multiply complex and real values
template<class TYPE>
TComplex<TYPE> operator/(const TComplex<TYPE> &a, const TYPE &value) // Divide complex value by real one
template<class TYPE>
TComplex<TYPE> &operator+=(TComplex<TYPE> &a, const TYPE &value) // Add real value to complex one
template<class TYPE>
TComplex<TYPE> &operator-=(TComplex<TYPE> &a, const TYPE &value) // Subtract real value from complex one
template<class TYPE>
TComplex<TYPE> &operator*=(TComplex<TYPE> &a, const TYPE &value) // Multiply complex value by real one
template<class TYPE>
TComplex<TYPE> &operator/=(TComplex<TYPE> &a, const TYPE &value) // Divide complex value by real one
template<class TYPE>
TComplex<TYPE> operator+(const TYPE &value, const TComplex<TYPE> &a) // Add real and complex values
template<class TYPE>
TComplex<TYPE> operator-(const TYPE &value, const TComplex<TYPE> &a) // Subtract complex value from real one
template<class TYPE>
TComplex<TYPE> operator*(const TYPE &value, const TComplex<TYPE> &a) // Multiply real and complex values
template<class TYPE>
TComplex<TYPE> operator/(const TYPE &value, const TComplex<TYPE> &a) // Divide real value by complex one
template<class TYPE>
TComplex<TYPE> operator+(const TComplex<TYPE> &a, const TComplex<TYPE> &b) // Add complex numbers
template<class TYPE>
TComplex<TYPE> operator-(const TComplex<TYPE> &a, const TComplex<TYPE> &b) // Subtract complex numbers
template<class TYPE>
TComplex<TYPE> operator*(const TComplex<TYPE> &a, const TComplex<TYPE> &b) // Multiply complex numbers
template<class TYPE>
TComplex<TYPE> operator/(const TComplex<TYPE> &a, const TComplex<TYPE> &b) // Divide complex numbers
template<class TYPE>
TComplex<TYPE> &operator+=(TComplex<TYPE> &a, const TComplex<TYPE> &b) // Add second complex number to first one
template<class TYPE>
TComplex<TYPE> &operator-=(TComplex<TYPE> &a, const TComplex<TYPE> &b) // Subtract second complex number from first one
template<class TYPE>
TComplex<TYPE> &operator*=(TComplex<TYPE> &a, const TComplex<TYPE> &b) // Multiply first complex number by second one
template<class TYPE>
TComplex<TYPE> &operator/=(TComplex<TYPE> &a, const TComplex<TYPE> &b) // Divide first complex number by second one
template<class TYPE>
TComplex<TYPE> operator-(const TComplex<TYPE> &a) // Inverse complex value
Also there are some functions which can be used with TComplex template. Here they are.
Namespace: | ntl |
Include: | NTL/Core/Bitmap.h |