commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/02: blocks: enable missing multiply_matr


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/02: blocks: enable missing multiply_matrix_cc and backport fixes
Date: Sat, 3 Oct 2015 19:14:10 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit 8d3f6e315bae1d3e7cc0de171aa4dab56bfd2d2d
Author: Johnathan Corgan <address@hidden>
Date:   Sat Oct 3 10:56:51 2015 -0700

    blocks: enable missing multiply_matrix_cc and backport fixes
    
    * multiply_matrix_cc_impl.cc existed but did not have fixes from master
    
    * multiply_matrix_cc_impl.cc was missing from CMakeLists.txt
    
    * multiply_matrix_cc was missing from SWIG
    
    * QA from from master branch was backported
---
 gr-blocks/lib/CMakeLists.txt                       |  1 +
 gr-blocks/lib/multiply_matrix_cc_impl.cc           |  2 +-
 ...tiply_matrix_ff.py => qa_multiply_matrix_xx.py} | 48 +++++++++++++++++++---
 gr-blocks/swig/blocks_swig3.i                      |  3 ++
 4 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 3b61d86..2af83aa 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -202,6 +202,7 @@ list(APPEND gr_blocks_sources
     vector_to_streams_impl.cc
     wavfile_sink_impl.cc
     wavfile_source_impl.cc
+    multiply_matrix_cc_impl.cc
     multiply_matrix_ff_impl.cc
 )
 
