summaryrefslogtreecommitdiff
path: root/gr-digital
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital')
-rw-r--r--gr-digital/grc/Makefile.am3
-rw-r--r--gr-digital/grc/digital_block_tree.xml1
-rw-r--r--gr-digital/grc/digital_kurtotic_equalizer_cc.xml31
-rw-r--r--gr-digital/lib/Makefile.am6
-rw-r--r--gr-digital/lib/digital_kurtotic_equalizer_cc.cc51
-rw-r--r--gr-digital/lib/digital_kurtotic_equalizer_cc.h111
-rw-r--r--gr-digital/swig/Makefile.am3
-rw-r--r--gr-digital/swig/digital_kurtotic_equalizer_cc.i40
-rw-r--r--gr-digital/swig/digital_swig.i2
9 files changed, 244 insertions, 4 deletions
diff --git a/gr-digital/grc/Makefile.am b/gr-digital/grc/Makefile.am
index a3414c077..4cc2e8d9d 100644
--- a/gr-digital/grc/Makefile.am
+++ b/gr-digital/grc/Makefile.am
@@ -26,4 +26,5 @@ grcblocksdir = $(grc_blocksdir)
dist_grcblocks_DATA = \
digital_block_tree.xml \
digital_costas_loop_cc.xml \
- digital_cma_equalizer_cc.xml \ No newline at end of file
+ digital_cma_equalizer_cc.xml \
+ digital_kurtotic_equalizer_cc.xml \ No newline at end of file
diff --git a/gr-digital/grc/digital_block_tree.xml b/gr-digital/grc/digital_block_tree.xml
index 353aa3e1d..ee2a0377f 100644
--- a/gr-digital/grc/digital_block_tree.xml
+++ b/gr-digital/grc/digital_block_tree.xml
@@ -10,5 +10,6 @@
<name>Digital</name>
<block>digital_costas_loop_cc</block>
<block>digital_cma_equalizer_cc</block>
+ <block>digital_kurtotic_equalizer_cc</block>
</cat>
</cat>
diff --git a/gr-digital/grc/digital_kurtotic_equalizer_cc.xml b/gr-digital/grc/digital_kurtotic_equalizer_cc.xml
new file mode 100644
index 000000000..8c4a2012d
--- /dev/null
+++ b/gr-digital/grc/digital_kurtotic_equalizer_cc.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## Kurtotic Equalizer
+###################################################
+ -->
+<block>
+ <name>Kurtotic Equalizer</name>
+ <key>digital_kurtotic_equalizer_cc</key>
+ <import>from gnuradio import digital</import>
+ <make>digital.kurtotic_equalizer_cc($num_taps, $mu)</make>
+ <callback>set_gain($mu)</callback>
+ <param>
+ <name>Num. Taps</name>
+ <key>num_taps</key>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Mu</name>
+ <key>mu</key>
+ <type>real</type>
+ </param>
+ <sink>
+ <name>in</name>
+ <type>complex</type>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>complex</type>
+ </source>
+</block>
diff --git a/gr-digital/lib/Makefile.am b/gr-digital/lib/Makefile.am
index cd80d7b1c..7113f94d2 100644
--- a/gr-digital/lib/Makefile.am
+++ b/gr-digital/lib/Makefile.am
@@ -26,13 +26,15 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES)
# These headers get installed in ${prefix}/include/gnuradio
grinclude_HEADERS = \
digital_costas_loop_cc.h \
- digital_cma_equalizer_cc.h
+ digital_cma_equalizer_cc.h \
+ digital_kurtotic_equalizer_cc.h
lib_LTLIBRARIES = libgnuradio-digital.la
libgnuradio_digital_la_SOURCES = \
digital_costas_loop_cc.cc \
- digital_cma_equalizer_cc.cc
+ digital_cma_equalizer_cc.cc \
+ digital_kurtotic_equalizer_cc.cc
libgnuradio_digital_la_LIBADD = \
$(GNURADIO_CORE_LA)
diff --git a/gr-digital/lib/digital_kurtotic_equalizer_cc.cc b/gr-digital/lib/digital_kurtotic_equalizer_cc.cc
new file mode 100644
index 000000000..c95b56021
--- /dev/null
+++ b/gr-digital/lib/digital_kurtotic_equalizer_cc.cc
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011 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 <digital_kurtotic_equalizer_cc.h>
+
+digital_kurtotic_equalizer_cc_sptr
+digital_make_kurtotic_equalizer_cc(int num_taps, float mu)
+{
+ return gnuradio::get_initial_sptr(new digital_kurtotic_equalizer_cc(num_taps, mu));
+}
+
+digital_kurtotic_equalizer_cc::digital_kurtotic_equalizer_cc(int num_taps, float mu)
+ : gr_adaptive_fir_ccc("kurtotic_equalizer_cc", 1, std::vector<gr_complex>(num_taps))
+{
+ set_gain(mu);
+ if (num_taps > 0)
+ d_taps[0] = 1.0;
+
+ d_alpha_p = 0.01;
+ d_alpha_q = 0.01;
+ d_alpha_m = 0.01;
+
+ d_p = 0.0f;
+ d_m = 0.0f;
+ d_q = gr_complex(0,0);
+ d_u = gr_complex(0,0);
+}
+
diff --git a/gr-digital/lib/digital_kurtotic_equalizer_cc.h b/gr-digital/lib/digital_kurtotic_equalizer_cc.h
new file mode 100644
index 000000000..e01cbd6e6
--- /dev/null
+++ b/gr-digital/lib/digital_kurtotic_equalizer_cc.h
@@ -0,0 +1,111 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011 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_DIGITAL_KURTOTIC_EQUALIZER_CC_H
+#define INCLUDED_DIGITAL_KURTOTIC_EQUALIZER_CC_H
+
+#include <gr_adaptive_fir_ccc.h>
+#include <gr_math.h>
+#include <iostream>
+
+class digital_kurtotic_equalizer_cc;
+typedef boost::shared_ptr<digital_kurtotic_equalizer_cc> digital_kurtotic_equalizer_cc_sptr;
+
+digital_kurtotic_equalizer_cc_sptr
+digital_make_kurtotic_equalizer_cc(int num_taps, float mu);
+
+/*!
+ * \brief Implements a kurtosis-based adaptive equalizer on complex stream
+ * \ingroup eq_blk
+ *
+ * Y. Guo, J. Zhao, Y. Sun, "Sign kurtosis maximization based blind
+ * equalization algorithm," IEEE Conf. on Control, Automation,
+ * Robotics and Vision, Vol. 3, Dec. 2004, pp. 2052 - 2057.
+ */
+class digital_kurtotic_equalizer_cc : public gr_adaptive_fir_ccc
+{
+private:
+ float d_mu;
+ float d_p, d_m;
+ gr_complex d_q, d_u;
+ float d_alpha_p, d_alpha_q, d_alpha_m;
+
+ friend digital_kurtotic_equalizer_cc_sptr digital_make_kurtotic_equalizer_cc(int num_taps,
+ float mu);
+ digital_kurtotic_equalizer_cc(int num_taps, float mu);
+
+ gr_complex sign(gr_complex x)
+ {
+ float re = (float)(x.real() >= 0.0f);
+ float im = (float)(x.imag() >= 0.0f);
+ return gr_complex(re, im);
+ }
+
+protected:
+
+ virtual gr_complex error(const gr_complex &out)
+ {
+
+ // p = E[|z|^2]
+ // q = E[z^2]
+ // m = E[|z|^4]
+ // u = E[kurtosis(z)]
+
+ float nrm = norm(out);
+ gr_complex cnj = conj(out);
+ float epsilon_f = 1e-12;
+ gr_complex epsilon_c = gr_complex(1e-12, 1e-12);
+
+
+ d_p = (1-d_alpha_p)*d_p + (d_alpha_p)*nrm + epsilon_f;
+ d_q = (1-d_alpha_q)*d_q + (d_alpha_q)*out*out + epsilon_c;
+ d_m = (1-d_alpha_m)*d_m + (d_alpha_m)*nrm*nrm + epsilon_f;
+ d_u = d_m - 2.0f*(d_p*d_p) - d_q*d_q;
+
+ gr_complex F = (1.0f / (d_p*d_p*d_p)) *
+ (sign(d_u) * (nrm*cnj - 2.0f*d_p*cnj - conj(d_q)*out) -
+ abs(d_u)*cnj);
+
+ //std::cout << "out: " << out << " p: " << d_p << " q: " << d_q;
+ //std::cout << " m: " << d_m << " u: " << d_u << std::endl;
+ //std::cout << "error: " << F << std::endl;
+
+ float re = gr_clip(F.real(), 1.0);
+ float im = gr_clip(F.imag(), 1.0);
+ return gr_complex(re, im);
+ }
+
+ virtual void update_tap(gr_complex &tap, const gr_complex &in)
+ {
+ tap += d_mu*in*d_error;
+ }
+
+public:
+ void set_gain(float mu)
+ {
+ if(mu < 0)
+ throw std::out_of_range("digital_kurtotic_equalizer::set_gain: Gain value must be >= 0");
+ d_mu = mu;
+ }
+};
+
+#endif
diff --git a/gr-digital/swig/Makefile.am b/gr-digital/swig/Makefile.am
index 918c8b52e..d06da3a26 100644
--- a/gr-digital/swig/Makefile.am
+++ b/gr-digital/swig/Makefile.am
@@ -58,7 +58,8 @@ digital_swig_la_swig_libadd = \
# additional SWIG files to be installed
digital_swig_swiginclude_headers = \
digital_costas_loop_cc.i \
- digital_cma_equalizer_cc.i
+ digital_cma_equalizer_cc.i \
+ digital_kurtotic_equalizer_cc.i
if GUILE
TESTS += run_guile_tests
diff --git a/gr-digital/swig/digital_kurtotic_equalizer_cc.i b/gr-digital/swig/digital_kurtotic_equalizer_cc.i
new file mode 100644
index 000000000..67a9dc6fd
--- /dev/null
+++ b/gr-digital/swig/digital_kurtotic_equalizer_cc.i
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(digital,kurtotic_equalizer_cc)
+
+// retrieve info on the base class, without generating wrappers since
+// the base class has a pure virual method.
+%import "gr_adaptive_fir_ccc.i"
+
+digital_kurtotic_equalizer_cc_sptr
+digital_make_kurtotic_equalizer_cc(int num_taps,
+ float mu);
+
+class digital_kurtotic_equalizer_cc : public gr_adaptive_fir_ccc
+{
+private:
+ digital_kurtotic_equalizer_cc(int num_taps, float mu);
+
+public:
+ void set_gain(float mu);
+};
diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i
index b1eaab571..c2416c6c2 100644
--- a/gr-digital/swig/digital_swig.i
+++ b/gr-digital/swig/digital_swig.i
@@ -24,10 +24,12 @@
%{
#include "digital_costas_loop_cc.h"
#include "digital_cma_equalizer_cc.h"
+#include "digital_kurtotic_equalizer_cc.h"
%}
%include "digital_costas_loop_cc.i"
%include "digital_cma_equalizer_cc.i"
+%include "digital_kurtotic_equalizer_cc.i"
#if SWIGGUILE
%scheme %{