SFT
Class Complex

java.lang.Object
  extended by SFT.Complex
All Implemented Interfaces:
java.io.Serializable

public class Complex
extends java.lang.Object
implements java.io.Serializable

This class is an implementation for representing Complex numbers.

Author:
Elizabeth Firman and Ariel Stolerman
See Also:
Serialized Form

Constructor Summary
Complex(double real, double imaginary)
          Constructs a new Complex object with real and imaginary coordinates.
Complex(java.lang.Double real, java.lang.Double imaginary)
           
 
Method Summary
 void addComplex(Complex complex)
          Adds the given complex number to this one.
 void addComplex(double real, double imaginary)
          Adds the given complex number to this one.
static Complex divComplex(Complex complex, double denum)
          Returns the division of the the given complex by the given double.
 double[] getComplexCoords()
          Returns an array of two doubles, where the first element is the number's real coordinate and the second element is the number's imaginary coordinate.
 Complex getConjugate()
          Returns the conjugate number.
 double getIm()
          Returns the imaginary coordinate of the complex number.
 double getNorm()
          Calculates and returns the norm of the complex number, i.e. for a+bi: |a+bi| = sqrt(a^2+b^2)
 double getNormSquare()
          Calculates and returns the Euclidean norm square of the complex number
 double getRe()
          Returns the real coordinate of the complex number.
static Complex mulComplex(Complex complex1, Complex complex2)
          Returns the multiplication of the two given complex numbers.
 void setComplex(double real, double imaginary)
          Sets the real and imaginary coordinates of the number to the new given coordinates.
 java.lang.String toString()
          Returns the string representation of the complex number in the form "a + bi".
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Complex

public Complex(double real,
               double imaginary)
Constructs a new Complex object with real and imaginary coordinates.

Parameters:
real - The real coordinate
imaginary - The imaginary coordinate

Complex

public Complex(java.lang.Double real,
               java.lang.Double imaginary)
Method Detail

getRe

public double getRe()
Returns the real coordinate of the complex number.

Returns:
The real coordinate of the complex number.

getIm

public double getIm()
Returns the imaginary coordinate of the complex number.

Returns:
The imaginary coordinate of the complex number.

getComplexCoords

public double[] getComplexCoords()
Returns an array of two doubles, where the first element is the number's real coordinate and the second element is the number's imaginary coordinate.

Returns:
A double array with the real coordinate as the first element and the imaginary coordinate as the second element.

getConjugate

public Complex getConjugate()
Returns the conjugate number.

Returns:
The conjugate number.

toString

public java.lang.String toString()
Returns the string representation of the complex number in the form "a + bi".

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the complex number in the form "a + bi".

getNorm

public double getNorm()
Calculates and returns the norm of the complex number, i.e. for a+bi: |a+bi| = sqrt(a^2+b^2)

Returns:
The Euclidean norm of the complex number

getNormSquare

public double getNormSquare()
Calculates and returns the Euclidean norm square of the complex number

Returns:
The Euclidean norm square of the complex number

setComplex

public void setComplex(double real,
                       double imaginary)
Sets the real and imaginary coordinates of the number to the new given coordinates.

Parameters:
real - The new real coordinate.
imaginary - The new imaginary coordinate.

addComplex

public void addComplex(double real,
                       double imaginary)
Adds the given complex number to this one.

Parameters:
real - The real value to be added.
imaginary - The imaginary value to be added.

addComplex

public void addComplex(Complex complex)
Adds the given complex number to this one.

Parameters:
complex - The complex number to be added.

mulComplex

public static Complex mulComplex(Complex complex1,
                                 Complex complex2)
Returns the multiplication of the two given complex numbers.

Parameters:
complex1 - The first complex number for the multiplication.
complex2 - The second complex number for the multiplication.
Returns:
The multiplication of the two given complex numbers.

divComplex

public static Complex divComplex(Complex complex,
                                 double denum)
Returns the division of the the given complex by the given double.