diff options
author | Johnathan Corgan | 2012-06-30 08:26:58 -0700 |
---|---|---|
committer | Johnathan Corgan | 2012-06-30 08:26:58 -0700 |
commit | ee1a53b4a971e4b9623f504628231a273157f462 (patch) | |
tree | e60b7606ce085f4ad5469c59e2d17eac2fd60fea /gr-blocks | |
parent | 25b0d584f5189c39817af98d403c461a59dd3419 (diff) | |
download | gnuradio-ee1a53b4a971e4b9623f504628231a273157f462.tar.gz gnuradio-ee1a53b4a971e4b9623f504628231a273157f462.tar.bz2 gnuradio-ee1a53b4a971e4b9623f504628231a273157f462.zip |
blocks: aded gr::blocks::multiply_conjugate_cc
Diffstat (limited to 'gr-blocks')
-rw-r--r-- | gr-blocks/grc/blocks_block_tree.xml | 1 | ||||
-rw-r--r-- | gr-blocks/grc/blocks_multiply_conjugate_cc.xml | 35 | ||||
-rw-r--r-- | gr-blocks/include/blocks/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/include/blocks/multiply_conjugate_cc.h | 50 | ||||
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/lib/multiply_conjugate_cc_impl.cc | 71 | ||||
-rw-r--r-- | gr-blocks/lib/multiply_conjugate_cc_impl.h | 47 | ||||
-rw-r--r-- | gr-blocks/python/qa_multiply_conjugate.py | 58 | ||||
-rw-r--r-- | gr-blocks/swig/blocks_swig.i | 3 |
9 files changed, 267 insertions, 0 deletions
diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index d7cbbeb55..638fb5941 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -35,6 +35,7 @@ <block>blocks_divide_xx</block> <block>blocks_multiply_xx</block> <block>blocks_multiply_const_vxx</block> + <block>blocks_multiply_conjugate_cc</block> <block>blocks_sub_xx</block> <block>blocks_conjugate_cc</block> <block>blocks_integrate_xx</block> diff --git a/gr-blocks/grc/blocks_multiply_conjugate_cc.xml b/gr-blocks/grc/blocks_multiply_conjugate_cc.xml new file mode 100644 index 000000000..cf0acf4d8 --- /dev/null +++ b/gr-blocks/grc/blocks_multiply_conjugate_cc.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Multiply Conjugate Block: +## 2 complex inputs, 1 complex output +################################################### + --> +<block> + <name>Multiply Conjugate</name> + <key>blocks_multiply_conjugate_cc</key> + <import>from gnuradio import blocks</import> + <make>blocks.multiply_conjugate_cc($vlen)</make> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in0</name> + <type>complex</type> + <vlen>$vlen</vlen> + </sink> + <sink> + <name>in1</name> + <type>complex</type> + <vlen>$vlen</vlen> + </sink> + <source> + <name>out</name> + <type>complex</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index 9f1af046d..f8e775397 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -104,6 +104,7 @@ install(FILES interleaved_short_to_complex.h multiply_cc.h multiply_ff.h + multiply_conjugate_cc.h multiply_const_cc.h multiply_const_ff.h short_to_char.h diff --git a/gr-blocks/include/blocks/multiply_conjugate_cc.h b/gr-blocks/include/blocks/multiply_conjugate_cc.h new file mode 100644 index 000000000..fc587ae2f --- /dev/null +++ b/gr-blocks/include/blocks/multiply_conjugate_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_CONJUGATE_CC_H +#define INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API multiply_conjugate_cc : virtual public gr_sync_block + { + public: + + // gr::blocks::multiply_conjugate_cc::sptr + typedef boost::shared_ptr<multiply_conjugate_cc> sptr; + + /*! + * \brief Multiplies a streams by the conjugate of a second stream + * \param vlen Vector length + * \ingroup math_blk + */ + static sptr make(size_t vlen=1); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_MULTIPLY_CONJUGATE_CC_H */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index e3a40dfc8..b73bf2994 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -141,6 +141,7 @@ list(APPEND gr_blocks_sources interleaved_short_to_complex_impl.cc multiply_cc_impl.cc multiply_ff_impl.cc + multiply_conjugate_cc_impl.cc multiply_const_cc_impl.cc multiply_const_ff_impl.cc short_to_char_impl.cc diff --git a/gr-blocks/lib/multiply_conjugate_cc_impl.cc b/gr-blocks/lib/multiply_conjugate_cc_impl.cc new file mode 100644 index 000000000..7a4356c45 --- /dev/null +++ b/gr-blocks/lib/multiply_conjugate_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_conjugate_cc_impl.h> +#include <gr_io_signature.h> +#include <volk/volk.h> + +namespace gr { + namespace blocks { + + multiply_conjugate_cc::sptr multiply_conjugate_cc::make(size_t vlen) + { + return gnuradio::get_initial_sptr(new multiply_conjugate_cc_impl(vlen)); + } + + multiply_conjugate_cc_impl::multiply_conjugate_cc_impl(size_t vlen) + : gr_sync_block("multiply_conjugate_cc", + gr_make_io_signature (2, 2, 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_conjugate_cc_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gr_complex *in0 = (gr_complex *) input_items[0]; + gr_complex *in1 = (gr_complex *) input_items[1]; + gr_complex *out = (gr_complex *) output_items[0]; + int noi = d_vlen*noutput_items; + + if(is_unaligned()) { + volk_32fc_x2_multiply_conjugate_32fc_u(out, in0, in1, noi); + } + else { + volk_32fc_x2_multiply_conjugate_32fc_a(out, in0, in1, noi); + } + + return noutput_items; + } + + } /* namespace blocks */ +}/* namespace gr */ diff --git a/gr-blocks/lib/multiply_conjugate_cc_impl.h b/gr-blocks/lib/multiply_conjugate_cc_impl.h new file mode 100644 index 000000000..66e7ec55b --- /dev/null +++ b/gr-blocks/lib/multiply_conjugate_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_CONJUGATE_CC_IMPL_H +#define INCLUDED_BLOCKS_MULTIPLY_CONJUGATE_CC_IMPL_H + +#include <blocks/multiply_conjugate_cc.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API multiply_conjugate_cc_impl : public multiply_conjugate_cc + { + size_t d_vlen; + + public: + multiply_conjugate_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_CONJUGATE_CC_IMPL_H */ diff --git a/gr-blocks/python/qa_multiply_conjugate.py b/gr-blocks/python/qa_multiply_conjugate.py new file mode 100644 index 000000000..f51563f85 --- /dev/null +++ b/gr-blocks/python/qa_multiply_conjugate.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig + +class test_multiply_conjugate (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_000 (self): + src_data0 = (-2-2j, -1-1j, -2+2j, -1+1j, + 2-2j, 1-1j, 2+2j, 1+1j, + 0+0j) + src_data1 = (-3-3j, -4-4j, -3+3j, -4+4j, + 3-3j, 4-4j, 3+3j, 4+4j, + 0+0j) + + exp_data = (12+0j, 8+0j, 12+0j, 8+0j, + 12+0j, 8+0j, 12+0j, 8+0j, + 0+0j) + src0 = gr.vector_source_c(src_data0) + src1 = gr.vector_source_c(src_data1) + op = blocks_swig.multiply_conjugate_cc () + dst = gr.vector_sink_c () + + 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 (exp_data, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_multiply_conjugate, "test_multiply_conjugate.xml") diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig.i index fe2745da0..43225a732 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig.i @@ -69,6 +69,7 @@ #include "blocks/multiply_ii.h" #include "blocks/multiply_ff.h" #include "blocks/multiply_cc.h" +#include "blocks/multiply_conjugate_cc.h" #include "blocks/multiply_const_ss.h" #include "blocks/multiply_const_ii.h" #include "blocks/multiply_const_ff.h" @@ -127,6 +128,7 @@ %include "blocks/multiply_ii.h" %include "blocks/multiply_ff.h" %include "blocks/multiply_cc.h" +%include "blocks/multiply_conjugate_cc.h" %include "blocks/multiply_const_ss.h" %include "blocks/multiply_const_ii.h" %include "blocks/multiply_const_ff.h" @@ -184,6 +186,7 @@ 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); +GR_SWIG_BLOCK_MAGIC2(blocks, multiply_conjugate_cc); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_ss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_ii); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_ff); |