org.knowceans.sandbox
Class FirFilter

java.lang.Object
  extended by org.knowceans.sandbox.FirFilter

public class FirFilter
extends java.lang.Object

FirFilter implements a simple FIR filter, exploiting the symmetries of the complex spectrum of real signals.

Conventions: suffix z specifies a complex quantity or its size, they are stored with interleaved real and imaginary parts.

Author:
gregor heinrich

Constructor Summary
FirFilter()
           
 
Method Summary
static long dualFir(double[] Wz, double[] Xz, double[] tempz, double[] Yz, double[] H1z, double[] H2z, int Nz)
          Frequency domain filtering of two real signals with two different real FIR filters.
static void fft(double[] Xz, double[] Wz, int Nz)
          forward FFT
static void fftr(double[] X, double[] Wz, int N)
          forward real-to-complex FFT with half length
static void ffw(double[] Wz, int Nz)
          create FFT coefficients for size N
static long fir(double[] Wz, double[] X, double[] tempz, double[] Y, double[] Hz, int N)
          Frequency domain filtering of one real sequence using half-size FFT.
static void ifft(double[] Xz, double[] Wz, int Nz)
          inverse FFT
static void ifftr(double[] Xz, double[] Wz, int Nz)
          inverse complex-to-real FFT with half length
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FirFilter

public FirFilter()
Method Detail

ffw

public static void ffw(double[] Wz,
                       int Nz)
create FFT coefficients for size N

Parameters:
Wz - N/2 complex values
Nz - FFT size

fft

public static void fft(double[] Xz,
                       double[] Wz,
                       int Nz)
forward FFT

Parameters:
Xz - data (complex interleaved)
Wz - coefficients (complex interleaved)
Nz - FFT size (complex)

ifft

public static void ifft(double[] Xz,
                        double[] Wz,
                        int Nz)
inverse FFT

Parameters:
Xz - data (complex interleaved)
Wz - coefficients (complex interleaved)
Nz - FFT size (complex)

fftr

public static void fftr(double[] X,
                        double[] Wz,
                        int N)
forward real-to-complex FFT with half length

Parameters:
X - data [N] (real)
Yz - output [N/2 + 1] (complex)
Wz - [N/2] coefficients (complex interleaved, of full-size FFT)
N - FFT size (real)

ifftr

public static void ifftr(double[] Xz,
                         double[] Wz,
                         int Nz)
inverse complex-to-real FFT with half length

Parameters:
Xz - data (complex interleaved)
Wz - coefficients (complex interleaved)
Nz - FFT size (complex)

dualFir

public static long dualFir(double[] Wz,
                           double[] Xz,
                           double[] tempz,
                           double[] Yz,
                           double[] H1z,
                           double[] H2z,
                           int Nz)
Frequency domain filtering of two real signals with two different real FIR filters. Filtering of a complex signal is possible by using H1z == H2z.

Parameters:
Wz - [N/2] twiddling factors (complex interleaved)
Xz - [N] complex input vector (pair = real, imag) (complex interleaved)
tempz - [N] temporary buffer
Yz - [N] complex output vector (complex interleaved)
H1z - [N/2 + 1] DFT of IR for filter 1 (complex interleaved)
H2z - --"-- for filter 2 (complex interleaved)
Nz - length of input and output vectors (complex)
Returns:

fir

public static long fir(double[] Wz,
                       double[] X,
                       double[] tempz,
                       double[] Y,
                       double[] Hz,
                       int N)
Frequency domain filtering of one real sequence using half-size FFT.

Parameters:
Wz - [N/4] twiddling factors (complex interleaved, of half-size FFT)
Xz - [N] real input vector
tempz - [N] temporary buffer
Y - [N] real output vector
Hz - [N/4 + 1] DFT of IR (complex interleaved)
N - length of input and output vectors
Returns:

main

public static void main(java.lang.String[] args)