summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-filter/grc/CMakeLists.txt1
-rw-r--r--gr-filter/grc/filter_block_tree.xml1
-rw-r--r--gr-filter/grc/iir_filter_ffd.xml31
-rw-r--r--gr-filter/include/filter/CMakeLists.txt2
-rw-r--r--gr-filter/include/filter/iir_filter.h183
-rw-r--r--gr-filter/include/filter/iir_filter_ffd.h82
-rw-r--r--gr-filter/lib/CMakeLists.txt1
-rw-r--r--gr-filter/lib/iir_filter_ffd_impl.cc85
-rw-r--r--gr-filter/lib/iir_filter_ffd_impl.h56
-rwxr-xr-xgr-filter/python/qa_iir_filter.py157
-rw-r--r--gr-filter/swig/filter_swig.i3
11 files changed, 602 insertions, 0 deletions
diff --git a/gr-filter/grc/CMakeLists.txt b/gr-filter/grc/CMakeLists.txt
index 83036a0b3..63434fe75 100644
--- a/gr-filter/grc/CMakeLists.txt
+++ b/gr-filter/grc/CMakeLists.txt
@@ -24,6 +24,7 @@ install(FILES
fir_filter_xxx.xml
filter_delay_fc.xml
hilbert_fc.xml
+ iir_filter_ffd.xml
pfb_channelizer.xml
single_pole_iir_filter_xx.xml
DESTINATION ${GRC_BLOCKS_DIR}
diff --git a/gr-filter/grc/filter_block_tree.xml b/gr-filter/grc/filter_block_tree.xml
index 6711e809f..2ae4eb628 100644
--- a/gr-filter/grc/filter_block_tree.xml
+++ b/gr-filter/grc/filter_block_tree.xml
@@ -35,6 +35,7 @@
<block>fir_filter_xxx</block>
<block>filter_delay_fc</block>
<block>hilbert_fc</block>
+ <block>iir_filter_ffd</block>
<block>pfb_channelizer_ccf</block>
<block>single_pole_iir_filter_xx</block>
</cat>
diff --git a/gr-filter/grc/iir_filter_ffd.xml b/gr-filter/grc/iir_filter_ffd.xml
new file mode 100644
index 000000000..261aba320
--- /dev/null
+++ b/gr-filter/grc/iir_filter_ffd.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##IIR Filter
+###################################################
+ -->
+<block>
+ <name>IIR Filter</name>
+ <key>iir_filter_ffd</key>
+ <import>from gnuradio import filter</import>
+ <make>filter.iir_filter_ffd($fftaps, $fbtaps)</make>
+ <callback>set_taps($fftaps, $fbtaps)</callback>
+ <param>
+ <name>Feed-forward Taps</name>
+ <key>fftaps</key>
+ <type>real_vector</type>
+ </param>
+ <param>
+ <name>Feedback Taps</name>
+ <key>fbtaps</key>
+ <type>real_vector</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>float</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>float</type>
+ </source>
+</block>
diff --git a/gr-filter/include/filter/CMakeLists.txt b/gr-filter/include/filter/CMakeLists.txt
index e0577fa00..ca8c7bf07 100644
--- a/gr-filter/include/filter/CMakeLists.txt
+++ b/gr-filter/include/filter/CMakeLists.txt
@@ -79,6 +79,7 @@ install(FILES
fir_filter.h
fir_filter_with_buffer.h
fft_filter.h
+ iir_filter.h
interpolator_taps.h
pm_remez.h
polyphase_filterbank.h
@@ -92,6 +93,7 @@ install(FILES
fft_filter_ccc.h
fft_filter_fff.h
hilbert_fc.h
+ iir_filter_ffd.h
pfb_channelizer_ccf.h
single_pole_iir_filter_cc.h
single_pole_iir_filter_ff.h
diff --git a/gr-filter/include/filter/iir_filter.h b/gr-filter/include/filter/iir_filter.h
new file mode 100644
index 000000000..667acec35
--- /dev/null
+++ b/gr-filter/include/filter/iir_filter.h
@@ -0,0 +1,183 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2002,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_IIR_FILTER_H
+#define INCLUDED_IIR_FILTER_H
+
+#include <filter/api.h>
+#include <vector>
+#include <stdexcept>
+
+namespace gr {
+ namespace filter {
+ namespace kernel {
+
+ /*!
+ * \brief base class template for Infinite Impulse Response filter (IIR)
+ */
+ template<class i_type, class o_type, class tap_type>
+ class iir_filter
+ {
+ public:
+ /*!
+ * \brief Construct an IIR with the given taps.
+ *
+ * This filter uses the Direct Form I implementation, where
+ * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones.
+ *
+ * \p fftaps and \p fbtaps must have equal numbers of taps
+ *
+ * The input and output satisfy a difference equation of the form
+
+ \f[
+ y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k]
+ \f]
+
+ * with the corresponding rational system function
+
+ \f[
+ H(z) = \frac{\sum_{k=0}^{N} b_k z^{-k}}{1 - \sum_{k=1}^{M} a_k z^{-k}}
+ \f]
+
+ * Note that some texts define the system function with a + in
+ * the denominator. If you're using that convention, you'll
+ * need to negate the feedback taps.
+ */
+ iir_filter(const std::vector<tap_type>& fftaps,
+ const std::vector<tap_type>& fbtaps) throw (std::invalid_argument)
+ {
+ set_taps(fftaps, fbtaps);
+ }
+
+ iir_filter() : d_latest_n(0),d_latest_m(0) { }
+
+ ~iir_filter() {}
+
+ /*!
+ * \brief compute a single output value.
+ * \returns the filtered input value.
+ */
+ o_type filter(const i_type input);
+
+ /*!
+ * \brief compute an array of N output values.
+ * \p input must have N valid entries.
+ */
+ void filter_n(o_type output[], const i_type input[], long n);
+
+ /*!
+ * \return number of taps in filter.
+ */
+ unsigned ntaps_ff() const { return d_fftaps.size(); }
+ unsigned ntaps_fb() const { return d_fbtaps.size(); }
+
+ /*!
+ * \brief install new taps.
+ */
+ void set_taps(const std::vector<tap_type> &fftaps,
+ const std::vector<tap_type> &fbtaps) throw (std::invalid_argument)
+ {
+ d_latest_n = 0;
+ d_latest_m = 0;
+ d_fftaps = fftaps;
+ d_fbtaps = fbtaps;
+
+ int n = fftaps.size();
+ int m = fbtaps.size();
+ d_prev_input.resize(2 * n);
+ d_prev_output.resize(2 * m);
+
+ for(int i = 0; i < 2 * n; i++) {
+ d_prev_input[i] = 0;
+ }
+ for(int i = 0; i < 2 * m; i++) {
+ d_prev_output[i] = 0;
+ }
+ }
+
+ protected:
+ std::vector<tap_type> d_fftaps;
+ std::vector<tap_type> d_fbtaps;
+ int d_latest_n;
+ int d_latest_m;
+ std::vector<tap_type> d_prev_output;
+ std::vector<i_type> d_prev_input;
+ };
+
+ //
+ // general case. We may want to specialize this
+ //
+ template<class i_type, class o_type, class tap_type>
+ o_type
+ iir_filter<i_type, o_type, tap_type>::filter(const i_type input)
+ {
+ tap_type acc;
+ unsigned i = 0;
+ unsigned n = ntaps_ff();
+ unsigned m = ntaps_fb();
+
+ if(n == 0)
+ return (o_type)0;
+
+ int latest_n = d_latest_n;
+ int latest_m = d_latest_m;
+
+ acc = d_fftaps[0] * input;
+ for(i = 1; i < n; i ++)
+ acc += (d_fftaps[i] * d_prev_input[latest_n + i]);
+ for(i = 1; i < m; i ++)
+ acc += (d_fbtaps[i] * d_prev_output[latest_m + i]);
+
+ // store the values twice to avoid having to handle wrap-around in the loop
+ d_prev_output[latest_m] = acc;
+ d_prev_output[latest_m+m] = acc;
+ d_prev_input[latest_n] = input;
+ d_prev_input[latest_n+n] = input;
+
+ latest_n--;
+ latest_m--;
+ if(latest_n < 0)
+ latest_n += n;
+ if(latest_m < 0)
+ latest_m += m;
+
+ d_latest_m = latest_m;
+ d_latest_n = latest_n;
+ return (o_type)acc;
+ }
+
+ template<class i_type, class o_type, class tap_type>
+ void
+ iir_filter<i_type, o_type, tap_type>::filter_n(o_type output[],
+ const i_type input[],
+ long n)
+ {
+ for(int i = 0; i < n; i++)
+ output[i] = filter(input[i]);
+ }
+
+ } /* namespace kernel */
+ } /* namespace filter */
+} /* namespace gr */
+
+#endif /* INCLUDED_IIR_FILTER_H */
+
diff --git a/gr-filter/include/filter/iir_filter_ffd.h b/gr-filter/include/filter/iir_filter_ffd.h
new file mode 100644
index 000000000..c23286ddc
--- /dev/null
+++ b/gr-filter/include/filter/iir_filter_ffd.h
@@ -0,0 +1,82 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_IIR_FILTER_FFD_H
+#define INCLUDED_IIR_FILTER_FFD_H
+
+#include <filter/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace filter {
+
+ /*!
+ * \brief IIR filter with float input, float output and double taps
+ * \ingroup filter_blk
+ *
+ * This filter uses the Direct Form I implementation, where
+ * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones.
+ *
+ *
+ * The input and output satisfy a difference equation of the form
+ \htmlonly
+ \f{
+ y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k]
+ \f}
+ \endhtmlonly
+
+ \xmlonly
+ y[n] - \sum_{k=1}^{M} a_k y[n-k] = \sum_{k=0}^{N} b_k x[n-k]
+ \endxmlonly
+
+ * with the corresponding rational system function
+ \htmlonly
+ \f{
+ H(z) = \ frac{\sum_{k=0}^{M} b_k z^{-k}}{1 - \sum_{k=1}^{N} a_k z^{-k}}
+ \f}
+ \endhtmlonly
+
+ \xmlonly
+ H(z) = \ frac{\sum_{k=0}^{M} b_k z^{-k}}{1 - \sum_{k=1}^{N} a_k z^{-k}}
+ \endxmlonly
+
+ * Note that some texts define the system function with a + in the
+ * denominator. If you're using that convention, you'll need to
+ * negate the feedback taps.
+ */
+ class FILTER_API iir_filter_ffd : virtual public gr_sync_block
+ {
+ public:
+ // gr::filter::iir_filter_ffd::sptr
+ typedef boost::shared_ptr<iir_filter_ffd> sptr;
+
+ static FILTER_API sptr make(const std::vector<double> &fftaps,
+ const std::vector<double> &fbtaps);
+
+ virtual void set_taps(const std::vector<double> &fftaps,
+ const std::vector<double> &fbtaps) = 0;
+ };
+
+ } /* namespace filter */
+} /* namespace gr */
+
+#endif /* INCLUDED_IIR_FILTER_FFD_H */
diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt
index d661d01b6..7a8b5aa0b 100644
--- a/gr-filter/lib/CMakeLists.txt
+++ b/gr-filter/lib/CMakeLists.txt
@@ -120,6 +120,7 @@ list(APPEND filter_sources
fft_filter_ccc_impl.cc
fft_filter_fff_impl.cc
hilbert_fc_impl.cc
+ iir_filter_ffd_impl.cc
pfb_channelizer_ccf_impl.cc
single_pole_iir_filter_cc_impl.cc
single_pole_iir_filter_ff_impl.cc
diff --git a/gr-filter/lib/iir_filter_ffd_impl.cc b/gr-filter/lib/iir_filter_ffd_impl.cc
new file mode 100644
index 000000000..24bfad190
--- /dev/null
+++ b/gr-filter/lib/iir_filter_ffd_impl.cc
@@ -0,0 +1,85 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "iir_filter_ffd_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace filter {
+
+ iir_filter_ffd::sptr
+ iir_filter_ffd::make(const std::vector<double> &fftaps,
+ const std::vector<double> &fbtaps)
+ {
+ return gnuradio::get_initial_sptr(new iir_filter_ffd_impl(fftaps, fbtaps));
+ }
+
+ iir_filter_ffd_impl::iir_filter_ffd_impl(const std::vector<double> &fftaps,
+ const std::vector<double> &fbtaps)
+
+ : gr_sync_block("iir_filter_ffd",
+ gr_make_io_signature(1, 1, sizeof (float)),
+ gr_make_io_signature(1, 1, sizeof (float))),
+ d_updated(false)
+ {
+ d_iir = new kernel::iir_filter<float,float,double>(fftaps, fbtaps);
+ //d_iir = new gri_iir<float,float,double>(fftaps, fbtaps);
+ }
+
+ iir_filter_ffd_impl::~iir_filter_ffd_impl()
+ {
+ delete d_iir;
+ }
+
+ void
+ iir_filter_ffd_impl::set_taps(const std::vector<double> &fftaps,
+ const std::vector<double> &fbtaps)
+ {
+ d_new_fftaps = fftaps;
+ d_new_fbtaps = fbtaps;
+ d_updated = true;
+ }
+
+ int
+ iir_filter_ffd_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const float *in = (const float*)input_items[0];
+ float *out = (float*)output_items[0];
+
+ if(d_updated) {
+ d_iir->set_taps(d_new_fftaps, d_new_fbtaps);
+ d_updated = false;
+ }
+
+ d_iir->filter_n(out, in, noutput_items);
+ return noutput_items;
+ };
+
+ } /* namespace filter */
+} /* namespace gr */
+
diff --git a/gr-filter/lib/iir_filter_ffd_impl.h b/gr-filter/lib/iir_filter_ffd_impl.h
new file mode 100644
index 000000000..45aab6c22
--- /dev/null
+++ b/gr-filter/lib/iir_filter_ffd_impl.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_IIR_FILTER_FFD_IMPL_H
+#define INCLUDED_IIR_FILTER_FFD_IMPL_H
+
+#include <filter/iir_filter.h>
+#include <filter/iir_filter_ffd.h>
+
+namespace gr {
+ namespace filter {
+
+ class FILTER_API iir_filter_ffd_impl : public iir_filter_ffd
+ {
+ private:
+ bool d_updated;
+ kernel::iir_filter<float,float,double> *d_iir;
+ std::vector<double> d_new_fftaps;
+ std::vector<double> d_new_fbtaps;
+
+ public:
+ iir_filter_ffd_impl(const std::vector<double> &fftaps,
+ const std::vector<double> &fbtaps);
+ ~iir_filter_ffd_impl();
+
+ void set_taps(const std::vector<double> &fftaps,
+ const std::vector<double> &fbtaps);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace filter */
+} /* namespace gr */
+
+#endif /* INCLUDED_IIR_FILTER_FFD_IMPL_H */
diff --git a/gr-filter/python/qa_iir_filter.py b/gr-filter/python/qa_iir_filter.py
new file mode 100755
index 000000000..645c4b66e
--- /dev/null
+++ b/gr-filter/python/qa_iir_filter.py
@@ -0,0 +1,157 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2007,2010 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest
+import filter_swig as filter
+
+class test_iir_filter(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_iir_direct_001(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8)
+ fftaps = ()
+ fbtaps = ()
+ expected_result = (0, 0, 0, 0, 0, 0, 0, 0)
+ src = gr.vector_source_f(src_data)
+ op = filter.iir_filter_ffd(fftaps, fbtaps)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+ def test_iir_direct_002(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8)
+ fftaps = (2,)
+ fbtaps = (0,)
+ expected_result = (2, 4, 6, 8, 10, 12, 14, 16)
+ src = gr.vector_source_f(src_data)
+ op = filter.iir_filter_ffd(fftaps, fbtaps)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+ def test_iir_direct_003(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8)
+ fftaps = (2, 11)
+ fbtaps = (0, 0)
+ expected_result = (2, 15, 28, 41, 54, 67, 80, 93)
+ src = gr.vector_source_f(src_data)
+ op = filter.iir_filter_ffd(fftaps, fbtaps)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+ def test_iir_direct_004(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8)
+ fftaps = (2, 11)
+ fbtaps = (0, -1)
+ expected_result = (2, 13, 15, 26, 28, 39, 41, 52)
+ src = gr.vector_source_f(src_data)
+ op = filter.iir_filter_ffd(fftaps, fbtaps)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+ def test_iir_direct_005(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8)
+ fftaps = (2, 11, 0)
+ fbtaps = (0, -1, 3)
+ expected_result = (2, 13, 21, 59, 58, 186, 68, 583)
+ src = gr.vector_source_f(src_data)
+ op = filter.iir_filter_ffd(fftaps, fbtaps)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+ def test_iir_direct_006(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8)
+ expected_result = (2, 13, 21, 59, 58, 186, 68, 583)
+ fftaps = (2, 1)
+ fbtaps = (0, -1)
+ src = gr.vector_source_f(src_data)
+ op = filter.iir_filter_ffd(fftaps, fbtaps)
+ fftaps = (2, 11, 0)
+ fbtaps = (0, -1, 3)
+ op.set_taps(fftaps, fbtaps)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+ def test_iir_direct_007(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8)
+ expected_result = (2,2,5,5,8,8,11,11)
+ fftaps = (2, 1)
+ fbtaps = (0, -1)
+ src = gr.vector_source_f(src_data)
+ op = filter.iir_filter_ffd(fftaps, fbtaps)
+ fftaps = (2,0,1)
+ fbtaps = (0, -1)
+ op.set_taps(fftaps, fbtaps)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual(expected_result, result_data)
+
+ def test_iir_direct_008(self):
+ src_data = (1, 2, 3, 4, 5, 6, 7, 8)
+ expected_result = (2,4,4,10,18,14,26,56)
+ fftaps = (2,)
+ fbtaps = (0, 1)
+ src = gr.vector_source_f(src_data)
+ op = filter.iir_filter_ffd(fftaps, fbtaps)
+ fftaps_data = (1)
+ fbtaps = (0,0, -1,3)
+ op.set_taps(fftaps, fbtaps)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, op)
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertFloatTuplesAlmostEqual (expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_iir_filter, "test_iir_filter.xml")
+
diff --git a/gr-filter/swig/filter_swig.i b/gr-filter/swig/filter_swig.i
index 8585bda32..be5338f4b 100644
--- a/gr-filter/swig/filter_swig.i
+++ b/gr-filter/swig/filter_swig.i
@@ -43,6 +43,7 @@
#include "filter/fft_filter_ccc.h"
#include "filter/fft_filter_fff.h"
#include "filter/hilbert_fc.h"
+#include "filter/iir_filter_ffd.h"
#include "filter/pfb_channelizer_ccf.h"
#include "filter/single_pole_iir_filter_cc.h"
#include "filter/single_pole_iir_filter_ff.h"
@@ -63,6 +64,7 @@
%include "filter/fft_filter_ccc.h"
%include "filter/fft_filter_fff.h"
%include "filter/hilbert_fc.h"
+%include "filter/iir_filter_ffd.h"
%include "filter/pfb_channelizer_ccf.h"
%include "filter/single_pole_iir_filter_cc.h"
%include "filter/single_pole_iir_filter_ff.h"
@@ -80,6 +82,7 @@ GR_SWIG_BLOCK_MAGIC2(filter, fir_filter_fsf);
GR_SWIG_BLOCK_MAGIC2(filter, fft_filter_ccc);
GR_SWIG_BLOCK_MAGIC2(filter, fft_filter_fff);
GR_SWIG_BLOCK_MAGIC2(filter, hilbert_fc);
+GR_SWIG_BLOCK_MAGIC2(filter, iir_filter_ffd);
GR_SWIG_BLOCK_MAGIC2(filter, pfb_channelizer_ccf);
GR_SWIG_BLOCK_MAGIC2(filter, single_pole_iir_filter_cc);
GR_SWIG_BLOCK_MAGIC2(filter, single_pole_iir_filter_ff);