edu.mines.jtk.dsp
Class Recursive2ndOrderFilter

java.lang.Object
  extended by edu.mines.jtk.dsp.Recursive2ndOrderFilter

public class Recursive2ndOrderFilter
extends java.lang.Object

Recursive 2nd-order filter. This filter solves a linear, 2nd-order, constant-coefficient difference equation in either forward or reverse directions along any dimension of a 1-D, 2-D, or 3-D array.

Application of the filter in the forward direction computes

 y[i] = b0*x[i]+b1*x[i-1]+b2*x[i-2]-a1*y[i-1]-a2*y[i-2],
 
for i = 0, 1, 2, ..., n-1, where x[i] = y[i] = 0 for i<0. Application of the filter in the reverse direction computes
 y[i] = b0*x[i]+b1*x[i+1]+b2*x[i+2]-a1*y[i+1]-a2*y[i+2],
 
for i = n-1, n-2, ..., 0, where x[i] = y[i] = 0 for i>=n.

Version:
2005.11.22
Author:
Dave Hale, Colorado School of Mines

Constructor Summary
Recursive2ndOrderFilter(Cdouble pole1, Cdouble pole2, Cdouble zero1, Cdouble zero2, double gain)
          Constructs a recursive 2nd-order filter from poles, zeros, and gain.
Recursive2ndOrderFilter(double pole, double zero, double gain)
          Constructs a recursive 2nd-order filter from pole, zero, and gain.
Recursive2ndOrderFilter(float b0, float b1, float b2, float a1, float a2)
          Constructs a recursive 2nd-order filter with specified coefficients.
 
