net.sarcommand.fft
Class Complex

java.lang.Object
  extended by net.sarcommand.fft.Complex

public class Complex
extends java.lang.Object

This class represents a complex number. If offers the basic operations required to compute the fast fourier transformation.


Field Summary
 double imag
          The imaginary part of this complex number.
 double real
          The real part of this complex number.
 
Constructor Summary
Complex(double re, double im)
          Creates a new complex number from the given real and imaginary part.
 
Method Summary
 Complex conjugate()
          Returns the conjugate of this complex.
 Complex divides(Complex b)
          Returns the quotient of this / b.
static Complex[] makeComplexArray(int n)
          Creates and initializes a complex array of length n.
 Complex minus(Complex b)
          Returns the difference between this complex and b.
 Complex plus(Complex b)
          Returns the sum of this complex and b.
 Complex reciprocal()
          Returns a complex which's value is the reciprocal of this.
 Complex times(Complex b)
          Returns the product of this and b.
 java.lang.String toString()
          Returns a string representation of this complex in the form '[real + i * imaginary]'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

real

public double real
The real part of this complex number.


imag

public double imag
The imaginary part of this complex number.

Constructor Detail

Complex

public Complex(double re,
               double im)
Creates a new complex number from the given real and imaginary part.

Parameters:
re - This complex's real part.
im - This complex's imaginary part.
Method Detail

makeComplexArray

public static Complex[] makeComplexArray(int n)
Creates and initializes a complex array of length n. All fields in the array will be initialized as [0,i*0].

Parameters:
n - Length of the required array
Returns:
Complex[n]

plus

public Complex plus(Complex b)
Returns the sum of this complex and b.

Parameters:
b - Other complex summand.
Returns:
[this + b]

minus

public Complex minus(Complex b)
Returns the difference between this complex and b.

Parameters:
b - Complex subtrahend.
Returns:
[this - b]

times

public Complex times(Complex b)
Returns the product of this and b.

Parameters:
b - Other complex factor.
Returns:
[this * b]

divides

public Complex divides(Complex b)
Returns the quotient of this / b.

Parameters:
b - Complex dividend.
Returns:
[this / b]

conjugate

public Complex conjugate()
Returns the conjugate of this complex.

Returns:
[this^-1]

reciprocal

public Complex reciprocal()
Returns a complex which's value is the reciprocal of this.

Returns:
reciprocal value of this.

toString

public java.lang.String toString()
Returns a string representation of this complex in the form '[real + i * imaginary]'.

Overrides:
toString in class java.lang.Object
Returns:
String representation.