diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-02-28 23:05:12 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-02-28 23:05:12 -0500 |
commit | 682b7c7c601446b64670f5041fa995ecffa06542 (patch) | |
tree | a642e64b1ed1aabab5fc61119f4e7f6c57ae835e | |
parent | ff9e66ad7c9f22bf2741e760940bb6609848ede8 (diff) | |
parent | 4c164f4cbb7fc9284bec147809b078d0a8ed9f88 (diff) |
Merge branch 'master' into next
Conflicts:
gr-blocks/python/qa_argmax.py
gr-blocks/python/qa_max.py
18 files changed, 374 insertions, 297 deletions
diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t deleted file mode 100644 index f780bd811f..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- 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@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ ( size_t vlen ) -{ - return @SPTR_NAME@ ( new @NAME@(vlen)); -} - -@NAME@::@NAME@( size_t vlen) - : gr_sync_block ( "@BASE_NAME@", - gr_make_io_signature (1, -1, vlen*sizeof (@I_TYPE@)), - gr_make_io_signature (2, 2, sizeof (@O_TYPE@))), - d_vlen(vlen) -{ -} - - -int -@NAME@::work( int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - - int ninputs = input_items.size (); - - @O_TYPE@ *x_optr = (@O_TYPE@ *) output_items[0]; - @O_TYPE@ *y_optr = (@O_TYPE@ *) output_items[1]; - - for (int i=0; i<noutput_items; i++) { - - @I_TYPE@ max = ((@I_TYPE@ *) input_items[0])[i*d_vlen]; - int x = 0; - int y = 0; - - for (int j=0; j < (int) d_vlen; j++ ) { - for (int k=0; k<ninputs; k++) { - if ( ((@I_TYPE@ *) input_items[k])[i*d_vlen + j] > max) { - max = ((@I_TYPE@ *) input_items[k])[i*d_vlen + j]; - x = j; - y = k; - } - } - } - - *x_optr++ = (@O_TYPE@) x; - *y_optr++ = (@O_TYPE@) y; - } - return noutput_items; -} - diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t deleted file mode 100644 index a706221fb9..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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_core_api.h> -#include <gr_sync_block.h> - -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; - -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t deleted file mode 100644 index c53820cd60..0000000000 --- a/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- 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@ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <@NAME@.h> -#include <gr_io_signature.h> - -@SPTR_NAME@ -gr_make_@BASE_NAME@ ( size_t vlen ) -{ - return @SPTR_NAME@ ( new @NAME@(vlen)); -} - -@NAME@::@NAME@( size_t vlen) - : gr_sync_block ( "@BASE_NAME@", - gr_make_io_signature (1, -1, vlen*sizeof (@I_TYPE@)), - gr_make_io_signature (1, 1, sizeof (@O_TYPE@))), - d_vlen(vlen) -{ -} - -int -@NAME@::work( int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0]; - - int ninputs = input_items.size (); - - for (int i=0; i<noutput_items; i++) { - - @I_TYPE@ max = ((@I_TYPE@ *) input_items[0])[i*d_vlen]; - - for (int j=0; j < (int) d_vlen; j++ ) { - for (int k=0; k<ninputs; k++) { - if ( ((@I_TYPE@ *) input_items[k])[i*d_vlen + j] > max) { - max = ((@I_TYPE@*) input_items[k])[i*d_vlen + j]; - } - } - } - - *optr++ = (@O_TYPE@) max; - } - return noutput_items; -} - diff --git a/grc/blocks/gr_argmax_xx.xml b/gr-blocks/grc/blocks_argmax_xx.xml index 95269292e7..7adfa75973 100644 --- a/grc/blocks/gr_argmax_xx.xml +++ b/gr-blocks/grc/blocks_argmax_xx.xml @@ -7,9 +7,9 @@ --> <block> <name>Argmax</name> - <key>gr_argmax_xx</key> - <import>from gnuradio import gr</import> - <make>gr.argmax_$(type.fcn)($vlen)</make> + <key>blocks_argmax_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.argmax_$(type.fcn)($vlen)</make> <param> <name>IO Type</name> <key>type</key> diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index 5d20aaf827..a1ecbe9436 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- - Copyright 2012 Free Software Foundation, Inc. + Copyright 2012,2013 Free Software Foundation, Inc. This file is part of GNU Radio @@ -54,6 +54,8 @@ <block>blocks_nlog10_ff</block> <block>blocks_rms_xx</block> <block>blocks_transcendental</block> + <block>blocks_argmax_xx</block> + <block>blocks_max_xx</block> </cat> <cat> <name>Boolean Operations (New) </name> diff --git a/grc/blocks/gr_max_xx.xml b/gr-blocks/grc/blocks_max_xx.xml index 9dbbe60e56..afbcae93dc 100644 --- a/grc/blocks/gr_max_xx.xml +++ b/gr-blocks/grc/blocks_max_xx.xml @@ -7,9 +7,9 @@ --> <block> <name>Max</name> - <key>gr_max_xx</key> - <import>from gnuradio import gr</import> - <make>gr.max_$(type.fcn)($vlen)</make> + <key>blocks_max_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.max_$(type.fcn)($vlen)</make> <param> <name>IO Type</name> <key>type</key> @@ -33,7 +33,7 @@ <param> <name>Num Inputs</name> <key>num_inputs</key> - <value>2</value> + <value>1</value> <type>int</type> </param> <param> @@ -42,7 +42,7 @@ <value>1</value> <type>int</type> </param> - <check>$num_inputs >= 2</check> + <check>$num_inputs >= 1</check> <check>$vlen >= 1</check> <sink> <name>in</name> @@ -53,6 +53,6 @@ <source> <name>out</name> <type>$type</type> - <vlen>$vlen</vlen> + <vlen>1</vlen> </source> </block> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index fdf3b08766..deebbdd6b7 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -69,8 +69,10 @@ expand_h(add_const_XX ss ii ff cc) expand_h(add_const_vXX ss ii ff cc) expand_h(and_XX bb ss ii) expand_h(and_const_XX bb ss ii) +expand_h(argmax_XX fs is ss) expand_h(divide_XX ss ii ff cc) expand_h(integrate_XX ss ii ff cc) +expand_h(max_XX ff ii ss) expand_h(multiply_XX ss ii) expand_h(multiply_const_XX ss ii) expand_h(multiply_const_vXX ss ii ff cc) diff --git a/gr-blocks/include/blocks/argmax_XX.h.t b/gr-blocks/include/blocks/argmax_XX.h.t new file mode 100644 index 0000000000..4c25c1c8c4 --- /dev/null +++ b/gr-blocks/include/blocks/argmax_XX.h.t @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 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 <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Compares vectors from multiple streams and determines + * the index in the vector and stream number where the maximum + * value occurred. + * \ingroup math_blk + * + * Data is passed in as a vector of length \p vlen from multiple + * input sources. It will look through these streams of \p vlen + * data items and output two streams. + * Stream 0 will contain the index value in the vector where + * the maximum value occurred. + * Stream 1 will contain the number of the input stream that + * held the maximum value. + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t vlen); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.h.t b/gr-blocks/include/blocks/max_XX.h.t index a706221fb9..9e74bf3cac 100644 --- a/gnuradio-core/src/lib/gengen/gr_max_XX.h.t +++ b/gr-blocks/include/blocks/max_XX.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,28 +25,34 @@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ -#include <gr_core_api.h> +#include <blocks/api.h> #include <gr_sync_block.h> -class @NAME@; -typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; +namespace gr { + namespace blocks { + + /*! + * \brief Compares vectors from multiple streams and determines + * the maximum value from each vector over all streams. + * \ingroup math_blk + * + * Data is passed in as a vector of length \p vlen from multiple + * input sources. It will look through these streams of \p vlen + * data items and output two streams. + * Stream 0 will contain the index value in the vector where + * the maximum value occurred. + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t vlen); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ -GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - -class GR_CORE_API @NAME@ : public gr_sync_block -{ - friend GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); - - @NAME@ (size_t vlen); - size_t d_vlen; - - public: - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - - -#endif diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 008f00f361..fb6a8bc369 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -95,8 +95,10 @@ expand_cc_h_impl(add_const_XX ss ii ff cc) expand_cc_h_impl(add_const_vXX ss ii ff cc) expand_cc_h_impl(and_XX bb ss ii) expand_cc_h_impl(and_const_XX bb ss ii) +expand_cc_h_impl(argmax_XX fs is ss) expand_cc_h_impl(divide_XX ss ii ff cc) expand_cc_h_impl(integrate_XX ss ii ff cc) +expand_cc_h_impl(max_XX ff ii ss) expand_cc_h_impl(multiply_XX ss ii) expand_cc_h_impl(multiply_const_XX ss ii) expand_cc_h_impl(multiply_const_vXX ss ii ff cc) diff --git a/gr-blocks/lib/add_XX_impl.h.t b/gr-blocks/lib/add_XX_impl.h.t index a1c486b859..2e20ef5fe3 100644 --- a/gr-blocks/lib/add_XX_impl.h.t +++ b/gr-blocks/lib/add_XX_impl.h.t @@ -32,6 +32,7 @@ namespace gr { class BLOCKS_API @NAME_IMPL@ : public @NAME@ { + private: size_t d_vlen; public: diff --git a/gr-blocks/lib/argmax_XX_impl.cc.t b/gr-blocks/lib/argmax_XX_impl.cc.t new file mode 100644 index 0000000000..56673ef995 --- /dev/null +++ b/gr-blocks/lib/argmax_XX_impl.cc.t @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2013 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_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(size_t vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t vlen) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, -1, vlen*sizeof(@I_TYPE@)), + gr_make_io_signature(2, 2, sizeof(@O_TYPE@))), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int ninputs = input_items.size (); + + @O_TYPE@ *x_optr = (@O_TYPE@ *)output_items[0]; + @O_TYPE@ *y_optr = (@O_TYPE@ *)output_items[1]; + + for(int i = 0; i < noutput_items; i++) { + @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen]; + int x = 0; + int y = 0; + + for(int j = 0; j < (int)d_vlen; j++ ) { + for(int k = 0; k < ninputs; k++) { + if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) { + max = ((@I_TYPE@ *)input_items[k])[i*d_vlen + j]; + x = j; + y = k; + } + } + } + + *x_optr++ = (@O_TYPE@)x; + *y_optr++ = (@O_TYPE@)y; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t b/gr-blocks/lib/argmax_XX_impl.h.t index 233551ad93..0f1643f6b9 100644 --- a/gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t +++ b/gr-blocks/lib/argmax_XX_impl.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,13 +22,29 @@ // @WARNING@ -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); +#include <blocks/@NAME@.h> -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); - size_t d_vlen; -}; +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + size_t d_vlen; + + public: + @NAME_IMPL@(size_t vlen); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/max_XX_impl.cc.t b/gr-blocks/lib/max_XX_impl.cc.t new file mode 100644 index 0000000000..669e2fd30d --- /dev/null +++ b/gr-blocks/lib/max_XX_impl.cc.t @@ -0,0 +1,81 @@ +/* -*- 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@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(size_t vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t vlen) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, -1, vlen*sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; + + int ninputs = input_items.size(); + + for(int i = 0; i < noutput_items; i++) { + @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen]; + + for(int j = 0; j < (int)d_vlen; j++ ) { + for(int k = 0; k < ninputs; k++) { + if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) { + max = ((@I_TYPE@*)input_items[k])[i*d_vlen + j]; + } + } + } + + *optr++ = (@O_TYPE@)max; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.i.t b/gr-blocks/lib/max_XX_impl.h.t index 233551ad93..0f1643f6b9 100644 --- a/gnuradio-core/src/lib/gengen/gr_max_XX.i.t +++ b/gr-blocks/lib/max_XX_impl.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,13 +22,29 @@ // @WARNING@ -GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ -@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen); +#include <blocks/@NAME@.h> -class @NAME@ : public gr_sync_block -{ - private: - @NAME@ (size_t vlen); - size_t d_vlen; -}; +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + size_t d_vlen; + + public: + @NAME_IMPL@(size_t vlen); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/python/qa_argmax.py b/gr-blocks/python/qa_argmax.py index 1fbda7a1f9..ec82b71cd4 100644 --- a/gr-blocks/python/qa_argmax.py +++ b/gr-blocks/python/qa_argmax.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010 Free Software Foundation, Inc. +# Copyright 2007,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,17 +24,14 @@ from gnuradio import gr, gr_unittest import blocks_swig as blocks import math +class test_arg_max(gr_unittest.TestCase): -class test_arg_max (gr_unittest.TestCase): + def setUp(self): + self.tb = gr.top_block() - def setUp (self): - self.tb = gr.top_block () - - - def tearDown (self): + def tearDown(self): self.tb = None - def test_001(self): tb = self.tb @@ -42,36 +39,34 @@ class test_arg_max (gr_unittest.TestCase): src2_data = (0,0.0,3.0,0,10,0) src3_data = (0,0.0,3.0,0,1,0) - src1 = gr.vector_source_f (src1_data) + src1 = gr.vector_source_f(src1_data) s2v1 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) - tb.connect( src1, s2v1 ) + tb.connect(src1, s2v1) - src2 = gr.vector_source_f (src2_data) + src2 = gr.vector_source_f(src2_data) s2v2 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) - tb.connect( src2, s2v2 ) + tb.connect(src2, s2v2) - src3 = gr.vector_source_f (src3_data) + src3 = gr.vector_source_f(src3_data) s2v3 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) - tb.connect( src3, s2v3 ) - - dst1 = gr.vector_sink_s () - dst2 = gr.vector_sink_s () - argmax = gr.argmax_fs (len(src1_data)) - - tb.connect (s2v1, (argmax, 0)) - tb.connect (s2v2, (argmax, 1)) - tb.connect (s2v3, (argmax, 2)) + tb.connect(src3, s2v3) - tb.connect ((argmax,0), dst1) - tb.connect ((argmax,1), dst2) + dst1 = gr.vector_sink_s() + dst2 = gr.vector_sink_s() + argmax = blocks.argmax_fs(len(src1_data)) - tb.run () - index = dst1.data () - source = dst2.data () - self.assertEqual ( index, (4,)) - self.assertEqual ( source, (0,)) + tb.connect(s2v1, (argmax, 0)) + tb.connect(s2v2, (argmax, 1)) + tb.connect(s2v3, (argmax, 2)) + tb.connect((argmax,0), dst1) + tb.connect((argmax,1), dst2) + tb.run() + index = dst1.data() + source = dst2.data() + self.assertEqual(index, (4,)) + self.assertEqual(source, (0,)) if __name__ == '__main__': gr_unittest.run(test_arg_max, "test_arg_max.xml") diff --git a/gr-blocks/python/qa_max.py b/gr-blocks/python/qa_max.py index 00c7e60110..4af70bd4be 100755 --- a/gr-blocks/python/qa_max.py +++ b/gr-blocks/python/qa_max.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007,2010 Free Software Foundation, Inc. +# Copyright 2007,2010,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,41 +24,35 @@ from gnuradio import gr, gr_unittest import blocks_swig as blocks import math +class test_max(gr_unittest.TestCase): -class test_max (gr_unittest.TestCase): + def setUp(self): + self.tb = gr.top_block() - def setUp (self): - self.tb = gr.top_block () - - - def tearDown (self): + def tearDown(self): self.tb = None - def test_001(self): - src_data = (0,0.2,-0.3,0,12,0) - expected_result = (float(max(src_data)), ) + expected_result = (float(max(src_data)),) src = gr.vector_source_f(src_data) s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) - op = gr.max_ff( len(src_data) ) + op = blocks.max_ff(len(src_data)) dst = gr.vector_sink_f() - self.tb.connect(src, s2v, op, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data) def test_002(self): - src_data=(-100,-99,-98,-97,-96,-1) - expected_result = (float(max(src_data)), ) + expected_result = (float(max(src_data)),) src = gr.vector_source_f(src_data) s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) - op = gr.max_ff( len(src_data) ) + op = blocks.max_ff(len(src_data)) dst = gr.vector_sink_f() self.tb.connect(src, s2v, op, dst) diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i index 38179a2d17..fa0c9583b1 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig.i @@ -49,6 +49,9 @@ #include "blocks/and_const_bb.h" #include "blocks/and_const_ss.h" #include "blocks/and_const_ii.h" +#include "blocks/argmax_fs.h" +#include "blocks/argmax_is.h" +#include "blocks/argmax_ss.h" #include "blocks/char_to_float.h" #include "blocks/char_to_short.h" #include "blocks/complex_to_interleaved_short.h" @@ -82,6 +85,9 @@ #include "blocks/interleaved_short_to_complex.h" #include "blocks/keep_m_in_n.h" #include "blocks/keep_one_in_n.h" +#include "blocks/max_ff.h" +#include "blocks/max_ii.h" +#include "blocks/max_ss.h" #include "blocks/multiply_ss.h" #include "blocks/multiply_ii.h" #include "blocks/multiply_ff.h" @@ -162,6 +168,9 @@ %include "blocks/and_const_bb.h" %include "blocks/and_const_ss.h" %include "blocks/and_const_ii.h" +%include "blocks/argmax_fs.h" +%include "blocks/argmax_is.h" +%include "blocks/argmax_ss.h" %include "blocks/char_to_float.h" %include "blocks/char_to_short.h" %include "blocks/complex_to_interleaved_short.h" @@ -195,6 +204,9 @@ %include "blocks/interleaved_short_to_complex.h" %include "blocks/keep_m_in_n.h" %include "blocks/keep_one_in_n.h" +%include "blocks/max_ff.h" +%include "blocks/max_ii.h" +%include "blocks/max_ss.h" %include "blocks/multiply_ss.h" %include "blocks/multiply_ii.h" %include "blocks/multiply_ff.h" @@ -274,6 +286,9 @@ GR_SWIG_BLOCK_MAGIC2(blocks, and_ii); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_bb); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ss); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_fs); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_is); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_ss); GR_SWIG_BLOCK_MAGIC2(blocks, char_to_float); GR_SWIG_BLOCK_MAGIC2(blocks, char_to_short); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_interleaved_short); @@ -307,6 +322,9 @@ GR_SWIG_BLOCK_MAGIC2(blocks, interleave); GR_SWIG_BLOCK_MAGIC2(blocks, interleaved_short_to_complex); GR_SWIG_BLOCK_MAGIC2(blocks, keep_m_in_n); GR_SWIG_BLOCK_MAGIC2(blocks, keep_one_in_n); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ii); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ff); |