SCCON Scientific Research Inc.

Testing an FFT Routine

Simple tests can determine if your FFT routine is operating properly.

Description

A test program creates an 8-element vector to test an FFT routine from within a C-program. Two sample input vectors with the expected output vectors are provided.


Fourier Transform Test Function I

FFT Test Example

The Fourier transform of an impulse at the origin is a constant in the transform domain. In discrete form, the impulse is a non-zero sample at REAL[0].

Test Input Data

The test program computes the discrete Fourier transform of an 8-element vector consisting of a real impulse at the origin.

      REAL[0]=  1.000,   IMAG[0]=  0.000
      REAL[1]=  0.000,   IMAG[1]=  0.000
      REAL[2]=  0.000,   IMAG[2]=  0.000
      REAL[3]=  0.000,   IMAG[3]=  0.000
      REAL[4]=  0.000,   IMAG[4]=  0.000
      REAL[5]=  0.000,   IMAG[5]=  0.000
      REAL[6]=  0.000,   IMAG[6]=  0.000
      REAL[7]=  0.000,   IMAG[7]=  0.000

Correct Test Results

The result should be a constant in the transform domain; in this case, eight real values, all equal to 0.125

      REAL[0]=  0.125,   IMAG[0]=  0.000
      REAL[1]=  0.125,   IMAG[1]=  0.000
      REAL[2]=  0.125,   IMAG[2]=  0.000
      REAL[3]=  0.125,   IMAG[3]=  0.000
      REAL[4]=  0.125,   IMAG[4]=  0.000
      REAL[5]=  0.125,   IMAG[5]=  0.000
      REAL[6]=  0.125,   IMAG[6]=  0.000
      REAL[7]=  0.125,   IMAG[7]=  0.000

Fourier Transform Test Function II

FFT Test Example

A shifted impulse alters only the phase of the transform components. The magnitude remains constant since "sin2x + cos2x = 1". In discrete form, the shifted impulse is a non-zero sample at REAL[1].
 

Test Input Data

With a small modification, the test program computes the discrete Fourier transform of an 8-element vector consisting of a shifted impulse.

      REAL[0]=  0.000,   IMAG[0]=  0.000
      REAL[1]= +1.000,   IMAG[1]=  0.000
      REAL[2]=  0.000,   IMAG[2]=  0.000
      REAL[3]=  0.000,   IMAG[3]=  0.000
      REAL[4]=  0.000,   IMAG[4]=  0.000
      REAL[5]=  0.000,   IMAG[5]=  0.000
      REAL[6]=  0.000,   IMAG[6]=  0.000
      REAL[7]=  0.000,   IMAG[7]=  0.000

Correct Test Results

The result should have constant magnitude in the transform domain; in this case, the squareroot of "real[x] squared imag[x] squared" equals 0.125 in every case.

      REAL[0]=  0.125,   IMAG[0]= +0.000
      REAL[1]= +0.088,   IMAG[1]= -0.088
      REAL[2]= +0.000,   IMAG[2]= -0.125
      REAL[3]= -0.088,   IMAG[3]= -0.088
      REAL[4]= -0.125,   IMAG[4]= +0.000
      REAL[5]= -0.088,   IMAG[5]= +0.088
      REAL[6]= +0.000,   IMAG[6]= +0.125
      REAL[7]= +0.088,   IMAG[7]= +0.088

 Tech fax: +1-506-458-5958 Contact:
Back