GNU Radio C++ API
gr_fir_ccf.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002,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 3, 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 
23 /*
24  * WARNING: This file is automatically generated by generate_gr_fir_XXX.py
25  * Any changes made to this file will be overwritten.
26  */
27 
28 
29 #ifndef INCLUDED_GR_FIR_CCF_H
30 #define INCLUDED_GR_FIR_CCF_H
31 
32 #include <gr_core_api.h>
33 #include <vector>
34 #include <gr_types.h>
35 #include <gr_reverse.h>
36 
37 /*!
38  * \brief Abstract class for FIR with gr_complex input, gr_complex output and float taps
39  * \ingroup filter_primitive
40  *
41  * This is the abstract class for a Finite Impulse Response filter.
42  *
43  * The trailing suffix has the form _IOT where I codes the input type,
44  * O codes the output type, and T codes the tap type.
45  * I,O,T are elements of the set 's' (short), 'f' (float), 'c' (gr_complex), 'i' (int)
46  */
47 
49 
50 protected:
51  std::vector<float> d_taps; // reversed taps
52 
53 public:
54 
55  // CONSTRUCTORS
56 
57  /*!
58  * \brief construct new FIR with given taps.
59  *
60  * Note that taps must be in forward order, e.g., coefficient 0 is
61  * stored in new_taps[0], coefficient 1 is stored in
62  * new_taps[1], etc.
63  */
64  gr_fir_ccf () {}
65  gr_fir_ccf (const std::vector<float> &taps) : d_taps (gr_reverse(taps)) {}
66 
67  virtual ~gr_fir_ccf ();
68 
69  // MANIPULATORS
70 
71  /*!
72  * \brief compute a single output value.
73  *
74  * \p input must have ntaps() valid entries.
75  * input[0] .. input[ntaps() - 1] are referenced to compute the output value.
76  *
77  * \returns the filtered input value.
78  */
79  virtual gr_complex filter (const gr_complex input[]) = 0;
80 
81  /*!
82  * \brief compute an array of N output values.
83  *
84  * \p input must have (n - 1 + ntaps()) valid entries.
85  * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values.
86  */
87  virtual void filterN (gr_complex output[], const gr_complex input[],
88  unsigned long n) = 0;
89 
90  /*!
91  * \brief compute an array of N output values, decimating the input
92  *
93  * \p input must have (decimate * (n - 1) + ntaps()) valid entries.
94  * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to
95  * compute the output values.
96  */
97  virtual void filterNdec (gr_complex output[], const gr_complex input[],
98  unsigned long n, unsigned decimate) = 0;
99 
100  /*!
101  * \brief install \p new_taps as the current taps.
102  */
103  virtual void set_taps (const std::vector<float> &taps)
104  {
105  d_taps = gr_reverse(taps);
106  }
107 
108  // ACCESSORS
109 
110  /*!
111  * \return number of taps in filter.
112  */
113  unsigned ntaps () const { return d_taps.size (); }
114 
115  /*!
116  * \return current taps
117  */
118  virtual const std::vector<float> get_taps () const
119  {
120  return gr_reverse(d_taps);
121  }
122 };
123 
124 #endif /* INCLUDED_GR_FIR_CCF_H */