Method Summary
 void accumulate1Forward(float[][][] x, float[][][] y)
          Accumulates output in 1st dimension in the forward direction.
 void accumulate1Forward(float[][] x, float[][] y)
          Accumulates output in 1st dimension in the forward direction.
 void accumulate1Reverse(float[][][] x, float[][][] y)
          Accumulates output in 1st dimension in the reverse direction.
 void accumulate1Reverse(float[][] x, float[][] y)
          Accumulates output in 1st dimension in the reverse direction.
 void accumulate2Forward(float[][][] x, float[][][] y)
          Accumulates output in 2nd dimension in the forward direction.
 void accumulate2Forward(float[][] x, float[][] y)
          Accumulates output in 2nd dimension in the forward direction.
 void accumulate2Reverse(float[][][] x, float[][][] y)
          Accumulates output in 2nd dimension in the reverse direction.
 void accumulate2Reverse(float[][] x, float[][] y)
          /** Accumulates output in 2nd dimension in the reverse direction.
 void accumulate3Forward(float[][][] x, float[][][] y)
          Accumulates output in 3rd dimension in the forward direction.
 void accumulate3Reverse(float[][][] x, float[][][] y)
          /** Accumulates output in 3rd dimension in the reverse direction.
 void accumulateForward(float[] x, float[] y)
          Applies this filter in the forward direction, accumulating the output.
 void accumulateReverse(float[] x, float[] y)
          Applies this filter in the reverse direction, accumulating the output.
 void apply1Forward(float[][][] x, float[][][] y)
          Applies this filter in 1st dimension in the forward direction.
 void apply1Forward(float[][] x, float[][] y)
          Applies this filter in 1st dimension in the forward direction.
 void apply1Reverse(float[][][] x, float[][][] y)
          Applies this filter in 1st dimension in the reverse direction.
 void apply1Reverse(float[][] x, float[][] y)
          Applies this filter in 1st dimension in the reverse direction.
 void apply2Forward(float[][][] x, float[][][] y)
          Applies this filter in 2nd dimension in the forward direction.
 void apply2Forward(float[][] x, float[][] y)
          Applies this filter in 2nd dimension in the forward direction.
 void apply2Reverse(float[][][] x, float[][][] y)
          Applies this filter in 2nd dimension in the reverse direction.
 void apply2Reverse(float[][] x, float[][] y)
          Applies this filter in 2nd dimension in the reverse direction.
 void apply3Forward(float[][][] x, float[][][] y)
          Applies this filter in 3rd dimension in the forward direction.
 void apply3Reverse(float[][][] x, float[][][] y)
          Applies this filter in 3rd dimension in the reverse direction.
 void applyForward(float[] x, float[] y)
          Applies this filter in the forward direction.
 void applyReverse(float[] x, float[] y)
          Applies this filter in the reverse direction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Recursive2ndOrderFilter

public Recursive2ndOrderFilter(float b0,
                               float b1,
                               float b2,
                               float a1,
                               float a2)
Constructs a recursive 2nd-order filter with specified coefficients. If some of the coefficients are zero, the filter may be of only 1st or even 0th order.

Parameters:
b0 - a filter coefficient.
b1 - a filter coefficient.
b2 - a filter coefficient.
a1 - a filter coefficient.
a2 - a filter coefficient.

Recursive2ndOrderFilter

public Recursive2ndOrderFilter(double pole,
                               double zero,
                               double gain)
Constructs a recursive 2nd-order filter from pole, zero, and gain. This filter is actually a 1st-order filter, because it has only one (real) pole and zero.

Parameters:
pole - the pole.
zero - the zero.
gain - the filter gain.

Recursive2ndOrderFilter

public Recursive2ndOrderFilter(Cdouble pole1,
                               Cdouble pole2,
                               Cdouble zero1,
                               Cdouble zero2,
                               double gain)
Constructs a recursive 2nd-order filter from poles, zeros, and gain. The poles must be real or conjugate pairs; likewise for the zeros.

Parameters:
pole1 - the 1st pole.
pole2 - the 2nd pole.
zero1 - the 1st zero.
zero2 - the 2nd zero.
gain - the filter gain.
Method Detail

applyForward

public void applyForward(float[] x,
                         float[] y)
Applies this filter in the forward direction.

Input and output arrays may be the same array, but must have equal lengths.

Parameters:
x - the input array.
y - the output array.

applyReverse

public void applyReverse(float[] x,
                         float[] y)
Applies this filter in the reverse direction.

Input and output arrays may be the same array, but must have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulateForward

public void accumulateForward(float[] x,
                              float[] y)
Applies this filter in the forward direction, accumulating the output. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulateReverse

public void accumulateReverse(float[] x,
                              float[] y)
Applies this filter in the reverse direction, accumulating the output. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply1Forward

public void apply1Forward(float[][] x,
                          float[][] y)
Applies this filter in 1st dimension in the forward direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply1Reverse

public void apply1Reverse(float[][] x,
                          float[][] y)
Applies this filter in 1st dimension in the reverse direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply2Forward

public void apply2Forward(float[][] x,
                          float[][] y)
Applies this filter in 2nd dimension in the forward direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply2Reverse

public void apply2Reverse(float[][] x,
                          float[][] y)
Applies this filter in 2nd dimension in the reverse direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate1Forward

public void accumulate1Forward(float[][] x,
                               float[][] y)
Accumulates output in 1st dimension in the forward direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate1Reverse

public void accumulate1Reverse(float[][] x,
                               float[][] y)
Accumulates output in 1st dimension in the reverse direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate2Forward

public void accumulate2Forward(float[][] x,
                               float[][] y)
Accumulates output in 2nd dimension in the forward direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate2Reverse

public void accumulate2Reverse(float[][] x,
                               float[][] y)
/** Accumulates output in 2nd dimension in the reverse direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply1Forward

public void apply1Forward(float[][][] x,
                          float[][][] y)
Applies this filter in 1st dimension in the forward direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply1Reverse

public void apply1Reverse(float[][][] x,
                          float[][][] y)
Applies this filter in 1st dimension in the reverse direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply2Forward

public void apply2Forward(float[][][] x,
                          float[][][] y)
Applies this filter in 2nd dimension in the forward direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply2Reverse

public void apply2Reverse(float[][][] x,
                          float[][][] y)
Applies this filter in 2nd dimension in the reverse direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply3Forward

public void apply3Forward(float[][][] x,
                          float[][][] y)
Applies this filter in 3rd dimension in the forward direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

apply3Reverse

public void apply3Reverse(float[][][] x,
                          float[][][] y)
Applies this filter in 3rd dimension in the reverse direction.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate1Forward

public void accumulate1Forward(float[][][] x,
                               float[][][] y)
Accumulates output in 1st dimension in the forward direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate1Reverse

public void accumulate1Reverse(float[][][] x,
                               float[][][] y)
Accumulates output in 1st dimension in the reverse direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate2Forward

public void accumulate2Forward(float[][][] x,
                               float[][][] y)
Accumulates output in 2nd dimension in the forward direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate2Reverse

public void accumulate2Reverse(float[][][] x,
                               float[][][] y)
Accumulates output in 2nd dimension in the reverse direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate3Forward

public void accumulate3Forward(float[][][] x,
                               float[][][] y)
Accumulates output in 3rd dimension in the forward direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.

accumulate3Reverse

public void accumulate3Reverse(float[][][] x,
                               float[][][] y)
/** Accumulates output in 3rd dimension in the reverse direction. This method filters the input, and adds the result to the output; it is most useful when implementing parallel forms of recursive filters.

Input and output arrays may be the same array, but must be regular and have equal lengths.

Parameters:
x - the input array.
y - the output array.