[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/04: blocks: adding VOLK support for some
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/04: blocks: adding VOLK support for some functions. |
Date: |
Wed, 30 Jul 2014 17:48:02 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 89f684339d1d75617badb5f8b19c5e0e8dc9b711
Author: Tom Rondeau <address@hidden>
Date: Tue Jul 29 15:24:16 2014 -0400
blocks: adding VOLK support for some functions.
* multipy_const_vcc and _vff
* sub_ff
* float_to_complex
* binary_slicer
Also adds a min_XX block to complement max_XX.
---
gr-blocks/grc/blocks_min_xx.xml | 58 +++++++
gr-blocks/include/gnuradio/blocks/CMakeLists.txt | 10 +-
.../blocks/{multiply_const_cc.h => min_XX.h.t} | 42 ++---
.../include/gnuradio/blocks/multiply_const_cc.h | 2 -
.../{multiply_const_cc.h => multiply_const_vcc.h} | 35 ++--
.../{multiply_const_cc.h => multiply_const_vff.h} | 35 ++--
.../gnuradio/blocks/sub_ff.h} | 37 ++---
gr-blocks/lib/CMakeLists.txt | 10 +-
gr-blocks/lib/float_to_complex_impl.cc | 15 +-
gr-blocks/lib/min_XX_impl.cc.t | 80 +++++++++
.../{multiply_const_cc_impl.h => min_XX_impl.h.t} | 26 ++-
gr-blocks/lib/multiply_const_cc_impl.cc | 2 -
gr-blocks/lib/multiply_const_cc_impl.h | 2 -
..._complex_impl.cc => multiply_const_vcc_impl.cc} | 52 +++---
...y_const_cc_impl.h => multiply_const_vcc_impl.h} | 26 ++-
..._complex_impl.cc => multiply_const_vff_impl.cc} | 50 +++---
...y_const_cc_impl.h => multiply_const_vff_impl.h} | 26 ++-
gr-blocks/lib/sub_ff_impl.cc | 82 ++++++++++
.../{multiply_const_cc_impl.h => sub_ff_impl.h} | 23 +--
gr-blocks/python/blocks/qa_max.py | 118 +++++++++++++-
gr-blocks/python/blocks/qa_min.py | 178 +++++++++++++++++++++
gr-blocks/swig/blocks_swig3.i | 9 ++
gr-digital/lib/binary_slicer_fb_impl.cc | 16 +-
gr-fec/lib/dummy_decoder_impl.cc | 1 +
24 files changed, 705 insertions(+), 230 deletions(-)
diff --git a/gr-blocks/grc/blocks_min_xx.xml b/gr-blocks/grc/blocks_min_xx.xml
new file mode 100644
index 0000000..7d117c0
--- /dev/null
+++ b/gr-blocks/grc/blocks_min_xx.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Min:
+## 1 output, 2 to inf inputs
+###################################################
+ -->
+<block>
+ <name>Min</name>
+ <key>blocks_min_xx</key>
+ <import>from gnuradio import blocks</import>
+ <make>blocks.min_$(type.fcn)($vlen)</make>
+ <param>
+ <name>IO Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <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>1</value>
+ <type>int</type>
+ </param>
+ <param>
+ <name>Vec Length</name>
+ <key>vlen</key>
+ <value>1</value>
+ <type>int</type>
+ </param>
+ <check>$num_inputs >= 1</check>
+ <check>$vlen >= 1</check>
+ <sink>
+ <name>in</name>
+ <type>$type</type>
+ <vlen>$vlen</vlen>
+ <nports>$num_inputs</nports>
+ </sink>
+ <source>
+ <name>out</name>
+ <type>$type</type>
+ <vlen>1</vlen>
+ </source>
+</block>
diff --git a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
index 96e8607..662f705 100644
--- a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
+++ b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt
@@ -30,11 +30,12 @@ GR_EXPAND_X_H(blocks and_const_XX bb ss ii)
GR_EXPAND_X_H(blocks argmax_XX fs is ss)
GR_EXPAND_X_H(blocks divide_XX ss ii ff cc)
GR_EXPAND_X_H(blocks integrate_XX ss ii ff cc)
-GR_EXPAND_X_H(blocks max_XX ff ii ss)
+GR_EXPAND_X_H(blocks max_XX ss ii ff)
+GR_EXPAND_X_H(blocks min_XX ss ii ff)
GR_EXPAND_X_H(blocks moving_average_XX ss ii ff cc)
GR_EXPAND_X_H(blocks multiply_XX ss ii)
GR_EXPAND_X_H(blocks multiply_const_XX ss ii)
-GR_EXPAND_X_H(blocks multiply_const_vXX ss ii ff cc)
+GR_EXPAND_X_H(blocks multiply_const_vXX ss ii)
GR_EXPAND_X_H(blocks multiply_matrix_XX ff cc)
GR_EXPAND_X_H(blocks mute_XX ss ii ff cc)
GR_EXPAND_X_H(blocks not_XX bb ss ii)
@@ -43,7 +44,7 @@ GR_EXPAND_X_H(blocks peak_detector_XX fb ib sb)
GR_EXPAND_X_H(blocks probe_signal_X b s i f c)
GR_EXPAND_X_H(blocks probe_signal_vX b s i f c)
GR_EXPAND_X_H(blocks sample_and_hold_XX bb ss ii ff)
-GR_EXPAND_X_H(blocks sub_XX ss ii ff cc)
+GR_EXPAND_X_H(blocks sub_XX ss ii cc)
GR_EXPAND_X_H(blocks tsb_vector_sink_X b s i f c)
GR_EXPAND_X_H(blocks xor_XX bb ss ii)
GR_EXPAND_X_H(blocks packed_to_unpacked_XX bb ss ii)
@@ -122,7 +123,9 @@ install(FILES
multiply_ff.h
multiply_conjugate_cc.h
multiply_const_cc.h
+ multiply_const_vcc.h
multiply_const_ff.h
+ multiply_const_vff.h
nlog10_ff.h
nop.h
null_sink.h
@@ -155,6 +158,7 @@ install(FILES
streams_to_stream.h
streams_to_vector.h
stretch_ff.h
+ sub_ff.h
tag_debug.h
tag_gate.h
tagged_file_sink.h
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
b/gr-blocks/include/gnuradio/blocks/min_XX.h.t
similarity index 54%
copy from gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
copy to gr-blocks/include/gnuradio/blocks/min_XX.h.t
index ff72572..45c7357 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/min_XX.h.t
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,8 +22,8 @@
// @WARNING@
-#ifndef INCLUDED_MULTIPLY_CONST_CC_H
-#define INCLUDED_MULTIPLY_CONST_CC_H
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
@@ -32,36 +32,26 @@ namespace gr {
namespace blocks {
/*!
- * \brief output = input * complex constant
+ * \brief Compares vectors from multiple streams and determines
+ * the minimum value from each vector over all streams.
* \ingroup math_operators_blk
+ *
+ * \details
+ * 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 the output stream will contain the minimum value
+ * in the vector.
*/
- class BLOCKS_API multiply_const_cc : virtual public sync_block
+ class BLOCKS_API @NAME@ : virtual public sync_block
{
-
public:
+ // gr::blocks::@NAME@::sptr
+ typedef boost::shared_ptr<@NAME@> sptr;
- // gr::blocks::multiply_const_cc::sptr
- typedef boost::shared_ptr<multiply_const_cc> sptr;
-
- /*!
- * \brief Create an instance of multiply_const_cc
- * \param k complex multiplicative constant
- * \param vlen Vector length of incoming stream
- */
- static sptr make(gr_complex k, size_t vlen=1);
-
- /*!
- * \brief Return complex multiplicative constant
- */
- virtual gr_complex k() const = 0;
-
- /*!
- * \brief Set complex multiplicative constant
- */
- virtual void set_k(gr_complex k) = 0;
+ static sptr make(size_t vlen);
};
} /* namespace blocks */
} /* namespace gr */
-#endif /* INCLUDED_MULTIPLY_CONST_CC_H */
+#endif /* @GUARD_NAME@ */
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
b/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
index ff72572..3e8ed7c 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
@@ -20,8 +20,6 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
#ifndef INCLUDED_MULTIPLY_CONST_CC_H
#define INCLUDED_MULTIPLY_CONST_CC_H
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
b/gr-blocks/include/gnuradio/blocks/multiply_const_vcc.h
similarity index 57%
copy from gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
copy to gr-blocks/include/gnuradio/blocks/multiply_const_vcc.h
index ff72572..78d2752 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply_const_vcc.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,10 +20,8 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
-#ifndef INCLUDED_MULTIPLY_CONST_CC_H
-#define INCLUDED_MULTIPLY_CONST_CC_H
+#ifndef INCLUDED_MULTIPLY_CONST_VCC_H
+#define INCLUDED_MULTIPLY_CONST_VCC_H
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
@@ -32,36 +30,33 @@ namespace gr {
namespace blocks {
/*!
- * \brief output = input * complex constant
+ * \brief output = input * constant vector (element-wise)
* \ingroup math_operators_blk
*/
- class BLOCKS_API multiply_const_cc : virtual public sync_block
+ class BLOCKS_API multiply_const_vcc : virtual public sync_block
{
-
public:
-
- // gr::blocks::multiply_const_cc::sptr
- typedef boost::shared_ptr<multiply_const_cc> sptr;
+ // gr::blocks::multiply_const_vcc::sptr
+ typedef boost::shared_ptr<multiply_const_vcc> sptr;
/*!
- * \brief Create an instance of multiply_const_cc
- * \param k complex multiplicative constant
- * \param vlen Vector length of incoming stream
+ * \brief Create an instance of multiply_const_vcc
+ * \param k multiplicative constant vector
*/
- static sptr make(gr_complex k, size_t vlen=1);
+ static sptr make(std::vector<gr_complex> k);
/*!
- * \brief Return complex multiplicative constant
+ * \brief Return multiplicative constant vector
*/
- virtual gr_complex k() const = 0;
+ virtual std::vector<gr_complex> k() const = 0;
/*!
- * \brief Set complex multiplicative constant
+ * \brief Set multiplicative constant vector
*/
- virtual void set_k(gr_complex k) = 0;
+ virtual void set_k(std::vector<gr_complex> k) = 0;
};
} /* namespace blocks */
} /* namespace gr */
-#endif /* INCLUDED_MULTIPLY_CONST_CC_H */
+#endif /* INCLUDED_MULTIPLY_CONST_VCC_H */
diff --git a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
b/gr-blocks/include/gnuradio/blocks/multiply_const_vff.h
similarity index 57%
copy from gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
copy to gr-blocks/include/gnuradio/blocks/multiply_const_vff.h
index ff72572..884088e 100644
--- a/gr-blocks/include/gnuradio/blocks/multiply_const_cc.h
+++ b/gr-blocks/include/gnuradio/blocks/multiply_const_vff.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,10 +20,8 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
-#ifndef INCLUDED_MULTIPLY_CONST_CC_H
-#define INCLUDED_MULTIPLY_CONST_CC_H
+#ifndef INCLUDED_MULTIPLY_CONST_VFF_H
+#define INCLUDED_MULTIPLY_CONST_VFF_H
#include <gnuradio/blocks/api.h>
#include <gnuradio/sync_block.h>
@@ -32,36 +30,33 @@ namespace gr {
namespace blocks {
/*!
- * \brief output = input * complex constant
+ * \brief output = input * constant vector (element-wise)
* \ingroup math_operators_blk
*/
- class BLOCKS_API multiply_const_cc : virtual public sync_block
+ class BLOCKS_API multiply_const_vff : virtual public sync_block
{
-
public:
-
- // gr::blocks::multiply_const_cc::sptr
- typedef boost::shared_ptr<multiply_const_cc> sptr;
+ // gr::blocks::multiply_const_vff::sptr
+ typedef boost::shared_ptr<multiply_const_vff> sptr;
/*!
- * \brief Create an instance of multiply_const_cc
- * \param k complex multiplicative constant
- * \param vlen Vector length of incoming stream
+ * \brief Create an instance of multiply_const_vff
+ * \param k multiplicative constant vector
*/
- static sptr make(gr_complex k, size_t vlen=1);
+ static sptr make(std::vector<float> k);
/*!
- * \brief Return complex multiplicative constant
+ * \brief Return multiplicative constant vector
*/
- virtual gr_complex k() const = 0;
+ virtual std::vector<float> k() const = 0;
/*!
- * \brief Set complex multiplicative constant
+ * \brief Set multiplicative constant vector
*/
- virtual void set_k(gr_complex k) = 0;
+ virtual void set_k(std::vector<float> k) = 0;
};
} /* namespace blocks */
} /* namespace gr */
-#endif /* INCLUDED_MULTIPLY_CONST_CC_H */
+#endif /* INCLUDED_MULTIPLY_CONST_VFF_H */
diff --git a/gr-blocks/lib/multiply_const_cc_impl.h
b/gr-blocks/include/gnuradio/blocks/sub_ff.h
similarity index 57%
copy from gr-blocks/lib/multiply_const_cc_impl.h
copy to gr-blocks/include/gnuradio/blocks/sub_ff.h
index 29ba6dd..3cc844f 100644
--- a/gr-blocks/lib/multiply_const_cc_impl.h
+++ b/gr-blocks/include/gnuradio/blocks/sub_ff.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,35 +20,32 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
+#ifndef INCLUDED_BLOCKS_SUB_FF_H
+#define INCLUDED_BLOCKS_SUB_FF_H
-#ifndef INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-#define INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-
-#include <gnuradio/blocks/multiply_const_cc.h>
+#include <gnuradio/blocks/api.h>
+#include <gnuradio/sync_block.h>
namespace gr {
namespace blocks {
- class BLOCKS_API multiply_const_cc_impl : public multiply_const_cc
+ /*!
+ * \brief output = input_0 - input_1 - ...)
+ * \ingroup math_operators_blk
+ *
+ * \details
+ * Subtract across all input streams.
+ */
+ class BLOCKS_API sub_ff : virtual public sync_block
{
- gr_complex d_k;
- size_t d_vlen;
-
public:
- multiply_const_cc_impl(gr_complex k, size_t vlen);
-
- void setup_rpc();
-
- gr_complex k() const { return d_k; }
- void set_k(gr_complex k) { d_k = k; }
+ // gr::blocks::sub_ff::sptr
+ typedef boost::shared_ptr<sub_ff> sptr;
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ static sptr make(size_t vlen=1);
};
} /* namespace blocks */
} /* namespace gr */
-#endif /* INCLUDED_MULTIPLY_CONST_CC_IMPL_H */
+#endif /* INCLUDED_BLOCKS_SUB_FF_H */
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index b3892ce..b2711c9 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -35,11 +35,12 @@ GR_EXPAND_X_CC_H_IMPL(blocks and_const_XX bb ss ii)
GR_EXPAND_X_CC_H_IMPL(blocks argmax_XX fs is ss)
GR_EXPAND_X_CC_H_IMPL(blocks divide_XX ss ii ff cc)
GR_EXPAND_X_CC_H_IMPL(blocks integrate_XX ss ii ff cc)
-GR_EXPAND_X_CC_H_IMPL(blocks max_XX ff ii ss)
+GR_EXPAND_X_CC_H_IMPL(blocks max_XX ss ii ff)
+GR_EXPAND_X_CC_H_IMPL(blocks min_XX ss ii ff)
GR_EXPAND_X_CC_H_IMPL(blocks moving_average_XX ss ii ff cc)
GR_EXPAND_X_CC_H_IMPL(blocks multiply_XX ss ii)
GR_EXPAND_X_CC_H_IMPL(blocks multiply_const_XX ss ii)
-GR_EXPAND_X_CC_H_IMPL(blocks multiply_const_vXX ss ii ff cc)
+GR_EXPAND_X_CC_H_IMPL(blocks multiply_const_vXX ss ii)
GR_EXPAND_X_CC_H_IMPL(blocks mute_XX ss ii ff cc)
GR_EXPAND_X_CC_H_IMPL(blocks not_XX bb ss ii)
GR_EXPAND_X_CC_H_IMPL(blocks or_XX bb ss ii)
@@ -47,7 +48,7 @@ GR_EXPAND_X_CC_H_IMPL(blocks peak_detector_XX fb ib sb)
GR_EXPAND_X_CC_H_IMPL(blocks probe_signal_X b s i f c)
GR_EXPAND_X_CC_H_IMPL(blocks probe_signal_vX b s i f c)
GR_EXPAND_X_CC_H_IMPL(blocks sample_and_hold_XX bb ss ii ff)
-GR_EXPAND_X_CC_H_IMPL(blocks sub_XX ss ii ff cc)
+GR_EXPAND_X_CC_H_IMPL(blocks sub_XX ss ii cc)
GR_EXPAND_X_CC_H_IMPL(blocks tsb_vector_sink_X b s i f c)
GR_EXPAND_X_CC_H_IMPL(blocks xor_XX bb ss ii)
GR_EXPAND_X_CC_H_IMPL(blocks packed_to_unpacked_XX bb ss ii)
@@ -140,7 +141,9 @@ list(APPEND gr_blocks_sources
multiply_ff_impl.cc
multiply_conjugate_cc_impl.cc
multiply_const_cc_impl.cc
+ multiply_const_vcc_impl.cc
multiply_const_ff_impl.cc
+ multiply_const_vff_impl.cc
nlog10_ff_impl.cc
nop_impl.cc
null_sink_impl.cc
@@ -175,6 +178,7 @@ list(APPEND gr_blocks_sources
streams_to_stream_impl.cc
streams_to_vector_impl.cc
stretch_ff_impl.cc
+ sub_ff_impl.cc
tagged_file_sink_impl.cc
tagged_stream_to_pdu_impl.cc
tagged_stream_multiply_length_impl.cc
diff --git a/gr-blocks/lib/float_to_complex_impl.cc
b/gr-blocks/lib/float_to_complex_impl.cc
index 236438d..a2dd0d3 100644
--- a/gr-blocks/lib/float_to_complex_impl.cc
+++ b/gr-blocks/lib/float_to_complex_impl.cc
@@ -31,15 +31,17 @@
namespace gr {
namespace blocks {
- float_to_complex::sptr float_to_complex::make(size_t vlen)
+ float_to_complex::sptr
+ float_to_complex::make(size_t vlen)
{
- return gnuradio::get_initial_sptr(new float_to_complex_impl(vlen));
+ return gnuradio::get_initial_sptr
+ (new float_to_complex_impl(vlen));
}
float_to_complex_impl::float_to_complex_impl(size_t vlen)
: sync_block("float_to_complex",
- io_signature::make (1, 2, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(gr_complex)*vlen)),
+ io_signature::make(1, 2, sizeof(float)*vlen),
+ io_signature::make(1, 1, sizeof(gr_complex)*vlen)),
d_vlen(vlen)
{
const int alignment_multiple =
@@ -63,8 +65,9 @@ namespace gr {
break;
case 2:
- for (size_t j = 0; j < noutput_items*d_vlen; j++)
- out[j] = gr_complex (r[j], i[j]);
+ //for (size_t j = 0; j < noutput_items*d_vlen; j++)
+ // out[j] = gr_complex (r[j], i[j]);
+ volk_32f_x2_interleave_32fc(out, r, i, noutput_items*d_vlen);
break;
default:
diff --git a/gr-blocks/lib/min_XX_impl.cc.t b/gr-blocks/lib/min_XX_impl.cc.t
new file mode 100644
index 0000000..d77dda2
--- /dev/null
+++ b/gr-blocks/lib/min_XX_impl.cc.t
@@ -0,0 +1,80 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 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 <@address@hidden>
+#include <gnuradio/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)
+ : sync_block("@BASE_NAME@",
+ io_signature::make(1, -1, vlen*sizeof(@I_TYPE@)),
+ io_signature::make(1, 1, sizeof(@O_TYPE@))),
+ d_vlen(vlen)
+ {
+ }
+
+ @NAME_IMPL@::address@hidden@()
+ {
+ }
+
+ 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@ min = ((@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] < min) {
+ min = ((@address@hidden)input_items[k])[i*d_vlen + j];
+ }
+ }
+ }
+
+ *optr++ = (@O_TYPE@)min;
+ }
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_cc_impl.h
b/gr-blocks/lib/min_XX_impl.h.t
similarity index 61%
copy from gr-blocks/lib/multiply_const_cc_impl.h
copy to gr-blocks/lib/min_XX_impl.h.t
index 29ba6dd..33be614 100644
--- a/gr-blocks/lib/multiply_const_cc_impl.h
+++ b/gr-blocks/lib/min_XX_impl.h.t
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,33 +22,29 @@
// @WARNING@
-#ifndef INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-#define INCLUDED_MULTIPLY_CONST_CC_IMPL_H
+#ifndef @GUARD_NAME_IMPL@
+#define @GUARD_NAME_IMPL@
-#include <gnuradio/blocks/multiply_const_cc.h>
+#include <gnuradio/blocks/@address@hidden>
namespace gr {
namespace blocks {
- class BLOCKS_API multiply_const_cc_impl : public multiply_const_cc
+ class @NAME_IMPL@ : public @NAME@
{
- gr_complex d_k;
+ private:
size_t d_vlen;
public:
- multiply_const_cc_impl(gr_complex k, size_t vlen);
-
- void setup_rpc();
-
- gr_complex k() const { return d_k; }
- void set_k(gr_complex k) { d_k = k; }
+ @NAME_IMPL@(size_t vlen);
+ address@hidden@();
int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
};
} /* namespace blocks */
} /* namespace gr */
-#endif /* INCLUDED_MULTIPLY_CONST_CC_IMPL_H */
+#endif /* @GUARD_NAME_IMPL@ */
diff --git a/gr-blocks/lib/multiply_const_cc_impl.cc
b/gr-blocks/lib/multiply_const_cc_impl.cc
index f6b8dc3..c082a1d 100644
--- a/gr-blocks/lib/multiply_const_cc_impl.cc
+++ b/gr-blocks/lib/multiply_const_cc_impl.cc
@@ -20,8 +20,6 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/gr-blocks/lib/multiply_const_cc_impl.h
b/gr-blocks/lib/multiply_const_cc_impl.h
index 29ba6dd..06f60b1 100644
--- a/gr-blocks/lib/multiply_const_cc_impl.h
+++ b/gr-blocks/lib/multiply_const_cc_impl.h
@@ -20,8 +20,6 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
-
#ifndef INCLUDED_MULTIPLY_CONST_CC_IMPL_H
#define INCLUDED_MULTIPLY_CONST_CC_IMPL_H
diff --git a/gr-blocks/lib/float_to_complex_impl.cc
b/gr-blocks/lib/multiply_const_vcc_impl.cc
similarity index 51%
copy from gr-blocks/lib/float_to_complex_impl.cc
copy to gr-blocks/lib/multiply_const_vcc_impl.cc
index 236438d..637f79e 100644
--- a/gr-blocks/lib/float_to_complex_impl.cc
+++ b/gr-blocks/lib/multiply_const_vcc_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,55 +24,49 @@
#include "config.h"
#endif
-#include "float_to_complex_impl.h"
+#include <multiply_const_vcc_impl.h>
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
namespace gr {
namespace blocks {
- float_to_complex::sptr float_to_complex::make(size_t vlen)
+ multiply_const_vcc::sptr
+ multiply_const_vcc::make(std::vector<gr_complex> k)
{
- return gnuradio::get_initial_sptr(new float_to_complex_impl(vlen));
+ return gnuradio::get_initial_sptr
+ (new multiply_const_vcc_impl(k));
}
- float_to_complex_impl::float_to_complex_impl(size_t vlen)
- : sync_block("float_to_complex",
- io_signature::make (1, 2, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(gr_complex)*vlen)),
- d_vlen(vlen)
+ multiply_const_vcc_impl::multiply_const_vcc_impl(std::vector<gr_complex> k)
+ : sync_block("multiply_const_vcc",
+ io_signature::make(1, 1, sizeof(gr_complex)*k.size()),
+ io_signature::make(1, 1, sizeof(gr_complex)*k.size())),
+ d_k(k)
{
const int alignment_multiple =
- volk_get_alignment() / sizeof(float);
+ volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1,alignment_multiple));
}
int
- float_to_complex_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ multiply_const_vcc_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- float *r = (float *)input_items[0];
- float *i = (float *)input_items[1];
- gr_complex *out = (gr_complex *) output_items[0];
+ gr_complex *iptr = (gr_complex*)input_items[0];
+ gr_complex *optr = (gr_complex*)output_items[0];
- switch (input_items.size ()){
- case 1:
- for (size_t j = 0; j < noutput_items*d_vlen; j++)
- out[j] = gr_complex (r[j], 0);
- break;
+ int nitems_per_block =
output_signature()->sizeof_stream_item(0)/sizeof(gr_complex);
- case 2:
- for (size_t j = 0; j < noutput_items*d_vlen; j++)
- out[j] = gr_complex (r[j], i[j]);
- break;
-
- default:
- assert (0);
+ 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;
}
} /* namespace blocks */
-}/* namespace gr */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_cc_impl.h
b/gr-blocks/lib/multiply_const_vcc_impl.h
similarity index 65%
copy from gr-blocks/lib/multiply_const_cc_impl.h
copy to gr-blocks/lib/multiply_const_vcc_impl.h
index 29ba6dd..18886ed 100644
--- a/gr-blocks/lib/multiply_const_cc_impl.h
+++ b/gr-blocks/lib/multiply_const_vcc_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,28 +20,24 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
+#ifndef INCLUDED_BLOCKS_MULTIPLY_CONST_VCC_IMPL_H
+#define INCLUDED_BLOCKS_MULTIPLY_CONST_VCC_IMPL_H
-#ifndef INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-#define INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-
-#include <gnuradio/blocks/multiply_const_cc.h>
+#include <gnuradio/blocks/multiply_const_vcc.h>
namespace gr {
namespace blocks {
- class BLOCKS_API multiply_const_cc_impl : public multiply_const_cc
+ class BLOCKS_API multiply_const_vcc_impl : public multiply_const_vcc
{
- gr_complex d_k;
- size_t d_vlen;
+ private:
+ std::vector<gr_complex> d_k;
public:
- multiply_const_cc_impl(gr_complex k, size_t vlen);
-
- void setup_rpc();
+ multiply_const_vcc_impl(std::vector<gr_complex> k);
- gr_complex k() const { return d_k; }
- void set_k(gr_complex k) { d_k = k; }
+ std::vector<gr_complex> k() const { return d_k; }
+ void set_k(std::vector<gr_complex> k) { d_k = k; }
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -51,4 +47,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* INCLUDED_MULTIPLY_CONST_CC_IMPL_H */
+#endif /* INCLUDED_BLOCKS_MULTIPLY_CONST_VCC_IMPL_H */
diff --git a/gr-blocks/lib/float_to_complex_impl.cc
b/gr-blocks/lib/multiply_const_vff_impl.cc
similarity index 52%
copy from gr-blocks/lib/float_to_complex_impl.cc
copy to gr-blocks/lib/multiply_const_vff_impl.cc
index 236438d..ab53ce3 100644
--- a/gr-blocks/lib/float_to_complex_impl.cc
+++ b/gr-blocks/lib/multiply_const_vff_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,23 +24,25 @@
#include "config.h"
#endif
-#include "float_to_complex_impl.h"
+#include <multiply_const_vff_impl.h>
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
namespace gr {
namespace blocks {
- float_to_complex::sptr float_to_complex::make(size_t vlen)
+ multiply_const_vff::sptr
+ multiply_const_vff::make(std::vector<float> k)
{
- return gnuradio::get_initial_sptr(new float_to_complex_impl(vlen));
+ return gnuradio::get_initial_sptr
+ (new multiply_const_vff_impl(k));
}
- float_to_complex_impl::float_to_complex_impl(size_t vlen)
- : sync_block("float_to_complex",
- io_signature::make (1, 2, sizeof(float)*vlen),
- io_signature::make (1, 1, sizeof(gr_complex)*vlen)),
- d_vlen(vlen)
+ multiply_const_vff_impl::multiply_const_vff_impl(std::vector<float> k)
+ : sync_block("multiply_const_vff",
+ io_signature::make(1, 1, sizeof(float)*k.size()),
+ io_signature::make(1, 1, sizeof(float)*k.size())),
+ d_k(k)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
@@ -48,31 +50,23 @@ namespace gr {
}
int
- float_to_complex_impl::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ multiply_const_vff_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- float *r = (float *)input_items[0];
- float *i = (float *)input_items[1];
- gr_complex *out = (gr_complex *) output_items[0];
+ float *iptr = (float*)input_items[0];
+ float *optr = (float*)output_items[0];
- switch (input_items.size ()){
- case 1:
- for (size_t j = 0; j < noutput_items*d_vlen; j++)
- out[j] = gr_complex (r[j], 0);
- break;
+ int nitems_per_block =
output_signature()->sizeof_stream_item(0)/sizeof(float);
- case 2:
- for (size_t j = 0; j < noutput_items*d_vlen; j++)
- out[j] = gr_complex (r[j], i[j]);
- break;
-
- default:
- assert (0);
+ 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;
}
} /* namespace blocks */
-}/* namespace gr */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_cc_impl.h
b/gr-blocks/lib/multiply_const_vff_impl.h
similarity index 65%
copy from gr-blocks/lib/multiply_const_cc_impl.h
copy to gr-blocks/lib/multiply_const_vff_impl.h
index 29ba6dd..4fda2a8 100644
--- a/gr-blocks/lib/multiply_const_cc_impl.h
+++ b/gr-blocks/lib/multiply_const_vff_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,28 +20,24 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
+#ifndef INCLUDED_BLOCKS_MULTIPLY_CONST_VFF_IMPL_H
+#define INCLUDED_BLOCKS_MULTIPLY_CONST_VFF_IMPL_H
-#ifndef INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-#define INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-
-#include <gnuradio/blocks/multiply_const_cc.h>
+#include <gnuradio/blocks/multiply_const_vff.h>
namespace gr {
namespace blocks {
- class BLOCKS_API multiply_const_cc_impl : public multiply_const_cc
+ class BLOCKS_API multiply_const_vff_impl : public multiply_const_vff
{
- gr_complex d_k;
- size_t d_vlen;
+ private:
+ std::vector<float> d_k;
public:
- multiply_const_cc_impl(gr_complex k, size_t vlen);
-
- void setup_rpc();
+ multiply_const_vff_impl(std::vector<float> k);
- gr_complex k() const { return d_k; }
- void set_k(gr_complex k) { d_k = k; }
+ std::vector<float> k() const { return d_k; }
+ void set_k(std::vector<float> k) { d_k = k; }
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -51,4 +47,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* INCLUDED_MULTIPLY_CONST_CC_IMPL_H */
+#endif /* INCLUDED_BLOCKS_MULTIPLY_CONST_VFF_IMPL_H */
diff --git a/gr-blocks/lib/sub_ff_impl.cc b/gr-blocks/lib/sub_ff_impl.cc
new file mode 100644
index 0000000..d3a0815
--- /dev/null
+++ b/gr-blocks/lib/sub_ff_impl.cc
@@ -0,0 +1,82 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 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 <sub_ff_impl.h>
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace blocks {
+
+ sub_ff::sptr
+ sub_ff::make(size_t vlen)
+ {
+ return gnuradio::get_initial_sptr
+ (new sub_ff_impl(vlen));
+ }
+
+ sub_ff_impl::sub_ff_impl(size_t vlen)
+ : sync_block("@sub_ff",
+ io_signature::make(1, -1, sizeof(float)*vlen),
+ io_signature::make(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
+ sub_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 ninputs = input_items.size();
+ int noi = noutput_items*d_vlen;
+
+ //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;
+ //}
+
+ const float *in = (const float*)input_items[0];
+ for(int i = 0; i < noi; i++)
+ out[i] = -in[i];
+ for(int i = 1; i < ninputs; i++) {
+ in = (const float*)input_items[i];
+ volk_32f_x2_subtract_32f(out, out, in, noi);
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace blocks */
+} /* namespace gr */
diff --git a/gr-blocks/lib/multiply_const_cc_impl.h
b/gr-blocks/lib/sub_ff_impl.h
similarity index 66%
copy from gr-blocks/lib/multiply_const_cc_impl.h
copy to gr-blocks/lib/sub_ff_impl.h
index 29ba6dd..b4eff66 100644
--- a/gr-blocks/lib/multiply_const_cc_impl.h
+++ b/gr-blocks/lib/sub_ff_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2009,2012 Free Software Foundation, Inc.
+ * Copyright 2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,28 +20,21 @@
* Boston, MA 02110-1301, USA.
*/
-// @WARNING@
+#ifndef INCLUDED_BLOCKS_SUB_FF_IMPL_H
+#define INCLUDED_BLOCKS_SUB_FF_IMPL_H
-#ifndef INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-#define INCLUDED_MULTIPLY_CONST_CC_IMPL_H
-
-#include <gnuradio/blocks/multiply_const_cc.h>
+#include <gnuradio/blocks/sub_ff.h>
namespace gr {
namespace blocks {
- class BLOCKS_API multiply_const_cc_impl : public multiply_const_cc
+ class BLOCKS_API sub_ff_impl : public sub_ff
{
- gr_complex d_k;
+ private:
size_t d_vlen;
public:
- multiply_const_cc_impl(gr_complex k, size_t vlen);
-
- void setup_rpc();
-
- gr_complex k() const { return d_k; }
- void set_k(gr_complex k) { d_k = k; }
+ sub_ff_impl(size_t vlen);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
@@ -51,4 +44,4 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-#endif /* INCLUDED_MULTIPLY_CONST_CC_IMPL_H */
+#endif /* INCLUDED_BLOCKS_SUB_FF_IMPL_H */
diff --git a/gr-blocks/python/blocks/qa_max.py
b/gr-blocks/python/blocks/qa_max.py
index 441582a..709dbee 100755
--- a/gr-blocks/python/blocks/qa_max.py
+++ b/gr-blocks/python/blocks/qa_max.py
@@ -46,7 +46,7 @@ class test_max(gr_unittest.TestCase):
result_data = dst.data()
self.assertEqual(expected_result, result_data)
- def test_002(self):
+ def stest_002(self):
src_data=(-100,-99,-98,-97,-96,-1)
expected_result = (float(max(src_data)),)
@@ -60,6 +60,120 @@ class test_max(gr_unittest.TestCase):
result_data = dst.data()
self.assertEqual(expected_result, result_data)
+ def stest_003(self):
+ src_data0 = (0, 2, -3, 0, 12, 0)
+ src_data1 = (1, 1, 1, 1, 1, 1)
+
+ expected_result = [float(max(x,y)) for x,y in zip(src_data0,
src_data1)]
+
+ src0 = blocks.vector_source_f(src_data0)
+ src1 = blocks.vector_source_f(src_data1)
+ op = blocks.max_ff(1)
+ dst = blocks.vector_sink_f()
+
+ self.tb.connect(src0, (op, 0))
+ self.tb.connect(src1, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def stest_004(self):
+ dim = 2
+ src_data0 = (0, 2, -3, 0, 12, 0)
+ src_data1 = (1, 1, 1, 1, 1, 1)
+
+ expected_data = []
+ tmp = [float(max(x,y)) for x,y in zip(src_data0, src_data1)]
+ for i in xrange(len(tmp)/dim):
+ expected_data.append(float(max(tmp[i*dim:(i+1)*dim])))
+
+ src0 = blocks.vector_source_f(src_data0)
+ s2v0 = blocks.stream_to_vector(gr.sizeof_float,dim)
+ src1 = blocks.vector_source_f(src_data1)
+ s2v1 = blocks.stream_to_vector(gr.sizeof_float,dim)
+ op = blocks.max_ff(dim)
+ dst = blocks.vector_sink_f()
+
+ self.tb.connect(src0, s2v0, (op, 0))
+ self.tb.connect(src1, s2v1, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+
+ def stest_s001(self):
+ src_data = (0, 2, -3, 0, 12, 0)
+ expected_result = (max(src_data),)
+
+ src = blocks.vector_source_s(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_short,len(src_data))
+ op = blocks.max_ss(len(src_data))
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src, s2v, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def stest_s002(self):
+ src_data=(-100,-99,-98,-97,-96,-1)
+ expected_result = (max(src_data),)
+
+ src = blocks.vector_source_s(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_short, len(src_data))
+ op = blocks.max_ss(len(src_data))
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src, s2v, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+
+ def stest_s003(self):
+ src_data0 = (0, 2, -3, 0, 12, 0)
+ src_data1 = (1, 1, 1, 1, 1, 1)
+
+ expected_result = [max(x,y) for x,y in zip(src_data0, src_data1)]
+
+ src0 = blocks.vector_source_s(src_data0)
+ src1 = blocks.vector_source_s(src_data1)
+ op = blocks.max_ss(1)
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src0, (op, 0))
+ self.tb.connect(src1, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def stest_s004(self):
+ dim = 2
+ src_data0 = (0, 2, -3, 0, 12, 0)
+ src_data1 = (1, 1, 1, 1, 1, 1)
+
+ expected_data = []
+ tmp = [max(x,y) for x,y in zip(src_data0, src_data1)]
+ for i in xrange(len(tmp)/dim):
+ expected_data.append(max(tmp[i*dim:(i+1)*dim]))
+
+ src0 = blocks.vector_source_s(src_data0)
+ s2v0 = blocks.stream_to_vector(gr.sizeof_short,dim)
+ src1 = blocks.vector_source_s(src_data1)
+ s2v1 = blocks.stream_to_vector(gr.sizeof_short,dim)
+ op = blocks.max_ss(dim)
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src0, s2v0, (op, 0))
+ self.tb.connect(src1, s2v1, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+
if __name__ == '__main__':
gr_unittest.run(test_max, "test_max.xml")
-
diff --git a/gr-blocks/python/blocks/qa_min.py
b/gr-blocks/python/blocks/qa_min.py
new file mode 100644
index 0000000..642782a
--- /dev/null
+++ b/gr-blocks/python/blocks/qa_min.py
@@ -0,0 +1,178 @@
+#!/usr/bin/env python
+#
+# Copyright 2014 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, blocks
+
+import math
+
+class test_min(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_001(self):
+ src_data = (0, 0.2, -0.25, 0, 12, 0)
+ expected_result = (float(min(src_data)),)
+
+ src = blocks.vector_source_f(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data))
+ op = blocks.min_ff(len(src_data))
+ dst = blocks.vector_sink_f()
+
+ self.tb.connect(src, s2v, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def stest_002(self):
+ src_data=(-100,-99,-98,-97,-96,-1)
+ expected_result = (float(min(src_data)),)
+
+ src = blocks.vector_source_f(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data))
+ op = blocks.min_ff(len(src_data))
+ dst = blocks.vector_sink_f()
+
+ self.tb.connect(src, s2v, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def stest_003(self):
+ src_data0 = (0, 2, -3, 0, 12, 0)
+ src_data1 = (1, 1, 1, 1, 1, 1)
+
+ expected_result = [float(min(x,y)) for x,y in zip(src_data0,
src_data1)]
+
+ src0 = blocks.vector_source_f(src_data0)
+ src1 = blocks.vector_source_f(src_data1)
+ op = blocks.min_ff(1)
+ dst = blocks.vector_sink_f()
+
+ self.tb.connect(src0, (op, 0))
+ self.tb.connect(src1, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def stest_004(self):
+ dim = 2
+ src_data0 = (0, 2, -3, 0, 12, 0)
+ src_data1 = (1, 1, 1, 1, 1, 1)
+
+ expected_data = []
+ tmp = [float(min(x,y)) for x,y in zip(src_data0, src_data1)]
+ for i in xrange(len(tmp)/dim):
+ expected_data.append(float(min(tmp[i*dim:(i+1)*dim])))
+
+ src0 = blocks.vector_source_f(src_data0)
+ s2v0 = blocks.stream_to_vector(gr.sizeof_float,dim)
+ src1 = blocks.vector_source_f(src_data1)
+ s2v1 = blocks.stream_to_vector(gr.sizeof_float,dim)
+ op = blocks.min_ff(dim)
+ dst = blocks.vector_sink_f()
+
+ self.tb.connect(src0, s2v0, (op, 0))
+ self.tb.connect(src1, s2v1, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+
+ def stest_s001(self):
+ src_data = (0, 2, -3, 0, 12, 0)
+ expected_result = (min(src_data),)
+
+ src = blocks.vector_source_s(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_short,len(src_data))
+ op = blocks.min_ss(len(src_data))
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src, s2v, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def stest_s002(self):
+ src_data=(-100,-99,-98,-97,-96,-1)
+ expected_result = (min(src_data),)
+
+ src = blocks.vector_source_s(src_data)
+ s2v = blocks.stream_to_vector(gr.sizeof_short, len(src_data))
+ op = blocks.min_ss(len(src_data))
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src, s2v, op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+
+ def stest_s003(self):
+ src_data0 = (0, 2, -3, 0, 12, 0)
+ src_data1 = (1, 1, 1, 1, 1, 1)
+
+ expected_result = [min(x,y) for x,y in zip(src_data0, src_data1)]
+
+ src0 = blocks.vector_source_s(src_data0)
+ src1 = blocks.vector_source_s(src_data1)
+ op = blocks.min_ss(1)
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src0, (op, 0))
+ self.tb.connect(src1, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+ def stest_s004(self):
+ dim = 2
+ src_data0 = (0, 2, -3, 0, 12, 0)
+ src_data1 = (1, 1, 1, 1, 1, 1)
+
+ expected_data = []
+ tmp = [min(x,y) for x,y in zip(src_data0, src_data1)]
+ for i in xrange(len(tmp)/dim):
+ expected_data.append(min(tmp[i*dim:(i+1)*dim]))
+
+ src0 = blocks.vector_source_s(src_data0)
+ s2v0 = blocks.stream_to_vector(gr.sizeof_short,dim)
+ src1 = blocks.vector_source_s(src_data1)
+ s2v1 = blocks.stream_to_vector(gr.sizeof_short,dim)
+ op = blocks.min_ss(dim)
+ dst = blocks.vector_sink_s()
+
+ self.tb.connect(src0, s2v0, (op, 0))
+ self.tb.connect(src1, s2v1, (op, 1))
+ self.tb.connect(op, dst)
+ self.tb.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+if __name__ == '__main__':
+ gr_unittest.run(test_min, "test_min.xml")
diff --git a/gr-blocks/swig/blocks_swig3.i b/gr-blocks/swig/blocks_swig3.i
index 43cc78a..9c02083 100644
--- a/gr-blocks/swig/blocks_swig3.i
+++ b/gr-blocks/swig/blocks_swig3.i
@@ -47,6 +47,9 @@
#include "gnuradio/blocks/max_ff.h"
#include "gnuradio/blocks/max_ii.h"
#include "gnuradio/blocks/max_ss.h"
+#include "gnuradio/blocks/min_ff.h"
+#include "gnuradio/blocks/min_ii.h"
+#include "gnuradio/blocks/min_ss.h"
#include "gnuradio/blocks/moving_average_cc.h"
#include "gnuradio/blocks/moving_average_ff.h"
#include "gnuradio/blocks/moving_average_ii.h"
@@ -90,6 +93,9 @@
%include "gnuradio/blocks/max_ff.h"
%include "gnuradio/blocks/max_ii.h"
%include "gnuradio/blocks/max_ss.h"
+%include "gnuradio/blocks/min_ff.h"
+%include "gnuradio/blocks/min_ii.h"
+%include "gnuradio/blocks/min_ss.h"
%include "gnuradio/blocks/moving_average_cc.h"
%include "gnuradio/blocks/moving_average_ff.h"
%include "gnuradio/blocks/moving_average_ii.h"
@@ -132,6 +138,9 @@ GR_SWIG_BLOCK_MAGIC2(blocks, lfsr_32k_source_s);
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, min_ff);
+GR_SWIG_BLOCK_MAGIC2(blocks, min_ii);
+GR_SWIG_BLOCK_MAGIC2(blocks, min_ss);
GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_cc);
GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ff);
GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ii);
diff --git a/gr-digital/lib/binary_slicer_fb_impl.cc
b/gr-digital/lib/binary_slicer_fb_impl.cc
index 565f751..6852661 100644
--- a/gr-digital/lib/binary_slicer_fb_impl.cc
+++ b/gr-digital/lib/binary_slicer_fb_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2010-2012 Free Software Foundation, Inc.
+ * Copyright 2006,2010-2012,2014 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -27,6 +27,7 @@
#include "binary_slicer_fb_impl.h"
#include <gnuradio/io_signature.h>
#include <gnuradio/math.h>
+#include <volk/volk.h>
namespace gr {
namespace digital {
@@ -38,9 +39,12 @@ namespace gr {
binary_slicer_fb_impl::binary_slicer_fb_impl()
: sync_block("binary_slicer_fb",
- io_signature::make(1, 1, sizeof(float)),
- io_signature::make(1, 1, sizeof(unsigned char)))
+ io_signature::make(1, 1, sizeof(float)),
+ io_signature::make(1, 1, sizeof(int8_t)))
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(int8_t);
+ set_alignment(std::max(1,alignment_multiple));
}
binary_slicer_fb_impl::~binary_slicer_fb_impl()
@@ -53,11 +57,9 @@ namespace gr {
gr_vector_void_star &output_items)
{
const float *in = (const float *)input_items[0];
- unsigned char *out = (unsigned char *)output_items[0];
+ int8_t *out = (int8_t *)output_items[0];
- for(int i = 0; i < noutput_items; i++) {
- out[i] = gr::binary_slicer(in[i]);
- }
+ volk_32f_binary_slicer_8i(out, in, noutput_items);
return noutput_items;
}
diff --git a/gr-fec/lib/dummy_decoder_impl.cc b/gr-fec/lib/dummy_decoder_impl.cc
index 5ab91d0..1050574 100644
--- a/gr-fec/lib/dummy_decoder_impl.cc
+++ b/gr-fec/lib/dummy_decoder_impl.cc
@@ -116,6 +116,7 @@ namespace gr {
int8_t *out = (int8_t*)outbuffer;
//memcpy(out, in, d_frame_size*sizeof(char));
+ //volk_32f_binary_slicer_8i(out, in, d_frame_size);
volk_32f_s32f_convert_8i(out, in, 1.0/2.0, d_frame_size);
}