name: SysComplex
synopsis:

>     g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_system.a

>     #include <SysComplex.h>

>     SysComplex();
>     SysComplex(const SysComplex& arg);
>     SysComplex(const SysComplex& arg);
>     TIntegral real() const;
>     TIntegral imag() const;
>     TIntegral mag() const;
>     TIntegral angle() const;
>     const SysComplex& operator += (const SysComplex& arg);
>     const SysComplex& operator -= (const SysComplex& arg);
>     const SysComplex& operator *= (const SysComplex& arg);
>     const SysComplex& operator /= (const SysComplex& arg);

quick start:

>     const SysComplex c0(4.0, 2.0);
>     const SysComplex c1(5);
>     float r1 = 5;

>     // complex addition
>     //
>     if ((c0 + c1) != SysComplex(9, 2)) {
>       Console::put(L"Error in complex addition");
>     }

>     // scalar addition
>     //
>     if ((c0 + r1) != SysComplex(9, 2)) {
>       Console::put(L"Error in scalar addition");
>     }

description:
The SysComplex class implements a complex numeric type. This class is introduced at this level so the mathematical functions defined in Integral can also be defined for complex numbers. A SysComplex number can be treated in code exactly as any other integral type due to the amount of functionality and number of operators defined in this class. This allows math templates to be built on top of this class with minimal modification.
The complex number functions defined below follow implementations given in:

R.V. Churchill, J.W. Brown, and R.F. Verhey, Complex Variables and Applications, Mc-Graw Hill, New York, New York, USA, 1976, pp. 52-71.

See Integral.h for implementations of mathematical functions. Several important standard complex data types, such as complexdouble, are defined in IntegralTypes.h using typdef's based on this class. These predefined types are an important part of our approach to provided easy to use complex number classes implemented in a way that is consistent with the real-valued scalar classes.
dependencies:

- none.

public constants:

- none.

error codes:

- none.

protected data:

- real component

      TIntegral real_d;

- imaginary component

      TIntegral imag_d;

required public methods:

- static methods: name method is omitted since this class acts like an Integral type. Diagnose method is in the SysComplexDiagnose class.
- debug methods: these methods are omitted since this class acts like an Integral type.
- destructor/constructor(s):

      ~SysComplex();

      SysComplex();

      SysComplex(const SysComplex& arg);

- assign methods: these methods are omitted since this class acts like an Integral type. Use the assignment operator overloads ("=") for this class.
- operator = (assignment) methods:

      SysComplex& operator = (const SysComplex& arg);

- i/o methods: these methods are omitted since this class acts like an Integral type. Use the complex scalar types in the math/scalar library for this functionality.
- equality methods: these methods are omitted since this class acts like an Integral type. Use the equality operator overloads ("==") for this class.
- memory management methods: these methods are omitted since this class acts like an Integral type. Use the complex scalar types in the math/scalar library for this functionality.

class-specific public methods:

- constructors:

      SysComplex(TIntegral real, TIntegral complex);

      SysComplex(double real);

- assign methods:

      bool assign(TIntegral real, TIntegral imag = 0);

- operator = (assignment) methods:

      SysComplex& operator = (TIntegral arg);

- cast operator () methods:

      operator SysComplex() const;

- methods to manipulate the representation of a complex number:

      TIntegral real() const;

      TIntegral imag() const;

      double mag() const;

      double angle() const;

- mathematical methods (with complex arguments):

      const SysComplex& operator += (const SysComplex& arg);

      const SysComplex& operator -= (const SysComplex& arg);

      const SysComplex& operator *= (const SysComplex& arg);

      const SysComplex& operator /=(const SysComplex& arg);

- mathematical methods (with real arguments):

      SysComplex& operator += (TIntegral arg);

      SysComplex& operator -= (TIntegral arg);

      SysComplex& operator *= (TIntegral arg);

      SysComplex& operator /= (TIntegral arg);

- mathematical methods (increment/decrement):

      SysComplex& operator ++ ();

      SysComplex& operator -- ();

      SysComplex operator ++ (int);

      SysComplex operator -- (int);

- relational methods (with complex arguments):

      bool operator == (const SysComplex& arg) const;

      bool operator != (const SysComplex& arg) const;

      bool operator < (const SysComplex& arg) const;

      bool operator > (const SysComplex& arg) const;

      bool operator <= (const SysComplex& arg) const;

      bool operator >= (const SysComplex& arg) const;

