# Complex Data Type

The Complex data type in MLDesigner contains real and imaginary components, each of them is specified as a double precision floating-point number.

The notation used to represent a complex number is a two number pair (real, imaginary) - for example, (1.3,-4.5) corresponds to the complex number 1.3 - 4.5j. Complex implements a subset of the functionality of the complex number classes in the cfront and libg++ libraries, including most of the standard arithmetic operators and a few transcendental functions.

## Constructors

Complex()

Create a complex number, initialized with zero (0.0, 0.0). For example:
Complex c;

Complex(double real, double imag)

Create a complex number with the value (real, imag). For example:
Complex c(1.3,-4.5);

Complex(const Complex& arg)

Create a complex number which is identical to the complex number arg. For example:
Complex c(complexSourceNumber);

## Basic Operators

The following list of arithmetic operators modify the value of the complex number. All functions return a reference to the modified complex number (*this).

Complex& operator =  (const Complex& arg)
Complex& operator += (const Complex& arg)
Complex& operator -= (const Complex& arg)
Complex& operator *= (const Complex& arg)
Complex& operator /= (const Complex& arg)
Complex& operator *= (double arg)
Complex& operator /= (double arg)

These two operators return the real and imaginary parts of the complex number:

double real() const
double imag() const

## Non-member functions and operators

The following unary and binary operators return a new complex number:

Complex operator + (const Complex& x, const Complex& y)
Complex operator - (const Complex& x, const Complex& y)
Complex operator * (const Complex& x, const Complex& y)
Complex operator * (double x, const Complex& y)
Complex operator * (const Complex& x, double y)
Complex operator / (const Complex& x, const Complex& y)
Complex operator / (const Complex& x, double y)
Complex operator - (const Complex& x)
Complex conj (const Complex& x)
Complex sin(const Complex& x)
Complex cos(const Complex& x)
Complex exp(const Complex& x)
Complex log(const Complex& x)
Complex sqrt(const Complex& x)
Complex pow(double base, const Complex& expon)
Complex pow(const Complex& base, const Complex& expon)

## Other general operators

double abs(const Complex& x)

Return the absolute value, defined as the square root of the norm.

double arg(const Complex& x)

Return the value defined by arctan(x.imag()/x.real()).

double norm(const Complex& x)

Return the value x.real() * x.real() + x.imag() * x.imag().

double real(const Complex& x)

Return the real part of the complex number.

double imag(const Complex& x)

Return the imaginary part of the complex number.

## Comparison Operators

int operator != (const Complex& x, const Complex& y)
int operator == (const Complex& x, const Complex& y)