[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 04/28: basic: added other basic operators
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 04/28: basic: added other basic operators |
Date: |
Mon, 15 Aug 2016 00:47:04 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
nwest pushed a commit to annotated tag gr_basic_work
in repository gnuradio.
commit 90e93f4ce7026a98c3f6cc75684d16a0a1505323
Author: Josh Blum <address@hidden>
Date: Tue Nov 8 17:13:16 2011 -0800
basic: added other basic operators
---
gr-basic/grc/{gr_add_xx.xml => basic_add.xml} | 37 ++++-----
gr-basic/grc/basic_block_tree.xml | 7 +-
gr-basic/grc/{gr_add_xx.xml => basic_divide.xml} | 41 ++++-----
gr-basic/grc/{gr_add_xx.xml => basic_multiply.xml} | 41 ++++-----
gr-basic/grc/{gr_add_xx.xml => basic_subtract.xml} | 41 ++++-----
gr-basic/include/CMakeLists.txt | 3 +
gr-basic/include/gr_basic_add.h | 13 ++-
.../include/{gr_basic_add.h => gr_basic_divide.h} | 35 +++++---
.../{gr_basic_add.h => gr_basic_multiply.h} | 35 +++++---
.../{gr_basic_add.h => gr_basic_subtract.h} | 31 ++++---
gr-basic/lib/CMakeLists.txt | 3 +
gr-basic/lib/gr_basic_add.cc | 44 ++++++----
gr-basic/lib/gr_basic_divide.cc | 96 ++++++++++++++++++++++
gr-basic/lib/gr_basic_multiply.cc | 96 ++++++++++++++++++++++
gr-basic/lib/gr_basic_subtract.cc | 96 ++++++++++++++++++++++
gr-basic/swig/CMakeLists.txt | 2 +-
gr-basic/swig/{basic_add.i => basic_ops.i} | 12 +++
gr-basic/swig/basic_swig.i | 2 +-
grc/blocks/block_tree.xml | 1 +
{gr-basic/grc => grc/blocks}/gr_add_xx.xml | 28 +++----
20 files changed, 502 insertions(+), 162 deletions(-)
diff --git a/gr-basic/grc/gr_add_xx.xml b/gr-basic/grc/basic_add.xml
similarity index 53%
copy from gr-basic/grc/gr_add_xx.xml
copy to gr-basic/grc/basic_add.xml
index 5138294..d02bc1b 100644
--- a/gr-basic/grc/gr_add_xx.xml
+++ b/gr-basic/grc/basic_add.xml
@@ -7,33 +7,26 @@
-->
<block>
<name>Add</name>
- <key>gr_add_xx</key>
+ <key>basic_add</key>
<import>from gnuradio import basic</import>
- <make>basic.add(basic.$type.enum, $vlen)</make>
+ <make>basic.add(basic.ADD_$($type().upper()), $vlen)</make>
<param>
<name>IO Type</name>
<key>type</key>
+ <value>fc32</value>
<type>enum</type>
- <option>
- <name>FC32</name>
- <key>fc32</key>
- <opt>enum:ADD_FC32</opt>
- </option>
- <option>
- <name>F32</name>
- <key>f32</key>
- <opt>enum:ADD_F32</opt>
- </option>
- <option>
- <name>SC16</name>
- <key>sc16</key>
- <opt>enum:ADD_SC16</opt>
- </option>
- <option>
- <name>S16</name>
- <key>s16</key>
- <opt>enum:ADD_S16</opt>
- </option>
+ <option><name>FC64</name><key>fc64</key></option>
+ <option><name>F64</name><key>f64</key></option>
+ <option><name>FC32</name><key>fc32</key></option>
+ <option><name>F32</name><key>f32</key></option>
+ <option><name>SC64</name><key>sc64</key></option>
+ <option><name>S64</name><key>s64</key></option>
+ <option><name>SC32</name><key>sc32</key></option>
+ <option><name>S32</name><key>s32</key></option>
+ <option><name>SC16</name><key>sc16</key></option>
+ <option><name>S16</name><key>s16</key></option>
+ <option><name>SC8</name><key>sc8</key></option>
+ <option><name>S8</name><key>s8</key></option>
</param>
<param>
<name>Num Inputs</name>
diff --git a/gr-basic/grc/basic_block_tree.xml
b/gr-basic/grc/basic_block_tree.xml
index 8cf14f3..1f41958 100644
--- a/gr-basic/grc/basic_block_tree.xml
+++ b/gr-basic/grc/basic_block_tree.xml
@@ -29,7 +29,10 @@
<cat>
<name></name> <!-- Blank for Root Name -->
<cat>
- <name>Operators</name>
- <block>gr_add_xx</block>
+ <name>Basic</name>
+ <block>basic_add</block>
+ <block>basic_subtract</block>
+ <block>basic_multiply</block>
+ <block>basic_divide</block>
</cat>
</cat>
diff --git a/gr-basic/grc/gr_add_xx.xml b/gr-basic/grc/basic_divide.xml
similarity index 50%
copy from gr-basic/grc/gr_add_xx.xml
copy to gr-basic/grc/basic_divide.xml
index 5138294..ac41336 100644
--- a/gr-basic/grc/gr_add_xx.xml
+++ b/gr-basic/grc/basic_divide.xml
@@ -1,39 +1,32 @@
<?xml version="1.0"?>
<!--
###################################################
-##Add Block:
+##Divide Block:
## all types, 1 output, 2 to inf inputs
###################################################
-->
<block>
- <name>Add</name>
- <key>gr_add_xx</key>
+ <name>Divide</name>
+ <key>basic_divide</key>
<import>from gnuradio import basic</import>
- <make>basic.add(basic.$type.enum, $vlen)</make>
+ <make>basic.divide(basic.DIVIDE_$($type().upper()), $vlen)</make>
<param>
<name>IO Type</name>
<key>type</key>
+ <value>fc32</value>
<type>enum</type>
- <option>
- <name>FC32</name>
- <key>fc32</key>
- <opt>enum:ADD_FC32</opt>
- </option>
- <option>
- <name>F32</name>
- <key>f32</key>
- <opt>enum:ADD_F32</opt>
- </option>
- <option>
- <name>SC16</name>
- <key>sc16</key>
- <opt>enum:ADD_SC16</opt>
- </option>
- <option>
- <name>S16</name>
- <key>s16</key>
- <opt>enum:ADD_S16</opt>
- </option>
+ <option><name>FC64</name><key>fc64</key></option>
+ <option><name>F64</name><key>f64</key></option>
+ <option><name>FC32</name><key>fc32</key></option>
+ <option><name>F32</name><key>f32</key></option>
+ <option><name>SC64</name><key>sc64</key></option>
+ <option><name>S64</name><key>s64</key></option>
+ <option><name>SC32</name><key>sc32</key></option>
+ <option><name>S32</name><key>s32</key></option>
+ <option><name>SC16</name><key>sc16</key></option>
+ <option><name>S16</name><key>s16</key></option>
+ <option><name>SC8</name><key>sc8</key></option>
+ <option><name>S8</name><key>s8</key></option>
</param>
<param>
<name>Num Inputs</name>
diff --git a/gr-basic/grc/gr_add_xx.xml b/gr-basic/grc/basic_multiply.xml
similarity index 50%
copy from gr-basic/grc/gr_add_xx.xml
copy to gr-basic/grc/basic_multiply.xml
index 5138294..e902a39 100644
--- a/gr-basic/grc/gr_add_xx.xml
+++ b/gr-basic/grc/basic_multiply.xml
@@ -1,39 +1,32 @@
<?xml version="1.0"?>
<!--
###################################################
-##Add Block:
+##Multiply Block:
## all types, 1 output, 2 to inf inputs
###################################################
-->
<block>
- <name>Add</name>
- <key>gr_add_xx</key>
+ <name>Multiply</name>
+ <key>basic_multiply</key>
<import>from gnuradio import basic</import>
- <make>basic.add(basic.$type.enum, $vlen)</make>
+ <make>basic.multiply(basic.MULTIPLY_$($type().upper()), $vlen)</make>
<param>
<name>IO Type</name>
<key>type</key>
+ <value>fc32</value>
<type>enum</type>
- <option>
- <name>FC32</name>
- <key>fc32</key>
- <opt>enum:ADD_FC32</opt>
- </option>
- <option>
- <name>F32</name>
- <key>f32</key>
- <opt>enum:ADD_F32</opt>
- </option>
- <option>
- <name>SC16</name>
- <key>sc16</key>
- <opt>enum:ADD_SC16</opt>
- </option>
- <option>
- <name>S16</name>
- <key>s16</key>
- <opt>enum:ADD_S16</opt>
- </option>
+ <option><name>FC64</name><key>fc64</key></option>
+ <option><name>F64</name><key>f64</key></option>
+ <option><name>FC32</name><key>fc32</key></option>
+ <option><name>F32</name><key>f32</key></option>
+ <option><name>SC64</name><key>sc64</key></option>
+ <option><name>S64</name><key>s64</key></option>
+ <option><name>SC32</name><key>sc32</key></option>
+ <option><name>S32</name><key>s32</key></option>
+ <option><name>SC16</name><key>sc16</key></option>
+ <option><name>S16</name><key>s16</key></option>
+ <option><name>SC8</name><key>sc8</key></option>
+ <option><name>S8</name><key>s8</key></option>
</param>
<param>
<name>Num Inputs</name>
diff --git a/gr-basic/grc/gr_add_xx.xml b/gr-basic/grc/basic_subtract.xml
similarity index 50%
copy from gr-basic/grc/gr_add_xx.xml
copy to gr-basic/grc/basic_subtract.xml
index 5138294..733713c 100644
--- a/gr-basic/grc/gr_add_xx.xml
+++ b/gr-basic/grc/basic_subtract.xml
@@ -1,39 +1,32 @@
<?xml version="1.0"?>
<!--
###################################################
-##Add Block:
+##Subtract Block:
## all types, 1 output, 2 to inf inputs
###################################################
-->
<block>
- <name>Add</name>
- <key>gr_add_xx</key>
+ <name>Subtract</name>
+ <key>basic_subtract</key>
<import>from gnuradio import basic</import>
- <make>basic.add(basic.$type.enum, $vlen)</make>
+ <make>basic.subtract(basic.SUBTRACT_$($type().upper()), $vlen)</make>
<param>
<name>IO Type</name>
<key>type</key>
+ <value>fc32</value>
<type>enum</type>
- <option>
- <name>FC32</name>
- <key>fc32</key>
- <opt>enum:ADD_FC32</opt>
- </option>
- <option>
- <name>F32</name>
- <key>f32</key>
- <opt>enum:ADD_F32</opt>
- </option>
- <option>
- <name>SC16</name>
- <key>sc16</key>
- <opt>enum:ADD_SC16</opt>
- </option>
- <option>
- <name>S16</name>
- <key>s16</key>
- <opt>enum:ADD_S16</opt>
- </option>
+ <option><name>FC64</name><key>fc64</key></option>
+ <option><name>F64</name><key>f64</key></option>
+ <option><name>FC32</name><key>fc32</key></option>
+ <option><name>F32</name><key>f32</key></option>
+ <option><name>SC64</name><key>sc64</key></option>
+ <option><name>S64</name><key>s64</key></option>
+ <option><name>SC32</name><key>sc32</key></option>
+ <option><name>S32</name><key>s32</key></option>
+ <option><name>SC16</name><key>sc16</key></option>
+ <option><name>S16</name><key>s16</key></option>
+ <option><name>SC8</name><key>sc8</key></option>
+ <option><name>S8</name><key>s8</key></option>
</param>
<param>
<name>Num Inputs</name>
diff --git a/gr-basic/include/CMakeLists.txt b/gr-basic/include/CMakeLists.txt
index 69a22c3..beff7cb 100644
--- a/gr-basic/include/CMakeLists.txt
+++ b/gr-basic/include/CMakeLists.txt
@@ -23,6 +23,9 @@
install(FILES
gr_basic_api.h
gr_basic_add.h
+ gr_basic_divide.h
+ gr_basic_multiply.h
+ gr_basic_subtract.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio
COMPONENT "basic_devel"
)
diff --git a/gr-basic/include/gr_basic_add.h b/gr-basic/include/gr_basic_add.h
index a1e5ef5..a9ef6a6 100644
--- a/gr-basic/include/gr_basic_add.h
+++ b/gr-basic/include/gr_basic_add.h
@@ -25,17 +25,26 @@
#include <gr_sync_block.h>
enum add_type{
+ ADD_FC64,
+ ADD_F64,
ADD_FC32,
- ADD_SC16,
ADD_F32,
+ ADD_SC64,
+ ADD_S64,
+ ADD_SC32,
+ ADD_S32,
+ ADD_SC16,
ADD_S16,
+ ADD_SC8,
+ ADD_S8,
};
class GR_BASIC_API basic_add : virtual public gr_sync_block{
public:
+ typedef boost::shared_ptr<basic_add> sptr;
};
-GR_BASIC_API boost::shared_ptr<basic_add> basic_make_add(
+GR_BASIC_API basic_add::sptr basic_make_add(
add_type type, const size_t vlen = 1
);
diff --git a/gr-basic/include/gr_basic_add.h
b/gr-basic/include/gr_basic_divide.h
similarity index 56%
copy from gr-basic/include/gr_basic_add.h
copy to gr-basic/include/gr_basic_divide.h
index a1e5ef5..ed00df5 100644
--- a/gr-basic/include/gr_basic_add.h
+++ b/gr-basic/include/gr_basic_divide.h
@@ -18,25 +18,38 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_GR_BASIC_ADD_H
-#define INCLUDED_GR_BASIC_ADD_H
+#ifndef INCLUDED_GR_BASIC_DIVIDE_H
+#define INCLUDED_GR_BASIC_DIVIDE_H
#include <gr_basic_api.h>
#include <gr_sync_block.h>
-enum add_type{
- ADD_FC32,
- ADD_SC16,
- ADD_F32,
- ADD_S16,
+//TODO may support non-homogeneous IO types,
+//DIVIDE_S16_S8 (int16 input, int8 output)
+//so this will easily fit into the framework.
+
+enum divide_type{
+ DIVIDE_FC64,
+ DIVIDE_F64,
+ DIVIDE_FC32,
+ DIVIDE_F32,
+ DIVIDE_SC64,
+ DIVIDE_S64,
+ DIVIDE_SC32,
+ DIVIDE_S32,
+ DIVIDE_SC16,
+ DIVIDE_S16,
+ DIVIDE_SC8,
+ DIVIDE_S8,
};
-class GR_BASIC_API basic_add : virtual public gr_sync_block{
+class GR_BASIC_API basic_divide : virtual public gr_sync_block{
public:
+ typedef boost::shared_ptr<basic_divide> sptr;
};
-GR_BASIC_API boost::shared_ptr<basic_add> basic_make_add(
- add_type type, const size_t vlen = 1
+GR_BASIC_API basic_divide::sptr basic_make_divide(
+ divide_type type, const size_t vlen = 1
);
-#endif /* INCLUDED_GR_BASIC_ADD_H */
+#endif /* INCLUDED_GR_BASIC_DIVIDE_H */
diff --git a/gr-basic/include/gr_basic_add.h
b/gr-basic/include/gr_basic_multiply.h
similarity index 55%
copy from gr-basic/include/gr_basic_add.h
copy to gr-basic/include/gr_basic_multiply.h
index a1e5ef5..54e4d6d 100644
--- a/gr-basic/include/gr_basic_add.h
+++ b/gr-basic/include/gr_basic_multiply.h
@@ -18,25 +18,38 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_GR_BASIC_ADD_H
-#define INCLUDED_GR_BASIC_ADD_H
+#ifndef INCLUDED_GR_BASIC_MULTIPLY_H
+#define INCLUDED_GR_BASIC_MULTIPLY_H
#include <gr_basic_api.h>
#include <gr_sync_block.h>
-enum add_type{
- ADD_FC32,
- ADD_SC16,
- ADD_F32,
- ADD_S16,
+//TODO may support non-homogeneous IO types,
+//MULTIPLY_S8_S16 (int8 input, int16 output)
+//so this will easily fit into the framework.
+
+enum multiply_type{
+ MULTIPLY_FC64,
+ MULTIPLY_F64,
+ MULTIPLY_FC32,
+ MULTIPLY_F32,
+ MULTIPLY_SC64,
+ MULTIPLY_S64,
+ MULTIPLY_SC32,
+ MULTIPLY_S32,
+ MULTIPLY_SC16,
+ MULTIPLY_S16,
+ MULTIPLY_SC8,
+ MULTIPLY_S8,
};
-class GR_BASIC_API basic_add : virtual public gr_sync_block{
+class GR_BASIC_API basic_multiply : virtual public gr_sync_block{
public:
+ typedef boost::shared_ptr<basic_multiply> sptr;
};
-GR_BASIC_API boost::shared_ptr<basic_add> basic_make_add(
- add_type type, const size_t vlen = 1
+GR_BASIC_API basic_multiply::sptr basic_make_multiply(
+ multiply_type type, const size_t vlen = 1
);
-#endif /* INCLUDED_GR_BASIC_ADD_H */
+#endif /* INCLUDED_GR_BASIC_MULTIPLY_H */
diff --git a/gr-basic/include/gr_basic_add.h
b/gr-basic/include/gr_basic_subtract.h
similarity index 60%
copy from gr-basic/include/gr_basic_add.h
copy to gr-basic/include/gr_basic_subtract.h
index a1e5ef5..7000630 100644
--- a/gr-basic/include/gr_basic_add.h
+++ b/gr-basic/include/gr_basic_subtract.h
@@ -18,25 +18,34 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_GR_BASIC_ADD_H
-#define INCLUDED_GR_BASIC_ADD_H
+#ifndef INCLUDED_GR_BASIC_SUBTRACT_H
+#define INCLUDED_GR_BASIC_SUBTRACT_H
#include <gr_basic_api.h>
#include <gr_sync_block.h>
-enum add_type{
- ADD_FC32,
- ADD_SC16,
- ADD_F32,
- ADD_S16,
+enum subtract_type{
+ SUBTRACT_FC64,
+ SUBTRACT_F64,
+ SUBTRACT_FC32,
+ SUBTRACT_F32,
+ SUBTRACT_SC64,
+ SUBTRACT_S64,
+ SUBTRACT_SC32,
+ SUBTRACT_S32,
+ SUBTRACT_SC16,
+ SUBTRACT_S16,
+ SUBTRACT_SC8,
+ SUBTRACT_S8,
};
-class GR_BASIC_API basic_add : virtual public gr_sync_block{
+class GR_BASIC_API basic_subtract : virtual public gr_sync_block{
public:
+ typedef boost::shared_ptr<basic_subtract> sptr;
};
-GR_BASIC_API boost::shared_ptr<basic_add> basic_make_add(
- add_type type, const size_t vlen = 1
+GR_BASIC_API basic_subtract::sptr basic_make_subtract(
+ subtract_type type, const size_t vlen = 1
);
-#endif /* INCLUDED_GR_BASIC_ADD_H */
+#endif /* INCLUDED_GR_BASIC_SUBTRACT_H */
diff --git a/gr-basic/lib/CMakeLists.txt b/gr-basic/lib/CMakeLists.txt
index 71e9ff7..254b99f 100644
--- a/gr-basic/lib/CMakeLists.txt
+++ b/gr-basic/lib/CMakeLists.txt
@@ -34,6 +34,9 @@ link_directories(${Boost_LIBRARY_DIRS})
########################################################################
list(APPEND gr_basic_sources
gr_basic_add.cc
+ gr_basic_divide.cc
+ gr_basic_multiply.cc
+ gr_basic_subtract.cc
)
list(APPEND basic_libs
diff --git a/gr-basic/lib/gr_basic_add.cc b/gr-basic/lib/gr_basic_add.cc
index 5415e9b..f56bf56 100644
--- a/gr-basic/lib/gr_basic_add.cc
+++ b/gr-basic/lib/gr_basic_add.cc
@@ -26,7 +26,7 @@
#include <volk/volk.h>
/***********************************************************************
- * Adder implementation with float32
+ * Adder implementation with float32 - calls volk
**********************************************************************/
class gr_basic_add_f32 : public basic_add{
public:
@@ -65,19 +65,20 @@ private:
};
/***********************************************************************
- * Adder implementation with int16
+ * Generic adder implementation
**********************************************************************/
-class gr_basic_add_s16 : public basic_add{
+template <typename type>
+class gr_basic_add_generic : public basic_add{
public:
- gr_basic_add_s16(const size_t vlen):
+ gr_basic_add_generic(const size_t vlen):
gr_sync_block(
- "add s16",
- gr_make_io_signature (1, -1, sizeof(uint16_t)*vlen),
- gr_make_io_signature (1, 1, sizeof(uint16_t)*vlen)
+ "add generic",
+ gr_make_io_signature (1, -1, sizeof(type)*vlen),
+ gr_make_io_signature (1, 1, sizeof(type)*vlen)
),
_vlen(vlen)
{
- //TODO set output multiple to volk alignment
+ //NOP
}
int work(
@@ -86,12 +87,11 @@ public:
gr_vector_void_star &output_items
){
const size_t n_nums = noutput_items * _vlen;
- uint16_t *out = reinterpret_cast<uint16_t *>(output_items[0]);
- const uint16_t *in0 = reinterpret_cast<const uint16_t
*>(input_items[0]);
+ type *out = reinterpret_cast<type *>(output_items[0]);
+ const type *in0 = reinterpret_cast<const type *>(input_items[0]);
for (size_t n = 1; n < input_items.size(); n++){
- const uint16_t *in = reinterpret_cast<const uint16_t
*>(input_items[n]);
- //TODO - this is where you call into volk
+ const type *in = reinterpret_cast<const type *>(input_items[n]);
for (size_t i = 0; i < n_nums; i++){
out[i] = in0[i] + in[i];
}
@@ -108,14 +108,28 @@ private:
/***********************************************************************
* Adder factory function
**********************************************************************/
-boost::shared_ptr<basic_add> basic_make_add(
+basic_add::sptr basic_make_add(
add_type type, const size_t vlen
){
switch(type){
+ case ADD_FC64: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<double>(2*vlen));
+ case ADD_F64: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<double>(vlen));
+
case ADD_FC32: return boost::shared_ptr<basic_add>(new
gr_basic_add_f32(2*vlen));
case ADD_F32: return boost::shared_ptr<basic_add>(new
gr_basic_add_f32(vlen));
- case ADD_SC16: return boost::shared_ptr<basic_add>(new
gr_basic_add_s16(2*vlen));
- case ADD_S16: return boost::shared_ptr<basic_add>(new
gr_basic_add_s16(vlen));
+
+ case ADD_SC64: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<int64_t>(2*vlen));
+ case ADD_S64: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<int64_t>(vlen));
+
+ case ADD_SC32: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<int32_t>(2*vlen));
+ case ADD_S32: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<int32_t>(vlen));
+
+ case ADD_SC16: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<int16_t>(2*vlen));
+ case ADD_S16: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<int16_t>(vlen));
+
+ case ADD_SC8: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<int8_t>(2*vlen));
+ case ADD_S8: return boost::shared_ptr<basic_add>(new
gr_basic_add_generic<int8_t>(vlen));
+
default: throw std::invalid_argument("basic_make_add got unknown add
type");
}
}
diff --git a/gr-basic/lib/gr_basic_divide.cc b/gr-basic/lib/gr_basic_divide.cc
new file mode 100644
index 0000000..a4eca4a
--- /dev/null
+++ b/gr-basic/lib/gr_basic_divide.cc
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2011 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.
+ */
+
+#include <gr_basic_divide.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <complex>
+#include <volk/volk.h>
+
+/***********************************************************************
+ * Generic divideer implementation
+ **********************************************************************/
+template <typename type>
+class gr_basic_divide_generic : public basic_divide{
+public:
+ gr_basic_divide_generic(const size_t vlen):
+ gr_sync_block(
+ "divide generic",
+ gr_make_io_signature (1, -1, sizeof(type)*vlen),
+ gr_make_io_signature (1, 1, sizeof(type)*vlen)
+ ),
+ _vlen(vlen)
+ {
+ //NOP
+ }
+
+ int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ const size_t n_nums = noutput_items * _vlen;
+ type *out = reinterpret_cast<type *>(output_items[0]);
+ const type *in0 = reinterpret_cast<const type *>(input_items[0]);
+
+ for (size_t n = 1; n < input_items.size(); n++){
+ const type *in = reinterpret_cast<const type *>(input_items[n]);
+ for (size_t i = 0; i < n_nums; i++){
+ out[i] = in0[i] * in[i];
+ }
+ in0 = out; //for next input, we do output *= input
+ }
+
+ return noutput_items;
+ }
+
+private:
+ const size_t _vlen;
+};
+
+/***********************************************************************
+ * Adder factory function
+ **********************************************************************/
+basic_divide::sptr basic_make_divide(
+ divide_type type, const size_t vlen
+){
+ switch(type){
+ case DIVIDE_FC64: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<std::complex<double> >(vlen));
+ case DIVIDE_F64: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<double>(vlen));
+
+ case DIVIDE_FC32: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<std::complex<float> >(vlen));
+ case DIVIDE_F32: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<float>(vlen));
+
+ case DIVIDE_SC64: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<std::complex<int64_t> >(vlen));
+ case DIVIDE_S64: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<int64_t>(vlen));
+
+ case DIVIDE_SC32: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<std::complex<int32_t> >(vlen));
+ case DIVIDE_S32: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<int32_t>(vlen));
+
+ case DIVIDE_SC16: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<std::complex<int16_t> >(vlen));
+ case DIVIDE_S16: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<int16_t>(vlen));
+
+ case DIVIDE_SC8: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<std::complex<int8_t> >(vlen));
+ case DIVIDE_S8: return boost::shared_ptr<basic_divide>(new
gr_basic_divide_generic<int8_t>(vlen));
+
+ default: throw std::invalid_argument("basic_make_divide got unknown divide
type");
+ }
+}
diff --git a/gr-basic/lib/gr_basic_multiply.cc
b/gr-basic/lib/gr_basic_multiply.cc
new file mode 100644
index 0000000..f306ddc
--- /dev/null
+++ b/gr-basic/lib/gr_basic_multiply.cc
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2011 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.
+ */
+
+#include <gr_basic_multiply.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <complex>
+#include <volk/volk.h>
+
+/***********************************************************************
+ * Generic multiplyer implementation
+ **********************************************************************/
+template <typename type>
+class gr_basic_multiply_generic : public basic_multiply{
+public:
+ gr_basic_multiply_generic(const size_t vlen):
+ gr_sync_block(
+ "multiply generic",
+ gr_make_io_signature (1, -1, sizeof(type)*vlen),
+ gr_make_io_signature (1, 1, sizeof(type)*vlen)
+ ),
+ _vlen(vlen)
+ {
+ //NOP
+ }
+
+ int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ const size_t n_nums = noutput_items * _vlen;
+ type *out = reinterpret_cast<type *>(output_items[0]);
+ const type *in0 = reinterpret_cast<const type *>(input_items[0]);
+
+ for (size_t n = 1; n < input_items.size(); n++){
+ const type *in = reinterpret_cast<const type *>(input_items[n]);
+ for (size_t i = 0; i < n_nums; i++){
+ out[i] = in0[i] * in[i];
+ }
+ in0 = out; //for next input, we do output *= input
+ }
+
+ return noutput_items;
+ }
+
+private:
+ const size_t _vlen;
+};
+
+/***********************************************************************
+ * Adder factory function
+ **********************************************************************/
+basic_multiply::sptr basic_make_multiply(
+ multiply_type type, const size_t vlen
+){
+ switch(type){
+ case MULTIPLY_FC64: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<std::complex<double> >(vlen));
+ case MULTIPLY_F64: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<double>(vlen));
+
+ case MULTIPLY_FC32: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<std::complex<float> >(vlen));
+ case MULTIPLY_F32: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<float>(vlen));
+
+ case MULTIPLY_SC64: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<std::complex<int64_t> >(vlen));
+ case MULTIPLY_S64: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<int64_t>(vlen));
+
+ case MULTIPLY_SC32: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<std::complex<int32_t> >(vlen));
+ case MULTIPLY_S32: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<int32_t>(vlen));
+
+ case MULTIPLY_SC16: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<std::complex<int16_t> >(vlen));
+ case MULTIPLY_S16: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<int16_t>(vlen));
+
+ case MULTIPLY_SC8: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<std::complex<int8_t> >(vlen));
+ case MULTIPLY_S8: return boost::shared_ptr<basic_multiply>(new
gr_basic_multiply_generic<int8_t>(vlen));
+
+ default: throw std::invalid_argument("basic_make_multiply got unknown
multiply type");
+ }
+}
diff --git a/gr-basic/lib/gr_basic_subtract.cc
b/gr-basic/lib/gr_basic_subtract.cc
new file mode 100644
index 0000000..bde41ed
--- /dev/null
+++ b/gr-basic/lib/gr_basic_subtract.cc
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2011 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.
+ */
+
+#include <gr_basic_subtract.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <complex>
+#include <volk/volk.h>
+
+/***********************************************************************
+ * Generic subtracter implementation
+ **********************************************************************/
+template <typename type>
+class gr_basic_subtract_generic : public basic_subtract{
+public:
+ gr_basic_subtract_generic(const size_t vlen):
+ gr_sync_block(
+ "subtract generic",
+ gr_make_io_signature (1, -1, sizeof(type)*vlen),
+ gr_make_io_signature (1, 1, sizeof(type)*vlen)
+ ),
+ _vlen(vlen)
+ {
+ //NOP
+ }
+
+ int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ const size_t n_nums = noutput_items * _vlen;
+ type *out = reinterpret_cast<type *>(output_items[0]);
+ const type *in0 = reinterpret_cast<const type *>(input_items[0]);
+
+ for (size_t n = 1; n < input_items.size(); n++){
+ const type *in = reinterpret_cast<const type *>(input_items[n]);
+ for (size_t i = 0; i < n_nums; i++){
+ out[i] = in0[i] - in[i];
+ }
+ in0 = out; //for next input, we do output -= input
+ }
+
+ return noutput_items;
+ }
+
+private:
+ const size_t _vlen;
+};
+
+/***********************************************************************
+ * Adder factory function
+ **********************************************************************/
+basic_subtract::sptr basic_make_subtract(
+ subtract_type type, const size_t vlen
+){
+ switch(type){
+ case SUBTRACT_FC64: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<double>(2*vlen));
+ case SUBTRACT_F64: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<double>(vlen));
+
+ case SUBTRACT_FC32: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<float>(2*vlen));
+ case SUBTRACT_F32: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<float>(vlen));
+
+ case SUBTRACT_SC64: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<int64_t>(2*vlen));
+ case SUBTRACT_S64: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<int64_t>(vlen));
+
+ case SUBTRACT_SC32: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<int32_t>(2*vlen));
+ case SUBTRACT_S32: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<int32_t>(vlen));
+
+ case SUBTRACT_SC16: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<int16_t>(2*vlen));
+ case SUBTRACT_S16: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<int16_t>(vlen));
+
+ case SUBTRACT_SC8: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<int8_t>(2*vlen));
+ case SUBTRACT_S8: return boost::shared_ptr<basic_subtract>(new
gr_basic_subtract_generic<int8_t>(vlen));
+
+ default: throw std::invalid_argument("basic_make_subtract got unknown
subtract type");
+ }
+}
diff --git a/gr-basic/swig/CMakeLists.txt b/gr-basic/swig/CMakeLists.txt
index 0a90bea..7cb5cc0 100644
--- a/gr-basic/swig/CMakeLists.txt
+++ b/gr-basic/swig/CMakeLists.txt
@@ -41,7 +41,7 @@ GR_SWIG_INSTALL(
install(
FILES
basic_swig.i
- basic_add.i
+ basic_ops.i
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
COMPONENT "basic_swig"
)
diff --git a/gr-basic/swig/basic_add.i b/gr-basic/swig/basic_ops.i
similarity index 80%
rename from gr-basic/swig/basic_add.i
rename to gr-basic/swig/basic_ops.i
index 234771c..1f3d27a 100644
--- a/gr-basic/swig/basic_add.i
+++ b/gr-basic/swig/basic_ops.i
@@ -24,6 +24,9 @@
////////////////////////////////////////////////////////////////////////
%{
#include <gr_basic_add.h>
+#include <gr_basic_divide.h>
+#include <gr_basic_multiply.h>
+#include <gr_basic_subtract.h>
%}
////////////////////////////////////////////////////////////////////////
@@ -31,3 +34,12 @@
////////////////////////////////////////////////////////////////////////
GR_SWIG_BLOCK_MAGIC(basic,add)
%include <gr_basic_add.h>
+
+GR_SWIG_BLOCK_MAGIC(basic,divide)
+%include <gr_basic_divide.h>
+
+GR_SWIG_BLOCK_MAGIC(basic,multiply)
+%include <gr_basic_multiply.h>
+
+GR_SWIG_BLOCK_MAGIC(basic,subtract)
+%include <gr_basic_subtract.h>
diff --git a/gr-basic/swig/basic_swig.i b/gr-basic/swig/basic_swig.i
index 0072dde..8bd5f42 100644
--- a/gr-basic/swig/basic_swig.i
+++ b/gr-basic/swig/basic_swig.i
@@ -29,4 +29,4 @@
////////////////////////////////////////////////////////////////////////
// block includes
////////////////////////////////////////////////////////////////////////
-%include <basic_add.i>
+%include <basic_ops.i>
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 0572e20..183408c 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -37,6 +37,7 @@
</cat>
<cat>
<name>Operators</name>
+ <block>gr_add_xx</block>
<block>gr_sub_xx</block>
<block>gr_multiply_xx</block>
<block>gr_divide_xx</block>
diff --git a/gr-basic/grc/gr_add_xx.xml b/grc/blocks/gr_add_xx.xml
similarity index 70%
rename from gr-basic/grc/gr_add_xx.xml
rename to grc/blocks/gr_add_xx.xml
index 5138294..97ed928 100644
--- a/gr-basic/grc/gr_add_xx.xml
+++ b/grc/blocks/gr_add_xx.xml
@@ -8,31 +8,31 @@
<block>
<name>Add</name>
<key>gr_add_xx</key>
- <import>from gnuradio import basic</import>
- <make>basic.add(basic.$type.enum, $vlen)</make>
+ <import>from gnuradio import gr</import>
+ <make>gr.add_v$(type.fcn)($vlen)</make>
<param>
<name>IO Type</name>
<key>type</key>
<type>enum</type>
<option>
- <name>FC32</name>
- <key>fc32</key>
- <opt>enum:ADD_FC32</opt>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>fcn:cc</opt>
</option>
<option>
- <name>F32</name>
- <key>f32</key>
- <opt>enum:ADD_F32</opt>
+ <name>Float</name>
+ <key>float</key>
+ <opt>fcn:ff</opt>
</option>
<option>
- <name>SC16</name>
- <key>sc16</key>
- <opt>enum:ADD_SC16</opt>
+ <name>Int</name>
+ <key>int</key>
+ <opt>fcn:ii</opt>
</option>
<option>
- <name>S16</name>
- <key>s16</key>
- <opt>enum:ADD_S16</opt>
+ <name>Short</name>
+ <key>short</key>
+ <opt>fcn:ss</opt>
</option>
</param>
<param>
- [Commit-gnuradio] [gnuradio] 02/28: gr-basic: volkified the add fn for f32, (continued)
- [Commit-gnuradio] [gnuradio] 02/28: gr-basic: volkified the add fn for f32, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 14/28: basic: integrated volk routine for float multiply const, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 23/28: Merge branch 'inplace_blocks' of gnuradio.org:jblum into gr_basic, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 10/28: Volk: add 32fc_s32fc_multiply_32fc to profiler, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 06/28: basic: call volk for float32 multiplier types, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 09/28: Volk: added 32fc x scalar multiply, implemented in Orc & generic. Orc/SSE tested 10x faster than generic., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 25/28: core: added set_output_alignment (policy 2 version), git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 11/28: basic: use volk multiply scalar function for multiply_const fc32, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 24/28: basic: set inplace on gr-basic math blocks, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 16/28: basic: performance tweak for sig source index mod, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 04/28: basic: added other basic operators,
git <=
- [Commit-gnuradio] [gnuradio] 01/28: basic: attempt at new component, partial adder implementation, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 27/28: basic: added dynamic delay block, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 13/28: Volk: whoops, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 17/28: core: squashed in-place block work, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 07/28: basic add/mult const, needs test, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 15/28: basic: added super fast signal source, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 26/28: basic: use set_output_alignment in the basic math blocks, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 19/28: core: make in-place buffering enabled per port, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 22/28: filter: added 32f decimating fir + tweaks, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 18/28: basic: added stream selector block, git, 2016/08/14