GNU Radio 3.4.2 C++ API
libfft.h
Go to the documentation of this file.
00001 /* --------------------------------------------------------------  */
00002 /* (C)Copyright 2008 Free Software Foundation, Inc.                */
00003 /* (C)Copyright 2001,2007,                                         */
00004 /* International Business Machines Corporation,                    */
00005 /* Sony Computer Entertainment, Incorporated,                      */
00006 /* Toshiba Corporation,                                            */
00007 /*                                                                 */
00008 /* All Rights Reserved.                                            */
00009 /*                                                                 */
00010 /* Redistribution and use in source and binary forms, with or      */
00011 /* without modification, are permitted provided that the           */
00012 /* following conditions are met:                                   */
00013 /*                                                                 */
00014 /* - Redistributions of source code must retain the above copyright*/
00015 /*   notice, this list of conditions and the following disclaimer. */
00016 /*                                                                 */
00017 /* - Redistributions in binary form must reproduce the above       */
00018 /*   copyright notice, this list of conditions and the following   */
00019 /*   disclaimer in the documentation and/or other materials        */
00020 /*   provided with the distribution.                               */
00021 /*                                                                 */
00022 /* - Neither the name of IBM Corporation nor the names of its      */
00023 /*   contributors may be used to endorse or promote products       */
00024 /*   derived from this software without specific prior written     */
00025 /*   permission.                                                   */
00026 /*                                                                 */
00027 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
00028 /* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
00029 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
00030 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
00031 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
00032 /* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
00033 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
00034 /* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
00035 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
00036 /* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
00037 /* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
00038 /* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
00039 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
00040 /* --------------------------------------------------------------  */
00041 /* PROLOG END TAG zYx                                              */
00042 
00043 #ifndef INCLUDED_LIBFFT_H
00044 #define INCLUDED_LIBFFT_H
00045 
00046 // must be defined before inclusion of fft_1d_r2.h
00047 #define MAX_FFT_1D_SIZE 4096
00048 
00049 /* fft_1d_r2
00050  * ---------
00051  * Performs a single precision, complex Fast Fourier Transform using 
00052  * the DFT (Discrete Fourier Transform) with radix-2 decimation in time. 
00053  * The input <in> is an array of complex numbers of length (1<<log2_size)
00054  * entries. The result is returned in the array of complex numbers specified
00055  * by <out>. Note: This routine can support an in-place transformation
00056  * by specifying <in> and <out> to be the same array.
00057  *
00058  * This implementation utilizes the Cooley-Tukey algorithm consisting 
00059  * of <log2_size> stages. The basic operation is the butterfly.
00060  *
00061  *          p --------------------------> P = p + q*Wi
00062  *                        \      /
00063  *                         \    /
00064  *                          \  /
00065  *                           \/
00066  *                           /\
00067  *                          /  \
00068  *                         /    \
00069  *               ____     /      \
00070  *          q --| Wi |-----------------> Q = p - q*Wi
00071  *               ----
00072  *
00073  * This routine also requires pre-computed twiddle values, W. W is an
00074  * array of single precision complex numbers of length 1<<(log2_size-2) 
00075  * and is computed as follows:
00076  *
00077  *      for (i=0; i<n/4; i++)
00078  *          W[i].real =  cos(i * 2*PI/n);
00079  *          W[i].imag = -sin(i * 2*PI/n);
00080  *      }
00081  *
00082  * This array actually only contains the first half of the twiddle
00083  * factors. Due for symmetry, the second half of the twiddle factors
00084  * are implied and equal:
00085  *
00086  *      for (i=0; i<n/4; i++)
00087  *          W[i+n/4].real =  W[i].imag =  sin(i * 2*PI/n);
00088  *          W[i+n/4].imag = -W[i].real = -cos(i * 2*PI/n);
00089  *      }
00090  *
00091  * Further symmetry allows one to generate the twiddle factor table 
00092  * using half the number of trig computations as follows:
00093  *
00094  *      W[0].real = 1.0;
00095  *      W[0].imag = 0.0;
00096  *      for (i=1; i<n/4; i++)
00097  *          W[i].real =  cos(i * 2*PI/n);
00098  *          W[n/4 - i].imag = -W[i].real;
00099  *      }
00100  *
00101  * The complex numbers are packed into quadwords as follows:
00102  *
00103  *    quadword                        complex
00104  *  array element                   array elements
00105  *             -----------------------------------------------------
00106  *       i    |  real 2*i   |  imag 2*i  | real 2*i+1  | imag 2*i+1 | 
00107  *             -----------------------------------------------------
00108  *
00109  */
00110 
00111 void fft_1d_r2(vector float *out, vector float *in, vector float *W, int log2_size);
00112 
00113 #endif /* INCLUDED_LIBFFT_H */