Facebook Twitter YouTube

class Complex

Defined in:  TSComplex.h
The Complex class encapsulates a complex number.
Definition

class Complex

Member Functions
Complex::Set Sets both components of a complex number.
Constructor

Complex();

Complex(float x, float y = 0.0F);

Parameters
x The real part of the complex number.
y The imaginary part of the complex number.
Description
The Complex class encapsulates a complex number having the form a + bi. The real and imaginary parts of the complex number can be accessed through the members a and b.

The default constructor leaves the components of a complex number undefined. If the values x and y are supplied, then they are assigned to the real and imaginary components of the complex number, respectively.
Overloaded Operators
floatoperator [](machine k); Returns a reference to the k-th component of a complex number. The value of k must be 0 or 1. Index 0 refers to the real part, and index 1 refers to the imaginary part.
const floatoperator [](machine k) const; Returns a constant reference to the k-th component of a complex number. The value of k must be 0 or 1. Index 0 refers to the real part, and index 1 refers to the imaginary part.
Complex& operator =(float r); Assigns the value r to the real component and sets the imaginary component to 0.
Complex& operator +=(const Complex& c); Adds the complex number c.
Complex& operator +=(float r); Adds the real number r.
Complex& operator -=(const Complex& c); Subtracts the complex number c.
Complex& operator -=(float r); Subtracts the real number r.
Complex& operator *=(const Complex& c); Multiplies by the complex number c.
Complex& operator *=(float r); Multiplies by the real number r.
Complex& operator /=(const Complex& c); Divides by the complex number c.
Complex& operator /=(float r); Divides by the real number r.
Nonmember Operations
Complex operator -(const Complex& c); Returns the negation of the complex number c.
Complex operator +(const Complex& c1, const Complex& c2); Returns the sum of the complex numbers c1 and c2.
Complex operator +(const Complex& c, float r); Returns the sum of the complex number c and the real number r.
Complex operator +(float r, const Complex& c); Returns the sum of the real number r and the complex number c.
Complex operator -(const Complex& c1, const Complex& c2); Returns the difference of the complex numbers c1 and c2.
Complex operator -(const Complex& c, float r); Returns the difference of the complex number c and the real number r.
Complex operator -(float r, const Complex& c); Returns the difference of the real number r and the complex number c.
Complex operator *(const Complex& c1, const Complex& c2); Returns the product of the complex numbers c1 and c2.
Complex operator *(const Complex& c, float r); Returns the product of the complex number c and the real number r.
Complex operator *(float r, const Complex& c); Returns the product of the real number r and the complex number c.
Complex operator /(const Complex& c1, const Complex& c2); Returns the quotient of the complex numbers c1 and c2.
Complex operator /(const Complex& c, float r); Returns the quotient of the complex number c and the real number r.
Complex operator /(float r, const Complex& c); Returns the quotient of the real number r and the complex number c.
bool operator ==(const Complex& c1, const Complex& c2); Returns a boolean value indicating the equality of the two complex numbers c1 and c2.
bool operator ==(const Complex& c, float r); Returns a boolean value indicating the equality of the complex number c and the real number r.
bool operator !=(const Complex& c1, const Complex& c2); Returns a boolean value indicating the inequality of the two complex numbers c1 and c2.
bool operator !=(const Complex& c, float r); Returns a boolean value indicating the inequality of the complex number c and the real number r.
float Modulus(const Complex& c); Returns the modulus of the complex number c.
float SquaredMod(const Complex& c); Returns the squared modulus of the complex number c.
Complex Conjugate(const Complex& c); Returns the conjugate of the complex number c.
Complex Inverse(const Complex& c); Returns the inverse of the complex number c.