Complex Class Reference

An implementation of a complex number with the associated basic functions. More...

#include <Complex.h>

List of all members.

Public Member Functions

 Complex ()
 Creates an object and initializes it to (0,0).
 Complex (double re, double im)
 Creates and initializes this object.
 Complex (const Complex &rhs)
 Creates an new instance of this object which is equal to another instance.
double real ()
 Real part of this number.
double imaginary ()
 Imaginary part of this number.
void operator= (const Complex &rhs)
 Sets two complex numbers equal.
void operator= (const double &rhs)
 Sets a complex number and a real number equal.
Complex operator+ (const Complex &rhs)
 Adds two complex numbers.
Complex operator+ (const double &rhs)
 Adds a complex and a real number.
Complex operator- (const Complex &rhs)
 Subtracts two complex numbers.
Complex operator- (const double &rhs)
 Subtracts a complex and a real number.
Complex operator* (const Complex &rhs)
 Multiplies two complex number.
Complex operator* (const double &rhs)
 Multiplies a complex and a real number.
Complex operator/ (const Complex &rhs)
 Divides two complex numbers.
Complex conjugate ()
 Calculates the complex conjugate of this number.
double abs ()
 Calculates the magniutde of this complex number.
Complex squareroot ()
 Calculates the square root of this complex number.

Private Attributes

double re
double im

Friends

ostream & operator<< (ostream &strm, Complex &c)
 Write the number to an output stream.


Detailed Description

An implementation of a complex number with the associated basic functions.

Definition at line 25 of file Complex.h.


Constructor & Destructor Documentation

Complex::Complex (  ) 

Creates an object and initializes it to (0,0).

Definition at line 15 of file Complex.cpp.

References im, and re.

Complex::Complex ( double  re,
double  im 
)

Creates and initializes this object.

Parameters:
re real part of this number.
im imaginary part of this number.

Definition at line 21 of file Complex.cpp.

Complex::Complex ( const Complex rhs  ) 

Creates an new instance of this object which is equal to another instance.

Parameters:
rhs object this new object will be set equal to.

Definition at line 27 of file Complex.cpp.


Member Function Documentation

double Complex::real (  ) 

Real part of this number.

Returns:
real part of this number.

Definition at line 32 of file Complex.cpp.

References re.

Referenced by Polynomial::laguer(), operator<<(), and Polynomial::zroots().

double Complex::imaginary (  ) 

Imaginary part of this number.

Returns:
imaginary part of this number.

Definition at line 37 of file Complex.cpp.

References im.

Referenced by Polynomial::laguer(), operator<<(), and Polynomial::zroots().

void Complex::operator= ( const Complex rhs  ) 

Sets two complex numbers equal.

number to set this one equal to.

Definition at line 42 of file Complex.cpp.

References im, and re.

void Complex::operator= ( const double &  rhs  ) 

Sets a complex number and a real number equal.

number to set this one equal to.

Definition at line 48 of file Complex.cpp.

References im, and re.

Complex Complex::operator+ ( const Complex rhs  ) 

Adds two complex numbers.

Returns:
sum of the arguments.

Definition at line 54 of file Complex.cpp.

References im, and re.

Complex Complex::operator+ ( const double &  rhs  ) 

Adds a complex and a real number.

Returns:
sum of the arguments.

Definition at line 64 of file Complex.cpp.

References im, and re.

Complex Complex::operator- ( const Complex rhs  ) 

Subtracts two complex numbers.

Returns:
difference of the arguments.

Definition at line 74 of file Complex.cpp.

References im, and re.

Complex Complex::operator- ( const double &  rhs  ) 

Subtracts a complex and a real number.

Returns:
difference of the arguments.

Definition at line 84 of file Complex.cpp.

References im, and re.

Complex Complex::operator* ( const Complex rhs  ) 

Multiplies two complex number.

Returns:
product of the arguments.

Definition at line 94 of file Complex.cpp.

References im, and re.

Complex Complex::operator* ( const double &  rhs  ) 

Multiplies a complex and a real number.

Returns:
product of the arguments.

Definition at line 104 of file Complex.cpp.

References im, and re.

Complex Complex::operator/ ( const Complex rhs  ) 

Divides two complex numbers.

Returns:
result of the division.

Definition at line 114 of file Complex.cpp.

References im, and re.

Complex Complex::conjugate (  ) 

Calculates the complex conjugate of this number.

Returns:
complex conjugate of this number.

Definition at line 136 of file Complex.cpp.

References im, and re.

double Complex::abs (  ) 

Calculates the magniutde of this complex number.

\[ c.abs() = \sqrt{\left( c.re()^{2} + c.im()^{2} \right)} \]

Returns:
magnitude of this complex number.

Definition at line 146 of file Complex.cpp.

References im, and re.

Referenced by Polynomial::laguer().

Complex Complex::squareroot (  ) 

Calculates the square root of this complex number.

Returns:
square root of this complex number.

Definition at line 174 of file Complex.cpp.

References im, and re.

Referenced by Polynomial::laguer().


Friends And Related Function Documentation

ostream& operator<< ( ostream &  strm,
Complex c 
) [friend]

Write the number to an output stream.

Definition at line 215 of file Complex.cpp.


Member Data Documentation

double Complex::re [private]

double Complex::im [private]


The documentation for this class was generated from the following files:

Generated on Sat Jul 5 16:14:01 2008 for QMcBeaver by  doxygen 1.5.6