summaryrefslogtreecommitdiff
path: root/gr-filter
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2012-06-15 11:53:58 -0400
committerTom Rondeau <trondeau@vt.edu>2012-06-15 15:59:07 -0400
commit05c117f359b831513bbf6c4f43dca9cb181e5920 (patch)
tree3364167872ae34e2c79e10bf72e925267c11ad48 /gr-filter
parent1e7aae3678b0ce08e71b444225aca794f490ffaf (diff)
filter: updating adaptive FIR filters.
No need for our own adaptive_fir class; can do everything with fir_filter. With QA code.
Diffstat (limited to 'gr-filter')
-rw-r--r--gr-filter/include/filter/CMakeLists.txt1
-rw-r--r--gr-filter/include/filter/adaptive_fir.h98
-rw-r--r--gr-filter/include/filter/adaptive_fir_ccc.h6
-rw-r--r--gr-filter/include/filter/adaptive_fir_ccf.h5
-rw-r--r--gr-filter/lib/CMakeLists.txt1
-rw-r--r--gr-filter/lib/adaptive_fir.cc185
-rw-r--r--gr-filter/lib/adaptive_fir_ccc_impl.cc18
-rw-r--r--gr-filter/lib/adaptive_fir_ccc_impl.h5
-rw-r--r--gr-filter/lib/adaptive_fir_ccf_impl.cc18
-rw-r--r--gr-filter/lib/adaptive_fir_ccf_impl.h5
-rwxr-xr-xgr-filter/python/qa_adaptive_fir_filter.py159
-rw-r--r--gr-filter/swig/filter_swig.i6
12 files changed, 208 insertions, 299 deletions
diff --git a/gr-filter/include/filter/CMakeLists.txt b/gr-filter/include/filter/CMakeLists.txt
index 2620d3f544..24e63dc0ca 100644
--- a/gr-filter/include/filter/CMakeLists.txt
+++ b/gr-filter/include/filter/CMakeLists.txt
@@ -75,7 +75,6 @@ add_custom_target(filter_generated_includes DEPENDS
########################################################################
install(FILES
api.h
- adaptive_fir.h
firdes.h
fir_filter.h
fir_filter_with_buffer.h
diff --git a/gr-filter/include/filter/adaptive_fir.h b/gr-filter/include/filter/adaptive_fir.h
deleted file mode 100644
index 75a5f57db7..0000000000
--- a/gr-filter/include/filter/adaptive_fir.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2011,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_FILTER_ADAPTIVE_FIR_H
-#define INCLUDED_FILTER_ADAPTIVE_FIR_H
-
-#include <filter/api.h>
-#include <vector>
-#include <gr_types.h>
-
-namespace gr {
- namespace filter {
- namespace kernel {
-
- class FILTER_API adaptive_fir_ccc
- {
- protected:
- int d_decim;
- unsigned int d_ntaps;
- gr_complex d_error;
- gr_complex *d_taps;
-
- // Override to calculate error signal per output
- virtual gr_complex error(const gr_complex &out) = 0;
-
- // Override to calculate new weight from old, corresponding input
- virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0;
-
- public:
- adaptive_fir_ccc(int decimation,
- const std::vector<gr_complex> &taps);
-
- void set_taps(const std::vector<gr_complex> &taps);
- std::vector<gr_complex> taps() const;
-
- int decimation() const;
- unsigned int ntaps() const;
-
- gr_complex filter(gr_complex *input);
- void filterN(gr_complex *out, gr_complex *in, int nitems);
- };
-
-
- /**************************************************************/
-
-
- class FILTER_API adaptive_fir_ccf
- {
- protected:
- int d_decim;
- unsigned int d_ntaps;
- float d_error;
- gr_complex *d_taps;
-
- // Override to calculate error signal per output
- virtual float error(const gr_complex &out) = 0;
-
- // Override to calculate new weight from old, corresponding input
- virtual void update_tap(gr_complex &tap, const gr_complex &in) = 0;
-
- public:
- adaptive_fir_ccf(int decimation,
- const std::vector<float> &taps);
-
- void set_taps(const std::vector<float> &taps);
- std::vector<float> taps() const;
-
- int decimation() const;
- unsigned int ntaps() const;
-
- gr_complex filter(gr_complex *input);
- void filterN(gr_complex *out, gr_complex *in, int nitems);
- };
-
- } /* namespace kernel */
- } /* namespace filter */
-} /* namespace gr */
-
-#endif /* INCLUDED_FILTER_ADAPTIVE_FIR_H */
diff --git a/gr-filter/include/filter/adaptive_fir_ccc.h b/gr-filter/include/filter/adaptive_fir_ccc.h
index 14e9f6f53e..b30cd353c3 100644
--- a/gr-filter/include/filter/adaptive_fir_ccc.h
+++ b/gr-filter/include/filter/adaptive_fir_ccc.h
@@ -24,8 +24,8 @@
#define INCLUDED_FILTER_ADAPTIVE_FIR_CCC_H
#include <filter/api.h>
-#include <filter/adaptive_fir.h>
#include <gr_sync_decimator.h>
+#include <filter/fir_filter.h>
namespace gr {
namespace filter {
@@ -43,8 +43,8 @@ namespace gr {
static FILTER_API sptr make(const char *name, int decimation,
const std::vector<gr_complex> &taps);
- void set_taps(const std::vector<gr_complex> &taps);
- std::vector<gr_complex> taps();
+ virtual void set_taps(const std::vector<gr_complex> &taps) = 0;
+ virtual std::vector<gr_complex> taps() const = 0;
};
} /* namespace filter */
diff --git a/gr-filter/include/filter/adaptive_fir_ccf.h b/gr-filter/include/filter/adaptive_fir_ccf.h
index 8eb01c8776..0503acd4e5 100644
--- a/gr-filter/include/filter/adaptive_fir_ccf.h
+++ b/gr-filter/include/filter/adaptive_fir_ccf.h
@@ -24,7 +24,6 @@
#define INCLUDED_FILTER_ADAPTIVE_FIR_CCF_H
#include <filter/api.h>
-#include <filter/adaptive_fir.h>
#include <gr_sync_decimator.h>
namespace gr {
@@ -43,8 +42,8 @@ namespace gr {
static FILTER_API sptr make(const char *name, int decimation,
const std::vector<float> &taps);
- void set_taps(const std::vector<float> &taps);
- std::vector<float> taps();
+ virtual void set_taps(const std::vector<float> &taps) = 0;
+ virtual std::vector<float> taps() = 0;
};
} /* namespace filter */
diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt
index f5dbd1bb3b..7a6394b572 100644
--- a/gr-filter/lib/CMakeLists.txt
+++ b/gr-filter/lib/CMakeLists.txt
@@ -105,7 +105,6 @@ link_directories(${FFTW3F_LIBRARY_DIRS})
# Setup library
########################################################################
list(APPEND filter_sources
- adaptive_fir.cc
fir_filter.cc
fir_filter_with_buffer.cc
fft_filter.cc
diff --git a/gr-filter/lib/adaptive_fir.cc b/gr-filter/lib/adaptive_fir.cc
deleted file mode 100644
index 9098e86ca1..0000000000
--- a/gr-filter/lib/adaptive_fir.cc
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 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 <filter/adaptive_fir.h>
-#include <fft/fft.h>
-#include <volk/volk.h>
-
-namespace gr {
- namespace filter {
- namespace kernel {
-
- adaptive_fir_ccc::adaptive_fir_ccc(int decimation,
- const std::vector<gr_complex> &taps)
- {
- d_taps = NULL;
- d_decim = decimation;
- set_taps(taps);
- }
-
- void
- adaptive_fir_ccc::set_taps(const std::vector<gr_complex> &taps)
- {
- // Free the taps if already allocated
- if(d_taps != NULL) {
- fft::free(d_taps);
- d_taps = NULL;
- }
-
- d_ntaps = (int)taps.size();
- d_taps = fft::malloc_complex(d_ntaps);
- for(unsigned int i = 0; i < d_ntaps; i++) {
- d_taps[d_ntaps-i-1] = taps[i];
- }
- }
-
- std::vector<gr_complex>
- adaptive_fir_ccc::taps() const
- {
- std::vector<gr_complex> t;
- for(unsigned int i = 0; i < d_ntaps; i++)
- t.push_back(d_taps[d_ntaps-i-1]);
- return t;
- }
-
- int
- adaptive_fir_ccc::decimation() const
- {
- return d_decim;
- }
-
- unsigned int
- adaptive_fir_ccc::ntaps() const
- {
- return d_ntaps;
- }
-
- gr_complex
- adaptive_fir_ccc::filter(gr_complex *input)
- {
- gr_complex output;
- volk_32fc_x2_dot_prod_32fc_u(&output, input, d_taps, d_ntaps);
- return output;
- }
-
- void
- adaptive_fir_ccc::filterN(gr_complex *out, gr_complex *in,
- int nitems)
- {
- int j = 0;
- unsigned int k;
- for(int i = 0; i < nitems; i++) {
- out[i] = filter(&in[j]);
-
- // Adjust taps
- d_error = error(out[i]);
- for(k = 0; k < d_ntaps; k++) {
- update_tap(d_taps[d_ntaps-k-1], in[j+k]);
- }
-
- j += decimation();
- }
- }
-
-
- /**************************************************************/
-
-
- adaptive_fir_ccf::adaptive_fir_ccf(int decimation,
- const std::vector<float> &taps)
- {
- d_taps = NULL;
- d_decim = decimation;
- set_taps(taps);
- }
-
- void
- adaptive_fir_ccf::set_taps(const std::vector<float> &taps)
- {
- // Free the taps if already allocated
- if(d_taps != NULL) {
- fft::free(d_taps);
- d_taps = NULL;
- }
-
- d_ntaps = (int)taps.size();
- d_taps = fft::malloc_complex(d_ntaps);
- for(unsigned int i = 0; i < d_ntaps; i++) {
- d_taps[d_ntaps-i-1] = taps[i];
- }
- }
-
- std::vector<float>
- adaptive_fir_ccf::taps() const
- {
- std::vector<float> t;
- for(unsigned int i = 0; i < d_ntaps; i++)
- t.push_back(d_taps[d_ntaps-i-1].real());
- return t;
- }
-
- int
- adaptive_fir_ccf::decimation() const
- {
- return d_decim;
- }
-
- unsigned int
- adaptive_fir_ccf::ntaps() const
- {
- return d_ntaps;
- }
-
- gr_complex
- adaptive_fir_ccf::filter(gr_complex *input)
- {
- gr_complex output;
- volk_32fc_x2_dot_prod_32fc_u(&output, input, d_taps, d_ntaps);
- return output;
- }
-
- void
- adaptive_fir_ccf::filterN(gr_complex *out, gr_complex *in,
- int nitems)
- {
- int j = 0;
- unsigned int k;
- for(int i = 0; i < nitems; i++) {
- out[i] = filter(&in[j]);
-
- // Adjust taps
- d_error = error(out[i]);
- for(k = 0; k < d_ntaps; k++) {
- update_tap(d_taps[d_ntaps-k-1], in[j+k]);
- }
-
- j += decimation();
- }
- }
-
- } /* namespace kernel */
- } /* namespace filter */
-} /* namespace gr */
diff --git a/gr-filter/lib/adaptive_fir_ccc_impl.cc b/gr-filter/lib/adaptive_fir_ccc_impl.cc
index 06736ae6f1..515ef90cd0 100644
--- a/gr-filter/lib/adaptive_fir_ccc_impl.cc
+++ b/gr-filter/lib/adaptive_fir_ccc_impl.cc
@@ -43,7 +43,7 @@ namespace gr {
gr_make_io_signature(1, 1, sizeof(gr_complex)),
gr_make_io_signature(1, 1, sizeof(gr_complex)),
decimation),
- kernel::adaptive_fir_ccc(decimation, taps),
+ kernel::fir_filter_ccc(decimation, taps),
d_updated(false)
{
set_history(d_ntaps);
@@ -56,6 +56,12 @@ namespace gr {
d_updated = true;
}
+ std::vector<gr_complex>
+ adaptive_fir_ccc_impl::taps() const
+ {
+ return kernel::fir_filter_ccc::taps();
+ }
+
gr_complex
adaptive_fir_ccc_impl::error(const gr_complex &out)
{
@@ -77,7 +83,7 @@ namespace gr {
gr_complex *out = (gr_complex *)output_items[0];
if (d_updated) {
- kernel::adaptive_fir_ccc::set_taps(d_new_taps);
+ kernel::fir_filter_ccc::set_taps(d_new_taps);
set_history(d_ntaps);
d_updated = false;
return 0; // history requirements may have changed.
@@ -85,7 +91,13 @@ namespace gr {
// Call base class filtering function that uses
// overloaded error and update_tap functions.
- filterN(out, in, noutput_items);
+ if (decimation() == 1) {
+ filterN(out, in, noutput_items);
+ }
+ else {
+ filterNdec(out, in, noutput_items,
+ decimation());
+ }
return noutput_items;
}
diff --git a/gr-filter/lib/adaptive_fir_ccc_impl.h b/gr-filter/lib/adaptive_fir_ccc_impl.h
index f145ceeaac..fd6274a1d6 100644
--- a/gr-filter/lib/adaptive_fir_ccc_impl.h
+++ b/gr-filter/lib/adaptive_fir_ccc_impl.h
@@ -24,17 +24,19 @@
#define INCLUDED_FILTER_ADAPTIVE_FIR_CCC_IMPL_H
#include <filter/adaptive_fir_ccc.h>
+#include <filter/fir_filter.h>
#include <gr_types.h>
namespace gr {
namespace filter {
- class FILTER_API adaptive_fir_ccc_impl : public adaptive_fir_ccc, public kernel::adaptive_fir_ccc
+ class FILTER_API adaptive_fir_ccc_impl : public adaptive_fir_ccc, public kernel::fir_filter_ccc
{
private:
std::vector<gr_complex> d_new_taps;
bool d_updated;
+ protected:
// Override to calculate error signal per output
gr_complex error(const gr_complex &out);
@@ -43,6 +45,7 @@ namespace gr {
public:
void set_taps(const std::vector<gr_complex> &taps);
+ std::vector<gr_complex> taps() const;
adaptive_fir_ccc_impl(const char *name, int decimation,
const std::vector<gr_complex> &taps);
diff --git a/gr-filter/lib/adaptive_fir_ccf_impl.cc b/gr-filter/lib/adaptive_fir_ccf_impl.cc
index 053facdc29..62d7e53371 100644
--- a/gr-filter/lib/adaptive_fir_ccf_impl.cc
+++ b/gr-filter/lib/adaptive_fir_ccf_impl.cc
@@ -43,7 +43,7 @@ namespace gr {
gr_make_io_signature(1, 1, sizeof(gr_complex)),
gr_make_io_signature(1, 1, sizeof(gr_complex)),
decimation),
- kernel::adaptive_fir_ccf(decimation, taps),
+ kernel::fir_filter_ccf(decimation, taps),
d_updated(false)
{
set_history(d_ntaps);
@@ -56,6 +56,12 @@ namespace gr {
d_updated = true;
}
+ std::vector<float>
+ adaptive_fir_ccf_impl::taps()
+ {
+ return kernel::fir_filter_ccf::taps();
+ }
+
float
adaptive_fir_ccf_impl::error(const gr_complex &out)
{
@@ -77,7 +83,7 @@ namespace gr {
gr_complex *out = (gr_complex *)output_items[0];
if (d_updated) {
- kernel::adaptive_fir_ccf::set_taps(d_new_taps);
+ kernel::fir_filter_ccf::set_taps(d_new_taps);
set_history(d_ntaps);
d_updated = false;
return 0; // history requirements may have changed.
@@ -85,7 +91,13 @@ namespace gr {
// Call base class filtering function that uses
// overloaded error and update_tap functions.
- filterN(out, in, noutput_items);
+ if (decimation() == 1) {
+ filterN(out, in, noutput_items);
+ }
+ else {
+ filterNdec(out, in, noutput_items,
+ decimation());
+ }
return noutput_items;
}
diff --git a/gr-filter/lib/adaptive_fir_ccf_impl.h b/gr-filter/lib/adaptive_fir_ccf_impl.h
index fa9a421899..2a1c7e5e9c 100644
--- a/gr-filter/lib/adaptive_fir_ccf_impl.h
+++ b/gr-filter/lib/adaptive_fir_ccf_impl.h
@@ -24,17 +24,19 @@
#define INCLUDED_FILTER_ADAPTIVE_FIR_CCF_IMPL_H
#include <filter/adaptive_fir_ccf.h>
+#include <filter/fir_filter.h>
#include <gr_types.h>
namespace gr {
namespace filter {
- class FILTER_API adaptive_fir_ccf_impl : public adaptive_fir_ccf, public kernel::adaptive_fir_ccf
+ class FILTER_API adaptive_fir_ccf_impl : public adaptive_fir_ccf, public kernel::fir_filter_ccf
{
private:
std::vector<float> d_new_taps;
bool d_updated;
+ protected:
// Override to calculate error signal per output
float error(const gr_complex &out);
@@ -43,6 +45,7 @@ namespace gr {
public:
void set_taps(const std::vector<float> &taps);
+ std::vector<float> taps();
adaptive_fir_ccf_impl(const char *name, int decimation,
const std::vector<float> &taps);
diff --git a/gr-filter/python/qa_adaptive_fir_filter.py b/gr-filter/python/qa_adaptive_fir_filter.py
new file mode 100755
index 0000000000..cadce52044
--- /dev/null
+++ b/gr-filter/python/qa_adaptive_fir_filter.py
@@ -0,0 +1,159 @@
+#!/usr/bin/env python
+#
+# Copyright 2008,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 this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+from gnuradio import gr, gr_unittest
+import filter_swig as filter
+
+class test_adaptive_filter(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block ()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_adaptive_fir_filter_ccf_001(self):
+ src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j]
+ expected_data = ((0.5+0.5j), (1.5+1.5j), (3+3j), (5+5j), (5.5+5.5j),
+ (6.5+6.5j), (8+8j), (10+10j), (10.5+10.5j), (11.5+11.5j),
+ (13+13j), (15+15j), (15.5+15.5j), (16.5+16.5j), (18+18j),
+ (20+20j), (20.5+20.5j), (21.5+21.5j), (23+23j), (25+25j),
+ (25.5+25.5j), (26.5+26.5j), (28+28j), (30+30j), (30.5+30.5j),
+ (31.5+31.5j), (33+33j), (35+35j), (35.5+35.5j), (36.5+36.5j),
+ (38+38j), (40+40j), (40.5+40.5j), (41.5+41.5j), (43+43j),
+ (45+45j), (45.5+45.5j), (46.5+46.5j), (48+48j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j))
+
+ src = gr.vector_source_c(src_data)
+ op = filter.adaptive_fir_ccf("test", 1, 20*[0.5, 0.5])
+ dst = gr.vector_sink_c()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
+
+ def test_adaptive_fir_filter_ccf_002(self):
+ src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j]
+ expected_data = ((0.5+0.5j), (5.5+5.5j), (10.5+10.5j), (15.5+15.5j),
+ (20.5+20.5j), (25.5+25.5j), (30.5+30.5j), (35.5+35.5j),
+ (40.5+40.5j), (45.5+45.5j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j), (50+50j),
+ (50+50j), (50+50j), (50+50j), (50+50j))
+
+ src = gr.vector_source_c(src_data)
+ op = filter.adaptive_fir_ccf("test", 4, 20*[0.5, 0.5])
+ dst = gr.vector_sink_c()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
+
+ def test_adaptive_fir_filter_ccc_001(self):
+ src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j]
+ expected_data = ((-0.5+1.5j), (-1.5+4.5j), (-3+9j), (-5+15j),
+ (-5.5+16.5j), (-6.5+19.5j), (-8+24j), (-10+30j),
+ (-10.5+31.5j), (-11.5+34.5j), (-13+39j), (-15+45j),
+ (-15.5+46.5j), (-16.5+49.5j), (-18+54j), (-20+60j),
+ (-20.5+61.5j), (-21.5+64.5j), (-23+69j), (-25+75j),
+ (-25.5+76.5j), (-26.5+79.5j), (-28+84j), (-30+90j),
+ (-30.5+91.5j), (-31.5+94.5j), (-33+99j), (-35+105j),
+ (-35.5+106.5j), (-36.5+109.5j), (-38+114j), (-40+120j),
+ (-40.5+121.5j), (-41.5+124.5j), (-43+129j), (-45+135j),
+ (-45.5+136.5j), (-46.5+139.5j), (-48+144j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j), (-50+150j))
+ src = gr.vector_source_c(src_data)
+ op = filter.adaptive_fir_ccc("test", 1, 20*[0.5+1j, 0.5+1j])
+ dst = gr.vector_sink_c()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
+
+
+ def test_adaptive_fir_filter_ccc_002(self):
+ src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j]
+ expected_data = ((-0.5+1.5j), (-5.5+16.5j), (-10.5+31.5j),
+ (-15.5+46.5j), (-20.5+61.5j), (-25.5+76.5j),
+ (-30.5+91.5j), (-35.5+106.5j), (-40.5+121.5j),
+ (-45.5+136.5j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j), (-50+150j),
+ (-50+150j), (-50+150j), (-50+150j))
+ src = gr.vector_source_c(src_data)
+ op = filter.adaptive_fir_ccc("test", 4, 20*[0.5+1j, 0.5+1j])
+ dst = gr.vector_sink_c()
+ self.tb.connect(src, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_adaptive_filter, "test_adaptive_filter.xml")
+
diff --git a/gr-filter/swig/filter_swig.i b/gr-filter/swig/filter_swig.i
index c9de3fb9af..1bcafeb8c6 100644
--- a/gr-filter/swig/filter_swig.i
+++ b/gr-filter/swig/filter_swig.i
@@ -30,6 +30,8 @@
%{
#include "filter/firdes.h"
#include "filter/pm_remez.h"
+#include "filter/adaptive_fir_ccc.h"
+#include "filter/adaptive_fir_ccf.h"
#include "filter/dc_blocker_cc.h"
#include "filter/dc_blocker_ff.h"
#include "filter/filter_delay_fc.h"
@@ -46,6 +48,8 @@
%include "filter/firdes.h"
%include "filter/pm_remez.h"
+%include "filter/adaptive_fir_ccc.h"
+%include "filter/adaptive_fir_ccf.h"
%include "filter/dc_blocker_cc.h"
%include "filter/dc_blocker_ff.h"
%include "filter/filter_delay_fc.h"
@@ -59,6 +63,8 @@
%include "filter/hilbert_fc.h"
%include "filter/pfb_channelizer_ccf.h"
+GR_SWIG_BLOCK_MAGIC2(filter, adaptive_fir_ccc);
+GR_SWIG_BLOCK_MAGIC2(filter, adaptive_fir_ccf);
GR_SWIG_BLOCK_MAGIC2(filter, dc_blocker_cc);
GR_SWIG_BLOCK_MAGIC2(filter, dc_blocker_ff);
GR_SWIG_BLOCK_MAGIC2(filter, filter_delay_fc);