Class ComplexNumber

java.lang.Object
  |
  +--ComplexNumber

public class ComplexNumber
extends java.lang.Object

Class representing a complex number.

Author:
Simon Horne.

Field Summary
 double imaginary
          The imaginary part of the complex number.
 double real
          The real part of the complex number.
 
Constructor Summary
ComplexNumber()
          Default no-arg constructor.
ComplexNumber(ComplexNumber c)
          Constructor taking a ComplexNumber to make an identical copy.
ComplexNumber(double r, double i)
          Constrctor taking two doubles, the real and the imaginary values.
 
Method Summary
static ComplexNumber cDif(ComplexNumber z1, ComplexNumber z2)
          Method to subtract a complex number from another.
static ComplexNumber cDiv(ComplexNumber z1, ComplexNumber z2)
          Method to divide a complex number by another.
static ComplexNumber cExp(ComplexNumber z)
          Method to obtain the exp of a complex number.
static ComplexNumber cMult(ComplexNumber z1, ComplexNumber z2)
          Method to multiply two complex numbers together.
static ComplexNumber cSum(ComplexNumber z1, ComplexNumber z2)
          Method to add two complex numbers together.
 double magnitude()
          Method to obtain the magnitude of the complex number.
 double phaseAngle()
          Method to obtain the phase angle (in radians) of the complex number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

real

public double real
The real part of the complex number.

imaginary

public double imaginary
The imaginary part of the complex number.
Constructor Detail

ComplexNumber

public ComplexNumber()
Default no-arg constructor.

ComplexNumber

public ComplexNumber(double r,
                     double i)
Constrctor taking two doubles, the real and the imaginary values.
Parameters:
r - A double representing the real value.
i - A double representing the imaginary value.

ComplexNumber

public ComplexNumber(ComplexNumber c)
Constructor taking a ComplexNumber to make an identical copy.
Parameters:
c - ComplexNumber to be copied.
Method Detail

magnitude

public double magnitude()
Method to obtain the magnitude of the complex number.
Returns:
double representing the magnitude.

phaseAngle

public double phaseAngle()
Method to obtain the phase angle (in radians) of the complex number.
Returns:
double representing the phase angle in radians.

cExp

public static ComplexNumber cExp(ComplexNumber z)
Method to obtain the exp of a complex number.
Parameters:
ComplexNumber - input.
Returns:
ComplexNumber output.

cMult

public static ComplexNumber cMult(ComplexNumber z1,
                                  ComplexNumber z2)
Method to multiply two complex numbers together.
Parameters:
z1 - ComplexNumber.
z2 - ComlexNumber.
Returns:
z3 ComplexNumber z3 = z1 * z2.

cSum

public static ComplexNumber cSum(ComplexNumber z1,
                                 ComplexNumber z2)
Method to add two complex numbers together.
Parameters:
z1 - ComplexNumber.
z2 - ComlexNumber.
Returns:
z3 ComplexNumber z3 = z1 + z2.

cDiv

public static ComplexNumber cDiv(ComplexNumber z1,
                                 ComplexNumber z2)
Method to divide a complex number by another.
Parameters:
z1 - ComplexNumber.
z2 - ComlexNumber.
Returns:
z3 ComplexNumber z3 = z1 / z2.

cDif

public static ComplexNumber cDif(ComplexNumber z1,
                                 ComplexNumber z2)
Method to subtract a complex number from another.
Parameters:
z1 - ComplexNumber.
z2 - ComlexNumber.
Returns:
z3 ComplexNumber z3 = z1 - z2.