Back: 7. Other Modules Forward: 7.2 EPR Modulation Functions   FastBack: 7. Other Modules Up: 7. Other Modules FastForward: 8. Using Pulsers         Top: fsc2 Contents: Table of Contents Index: Index About: About This Document

7.1 FFT Functions

A module that can be loaded within the DEVICES section by adding

 
fft;

adds three EDL functions that allow to do Fast Fourier Transfirmations on real and complex data sets.

Please note: calculating a discrete Fourier Transformation can be quite time consuming, so you may want to avoid using it on huge arrays.

This module can only be compiled if the FFTW library is installed (make sure it's version 3 or higher). For this reason it isn't created by default but only if the variable WITH_FFT is set in the Makefile or configuration file that controls how fsc2 gets compiled.

List of FFT functions:

`fft_name()'
`fft_real()'
`fft_power_spectrum()'
`fft_complex()'

Descriptions of FFT functions:

`fft_name()'

Returns a "device name" for the module that can be used in messages.

`fft_real()'

If called with a 1-dimensinal array as its only argument the function does a Fast Fourier Transformation of this array. The result is a 2-dimensional array of floating point values. The length of the sub-arrays of the result depend on the length of the input array. If the length of the input array is N then the lengths of the result arrays are N/2+1 if N is even, and (N+1)/2 if N is odd. The first sub-array is the real part of the result of the transformation (i.e. the coeficients of the cos functions), and the second sub-array the imaginary part (i.e. the sin coefficients). The coefficients stored in the output arrays start with the one for the zero frequency, followed by the coefficients for increasing frequencies.

To do a back-transformation the same function must be called, but with either a 2-dimensional array (with sub-arrays of equal lengths) or two 1-dimensional arrays (of equal lengths), with a 1-dimensional array as the result. The third argument must be an integer, the length of the 1-dimensional floating point result array. Passing this third argument is necessary since both a result length of 2N as well as 2N + 1 (where N is the length of both input arrays) are possible. If used for a back-transformation care has to be taken that this argument is identical to the original array length (i.e. if an array of length N was forward-transformed using fft_real() and the result is again transformed backward this third argument must be set to N to reproduce the original array).

The FFT coefficients are normalized for the most typical application, tranforming from time to frequency domain, so that they directly represent the strengths of the contributing freqencies. For example, when Fourier-transforming an array of even length, consisting of alternating values of 1 and -1, the result will have a single coefficient of 1 in the entry for the highest frequency in the real (cos) array and all other elements of both output arrays are 0.

`fft_power_spectrum()'

What this function does is very similar to fft_real() (when used for a forward transformation). It takes a single argument, a 1-dimensional array and applies a real Fast Fourier Transformation. Afterwards the squares of the magnitudes of the frequency components are calculated, resulting in a 1-dimensional array of floating point values that are proportional to the energy of each frequency component. If the input array had N elements the output array has N/2+1 if N is even, if N is odd (N+1)/2.

`fft_complex()'

This function can be used for Fast Fourier Transformations (both forward and backward) of complex data (represented by two arrays, one for the real and one for the imagary data). It expects either a single 2-dimensional array or 2 1-dimensional arrays. As a further argument the direction of the transformation must be given. either the string "FORWARD" (or a value positive value) or the string "BACKWARD" (or a negative value). The result of the transformation is a 2-dimensional array of floating point numbers with the sub-arrays having the same lengths as the input arrays.

The first sub-array of the result contains the real coefficients (i.e. for the cos functions) and the second the imaginary (sin) coefficients. The first element of the array is the coefficient for the lowest (most negative frequency), followed by the coefficient for higher frequencies. The coefficient for the zero frequency is in the middle of the array (or at N/2-1 if the lengths N of the arrays are even).

The scaling of the coefficients is chosen in a way that after a forward transformation from time to frequency domain the coefficents represent the strengths of the contributing frequencies.


Back: 7. Other Modules Forward: 7.2 EPR Modulation Functions   FastBack: 7. Other Modules Up: 7. Other Modules FastForward: 8. Using Pulsers

This document was generated by Jens Thoms Toerring on September 6, 2017 using texi2html 1.82.