com.oregondsp.signalProcessing.filter.iir
Class Complex

java.lang.Object
  extended by com.oregondsp.signalProcessing.filter.iir.Complex

public class Complex
extends java.lang.Object

Class to represent complex numbers and certain basic functions of complex numbers.

Author:
David B. Harris Deschutes Signal Processing LLC

Constructor Summary
Complex(double real)
          Instantiates a new complex number object from a real number (imaginary part is zero).
Complex(double real, double imag)
          Instantiates a new complex number object.
 
Method Summary
 double abs()
          Computes the absolute value of this Complex number.
static double abs(Complex c)
          Computes the absolute value of a complex number.
static Complex add(Complex c1, Complex c2)
          Adds two complex numbers.
static Complex add(Complex c, double a)
          Calculates the sum of a complex number and a real number.
static Complex add(double a, Complex c)
          Calculates the sum of a real number and a complex number.
 double angle()
          Computes the phase angle of this Complex number.
static double angle(Complex c)
          Computes the phase angle of a complex number.
static Complex ComplexFromPolar(double r, double phi)
          Instantiates a new complex number object from polar representation parameters.
 Complex conjugate()
          Returns the conjugate of this Complex number.
static Complex conjugate(Complex c)
          Conjugates a complex number.
static Complex divide(Complex c1, Complex c2)
          Divides one complex number by another.
static Complex divide(Complex c, double a)
          Divides a complex number by a real number.
static Complex divide(double a, Complex c)
          Divide a real number by a complex number.
 void divideEquals(Complex c)
          Divides this Complex number by another Complex number.
 void divideEquals(double a)
          Divides this Complex number by a real number.
static Complex exp(Complex c)
          Computes the complex exponential function of a complex number.
 double imag()
          Returns the imaginary part of a complex number.
 Complex minus(Complex c)
          Subtracts a complex number from this complex number.
 Complex minus(double a)
          Subtracts a real number from this Complex number.
 void minusEquals(Complex c)
          Subtracts another Complex number from this Complex number.
 void minusEquals(double a)
          Subtracts a real number from this Complex number.
static Complex multiply(Complex c1, Complex c2)
          Multiplies two complex numbers.
static Complex multiply(Complex c, double a)
          Multiplies a real and a complex number.
static Complex multiply(double a, Complex c)
          Multiplies a real and a complex number.
 Complex over(Complex c)
          Divides this Complex number by another Complex number.
 Complex over(double a)
          Divides this Complex number by a real number.
 Complex plus(Complex c)
          Computes the sum of this Complex number and another.
 Complex plus(double a)
          Computes the sum of this Complex number and a real number.
 void plusEquals(Complex c)
          Adds a Complex number to this Complex number.
 void plusEquals(double a)
          Adds a real number to this Complex number.
 double real()
          Returns the real part of a complex number.
static Complex sqrt(Complex c)
          Computes the square root of a complex number.
static Complex subtract(Complex c1, Complex c2)
          Subtracts one complex number from another.
static Complex subtract(Complex c, double a)
          Calculates the difference of a complex number and a real number.
static Complex subtract(double a, Complex c)
          Calculates the difference of a real number and a complex number.
 Complex times(Complex c)
          Multiplies this Complex number by another Complex number.
 Complex times(double a)
          Multiplies this Complex number by a real number.
 void timesEquals(Complex c)
          Multiplies this Complex number by another Complex number.
 void timesEquals(double a)
          Multiplies this Complex number by a real number.
 java.lang.String toString()
          Generates a String representation for this Complex number object.
static Complex unaryMinus(Complex c)
          Unary minus - negates a complex number.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Complex

public Complex(double real,
               double imag)
Instantiates a new complex number object.

Parameters:
real - double specifying the real part.
imag - double specifying the imaginary part.

Complex

public Complex(double real)
Instantiates a new complex number object from a real number (imaginary part is zero).

Parameters:
real - double specifying the real part.
Method Detail

