com.oregondsp.signalProcessing.filter.iir
Class Rational

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

public class Rational
extends java.lang.Object

Class implementing rational functions. Used to design and represent analog and digital filters. The rational function is of the form H(s) = N(s)/D(s), where N and D are polynomials.

Author:
David B. Harris, Deschutes Signal Processing LLC

Constructor Summary
Rational(double c)
          Instantiates a new rational function object from a constant.
Rational(double[] num, double[] denom)
          Instantiates a new rational function, given arrays specifying the numerator and denominator polynomials.
Rational(Polynomial N, Polynomial D)
          Instantiates a new rational function, given Polynomial objects for the numerator and denominator.
Rational(Rational R)
          Constructs a new rational function by copying an existing rational function object.
 
Method Summary
 double canonicalForm()
          Puts the rational function representation in canonical form.
 Polynomial denominator()
          Returns a copy of the denominator polynomial.
 double discreteTimeGroupDelay(double Omega)
          Calculates the group delay of a digital filter with transfer function specified by this rational function.
 Complex evaluate(Complex c)
          Evaluates a rational function for a complex argument.
 double evaluate(double x)
          Evaluates the rational function for a real argument.
 double groupDelay(double omega)
          Calculates the group delay of an analog filter with transfer function specified by this rational function.
 Rational map(Rational S)
          Maps a rational function to a new rational function by substitution of a rational function for the argument.
 Polynomial numerator()
          Returns a copy of the numerator polynomial.
 int[] order()
          Returns the orders of the numerator and denominator polynomials.
 void print(java.io.PrintStream ps)
          Prints the coefficients of the rational function.
 Complex residue(Complex pole)
          Calculates the residue of a complex pole of the rational function.
 double residue(double pole)
          Calculates the residue of a real pole of the rational function.
 void timesEquals(double A)
          Scales (in-place) a rational function by a constant.
 void timesEquals(Polynomial P)
          Multiplies (in-place) a rational function by a polynomial.
 void timesEquals(Rational R)
          Multiplies(in-place) a rational function by another rational function.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Rational

public Rational(double[] num,
                double[] denom)
Instantiates a new rational function, given arrays specifying the numerator and denominator polynomials.

Parameters:
num - double[] specifying coefficients of the numerator polynomial.
denom - double[] specifying coefficients of the denominator polynomial.

Rational

public Rational(Polynomial N,
                Polynomial D)
Instantiates a new rational function, given Polynomial objects for the numerator and denominator.

Parameters:
N - Polynomial instance specifying the numerator polynomial.
D - Polynomial instance specifying the denominator polynomial.

Rational

public Rational(Rational R)
Constructs a new rational function by copying an existing rational function object.

Parameters:
R - Rational function object to be copied.

Rational

public Rational(double c)
Instantiates a new rational function object from a constant.

Parameters:
c - double specifying the constant of the numerator.
Method Detail

order

public int[] order()
Returns the orders of the numerator and denominator polynomials.

Returns:
int[] - first element is the order of the numerator and second element is the order of the denominator.

numerator

public Polynomial numerator()
Returns a copy of the numerator polynomial.

Returns:
Polynomial copy of the numerator.

denominator

public Polynomial denominator()
Returns a copy of the denominator polynomial.

Returns:
Polynomial copy of the denominator.

canonicalForm

public double canonicalForm()
Puts the rational function representation in canonical form. Normalizes the numerator and denominator polynomials to have unit lead coefficients. Returns the gain factor required to perform the normalization.

Returns:
double specifying the gain

timesEquals

public void timesEquals(double A)
Scales (in-place) a rational function by a constant.

Parameters:
A - double specifying the scale factor.

timesEquals

public void timesEquals(Polynomial P)
Multiplies (in-place) a rational function by a polynomial.

Parameters:
P - Polynomial object specifying the multiplicative polynomial factor.

timesEquals

public void timesEquals(Rational R)
Multiplies(in-place) a rational function by another rational function.

Parameters:
R - Rational object specifying the multiplicative rational factor.

evaluate

public double evaluate(double x)
Evaluates the rational function for a real argument.

Parameters:
x - double specifying the argument to the rational function.
Returns:
double specifying the resulting value of the rational function.

evaluate

public Complex evaluate(Complex c)
Evaluates a rational function for a complex argument.

Parameters:
c - Complex object specifying the complex argument.
Returns:
Complex object specifying the resulting complex value of the rational function.

map

public Rational map(Rational S)
Maps a rational function to a new rational function by substitution of a rational function for the argument. Uses a modification of Horner's scheme to perform the mapping.

Parameters:
S - Rational object specifying the mapping function.
Returns:
Rational object specifying the resulting mapped rational function.

residue

public double residue(double pole)
Calculates the residue of a real pole of the rational function. Uses L'Hopital's rule to calculate the residue of a real pole. Potentially useful to find parallel implementations of IIR digital filters. Suitable only for simple poles.

Parameters:
pole - double specifying the real pole (root of the denominator).
Returns:
double specifying the residue.

residue

public Complex residue(Complex pole)
Calculates the residue of a complex pole of the rational function. Uses L'Hopital's rule to calculate the residue of a complex pole. Potentially useful to find parallel implementations of IIR digital filters. Suitable only for simple poles.

Parameters:
pole - Complex object specifying the pole.
Returns:
Complex object specifying the residue.

groupDelay

public double groupDelay(double omega)
Calculates the group delay of an analog filter with transfer function specified by this rational function.

Parameters:
omega - double specifying the radial frequency (2*pi*f) at which the group delay is evaluated.
Returns:
double specifying the group delay in seconds.

discreteTimeGroupDelay

public double discreteTimeGroupDelay(double Omega)
Calculates the group delay of a digital filter with transfer function specified by this rational function. For this evaluation, the numerator and denominator are assumed to be polynomials in z^-1.

Parameters:
Omega - double specifying the digital frequency [0 pi] at which the group delay is evaluated.
Returns:
double specifying the group delay in samples.

print

public void print(java.io.PrintStream ps)
Prints the coefficients of the rational function.

Parameters:
ps - Printstream to which the rational function coefficients are printed.