summaryrefslogtreecommitdiff
path: root/gr-blocks
diff options
context:
space:
mode:
authorJohnathan Corgan2012-06-14 10:09:14 -0700
committerJohnathan Corgan2012-06-14 10:09:14 -0700
commit6a2d514fab10f692d49f724d1d09afce1c603fa0 (patch)
tree301bb37ed3158e4506cb206f5c18ade499da633c /gr-blocks
parent926f7cba99c4fa3906853e11ff4e91eea93a5a53 (diff)
downloadgnuradio-6a2d514fab10f692d49f724d1d09afce1c603fa0.tar.gz
gnuradio-6a2d514fab10f692d49f724d1d09afce1c603fa0.tar.bz2
gnuradio-6a2d514fab10f692d49f724d1d09afce1c603fa0.zip
blocks: added multiply_xx, some cleanup on add_xx
Diffstat (limited to 'gr-blocks')
-rw-r--r--gr-blocks/grc/blocks_block_tree.xml1
-rw-r--r--gr-blocks/grc/blocks_multiply_xx.xml63
-rw-r--r--gr-blocks/include/blocks/CMakeLists.txt3
-rw-r--r--gr-blocks/include/blocks/add_ff.h3
-rw-r--r--gr-blocks/include/blocks/multiply_XX.h.t53
-rw-r--r--gr-blocks/include/blocks/multiply_cc.h50
-rw-r--r--gr-blocks/include/blocks/multiply_ff.h50
-rw-r--r--gr-blocks/lib/CMakeLists.txt3
-rw-r--r--gr-blocks/lib/add_XX_impl.h.t1
-rw-r--r--gr-blocks/lib/add_const_XX_impl.h.t1
-rw-r--r--gr-blocks/lib/add_ff_impl.h1
-rw-r--r--gr-blocks/lib/multiply_XX_impl.cc.t69
-rw-r--r--gr-blocks/lib/multiply_XX_impl.h.t47
-rw-r--r--gr-blocks/lib/multiply_cc_impl.cc71
-rw-r--r--gr-blocks/lib/multiply_cc_impl.h47
-rw-r--r--gr-blocks/lib/multiply_ff_impl.cc71
-rw-r--r--gr-blocks/lib/multiply_ff_impl.h47
-rwxr-xr-xgr-blocks/python/qa_add_and_friends.py10
-rw-r--r--gr-blocks/swig/blocks_swig.i12
19 files changed, 597 insertions, 6 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml
index b4834d06f..125137d8b 100644
--- a/gr-blocks/grc/blocks_block_tree.xml
+++ b/gr-blocks/grc/blocks_block_tree.xml
@@ -32,5 +32,6 @@
<name>Math Operations</name>
<block>blocks_add_xx</block>
<block>blocks_add_const_xx</block>
+ <block>blocks_multiply_xx</block>
</cat>
</cat>
diff --git a/gr-blocks/grc/blocks_multiply_xx.xml b/gr-blocks/grc/blocks_multiply_xx.xml
new file mode 100644
index 000000000..d1578ca11
--- /dev/null
+++ b/gr-blocks/grc/blocks_multiply_xx.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Multiply Block:
+## all types, 1 output, 2 to inf inputs
+###################################################
+ -->
+<block>
+ <name>Multiply</name>
+ <key>blocks_multiply_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>gr.multiply_v$(type.fcn)($vlen)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:cc</opt>
+ </option>
+ <option>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
+ </option>
+ <option>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:ii</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:ss</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Inputs</name>
+ <key>num_inputs</key>
+ <value>2</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$num_inputs &gt; 1</check>
+ <check>$vlen &gt; 0</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_inputs</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt
index 68002588b..77dd91e28 100644
--- a/gr-blocks/include/blocks/CMakeLists.txt
+++ b/gr-blocks/include/blocks/CMakeLists.txt
@@ -66,6 +66,7 @@ endmacro(expand_h)
########################################################################
expand_h(add_XX ss ii cc)
expand_h(add_const_XX ss ii ff cc)
+expand_h(multiply_XX ss ii)
add_custom_target(blocks_generated_includes DEPENDS
${generated_includes}
@@ -78,6 +79,8 @@ install(FILES
${generated_includes}
api.h
add_ff.h
+ multiply_cc.h
+ multiply_ff.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks
COMPONENT "blocks_devel"
)
diff --git a/gr-blocks/include/blocks/add_ff.h b/gr-blocks/include/blocks/add_ff.h
index 22d382c4a..1e7350c1b 100644
--- a/gr-blocks/include/blocks/add_ff.h
+++ b/gr-blocks/include/blocks/add_ff.h
@@ -37,7 +37,8 @@ namespace gr {
typedef boost::shared_ptr<add_ff> sptr;
/*!
- * \brief Add streams of complex values
+ * \brief Add streams of float values
+ * \param vlen Vector length
* \ingroup math_blk
*/
static sptr make(size_t vlen=1);
diff --git a/gr-blocks/include/blocks/multiply_XX.h.t b/gr-blocks/include/blocks/multiply_XX.h.t
new file mode 100644
index 000000000..47ed3746c
--- /dev/null
+++ b/gr-blocks/include/blocks/multiply_XX.h.t
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004, 2009, 2012 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 output = prod (input_0, input_1, ...)
+ * \ingroup math_blk
+ *
+ * Multiply across all input streams.
+ */
+ 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=1);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/blocks/multiply_cc.h b/gr-blocks/include/blocks/multiply_cc.h
new file mode 100644
index 000000000..559fcda57
--- /dev/null
+++ b/gr-blocks/include/blocks/multiply_cc.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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_GR_MULTIPLY_CC_H
+#define INCLUDED_GR_MULTIPLY_CC_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API multiply_cc : virtual public gr_sync_block
+ {
+ public:
+
+ // gr::blocks::multiply_cc::sptr
+ typedef boost::shared_ptr<multiply_cc> sptr;
+
+ /*!
+ * \brief Multiply streams of complex values
+ * \param vlen Vector length
+ * \ingroup math_blk
+ */
+ static sptr make(size_t vlen=1);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_MULTIPLY_CC_H */
diff --git a/gr-blocks/include/blocks/multiply_ff.h b/gr-blocks/include/blocks/multiply_ff.h
new file mode 100644
index 000000000..683b540bb
--- /dev/null
+++ b/gr-blocks/include/blocks/multiply_ff.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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_GR_MULTIPLY_FF_H
+#define INCLUDED_GR_MULTIPLY_FF_H
+
+#include <blocks/api.h>
+#include <gr_sync_block.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API multiply_ff : virtual public gr_sync_block
+ {
+ public:
+
+ // gr::blocks::multiply_ff::sptr
+ typedef boost::shared_ptr<multiply_ff> sptr;
+
+ /*!
+ * \brief Multiply streams of float values
+ * \param vlen Vector length
+ * \ingroup math_blk
+ */
+ static sptr make(size_t vlen=1);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+#endif /* INCLUDED_BLOCKS_MULTIPLY_FF_H */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 334d18830..7894c34ea 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -87,6 +87,7 @@ endmacro(expand_cc_h_impl)
########################################################################
expand_cc_h_impl(add_XX ss ii cc)
expand_cc_h_impl(add_const_XX ss ii ff cc)
+expand_cc_h_impl(multiply_XX ss ii)
########################################################################
# Setup the include and linker paths
@@ -112,6 +113,8 @@ link_directories(${Boost_LIBRARY_DIRS})
list(APPEND gr_blocks_sources
${generated_sources}
add_ff_impl.cc
+ multiply_cc_impl.cc
+ multiply_ff_impl.cc
)
list(APPEND blocks_libs
diff --git a/gr-blocks/lib/add_XX_impl.h.t b/gr-blocks/lib/add_XX_impl.h.t
index 78c62b5e1..a1c486b85 100644
--- a/gr-blocks/lib/add_XX_impl.h.t
+++ b/gr-blocks/lib/add_XX_impl.h.t
@@ -41,6 +41,7 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
+
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_const_XX_impl.h.t b/gr-blocks/lib/add_const_XX_impl.h.t
index 1b21480c1..cae5ca813 100644
--- a/gr-blocks/lib/add_const_XX_impl.h.t
+++ b/gr-blocks/lib/add_const_XX_impl.h.t
@@ -44,6 +44,7 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
+
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/add_ff_impl.h b/gr-blocks/lib/add_ff_impl.h
index 5ebf173d6..77b90d079 100644
--- a/gr-blocks/lib/add_ff_impl.h
+++ b/gr-blocks/lib/add_ff_impl.h
@@ -39,6 +39,7 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
+
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_XX_impl.cc.t b/gr-blocks/lib/multiply_XX_impl.cc.t
new file mode 100644
index 000000000..bda4eac6a
--- /dev/null
+++ b/gr-blocks/lib/multiply_XX_impl.cc.t
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2010,2012 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 ("@NAME@",
+ gr_make_io_signature (1, -1, sizeof (@I_TYPE@)*vlen),
+ gr_make_io_signature (1, 1, sizeof (@O_TYPE@)*vlen)),
+ d_vlen(vlen)
+ {
+ }
+
+ 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 (size_t i = 0; i < noutput_items*d_vlen; i++){
+ @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i];
+ for (int j = 1; j < ninputs; j++)
+ acc *= ((@I_TYPE@ *) input_items[j])[i];
+
+ *optr++ = (@O_TYPE@) acc;
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_XX_impl.h.t b/gr-blocks/lib/multiply_XX_impl.h.t
new file mode 100644
index 000000000..78c62b5e1
--- /dev/null
+++ b/gr-blocks/lib/multiply_XX_impl.h.t
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2009,2012 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_IMPL@
+#define @GUARD_NAME_IMPL@
+
+#include <blocks/@NAME@.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API @NAME_IMPL@ : public @NAME@
+ {
+ size_t d_vlen;
+
+ public:
+ @NAME_IMPL@(size_t vlen);
+
+ 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/multiply_cc_impl.cc b/gr-blocks/lib/multiply_cc_impl.cc
new file mode 100644
index 000000000..e5160a9d5
--- /dev/null
+++ b/gr-blocks/lib/multiply_cc_impl.cc
@@ -0,0 +1,71 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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 <multiply_cc_impl.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ multiply_cc::sptr multiply_cc::make(size_t vlen)
+ {
+ return gnuradio::get_initial_sptr(new multiply_cc_impl(vlen));
+ }
+
+ multiply_cc_impl::multiply_cc_impl(size_t vlen)
+ : gr_sync_block("multiply_cc",
+ gr_make_io_signature (1, -1, sizeof(gr_complex)*vlen),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen)),
+ d_vlen(vlen)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1, alignment_multiple));
+ }
+
+ int
+ multiply_cc_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ gr_complex *out = (gr_complex *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ memcpy(out, input_items[0], noi*sizeof(gr_complex));
+ if(is_unaligned()) {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32fc_x2_multiply_32fc_u(out, out, (gr_complex*)input_items[i], noi);
+ }
+ else {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32fc_x2_multiply_32fc_a(out, out, (gr_complex*)input_items[i], noi);
+ }
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+}/* namespace gr */
diff --git a/gr-blocks/lib/multiply_cc_impl.h b/gr-blocks/lib/multiply_cc_impl.h
new file mode 100644
index 000000000..1595dc524
--- /dev/null
+++ b/gr-blocks/lib/multiply_cc_impl.h
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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_BLOCKS_MULTIPLY_CC_IMPL_H
+#define INCLUDED_BLOCKS_MULTIPLY_CC_IMPL_H
+
+#include <blocks/multiply_cc.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API multiply_cc_impl : public multiply_cc
+ {
+ size_t d_vlen;
+
+ public:
+ multiply_cc_impl(size_t vlen);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+
+#endif /* INCLUDED_BLOCKS_MULTIPLY_CC_IMPL_H */
diff --git a/gr-blocks/lib/multiply_ff_impl.cc b/gr-blocks/lib/multiply_ff_impl.cc
new file mode 100644
index 000000000..6e8f27711
--- /dev/null
+++ b/gr-blocks/lib/multiply_ff_impl.cc
@@ -0,0 +1,71 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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 <multiply_ff_impl.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ multiply_ff::sptr multiply_ff::make(size_t vlen)
+ {
+ return gnuradio::get_initial_sptr(new multiply_ff_impl(vlen));
+ }
+
+ multiply_ff_impl::multiply_ff_impl(size_t vlen)
+ : gr_sync_block("multiply_ff",
+ gr_make_io_signature (1, -1, sizeof(float)*vlen),
+ gr_make_io_signature (1, 1, sizeof(float)*vlen)),
+ d_vlen(vlen)
+ {
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(std::max(1, alignment_multiple));
+ }
+
+ int
+ multiply_ff_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ float *out = (float *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ memcpy(out, input_items[0], noi*sizeof(float));
+ if(is_unaligned()) {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32f_x2_multiply_32f_u(out, out, (float*)input_items[i], noi);
+ }
+ else {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32f_x2_multiply_32f_a(out, out, (float*)input_items[i], noi);
+ }
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+}/* namespace gr */
diff --git a/gr-blocks/lib/multiply_ff_impl.h b/gr-blocks/lib/multiply_ff_impl.h
new file mode 100644
index 000000000..2c5325a98
--- /dev/null
+++ b/gr-blocks/lib/multiply_ff_impl.h
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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_BLOCKS_MULTIPLY_FF_IMPL_H
+#define INCLUDED_BLOCKS_MULTIPLY_FF_IMPL_H
+
+#include <blocks/multiply_ff.h>
+
+namespace gr {
+ namespace blocks {
+
+ class BLOCKS_API multiply_ff_impl : public multiply_ff
+ {
+ size_t d_vlen;
+
+ public:
+ multiply_ff_impl(size_t vlen);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace blocks */
+} /* namespace gr */
+
+
+#endif /* INCLUDED_BLOCKS_MULTIPLY_FF_IMPL_H */
diff --git a/gr-blocks/python/qa_add_and_friends.py b/gr-blocks/python/qa_add_and_friends.py
index f38c135f2..0c8a91ce9 100755
--- a/gr-blocks/python/qa_add_and_friends.py
+++ b/gr-blocks/python/qa_add_and_friends.py
@@ -134,12 +134,12 @@ class test_add_and_friends(gr_unittest.TestCase):
expected_result = (-3-7j, 0+0j, 3+7j, 6+14j, 9+21j)
op = gr.multiply_const_cc(5+2j)
self.help_cc((src_data,), expected_result, op)
-
+ """
def test_mult_ii(self):
src1_data = (1, 2, 3, 4, 5)
src2_data = (8, -3, 4, 8, 2)
expected_result = (8, -6, 12, 32, 10)
- op = gr.multiply_ii()
+ op = blocks_swig.multiply_ii()
self.help_ii((src1_data, src2_data),
expected_result, op)
@@ -147,7 +147,7 @@ class test_add_and_friends(gr_unittest.TestCase):
src1_data = (1, 2, 3, 4, 5)
src2_data = (8, -3, 4, 8, 2)
expected_result = (8, -6, 12, 32, 10)
- op = gr.multiply_ff()
+ op = blocks_swig.multiply_ff()
self.help_ff((src1_data, src2_data),
expected_result, op)
@@ -155,10 +155,10 @@ class test_add_and_friends(gr_unittest.TestCase):
src1_data = (1+1j, 2+2j, 3+3j, 4+4j, 5+5j)
src2_data = (8, -3, 4, 8, 2)
expected_result = (8+8j, -6-6j, 12+12j, 32+32j, 10+10j)
- op = gr.multiply_cc()
+ op = blocks_swig.multiply_cc()
self.help_cc((src1_data, src2_data),
expected_result, op)
-
+ """
def test_sub_ii_1(self):
src1_data = (1, 2, 3, 4, 5)
expected_result = (-1, -2, -3, -4, -5)
diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i
index 7be0396f4..dc87f4f12 100644
--- a/gr-blocks/swig/blocks_swig.i
+++ b/gr-blocks/swig/blocks_swig.i
@@ -36,6 +36,10 @@
#include "blocks/add_const_ss.h"
#include "blocks/add_const_ii.h"
#include "blocks/add_const_cc.h"
+#include "blocks/multiply_ss.h"
+#include "blocks/multiply_ii.h"
+#include "blocks/multiply_ff.h"
+#include "blocks/multiply_cc.h"
%}
%include "blocks/add_ff.h"
@@ -46,6 +50,10 @@
%include "blocks/add_const_ss.h"
%include "blocks/add_const_ii.h"
%include "blocks/add_const_cc.h"
+%include "blocks/multiply_ss.h"
+%include "blocks/multiply_ii.h"
+%include "blocks/multiply_ff.h"
+%include "blocks/multiply_cc.h"
GR_SWIG_BLOCK_MAGIC2(blocks, add_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, add_ss);
@@ -55,3 +63,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, add_const_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, add_const_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, add_const_ii);
GR_SWIG_BLOCK_MAGIC2(blocks, add_const_cc);
+GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ss);
+GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ff);
+GR_SWIG_BLOCK_MAGIC2(blocks, multiply_cc);