ComplexFromPolar

public static Complex ComplexFromPolar(double r,
                                       double phi)
Instantiates a new complex number object from polar representation parameters.

Parameters:
r - double specifying the radius (magnitude) of the complex number.
phi - double specifying the phase angle of the complex number.
Returns:
Resulting Complex number object.

add

public static Complex add(double a,
                          Complex c)
Calculates the sum of a real number and a complex number.

Parameters:
a - double specifying the real number.
c - Complex number object.
Returns:
New Complex object containing the sum.

add

public static Complex add(Complex c,
                          double a)
Calculates the sum of a complex number and a real number.

Parameters:
c - Complex number object.
a - double specifying the real number.
Returns:
New Complex object containing the sum.

subtract

public static Complex subtract(Complex c,
                               double a)
Calculates the difference of a complex number and a real number.

Parameters:
c - Complex number object.
a - double specifying the real number.
Returns:
New Complex object containing the difference.

subtract

public static Complex subtract(double a,
                               Complex c)
Calculates the difference of a real number and a complex number.

Parameters:
a - double specifying the real number.
c - Complex number object.
Returns:
New Complex object containing the difference.

unaryMinus

public static Complex unaryMinus(Complex c)
Unary minus - negates a complex number.

Parameters:
c - Complex number to be negated.
Returns:
New Complex object containing the negative of the operand.

multiply

public static Complex multiply(double a,
                               Complex c)
Multiplies a real and a complex number.

Parameters:
a - double specifying the real factor.
c - Complex object specifying the complex factor.
Returns:
New Complex object containing the product.

multiply

public static Complex multiply(Complex c,
                               double a)
Multiplies a real and a complex number.

Parameters:
c - Complex object specifying the complex factor.
a - double specifying the real factor.
Returns:
New Complex object containing the product.

add

public static Complex add(Complex c1,
                          Complex c2)
Adds two complex numbers.

Parameters:
c1 - First Complex summand.
c2 - Second Complex summand.
Returns:
New Complex object containing the sum.

subtract

public static Complex subtract(Complex c1,
                               Complex c2)
Subtracts one complex number from another.

Parameters:
c1 - First Complex number.
c2 - Second Complex number to be subtracted from the first.
Returns:
New Complex object containing the difference.

multiply

public static Complex multiply(Complex c1,
                               Complex c2)
Multiplies two complex numbers.

Parameters:
c1 - First Complex factor.
c2 - Second Complex factor.
Returns:
New Complex object containing the product.

divide

public static Complex divide(Complex c,
                             double a)
Divides a complex number by a real number.

Parameters:
c - The Complex number.
a - double containing the real divisor.
Returns:
New Complex object containing the result of division.

divide

public static Complex divide(double a,
                             Complex c)
Divide a real number by a complex number.

Parameters:
a - double containing the real number.
c - Complex divisor.
Returns:
New Complex object containing the result of division.

divide

public static Complex divide(Complex c1,
                             Complex c2)
Divides one complex number by another.

Parameters:
c1 - The first Complex number.
c2 - The Complex divisor.
Returns:
New Complex object containing the result of division.

sqrt

public static Complex sqrt(Complex c)
Computes the square root of a complex number.

Parameters:
c - Complex argument of the square root function.
Returns:
New Complex object containing the square root of the argument.

abs

public static double abs(Complex c)
Computes the absolute value of a complex number.

Parameters:
c - Complex argument of the absolute value operator.
Returns:
double containing the absolute value of the argument.

angle

public static double angle(Complex c)
Computes the phase angle of a complex number.

Parameters:
c - Complex argument of the phase function.
Returns:
double containing the phase of the argument.

exp

public static Complex exp(Complex c)
Computes the complex exponential function of a complex number.

Parameters:
c - Complex argument to the exponential function.
Returns:
New Complex object containing the complex exponential of the argument.

conjugate

