fftManager
Class Complex

java.lang.Object
  extended by fftManager.Complex
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

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

Class definition for a Complex number type.

Author:
Paul Redmond / Doug Gillespie
See Also:
Serialized Form

Field Summary
 double imag
           
 double real
           
static long serialVersionUID
           
 
Constructor Summary
Complex()
           
Complex(Complex a)
          Constructor
Complex(double real, double imag)
          Constructor
 
Method Summary
static Complex[] allocateComplexArray(int n)
          Allocate a new complex array in which each element has been created and it's contents set to 0 +i0;
static Complex[][] allocateComplexArray(int n, int m)
           
 double ang()
          Gets the angle of a complex number
 void assign(Complex b)
          Assign new real and imaginary values to an existing Complex number
 void assign(double real, double imag)
          Assign new real and imaginary values to an existing Complex number
 Complex clone()
           
 Complex conj()
           
static void conj(Complex x)
          Converts a number to it's own complex conjugate
 void internalTimes(Complex b)
          Multiply a complex numbers real and imaginary parts by a complex number
 void internalTimes(double b)
          Multiply a complex numbers real and imaginary parts by a real number
 boolean isInfinite()
          Returns true if either the real or imaginary part is infinite, false otherwise
 boolean isNaN()
          Returns true if either the real or imaginary part is a Not-a-Number (NaN) value, false otherwise
 double mag()
          Gets the magnitude of a complex number
 double magsq()
          Gets the squared magnitude of a complex number
 Complex minus(Complex b)
          Subtract a real number from a complex number
 Complex minus(double b)
          Subtract a real number from a complex number
 double norm()
          Deprecated. 
 Complex plus(Complex b)
          Adds a complex number
 Complex plus(double b)
          Add a real number to a complex number
 Complex pow(double f)
          Raises a complex number to a scalar power.
 Complex sqrt()
          Gets the square root of a Complex number
 Complex times(Complex b)
          Multiply a complex number by another complex number
 Complex times(double b)
          Multiply a complex number by a real
static void zeroComplexArray(Complex[] array)
          Sets all the elements of a complex array to zero
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

real

public double real

imag

public double imag
Constructor Detail

Complex

public Complex()

Complex

public Complex(double real,
               double imag)
Constructor

Parameters:
real - real part
imag - imaginary part

Complex

public Complex(Complex a)
Constructor

Parameters:
a - Complex Number (to clone)
Method Detail

clone

public Complex clone()
Overrides:
clone in class java.lang.Object

ang

public double ang()
Gets the angle of a complex number

Returns:
angle in radians

magsq

public double magsq()
Gets the squared magnitude of a complex number

Returns:
squared magnitude

norm

@Deprecated
public double norm()
Deprecated. 

Gets the squared magnitude of a complex number

Returns:
squared magnitude

mag

public double mag()
Gets the magnitude of a complex number

Returns:
magnitude

sqrt

public Complex sqrt()
Gets the square root of a Complex number

Returns:
square root of the Complex number

pow

public Complex pow(double f)
Raises a complex number to a scalar power.

Parameters:
f - power to raise number to
Returns:
new Complex number

plus

public Complex plus(Complex b)
Adds a complex number

Parameters:
b - Complex number to add
Returns:
new Complex number

assign

public void assign(Complex b)
Assign new real and imaginary values to an existing Complex number

Parameters:
b - Complex number to take values from

assign

public void assign(double real,
                   double imag)
Assign new real and imaginary values to an existing Complex number

Parameters:
real - new real part
imag - new imaginary part

plus

public Complex plus(double b)
Add a real number to a complex number

Parameters:
b - real number
Returns:
new Complex number

minus

public Complex minus(Complex b)
Subtract a real number from a complex number

Parameters:
b - real number
Returns:
new Complex number

minus

public Complex minus(double b)
Subtract a real number from a complex number

Parameters:
b - real number
Returns:
new Complex number

times

public Complex times(double b)
Multiply a complex number by a real

Parameters:
b - real number
Returns:
new Complex number

times

public Complex times(Complex b)
Multiply a complex number by another complex number

Parameters:
b - complex number
Returns:
new complex number

internalTimes

public void internalTimes(double b)
Multiply a complex numbers real and imaginary parts by a real number

Parameters:
b - real number

internalTimes

public void internalTimes(Complex b)
Multiply a complex numbers real and imaginary parts by a complex number

Parameters:
b - complex number

conj

public Complex conj()

conj

public static void conj(Complex x)
Converts a number to it's own complex conjugate

Parameters:
x -

isNaN

public boolean isNaN()
Returns true if either the real or imaginary part is a Not-a-Number (NaN) value, false otherwise

Returns:
true if either part of the number is NaN

isInfinite

public boolean isInfinite()
Returns true if either the real or imaginary part is infinite, false otherwise

Returns:
true if either part of the number is infinite

allocateComplexArray

public static Complex[] allocateComplexArray(int n)
Allocate a new complex array in which each element has been created and it's contents set to 0 +i0;

Parameters:
n - length of array
Returns:
Complex array of length n

allocateComplexArray

public static Complex[][] allocateComplexArray(int n,
                                               int m)

zeroComplexArray

public static void zeroComplexArray(Complex[] array)
Sets all the elements of a complex array to zero

Parameters:
array - Complex Array