UPDATE: Fixed copyright strings to add GPL where needed and indicate current year.
Attached are patches and new files to implement both gr_add_const_vXX gr_multiply_const_vXX New files for gnuradio-core/src/lib/general: gr_add_const_vXX.cc.t gr_add_const_vXX.h.t gr_add_const_vXX.i.t gr_multiply_const_vXX.cc.t gr_multiply_const_vXX.h.t gr_multiply_const_vXX.i.t patch-gnuradio-vector-add-multiply-const.diff updates gnuradio-core build machinery and qa code. patch-gnuradio-examples-dialtone-v.diff updates gnuradio-examples to use the above. -Johnathan, AE6HO
/* -*- c++ -*- */ /* * Copyright 2004,2006 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 2, 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // @WARNING@ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <@[EMAIL PROTECTED]> #include <gr_io_signature.h> @SPTR_NAME@ [EMAIL PROTECTED]@ (const std::vector<@I_TYPE@> k) { return @SPTR_NAME@ (new @NAME@ (k)); } @NAME@::@NAME@ (const std::vector<@I_TYPE@> k) : gr_sync_block ("@BASE_NAME@", gr_make_io_signature (1, 1, sizeof(@I_TYPE@)*k.size()), gr_make_io_signature (1, 1, sizeof(@O_TYPE@)*k.size())) { d_k = k; } int @NAME@::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @I_TYPE@ *iptr = (@O_TYPE@ *)input_items[0]; @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(@I_TYPE@); for (int i = 0; i < noutput_items; i++) for (int j = 0; j < nitems_per_block; j++) *optr++ = *iptr++ + d_k[j]; return noutput_items; }
/* -*- c++ -*- */ /* * Copyright 2004,2006 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 2, 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // @WARNING@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; @SPTR_NAME@ [EMAIL PROTECTED]@ (const std::vector<@I_TYPE@> k); /*! * \brief output vector = input vector + constant vector * \ingroup block */ class @NAME@ : public gr_sync_block { friend @SPTR_NAME@ [EMAIL PROTECTED]@ (const std::vector<@I_TYPE@> k); std::vector<@I_TYPE@> d_k; // the constant @NAME@ (const std::vector<@I_TYPE@> k); public: const std::vector<@I_TYPE@> k () const { return d_k; } void set_k (const std::vector<@I_TYPE@> k) { d_k = k; } int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); }; #endif
/* -*- c++ -*- */ /* * Copyright 2004,2006 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 2, 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // @WARNING@ GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) @SPTR_NAME@ [EMAIL PROTECTED]@ (const std::vector<@I_TYPE@> k); class @NAME@ : public gr_sync_block { private: @NAME@ (const std::vector<@I_TYPE@> k); public: std::vector<@I_TYPE@> k () const { return d_k; } void set_k (const std::vector<@I_TYPE@> k) { d_k = k; } };
/* -*- c++ -*- */ /* * Copyright 2004,2006 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 2, 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // @WARNING@ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <@[EMAIL PROTECTED]> #include <gr_io_signature.h> @SPTR_NAME@ [EMAIL PROTECTED]@ (const std::vector<@I_TYPE@> k) { return @SPTR_NAME@ (new @NAME@ (k)); } @NAME@::@NAME@ (const std::vector<@I_TYPE@> k) : gr_sync_block ("@BASE_NAME@", gr_make_io_signature (1, 1, sizeof(@I_TYPE@)*k.size()), gr_make_io_signature (1, 1, sizeof(@O_TYPE@)*k.size())) { d_k = k; } int @NAME@::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @I_TYPE@ *iptr = (@O_TYPE@ *)input_items[0]; @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; int nitems_per_block = output_signature()->sizeof_stream_item(0)/sizeof(@I_TYPE@); for (int i = 0; i < noutput_items; i++) for (int j = 0; j < nitems_per_block; j++) *optr++ = *iptr++ * d_k[j]; return noutput_items; }
/* -*- c++ -*- */ /* * Copyright 2004,2006 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 2, 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // @WARNING@ #ifndef @GUARD_NAME@ #define @GUARD_NAME@ #include <gr_sync_block.h> class @NAME@; typedef boost::shared_ptr<@NAME@> @SPTR_NAME@; @SPTR_NAME@ [EMAIL PROTECTED]@ (const std::vector<@I_TYPE@> k); /*! * \brief output vector = input vector * constant vector (element-wise) * \ingroup block */ class @NAME@ : public gr_sync_block { friend @SPTR_NAME@ [EMAIL PROTECTED]@ (const std::vector<@I_TYPE@> k); std::vector<@I_TYPE@> d_k; // the constant @NAME@ (const std::vector<@I_TYPE@> k); public: const std::vector<@I_TYPE@> k () const { return d_k; } void set_k (const std::vector<@I_TYPE@> k) { d_k = k; } int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); }; #endif
/* -*- c++ -*- */ /* * Copyright 2004,2006 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 2, 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., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // @WARNING@ GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@) @SPTR_NAME@ [EMAIL PROTECTED]@ (const std::vector<@I_TYPE@> k); class @NAME@ : public gr_sync_block { private: @NAME@ (const std::vector<@I_TYPE@> k); public: std::vector<@I_TYPE@> k () const { return d_k; } void set_k (const std::vector<@I_TYPE@> k) { d_k = k; } };
Index: python/audio/dialtone_v.py =================================================================== RCS file: /sources/gnuradio/gnuradio-examples/python/audio/dialtone_v.py,v retrieving revision 1.2 diff -u -r1.2 dialtone_v.py --- python/audio/dialtone_v.py 13 Jun 2006 16:32:53 -0000 1.2 +++ python/audio/dialtone_v.py 15 Jun 2006 19:34:35 -0000 @@ -1,9 +1,36 @@ #!/usr/bin/env python +# Copyright 2006 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 2, 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., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + from gnuradio import gr, audio +from math import pi, sin + +""" +This test script demonstrates the use of element-wise vector processing +vs. stream processing. The example is artificial in that the stream +version in dial_tone.py is the normal way to do it; in addition, the +envelope processing here is just for demo purposes and isn't needed. +""" # For testing different buffer sizes -size = 1024 rate = 48000 fg = gr.flow_graph() @@ -13,21 +40,21 @@ b = gr.sig_source_f(rate, gr.GR_SIN_WAVE, 440, 0.5, 0.0); # Turn them into vectors of length 'size' -av = gr.stream_to_vector(gr.sizeof_float, size) -bv = gr.stream_to_vector(gr.sizeof_float, size) +av = gr.stream_to_vector(gr.sizeof_float, rate) +bv = gr.stream_to_vector(gr.sizeof_float, rate) # Make a vector adder for float vectors -adder = gr.add_vff(size) +adder = gr.add_vff(rate) # Make a 1 Hz sine envelope -envelope = gr.sig_source_f(rate, gr.GR_SIN_WAVE, 1, 0.5, 0.5); -envelopev = gr.stream_to_vector(gr.sizeof_float, size) +envelope = [sin(2*pi*x/rate)*0.5 for x in range(rate)] +multiplier = gr.multiply_const_vff(envelope) -# Make a mixer to apply the envelope -mixer = gr.multiply_vff(size) +# Make an offset adder +offset = gr.add_const_vff((0.5,)*rate) # Turn the vector back into a stream of floats -result = gr.vector_to_stream(gr.sizeof_float, size) +result = gr.vector_to_stream(gr.sizeof_float, rate) # Play it sink = audio.sink(rate) @@ -36,11 +63,7 @@ fg.connect(b, bv) fg.connect(av, (adder, 0)) fg.connect(bv, (adder, 1)) -fg.connect(adder, (mixer, 0)) -fg.connect(envelope, envelopev) -fg.connect(envelopev, (mixer, 1)) -fg.connect(mixer, result) -fg.connect(result, sink) +fg.connect(adder, multiplier, offset, result, sink) try: fg.run()
Index: src/lib/general/.cvsignore =================================================================== RCS file: /sources/gnuradio/gnuradio-core/src/lib/general/.cvsignore,v retrieving revision 1.12 diff -u -r1.12 .cvsignore --- src/lib/general/.cvsignore 14 Jun 2006 06:10:55 -0000 1.12 +++ src/lib/general/.cvsignore 15 Jun 2006 19:29:17 -0000 @@ -111,6 +111,18 @@ gr_add_const_ss.cc gr_add_const_ss.h gr_add_const_ss.i +gr_add_const_vcc.cc +gr_add_const_vcc.h +gr_add_const_vcc.i +gr_add_const_vff.cc +gr_add_const_vff.h +gr_add_const_vff.i +gr_add_const_vii.cc +gr_add_const_vii.h +gr_add_const_vii.i +gr_add_const_vss.cc +gr_add_const_vss.h +gr_add_const_vss.i gr_add_ff.cc gr_add_ff.h gr_add_ff.i @@ -180,6 +192,18 @@ gr_multiply_vss.cc gr_multiply_vss.h gr_multiply_vss.i +gr_multiply_const_vcc.cc +gr_multiply_const_vcc.h +gr_multiply_const_vcc.i +gr_multiply_const_vff.cc +gr_multiply_const_vff.h +gr_multiply_const_vff.i +gr_multiply_const_vii.cc +gr_multiply_const_vii.h +gr_multiply_const_vii.i +gr_multiply_const_vss.cc +gr_multiply_const_vss.h +gr_multiply_const_vss.i gr_noise_source_c.cc gr_noise_source_c.h gr_noise_source_c.i Index: src/lib/general/Makefile.gen =================================================================== RCS file: /sources/gnuradio/gnuradio-core/src/lib/general/Makefile.gen,v retrieving revision 1.9 diff -u -r1.9 Makefile.gen --- src/lib/general/Makefile.gen 13 Jun 2006 13:28:52 -0000 1.9 +++ src/lib/general/Makefile.gen 15 Jun 2006 19:29:17 -0000 @@ -8,6 +8,10 @@ gr_add_const_ii.h \ gr_add_const_sf.h \ gr_add_const_ss.h \ + gr_add_const_vcc.h \ + gr_add_const_vff.h \ + gr_add_const_vii.h \ + gr_add_const_vss.h \ gr_add_ff.h \ gr_add_ii.h \ gr_add_ss.h \ @@ -30,6 +34,10 @@ gr_multiply_const_ff.h \ gr_multiply_const_ii.h \ gr_multiply_const_ss.h \ + gr_multiply_const_vcc.h \ + gr_multiply_const_vff.h \ + gr_multiply_const_vii.h \ + gr_multiply_const_vss.h \ gr_multiply_ff.h \ gr_multiply_ii.h \ gr_multiply_ss.h \ @@ -77,6 +85,10 @@ gr_add_const_ii.i \ gr_add_const_sf.i \ gr_add_const_ss.i \ + gr_add_const_vcc.i \ + gr_add_const_vff.i \ + gr_add_const_vii.i \ + gr_add_const_vss.i \ gr_add_ff.i \ gr_add_ii.i \ gr_add_ss.i \ @@ -99,6 +111,10 @@ gr_multiply_const_ff.i \ gr_multiply_const_ii.i \ gr_multiply_const_ss.i \ + gr_multiply_const_vcc.i \ + gr_multiply_const_vff.i \ + gr_multiply_const_vii.i \ + gr_multiply_const_vss.i \ gr_multiply_ff.i \ gr_multiply_ii.i \ gr_multiply_ss.i \ @@ -146,6 +162,10 @@ gr_add_const_ii.cc \ gr_add_const_sf.cc \ gr_add_const_ss.cc \ + gr_add_const_vcc.cc \ + gr_add_const_vff.cc \ + gr_add_const_vii.cc \ + gr_add_const_vss.cc \ gr_add_ff.cc \ gr_add_ii.cc \ gr_add_ss.cc \ @@ -168,6 +188,10 @@ gr_multiply_const_ff.cc \ gr_multiply_const_ii.cc \ gr_multiply_const_ss.cc \ + gr_multiply_const_vcc.cc \ + gr_multiply_const_vff.cc \ + gr_multiply_const_vii.cc \ + gr_multiply_const_vss.cc \ gr_multiply_ff.cc \ gr_multiply_ii.cc \ gr_multiply_ss.cc \ Index: src/lib/general/general_generated.i =================================================================== RCS file: /sources/gnuradio/gnuradio-core/src/lib/general/general_generated.i,v retrieving revision 1.9 diff -u -r1.9 general_generated.i --- src/lib/general/general_generated.i 13 Jun 2006 13:28:52 -0000 1.9 +++ src/lib/general/general_generated.i 15 Jun 2006 19:29:17 -0000 @@ -8,6 +8,10 @@ #include <gr_add_const_ii.h> #include <gr_add_const_sf.h> #include <gr_add_const_ss.h> +#include <gr_add_const_vcc.h> +#include <gr_add_const_vff.h> +#include <gr_add_const_vii.h> +#include <gr_add_const_vss.h> #include <gr_add_ff.h> #include <gr_add_ii.h> #include <gr_add_ss.h> @@ -30,6 +34,10 @@ #include <gr_multiply_const_ff.h> #include <gr_multiply_const_ii.h> #include <gr_multiply_const_ss.h> +#include <gr_multiply_const_vcc.h> +#include <gr_multiply_const_vff.h> +#include <gr_multiply_const_vii.h> +#include <gr_multiply_const_vss.h> #include <gr_multiply_ff.h> #include <gr_multiply_ii.h> #include <gr_multiply_ss.h> @@ -77,6 +85,10 @@ %include <gr_add_const_ii.i> %include <gr_add_const_sf.i> %include <gr_add_const_ss.i> +%include <gr_add_const_vcc.i> +%include <gr_add_const_vff.i> +%include <gr_add_const_vii.i> +%include <gr_add_const_vss.i> %include <gr_add_ff.i> %include <gr_add_ii.i> %include <gr_add_ss.i> @@ -99,6 +111,10 @@ %include <gr_multiply_const_ff.i> %include <gr_multiply_const_ii.i> %include <gr_multiply_const_ss.i> +%include <gr_multiply_const_vcc.i> +%include <gr_multiply_const_vff.i> +%include <gr_multiply_const_vii.i> +%include <gr_multiply_const_vss.i> %include <gr_multiply_ff.i> %include <gr_multiply_ii.i> %include <gr_multiply_ss.i> Index: src/lib/general/generate_common.py =================================================================== RCS file: /sources/gnuradio/gnuradio-core/src/lib/general/generate_common.py,v retrieving revision 1.10 diff -u -r1.10 generate_common.py --- src/lib/general/generate_common.py 13 Jun 2006 13:28:52 -0000 1.10 +++ src/lib/general/generate_common.py 15 Jun 2006 19:29:17 -0000 @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2004,2006 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -48,7 +48,9 @@ 'gr_divide_XX', 'gr_mute_XX', 'gr_add_vXX', - 'gr_multiply_vXX' + 'gr_multiply_vXX', + 'gr_add_const_vXX', + 'gr_multiply_const_vXX' ] # other blocks Index: src/python/gnuradio/gr/qa_add_v_and_friends.py =================================================================== RCS file: /sources/gnuradio/gnuradio-core/src/python/gnuradio/gr/qa_add_v_and_friends.py,v retrieving revision 1.2 diff -u -r1.2 qa_add_v_and_friends.py --- src/python/gnuradio/gr/qa_add_v_and_friends.py 13 Jun 2006 16:31:54 -0000 1.2 +++ src/python/gnuradio/gr/qa_add_v_and_friends.py 15 Jun 2006 19:29:19 -0000 @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2004,2006 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -82,6 +82,46 @@ result_data = dst.data() self.assertEqual(exp_data, result_data) + def help_const_ss(self, src_data, exp_data, op): + src = gr.vector_source_s(src_data) + srcv = gr.stream_to_vector(gr.sizeof_short, len(src_data)) + rhs = gr.vector_to_stream(gr.sizeof_short, len(src_data)) + dst = gr.vector_sink_s() + self.fg.connect(src, srcv, op, rhs, dst) + self.fg.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def help_const_ii(self, src_data, exp_data, op): + src = gr.vector_source_i(src_data) + srcv = gr.stream_to_vector(gr.sizeof_int, len(src_data)) + rhs = gr.vector_to_stream(gr.sizeof_int, len(src_data)) + dst = gr.vector_sink_i() + self.fg.connect(src, srcv, op, rhs, dst) + self.fg.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def help_const_ff(self, src_data, exp_data, op): + src = gr.vector_source_f(src_data) + srcv = gr.stream_to_vector(gr.sizeof_float, len(src_data)) + rhs = gr.vector_to_stream(gr.sizeof_float, len(src_data)) + dst = gr.vector_sink_f() + self.fg.connect(src, srcv, op, rhs, dst) + self.fg.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def help_const_cc(self, src_data, exp_data, op): + src = gr.vector_source_c(src_data) + srcv = gr.stream_to_vector(gr.sizeof_gr_complex, len(src_data)) + rhs = gr.vector_to_stream(gr.sizeof_gr_complex, len(src_data)) + dst = gr.vector_sink_c() + self.fg.connect(src, srcv, op, rhs, dst) + self.fg.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + def test_add_vss_one(self): src1_data = (1,) src2_data = (2,) @@ -146,6 +186,54 @@ op = gr.add_vcc(5) self.help_cc(5, (src1_data, src2_data, src3_data), expected_result, op) + def test_add_const_vss_one(self): + src_data = (1,) + op = gr.add_const_vss((2,)) + exp_data = (3,) + self.help_const_ss(src_data, exp_data, op) + + def test_add_const_vss_five(self): + src_data = (1, 2, 3, 4, 5) + op = gr.add_const_vss((6, 7, 8, 9, 10)) + exp_data = (7, 9, 11, 13, 15) + self.help_const_ss(src_data, exp_data, op) + + def test_add_const_vii_one(self): + src_data = (1,) + op = gr.add_const_vii((2,)) + exp_data = (3,) + self.help_const_ii(src_data, exp_data, op) + + def test_add_const_vii_five(self): + src_data = (1, 2, 3, 4, 5) + op = gr.add_const_vii((6, 7, 8, 9, 10)) + exp_data = (7, 9, 11, 13, 15) + self.help_const_ii(src_data, exp_data, op) + + def test_add_const_vff_one(self): + src_data = (1.0,) + op = gr.add_const_vff((2.0,)) + exp_data = (3.0,) + self.help_const_ff(src_data, exp_data, op) + + def test_add_const_vff_five(self): + src_data = (1.0, 2.0, 3.0, 4.0, 5.0) + op = gr.add_const_vff((6.0, 7.0, 8.0, 9.0, 10.0)) + exp_data = (7.0, 9.0, 11.0, 13.0, 15.0) + self.help_const_ff(src_data, exp_data, op) + + def test_add_const_vcc_one(self): + src_data = (1.0+2.0j,) + op = gr.add_const_vcc((2.0+3.0j,)) + exp_data = (3.0+5.0j,) + self.help_const_cc(src_data, exp_data, op) + + def test_add_const_vcc_five(self): + src_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j) + op = gr.add_const_vcc((11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)) + exp_data = (12.0+14.0j, 16.0+18.0j, 20.0+22.0j, 24.0+26.0j, 28.0+30.0j) + self.help_const_cc(src_data, exp_data, op) + def test_multiply_vss_one(self): src1_data = (1,) src2_data = (2,) @@ -210,5 +298,54 @@ op = gr.multiply_vcc(5) self.help_cc(5, (src1_data, src2_data, src3_data), expected_result, op) + def test_multiply_const_vss_one(self): + src_data = (2,) + op = gr.multiply_const_vss((3,)) + exp_data = (6,) + self.help_const_ss(src_data, exp_data, op) + + def test_multiply_const_vss_five(self): + src_data = (1, 2, 3, 4, 5) + op = gr.multiply_const_vss((6, 7, 8, 9, 10)) + exp_data = (6, 14, 24, 36, 50) + self.help_const_ss(src_data, exp_data, op) + + def test_multiply_const_vii_one(self): + src_data = (2,) + op = gr.multiply_const_vii((3,)) + exp_data = (6,) + self.help_const_ii(src_data, exp_data, op) + + def test_multiply_const_vii_five(self): + src_data = (1, 2, 3, 4, 5) + op = gr.multiply_const_vii((6, 7, 8, 9, 10)) + exp_data = (6, 14, 24, 36, 50) + self.help_const_ii(src_data, exp_data, op) + + def test_multiply_const_vff_one(self): + src_data = (2.0,) + op = gr.multiply_const_vff((3.0,)) + exp_data = (6.0,) + self.help_const_ff(src_data, exp_data, op) + + def test_multiply_const_vff_five(self): + src_data = (1.0, 2.0, 3.0, 4.0, 5.0) + op = gr.multiply_const_vff((6.0, 7.0, 8.0, 9.0, 10.0)) + exp_data = (6.0, 14.0, 24.0, 36.0, 50.0) + self.help_const_ff(src_data, exp_data, op) + + def test_multiply_const_vcc_one(self): + src_data = (1.0+2.0j,) + op = gr.multiply_const_vcc((2.0+3.0j,)) + exp_data = (-4.0+7.0j,) + self.help_const_cc(src_data, exp_data, op) + + def test_multiply_const_vcc_five(self): + src_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j) + op = gr.multiply_const_vcc((11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)) + exp_data = (-13.0+34.0j, -17.0+94.0j, -21.0+170.0j, -25.0+262.0j, -29.0+370.0j) + self.help_const_cc(src_data, exp_data, op) + + if __name__ == '__main__': gr_unittest.main ()
_______________________________________________ Patch-gnuradio mailing list Patch-gnuradio@gnu.org http://lists.gnu.org/mailman/listinfo/patch-gnuradio