Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / lib / general / gri_fft.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2003 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 #ifndef _GRI_FFT_H_
23 #define _GRI_FFT_H_
24
25 /*
26  * Wrappers for FFTW single precision 1d dft
27  */
28
29 #include <gr_complex.h>
30
31 /*!
32  * \brief FFT: complex in, complex out
33  */
34
35 class gri_fft_complex {
36   int         d_fft_size;
37   gr_complex *d_inbuf;
38   gr_complex *d_outbuf;
39   void       *d_plan;
40   
41 public:
42   gri_fft_complex (int fft_size, bool forward = true);
43   virtual ~gri_fft_complex ();
44
45   /*
46    * These return pointers to buffers owned by gri_fft_complex into which
47    * input and output take place.  It's done this way in order to
48    * ensure optimal alignment for SIMD instructions.
49    */
50   gr_complex *get_inbuf ()  const { return d_inbuf; }
51   gr_complex *get_outbuf () const { return d_outbuf; }
52
53   int inbuf_length ()  const { return d_fft_size; }
54   int outbuf_length () const { return d_fft_size; }
55
56   /*!
57    * compute FFT.  The input comes from inbuf, the output is placed in outbuf.
58    */
59   void execute ();
60 };
61
62 /*!
63  * \brief FFT: real in, complex out
64  */
65 class gri_fft_real_fwd {
66   int         d_fft_size;
67   float      *d_inbuf;
68   gr_complex *d_outbuf;
69   void       *d_plan;
70   
71 public:
72   gri_fft_real_fwd (int fft_size);
73   virtual ~gri_fft_real_fwd ();
74
75   /*
76    * These return pointers to buffers owned by gri_fft_real_fwd into
77    * which input and output take place.  It's done this way in order
78    * to ensure optimal alignment for SIMD instructions.
79    */
80   float *get_inbuf ()      const { return d_inbuf; }
81   gr_complex *get_outbuf () const { return d_outbuf; }
82
83   int inbuf_length ()  const { return d_fft_size; }
84   int outbuf_length () const { return d_fft_size / 2 + 1; }
85
86   /*!
87    * compute FFT.  The input comes from inbuf, the output is placed in outbuf.
88    */
89   void execute ();
90 };
91
92 /*!
93  * \brief FFT: complex in, float out
94  */
95 class gri_fft_real_rev {
96   int         d_fft_size;
97   gr_complex *d_inbuf;
98   float      *d_outbuf;
99   void       *d_plan;
100   
101 public:
102   gri_fft_real_rev (int fft_size);
103   virtual ~gri_fft_real_rev ();
104
105   /*
106    * These return pointers to buffers owned by gri_fft_real_rev into
107    * which input and output take place.  It's done this way in order
108    * to ensure optimal alignment for SIMD instructions.
109    */
110   gr_complex *get_inbuf () const { return d_inbuf; }
111   float *get_outbuf () const { return d_outbuf; }
112
113   int inbuf_length ()  const { return d_fft_size / 2 + 1; }
114   int outbuf_length () const { return d_fft_size; }
115
116   /*!
117    * compute FFT.  The input comes from inbuf, the output is placed in outbuf.
118    */
119   void execute ();
120 };
121
122 #endif