TComplex


This object has been removed in release 10.0.0. Use NTL objects instead.

This template represent complex numbers.

Some operators(like division) and methods(like argument()) may not be appliable for some complex number. You must check this before using such operators and methods.

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 
        bool operator==(const TComplex &other) const; // Strict comparison with another complex number for equality 
        bool operator!=(const TComplex &other) const; // Strict comparison with another complex number for inequality 
    
        TComplex operator+(const TComplex &other) const; // Add complex numbers 
        TComplex operator-(const TComplex &other) const; // Subtract complex numbers 
        TComplex operator*(const TComplex &other) const; // Multiply complex numbers 
        TComplex operator/(const TComplex &other) const; // Divide complex numbers 
        TComplex operator+=(const TComplex &other); // Add another complex number to this one 
        TComplex operator-=(const TComplex &other); // Subtract another complex number from this one 
        TComplex operator*=(const TComplex &other); // Multiply this complex number on another one 
        TComplex operator/=(const TComplex &other); // Divide this complex number on another one 
    
        template<class DEST_TYPE> TComplex<DEST_TYPE> convert() const; // Return complex with the same components but different data type 
        template<class DEST_TYPE> void convert(TComplex<DEST_TYPE> &dest) const; // Copy elements into the destination complex converting them to new data type 
        bool has_re(const TYPE tolerance) const; // Check whether real part is not equal to zero with specified tolerance 
        bool has_im(const TYPE tolerance) const; // Check whether imaginary part is not equal to zero with specified tolerance 
        bool is_equal(const TComplex &other, const TYPE tolerance) const; // Soft comparison with another complex number for equality 
        bool is_not_equal(const TComplex &other, const TYPE tolerance) const; // Soft comparison with another complex number for inequality 
        TYPE modulus() const; // Return modulus 
        TYPE argument() const; // Return argument 
    };
Namespace: nitisa::math
Include: Nitisa/Modules/Math/Complex.h