summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
authorjcorgan2008-04-12 17:42:20 +0000
committerjcorgan2008-04-12 17:42:20 +0000
commit296f981f79344d042f09ca2b30dcd7aa56f32981 (patch)
tree4fafe59893f9a6af9cd38a396fb57a8f9c0fa976 /gnuradio-core/src
parent5b45a79a57750fec9f1585ad0f15b1050dc76f98 (diff)
downloadgnuradio-296f981f79344d042f09ca2b30dcd7aa56f32981.tar.gz
gnuradio-296f981f79344d042f09ca2b30dcd7aa56f32981.tar.bz2
gnuradio-296f981f79344d042f09ca2b30dcd7aa56f32981.zip
Adds gr.integrate_XX for ss, ii, ff, and cc. Sums successive samples and decimates. Trunk passes distcheck.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8190 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/gengen/Makefile.am3
-rw-r--r--gnuradio-core/src/lib/gengen/Makefile.gen12
-rwxr-xr-xgnuradio-core/src/lib/gengen/generate_common.py1
-rw-r--r--gnuradio-core/src/lib/gengen/gengen_generated.i8
-rw-r--r--gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t67
-rw-r--r--gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t60
-rw-r--r--gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t33
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_integrate.py75
8 files changed, 259 insertions, 0 deletions
diff --git a/gnuradio-core/src/lib/gengen/Makefile.am b/gnuradio-core/src/lib/gengen/Makefile.am
index ebc403e3f..fb96ed2be 100644
--- a/gnuradio-core/src/lib/gengen/Makefile.am
+++ b/gnuradio-core/src/lib/gengen/Makefile.am
@@ -53,6 +53,9 @@ CODE_GENERATOR = \
gr_divide_XX.cc.t \
gr_divide_XX.h.t \
gr_divide_XX.i.t \
+ gr_integrate_XX.cc.t \
+ gr_integrate_XX.h.t \
+ gr_integrate_XX.i.t \
gr_max_XX.cc.t \
gr_max_XX.h.t \
gr_max_XX.i.t \
diff --git a/gnuradio-core/src/lib/gengen/Makefile.gen b/gnuradio-core/src/lib/gengen/Makefile.gen
index 512576ac2..79b0ef7bd 100644
--- a/gnuradio-core/src/lib/gengen/Makefile.gen
+++ b/gnuradio-core/src/lib/gengen/Makefile.gen
@@ -35,6 +35,10 @@ GENERATED_H = \
gr_divide_ff.h \
gr_divide_ii.h \
gr_divide_ss.h \
+ gr_integrate_cc.h \
+ gr_integrate_ff.h \
+ gr_integrate_ii.h \
+ gr_integrate_ss.h \
gr_max_ff.h \
gr_max_ii.h \
gr_max_ss.h \
@@ -137,6 +141,10 @@ GENERATED_I = \
gr_divide_ff.i \
gr_divide_ii.i \
gr_divide_ss.i \
+ gr_integrate_cc.i \
+ gr_integrate_ff.i \
+ gr_integrate_ii.i \
+ gr_integrate_ss.i \
gr_max_ff.i \
gr_max_ii.i \
gr_max_ss.i \
@@ -239,6 +247,10 @@ GENERATED_CC = \
gr_divide_ff.cc \
gr_divide_ii.cc \
gr_divide_ss.cc \
+ gr_integrate_cc.cc \
+ gr_integrate_ff.cc \
+ gr_integrate_ii.cc \
+ gr_integrate_ss.cc \
gr_max_ff.cc \
gr_max_ii.cc \
gr_max_ss.cc \
diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py
index 089d7d380..e46d4b74a 100755
--- a/gnuradio-core/src/lib/gengen/generate_common.py
+++ b/gnuradio-core/src/lib/gengen/generate_common.py
@@ -51,6 +51,7 @@ reg_roots = [
'gr_multiply_vXX',
'gr_add_const_vXX',
'gr_multiply_const_vXX',
+ 'gr_integrate_XX',
]
# other blocks
diff --git a/gnuradio-core/src/lib/gengen/gengen_generated.i b/gnuradio-core/src/lib/gengen/gengen_generated.i
index a4de58dbe..bdc15e50c 100644
--- a/gnuradio-core/src/lib/gengen/gengen_generated.i
+++ b/gnuradio-core/src/lib/gengen/gengen_generated.i
@@ -35,6 +35,10 @@
#include <gr_divide_ff.h>
#include <gr_divide_ii.h>
#include <gr_divide_ss.h>
+#include <gr_integrate_cc.h>
+#include <gr_integrate_ff.h>
+#include <gr_integrate_ii.h>
+#include <gr_integrate_ss.h>
#include <gr_max_ff.h>
#include <gr_max_ii.h>
#include <gr_max_ss.h>
@@ -137,6 +141,10 @@
%include <gr_divide_ff.i>
%include <gr_divide_ii.i>
%include <gr_divide_ss.i>
+%include <gr_integrate_cc.i>
+%include <gr_integrate_ff.i>
+%include <gr_integrate_ii.i>
+%include <gr_integrate_ss.i>
%include <gr_max_ff.i>
%include <gr_max_ii.i>
%include <gr_max_ss.i>
diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t
new file mode 100644
index 000000000..0a62554bd
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t
@@ -0,0 +1,67 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME@.h>
+#include <gr_io_signature.h>
+
+@SPTR_NAME@
+gr_make_@BASE_NAME@ (int decim)
+{
+ return @SPTR_NAME@ (new @NAME@ (decim));
+}
+
+@NAME@::@NAME@ (int decim)
+ : gr_sync_decimator ("@BASE_NAME@",
+ gr_make_io_signature (1, 1, sizeof (@I_TYPE@)),
+ gr_make_io_signature (1, 1, sizeof (@O_TYPE@)),
+ decim),
+ d_decim(decim),
+ d_count(0)
+{
+}
+
+@NAME@::~@NAME@ ()
+{
+}
+
+int
+@NAME@::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const @I_TYPE@ *in = (const @I_TYPE@ *) input_items[0];
+ @O_TYPE@ *out = (@O_TYPE@ *) output_items[0];
+
+ for (int i = 0; i < noutput_items; i++) {
+ out[i] = (@O_TYPE@)0;
+ for (int j = 0; j < d_decim; j++)
+ out[i] += in[i*d_decim+j];
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t
new file mode 100644
index 000000000..c8eca2d0a
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_integrate_XX.h.t
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gr_sync_decimator.h>
+
+class @NAME@;
+
+typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (int decim);
+
+/*!
+ * \brief output = sum(input[0]...input[n])
+ * \ingroup math
+ *
+ * Integrate successive samples in input stream and decimate
+ */
+class @NAME@ : public gr_sync_decimator
+{
+private:
+ friend @SPTR_NAME@ gr_make_@BASE_NAME@(int decim);
+
+ @NAME@ (int decim);
+
+ int d_decim;
+ int d_count;
+
+public:
+ ~@NAME@ ();
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* @GUARD_NAME@ */
diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t
new file mode 100644
index 000000000..24a2381ad
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_integrate_XX.i.t
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 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.
+ */
+
+// @WARNING@
+
+GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@);
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (int decim);
+
+class @NAME@ : public gr_sync_decimator
+{
+private:
+ @NAME@ ();
+};
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py b/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py
new file mode 100755
index 000000000..fbd601e34
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 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 math
+
+class test_integrate (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+ def test_000_ss(self):
+ src_data = (1, 2, 3, 4, 5, 6)
+ dst_data = (6, 15)
+ src = gr.vector_source_s(src_data)
+ itg = gr.integrate_ss(3)
+ dst = gr.vector_sink_s()
+ self.tb.connect(src, itg, dst)
+ self.tb.run()
+ self.assertEqual(dst_data, dst.data())
+
+ def test_001_ii(self):
+ src_data = (1, 2, 3, 4, 5, 6)
+ dst_data = (6, 15)
+ src = gr.vector_source_i(src_data)
+ itg = gr.integrate_ii(3)
+ dst = gr.vector_sink_i()
+ self.tb.connect(src, itg, dst)
+ self.tb.run()
+ self.assertEqual(dst_data, dst.data())
+
+ def test_002_ff(self):
+ src_data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
+ dst_data = [6.0, 15.0]
+ src = gr.vector_source_f(src_data)
+ itg = gr.integrate_ff(3)
+ dst = gr.vector_sink_f()
+ self.tb.connect(src, itg, dst)
+ self.tb.run()
+ self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6)
+
+ def test_003_cc(self):
+ src_data = [1.0+1.0j, 2.0+2.0j, 3.0+3.0j, 4.0+4.0j, 5.0+5.0j, 6.0+6.0j]
+ dst_data = [6.0+6.0j, 15.0+15.0j]
+ src = gr.vector_source_c(src_data)
+ itg = gr.integrate_cc(3)
+ dst = gr.vector_sink_c()
+ self.tb.connect(src, itg, dst)
+ self.tb.run()
+ self.assertComplexTuplesAlmostEqual(dst_data, dst.data(), 6)
+
+if __name__ == '__main__':
+ gr_unittest.main ()