- relational methods (with real arguments):

      bool operator == (TIntegral arg) const;

      bool operator !=(TIntegral arg) const;

      bool operator < (TIntegral arg) const;

      bool operator > (TIntegral arg) const;

      bool operator <= (TIntegral arg) cons;

      bool operator >= (TIntegral arg) const;

- arithmetic methods (with two complex arguments):

      SysComplex operator + (const SysComplex& arg) const;

      SysComplex operator - (const SysComplex& arg) const;

      SysComplex operator * (const SysComplex& arg) const;

      SysComplex operator / (const SysComplex& arg) const;

- arithmetic methods (with one complex, one real arg):

      SysComplex operator + (const TIntegral arg) const;

      SysComplex operator - (const TIntegral arg) const;

      SysComplex operator * (const TIntegral arg) const;

      SysComplex operator / (const TIntegral arg) const;

      SysComplex inverse() const;

- miscellaneous complex methods:

      SysComplex conjugate() const;

      SysComplex polar(double mag, double angle);

- arithmetic methods (with one complex, one real arg): since the complex arg is to the right these cannot be member functions. For further explanations, see the notes section.

      SysComplex operator + (TIntegral x, const SysComplex& y);

      SysComplex operator - (TIntegral x, const SysComplex& y);

      SysComplex operator * (TIntegral x, const SysComplex& y);

      SysComplex operator / (TIntegral x, const SysComplex& y);

      SysComplex operator - (const SysComplex& x);

- relational methods (with TIntegral and complex types): since the complex arg is to the right these cannot be member functions. For further explanations, see the notes section.

      bool operator > (TIntegral x, const SysComplex& y);

      bool operator < (TIntegral x, const SysComplex& y);

      bool operator >= (TIntegral x, const SysComplex& y);

      bool operator <= (TIntegral x, const SysComplex& y);

private methods:

- method for faster comparisons than calling mag:

      TIntegral sumSquare() const;

examples:

- This is a simple example that demonstrates the complex addition and subtraction methods:

      # include <SysComplex.h>
      # include <Console.h>

      int main() {

        // declare SysComplex objects
        //
        const SysComplex c0(4.0, 2.0);
        const SysComplex c1(5);
        const SysComplex c2(0, 3.3);
        SysComplex t;
        float r1 = 5;

        // test complex addition
        //
        if ((c0 + c1) != SysComplex(9, 2)) {
         Console::put(L"Error in complex addition");
        }
        if ((c0 + c2) != SysComplex(4, 5.3)) {
         Console::put(L"Error in complex addition");
        }
        if ((c1 + c2) != SysComplex(5, 3.3)) {
         Console::put(L"Error in complex addition");
        }

        // test scalar addition
        //
        if ((c0 + r1) != SysComplex(9, 2)) {
         Console::put(L"Error in scalar addition");
        }
        if ((r1 + c2) != SysComplex(5, 3.3)) {
         Console::put(L"Error in scalar addition");
        }

        // test complex subtraction
        //
        if ((c0 - c1) != SysComplex(-1, 2)) {
         Console::put(L"Error in complex subtraction");
        }
        if ((c0 - c2) != SysComplex(4, -1.3)) {
         Console::put(L"Error in complex subtraction");
        }
        if ((c1 - c2) != SysComplex(5, -3.3)) {
         Console::put(L"Error in complex subtraction");
        }

        // test scalar subtraction
        //
        if ((c0 - r1) != SysComplex(-1, 2)) {
         Console::put(L"Error in scalar subtraction");
        }
        if ((r1 - c2) != SysComplex(5, -3.3)) {
         Console::put(L"Error in scalar subtraction");
        }
      }

notes:

- This class, as with most System classes, is not intended to be used directly by programmers. The Math scalar class ComplexFloat is an example of a higher-level class intended for users.
- The arithmetic operator overloads that appear at the end of this header file are provided so that mixed type operations can be performed (for example, "x * y" where x is float and y is complex). Since the complex argument is on the right, to implement these, we needed to define global functions (in this case, templatized operator overloads). Hence, these appear outside the class definition, but are included in this header file for obvious reasons.