diff --git a/gr-blocks/lib/multiply_matrix_cc_impl.cc 
b/gr-blocks/lib/multiply_matrix_cc_impl.cc
index 603347d..e9800c7 100644
--- a/gr-blocks/lib/multiply_matrix_cc_impl.cc
+++ b/gr-blocks/lib/multiply_matrix_cc_impl.cc
@@ -106,7 +106,7 @@ namespace gr {
         );
 
         for (size_t out_idx = 0; out_idx < noutput_ports; out_idx++) {
-          if (d_A[out_idx][in_idx] == 0) {
+          if (d_A[out_idx][in_idx] == std::complex<float>(0, 0)) {
             continue;
           }
           for (size_t i = 0; i < tags.size(); i++) {
diff --git a/gr-blocks/python/blocks/qa_multiply_matrix_ff.py 
b/gr-blocks/python/blocks/qa_multiply_matrix_xx.py
similarity index 78%
rename from gr-blocks/python/blocks/qa_multiply_matrix_ff.py
rename to gr-blocks/python/blocks/qa_multiply_matrix_xx.py
index 357120b..feee53d 100755
--- a/gr-blocks/python/blocks/qa_multiply_matrix_ff.py
+++ b/gr-blocks/python/blocks/qa_multiply_matrix_xx.py
@@ -28,7 +28,20 @@ import pmt
 from gnuradio import gr, gr_unittest
 from gnuradio import blocks
 
-class test_multiply_matrix_ff (gr_unittest.TestCase):
+BLOCK_LOOKUP = {
+    'float': {
+        'src':  blocks.vector_source_f,
+        'sink': blocks.vector_sink_f,
+        'mult': blocks.multiply_matrix_ff,
+    },
+    'complex': {
+        'src':  blocks.vector_source_c,
+        'sink': blocks.vector_sink_c,
+        'mult': blocks.multiply_matrix_cc,
+    },
+}
+
+class test_multiply_matrix_xx (gr_unittest.TestCase):
 
     def setUp (self):
         self.tb = gr.top_block ()
@@ -38,7 +51,15 @@ class test_multiply_matrix_ff (gr_unittest.TestCase):
         self.tb = None
         self.multiplier = None
 
-    def run_once(self, X_in, A, tpp=gr.TPP_DONT, A2=None, tags=None, 
msg_A=None):
+    def run_once(self,
+            X_in,
+            A,
+            tpp=gr.TPP_DONT,
+            A2=None,
+            tags=None,
+            msg_A=None,
+            datatype='float',
+        ):
         """ Run the test for given input-, output- and matrix values.
         Every row from X_in is considered an input signal on a port. """
         X_in = numpy.matrix(X_in)
@@ -47,7 +68,7 @@ class test_multiply_matrix_ff (gr_unittest.TestCase):
         self.assertTrue(N == X_in.shape[0])
         # Calc expected
         Y_out_exp = numpy.matrix(numpy.zeros((M, X_in.shape[1])))
-        self.multiplier = blocks.multiply_matrix_ff(A, tpp)
+        self.multiplier = BLOCK_LOOKUP[datatype]['mult'](A, tpp)
         if A2 is not None:
             self.multiplier.set_A(A2)
             A = A2
@@ -57,10 +78,13 @@ class test_multiply_matrix_ff (gr_unittest.TestCase):
                 these_tags = ()
             else:
                 these_tags = (tags[i],)
-            self.tb.connect(blocks.vector_source_f(X_in[i].tolist()[0], 
tags=these_tags), (self.multiplier, i))
+            self.tb.connect(
+                    BLOCK_LOOKUP[datatype]['src'](X_in[i].tolist()[0], 
tags=these_tags),
+                    (self.multiplier, i)
+            )
         sinks = []
         for i in xrange(M):
-            sinks.append(blocks.vector_sink_f())
+            sinks.append(BLOCK_LOOKUP[datatype]['sink']())
             self.tb.connect((self.multiplier, i), sinks[i])
         # Run and check
         self.tb.run()
@@ -86,6 +110,18 @@ class test_multiply_matrix_ff (gr_unittest.TestCase):
         )
         self.run_once(X_in, A)
 
+    def test_001_t_complex (self):
+        """ Simplest possible check: N==M, unit matrix """
+        X_in = (
+            (1, 2, 3, 4),
+            (5, 6, 7, 8),
+        )
+        A = (
+            (1, 0),
+            (0, 1),
+        )
+        self.run_once(X_in, A, datatype='complex')
+
     def test_002_t (self):
         """ Switch check: N==M, flipped unit matrix """
         X_in = (
@@ -168,5 +204,5 @@ class test_multiply_matrix_ff (gr_unittest.TestCase):
 
 if __name__ == '__main__':
     #gr_unittest.run(test_multiply_matrix_ff, "test_multiply_matrix_ff.xml")
-    gr_unittest.run(test_multiply_matrix_ff)
+    gr_unittest.run(test_multiply_matrix_xx)
 
diff --git a/gr-blocks/swig/blocks_swig3.i b/gr-blocks/swig/blocks_swig3.i
index 9c02083..f0b7750 100644
--- a/gr-blocks/swig/blocks_swig3.i
+++ b/gr-blocks/swig/blocks_swig3.i
@@ -67,6 +67,7 @@
 #include "gnuradio/blocks/multiply_const_vii.h"
 #include "gnuradio/blocks/multiply_const_vff.h"
 #include "gnuradio/blocks/multiply_const_vcc.h"
+#include "gnuradio/blocks/multiply_matrix_cc.h"
 #include "gnuradio/blocks/multiply_matrix_ff.h"
 #include "gnuradio/blocks/mute_ss.h"
 #include "gnuradio/blocks/mute_ii.h"
@@ -113,6 +114,7 @@
 %include "gnuradio/blocks/multiply_const_vii.h"
 %include "gnuradio/blocks/multiply_const_vff.h"
 %include "gnuradio/blocks/multiply_const_vcc.h"
+%include "gnuradio/blocks/multiply_matrix_cc.h"
 %include "gnuradio/blocks/multiply_matrix_ff.h"
 %include "gnuradio/blocks/mute_ss.h"
 %include "gnuradio/blocks/mute_ii.h"
@@ -158,6 +160,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vss);
 GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vii);
 GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vff);
 GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vcc);
+GR_SWIG_BLOCK_MAGIC2(blocks, multiply_matrix_cc);
 GR_SWIG_BLOCK_MAGIC2(blocks, multiply_matrix_ff);
 GR_SWIG_BLOCK_MAGIC2(blocks, mute_ss);
 GR_SWIG_BLOCK_MAGIC2(blocks, mute_ii);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]