diff options
author | matt | 2008-07-21 23:32:23 +0000 |
---|---|---|
committer | matt | 2008-07-21 23:32:23 +0000 |
commit | 5c8fcd7a45f2a32589ad87e1a14c8eed30bfd006 (patch) | |
tree | d3d8c768711fcf915244cd281157bbe4a0d479ca /gnuradio-core/src/lib/gengen | |
parent | c8317fadf92f079b0a99f5b0c8a9041410c6ae6b (diff) | |
download | gnuradio-5c8fcd7a45f2a32589ad87e1a14c8eed30bfd006.tar.gz gnuradio-5c8fcd7a45f2a32589ad87e1a14c8eed30bfd006.tar.bz2 gnuradio-5c8fcd7a45f2a32589ad87e1a14c8eed30bfd006.zip |
efficient moving average filters, should speed up OFDM significantly
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8965 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/lib/gengen')
-rw-r--r-- | gnuradio-core/src/lib/gengen/Makefile.am | 5 | ||||
-rw-r--r-- | gnuradio-core/src/lib/gengen/Makefile.gen | 12 | ||||
-rwxr-xr-x | gnuradio-core/src/lib/gengen/generate_common.py | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/gengen/gengen_generated.i | 8 | ||||
-rw-r--r-- | gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t | 74 | ||||
-rw-r--r-- | gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t | 61 | ||||
-rw-r--r-- | gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t | 33 |
7 files changed, 193 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/gengen/Makefile.am b/gnuradio-core/src/lib/gengen/Makefile.am index fb96ed2be..aaf9dd5fc 100644 --- a/gnuradio-core/src/lib/gengen/Makefile.am +++ b/gnuradio-core/src/lib/gengen/Makefile.am @@ -112,7 +112,10 @@ CODE_GENERATOR = \ gr_or_XX.i.t \ gr_not_XX.cc.t \ gr_not_XX.h.t \ - gr_not_XX.i.t + gr_not_XX.i.t \ + gr_moving_average_XX.cc.t \ + gr_moving_average_XX.h.t \ + gr_moving_average_XX.i.t include Makefile.gen diff --git a/gnuradio-core/src/lib/gengen/Makefile.gen b/gnuradio-core/src/lib/gengen/Makefile.gen index 79b0ef7bd..7ee92a25a 100644 --- a/gnuradio-core/src/lib/gengen/Makefile.gen +++ b/gnuradio-core/src/lib/gengen/Makefile.gen @@ -42,6 +42,10 @@ GENERATED_H = \ gr_max_ff.h \ gr_max_ii.h \ gr_max_ss.h \ + gr_moving_average_cc.h \ + gr_moving_average_ff.h \ + gr_moving_average_ii.h \ + gr_moving_average_ss.h \ gr_multiply_cc.h \ gr_multiply_const_cc.h \ gr_multiply_const_ff.h \ @@ -148,6 +152,10 @@ GENERATED_I = \ gr_max_ff.i \ gr_max_ii.i \ gr_max_ss.i \ + gr_moving_average_cc.i \ + gr_moving_average_ff.i \ + gr_moving_average_ii.i \ + gr_moving_average_ss.i \ gr_multiply_cc.i \ gr_multiply_const_cc.i \ gr_multiply_const_ff.i \ @@ -254,6 +262,10 @@ GENERATED_CC = \ gr_max_ff.cc \ gr_max_ii.cc \ gr_max_ss.cc \ + gr_moving_average_cc.cc \ + gr_moving_average_ff.cc \ + gr_moving_average_ii.cc \ + gr_moving_average_ss.cc \ gr_multiply_cc.cc \ gr_multiply_const_cc.cc \ gr_multiply_const_ff.cc \ diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py index e46d4b74a..182b74070 100755 --- a/gnuradio-core/src/lib/gengen/generate_common.py +++ b/gnuradio-core/src/lib/gengen/generate_common.py @@ -52,6 +52,7 @@ reg_roots = [ 'gr_add_const_vXX', 'gr_multiply_const_vXX', 'gr_integrate_XX', + 'gr_moving_average_XX', ] # other blocks diff --git a/gnuradio-core/src/lib/gengen/gengen_generated.i b/gnuradio-core/src/lib/gengen/gengen_generated.i index bdc15e50c..f1be17f7a 100644 --- a/gnuradio-core/src/lib/gengen/gengen_generated.i +++ b/gnuradio-core/src/lib/gengen/gengen_generated.i @@ -42,6 +42,10 @@ #include <gr_max_ff.h> #include <gr_max_ii.h> #include <gr_max_ss.h> +#include <gr_moving_average_cc.h> +#include <gr_moving_average_ff.h> +#include <gr_moving_average_ii.h> +#include <gr_moving_average_ss.h> #include <gr_multiply_cc.h> #include <gr_multiply_const_cc.h> #include <gr_multiply_const_ff.h> @@ -148,6 +152,10 @@ %include <gr_max_ff.i> %include <gr_max_ii.i> %include <gr_max_ss.i> +%include <gr_moving_average_cc.i> +%include <gr_moving_average_ff.i> +%include <gr_moving_average_ii.i> +%include <gr_moving_average_ss.i> %include <gr_multiply_cc.i> %include <gr_multiply_const_cc.i> %include <gr_multiply_const_ff.i> diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t new file mode 100644 index 000000000..e5e985235 --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t @@ -0,0 +1,74 @@ +/* -*- 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 length, @O_TYPE@ scale, int max_iter) +{ + return @SPTR_NAME@ (new @NAME@ (length, scale, max_iter)); +} + +@NAME@::@NAME@ (int length, @O_TYPE@ scale, int max_iter) + : gr_sync_block ("@BASE_NAME@", + gr_make_io_signature (1, 1, sizeof (@I_TYPE@)), + gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), + d_length(length), + d_scale(scale), + d_max_iter(max_iter) +{ + set_history(length); +} + +@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]; + + @I_TYPE@ sum = 0; + int num_iter = (noutput_items>d_max_iter) ? d_max_iter : noutput_items; + for (int i = 0; i < d_length-1 ; i++) { + sum += in[i]; + } + + for (int i = 0; i < num_iter; i++) { + sum += in[i+d_length-1]; + out[i] = sum * d_scale; + sum -= in[i]; + } + + return num_iter; +} diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t new file mode 100644 index 000000000..3121e3bfd --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t @@ -0,0 +1,61 @@ +/* -*- 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@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <gr_sync_block.h> + +class @NAME@; + +typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; + +@SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096); + +/*! + * \brief output is the moving sum of the last N samples, scaled by the scale factor + * \ingroup filter. max_iter limits how long we go without flushing the accumulator + * This is necessary to avoid numerical instability for float and complex. + * + */ +class @NAME@ : public gr_sync_block +{ +private: + friend @SPTR_NAME@ gr_make_@BASE_NAME@(int length, @O_TYPE@ scale, int max_iter); + + @NAME@ (int length, @O_TYPE@ scale, int max_iter = 4096); + + int d_length; + @O_TYPE@ d_scale; + int d_max_iter; + +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_moving_average_XX.i.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.i.t new file mode 100644 index 000000000..c7da8d94e --- /dev/null +++ b/gnuradio-core/src/lib/gengen/gr_moving_average_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 length, @O_TYPE@ scale, int max_iter=4096); + +class @NAME@ : public gr_sync_block +{ +private: + @NAME@ (); +}; |