public static Complex conjugate(Complex c)
Conjugates a complex number.

Parameters:
c - Complex argument.
Returns:
New Complex object containing the conjugate of the argument.

real

public double real()
Returns the real part of a complex number.

Returns:
double containing the real part of a Complex number object.

imag

public double imag()
Returns the imaginary part of a complex number.

Returns:
double containing the imaginary part of a Complex number object.

abs

public double abs()
Computes the absolute value of this Complex number.

Returns:
double containing the absolute value of this Complex number.

angle

public double angle()
Computes the phase angle of this Complex number.

Returns:
double containing the phase angle of this Complex number.

times

public Complex times(Complex c)
Multiplies this Complex number by another Complex number. Does not alter the value of this Complex object.

Parameters:
c - The other Complex factor.
Returns:
New Complex object containing the product.

times

public Complex times(double a)
Multiplies this Complex number by a real number. Does not alter the value of this Complex object.

Parameters:
a - The real multiplicand.
Returns:
New Complex object containing the product.

conjugate

public Complex conjugate()
Returns the conjugate of this Complex number. Does not alter the value of this Complex object.

Returns:
New Complex object containing the conjugate of this.

plus

public Complex plus(Complex c)
Computes the sum of this Complex number and another. Does not alter the value of this Complex object.

Parameters:
c - Complex object containing the other summand.
Returns:
New Complex object containing the sum.

plus

public Complex plus(double a)
Computes the sum of this Complex number and a real number. Does not alter the value of this Complex object.

Parameters:
a - double containing the real summand.
Returns:
New Complex object containing the sum.

minus

public Complex minus(Complex c)
Subtracts a complex number from this complex number. Does not alter the value of this Complex object.

Parameters:
c - Complex number to be subtracted from this Complex number.
Returns:
New Complex object containing the difference.

minus

public Complex minus(double a)
Subtracts a real number from this Complex number. Does not alter the value of this Complex object.

Parameters:
a - double containing the real number to be subtracted from this Complex number.
Returns:
New Complex object containing the complex difference.

over

public Complex over(double a)
Divides this Complex number by a real number. Does not alter the value of this Complex object.

Parameters:
a - double containing the real divisor.
Returns:
New Complex object containing the result of division.

over

public Complex over(Complex c)
Divides this Complex number by another Complex number. Does not alter the value of this Complex object.

Parameters:
c - The Complex divisor.
Returns:
New Complex object containint the result of division.

plusEquals

public void plusEquals(double a)
Adds a real number to this Complex number. Alters the value of this Complex object.

Parameters:
a - double containing the other summand.

plusEquals

public void plusEquals(Complex c)
Adds a Complex number to this Complex number. Alters the value of this Complex object.

Parameters:
c - Complex object containing the other summand.

minusEquals

public void minusEquals(double a)
Subtracts a real number from this Complex number. Alters the value of this Complex object.

Parameters:
a - double containing the real number to be subtracted from this Complex number.

minusEquals

public void minusEquals(Complex c)
Subtracts another Complex number from this Complex number. Alters the value of this Complex object.

Parameters:
c - The other Complex number to be subtracted from this Complex number.

timesEquals

public void timesEquals(double a)
Multiplies this Complex number by a real number. Alters the value of this Complex object.

Parameters:
a - double containing the multiplicand.

timesEquals

public void timesEquals(Complex c)
Multiplies this Complex number by another Complex number. Alters the value of this Complex object.

Parameters:
c - Complex object containing the other multiplicand.

divideEquals

public void divideEquals(double a)
Divides this Complex number by a real number. Alters the value of this Complex object.

Parameters:
a - double containing the real divisor.

divideEquals

public void divideEquals(Complex c)
Divides this Complex number by another Complex number. Alters the value of this Complex object.

Parameters:
c - Complex object containing the divisor.

toString

public java.lang.String toString()
Generates a String representation for this Complex number object.

Overrides:
toString in class java.lang.Object