diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-03-06 15:14:19 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-03-06 15:14:19 -0500 |
commit | cf2c954ba4fc54909515f8550fd55741c9603a11 (patch) | |
tree | f3520b072bd7e3f98fbef80052327411d5c32246 /gnuradio-core/src | |
parent | 2fb54bc604578db99ee788799a7723ed5eddb65a (diff) |
core: removed all complex_to_<type> blocks from core; using gr-blocks.
Diffstat (limited to 'gnuradio-core/src')
10 files changed, 5 insertions, 801 deletions
diff --git a/gnuradio-core/src/examples/volk_benchmark/volk_types.py b/gnuradio-core/src/examples/volk_benchmark/volk_types.py index 134a3db781..e8db14aff7 100755 --- a/gnuradio-core/src/examples/volk_benchmark/volk_types.py +++ b/gnuradio-core/src/examples/volk_benchmark/volk_types.py @@ -50,35 +50,35 @@ def int_to_float(N): ###################################################################### def complex_to_float(N): - op = gr.complex_to_float() + op = blocks.complex_to_float() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 2) return tb ###################################################################### def complex_to_real(N): - op = gr.complex_to_real() + op = blocks.complex_to_real() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 1) return tb ###################################################################### def complex_to_imag(N): - op = gr.complex_to_imag() + op = blocks.complex_to_imag() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 1) return tb ###################################################################### def complex_to_mag(N): - op = gr.complex_to_mag() + op = blocks.complex_to_mag() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 1) return tb ###################################################################### def complex_to_mag_squared(N): - op = gr.complex_to_mag_squared() + op = blocks.complex_to_mag_squared() tb = helper(N, op, gr.sizeof_gr_complex, gr.sizeof_float, 1, 1) return tb diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt index 599d0f2a0d..bf9d43ec1a 100644 --- a/gnuradio-core/src/lib/general/CMakeLists.txt +++ b/gnuradio-core/src/lib/general/CMakeLists.txt @@ -147,8 +147,6 @@ set(gr_core_general_triple_threats gr_block_gateway gr_check_counting_s gr_check_lfsr_32k_s - gr_complex_to_interleaved_short - gr_complex_to_xxx gr_copy gr_endian_swap gr_fake_channel_coder_pp diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 030dce92a2..8be52295b9 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -33,8 +33,6 @@ #include <gr_lfsr_32k_source_s.h> #include <gr_check_lfsr_32k_s.h> #include <gr_align_on_samplenumbers_ss.h> -#include <gr_complex_to_xxx.h> -#include <gr_complex_to_interleaved_short.h> //#include <gr_endianness.h> #include <gr_endian_swap.h> #include <gr_firdes.h> @@ -69,8 +67,6 @@ %include "gr_lfsr_32k_source_s.i" %include "gr_check_lfsr_32k_s.i" %include "gr_align_on_samplenumbers_ss.i" -%include "gr_complex_to_xxx.i" -%include "gr_complex_to_interleaved_short.i" //%include "gr_endianness.i" %include "gr_endian_swap.i" %include "gr_firdes.i" diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc deleted file mode 100644 index 596c149961..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,2010 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 <gr_complex_to_interleaved_short.h> -#include <gr_io_signature.h> -#include <math.h> - -gr_complex_to_interleaved_short_sptr -gr_make_complex_to_interleaved_short () -{ - return gnuradio::get_initial_sptr(new gr_complex_to_interleaved_short ()); -} - -gr_complex_to_interleaved_short::gr_complex_to_interleaved_short () - : gr_sync_interpolator ("gr_complex_to_interleaved_short", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (short)), - 2) -{ -} - -int -gr_complex_to_interleaved_short::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - short *out = (short *) output_items[0]; - - for (int i = 0; i < noutput_items/2; i++){ - *out++ = (short) lrintf(in[i].real()); // FIXME saturate? - *out++ = (short) lrintf(in[i].imag()); - } - - return noutput_items; -} - - - diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h deleted file mode 100644 index 66503413ff..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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_COMPLEX_TO_INTERLEAVED_SHORT_H -#define INCLUDED_GR_COMPLEX_TO_INTERLEAVED_SHORT_H - -#include <gr_core_api.h> -#include <gr_sync_interpolator.h> - -class gr_complex_to_interleaved_short; -typedef boost::shared_ptr<gr_complex_to_interleaved_short> - gr_complex_to_interleaved_short_sptr; - -GR_CORE_API gr_complex_to_interleaved_short_sptr -gr_make_complex_to_interleaved_short (); - -/*! - * \brief Convert stream of complex to a stream of interleaved shorts - * \ingroup converter_blk - */ - -class GR_CORE_API gr_complex_to_interleaved_short : public gr_sync_interpolator -{ - friend GR_CORE_API gr_complex_to_interleaved_short_sptr gr_make_complex_to_interleaved_short (); - gr_complex_to_interleaved_short (); - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_COMPLEX_TO_INTERLEAVED_SHORT_H */ diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.i b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.i deleted file mode 100644 index 19c01b7c66..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.i +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_interleaved_short) - -gr_complex_to_interleaved_short_sptr gr_make_complex_to_interleaved_short (); - -class gr_complex_to_interleaved_short : public gr_sync_interpolator -{ - gr_complex_to_interleaved_short (); -}; diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc deleted file mode 100644 index cdf6d7f3a6..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc +++ /dev/null @@ -1,280 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2008,2010,2012 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_complex_to_xxx.h> -#include <gr_io_signature.h> -#include <gr_math.h> -#include <volk/volk.h> - -// ---------------------------------------------------------------- - -gr_complex_to_float_sptr -gr_make_complex_to_float (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_float (vlen)); -} - -gr_complex_to_float::gr_complex_to_float (unsigned int vlen) - : gr_sync_block ("complex_to_float", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 2, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_float::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out0 = (float *) output_items[0]; - float* out1; - int noi = noutput_items * d_vlen; - - switch (output_items.size ()){ - case 1: - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out0[i] = in[i].real (); - } - } - else { - volk_32fc_deinterleave_real_32f_a(out0, in, noi); - } - break; - - case 2: - out1 = (float *) output_items[1]; - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out0[i] = in[i].real (); - out1[i] = in[i].imag (); - } - } - else { - volk_32fc_deinterleave_32f_x2_a(out0, out1, in, noi); - } - break; - - default: - abort (); - } - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_real_sptr -gr_make_complex_to_real (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_real (vlen)); -} - -gr_complex_to_real::gr_complex_to_real (unsigned int vlen) - : gr_sync_block ("complex_to_real", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_real::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out[i] = in[i].real (); - } - } - else { - volk_32fc_deinterleave_real_32f_a(out, in, noi); - } - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_imag_sptr -gr_make_complex_to_imag (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_imag (vlen)); -} - -gr_complex_to_imag::gr_complex_to_imag (unsigned int vlen) - : gr_sync_block ("complex_to_imag", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_imag::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - if(is_unaligned()) { - for (int i = 0; i < noi; i++){ - out[i] = in[i].imag (); - } - } - else { - volk_32fc_deinterleave_imag_32f_a(out, in, noi); - } - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_mag_sptr -gr_make_complex_to_mag (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_mag (vlen)); -} - -gr_complex_to_mag::gr_complex_to_mag (unsigned int vlen) - : gr_sync_block ("complex_to_mag", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_mag::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - // turned out to be faster than aligned/unaligned switching - volk_32fc_magnitude_32f_u(out, in, noi); - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_mag_squared_sptr -gr_make_complex_to_mag_squared (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_mag_squared (vlen)); -} - -gr_complex_to_mag_squared::gr_complex_to_mag_squared (unsigned int vlen) - : gr_sync_block ("complex_to_mag_squared", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_mag_squared::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - if(is_unaligned()) { - volk_32fc_magnitude_squared_32f_u(out, in, noi); - } - else { - volk_32fc_magnitude_squared_32f_a(out, in, noi); - } - - return noutput_items; -} - -// ---------------------------------------------------------------- - -gr_complex_to_arg_sptr -gr_make_complex_to_arg (unsigned int vlen) -{ - return gnuradio::get_initial_sptr(new gr_complex_to_arg (vlen)); -} - -gr_complex_to_arg::gr_complex_to_arg (unsigned int vlen) - : gr_sync_block ("complex_to_arg", - gr_make_io_signature (1, 1, sizeof (gr_complex) * vlen), - gr_make_io_signature (1, 1, sizeof (float) * vlen)), - d_vlen(vlen) -{ - const int alignment_multiple = - volk_get_alignment() / sizeof(float); - set_alignment(std::max(1,alignment_multiple)); -} - -int -gr_complex_to_arg::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (const gr_complex *) input_items[0]; - float *out = (float *) output_items[0]; - int noi = noutput_items * d_vlen; - - // The fast_atan2f is faster than Volk - for (int i = 0; i < noi; i++){ - // out[i] = std::arg (in[i]); - out[i] = gr_fast_atan2f(in[i]); - } - - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h deleted file mode 100644 index a2f06ea28c..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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_COMPLEX_TO_XXX_H -#define INCLUDED_GR_COMPLEX_TO_XXX_H - -#include <gr_core_api.h> -#include <gr_sync_block.h> -#include <gr_complex.h> - -class gr_complex_to_float; -class gr_complex_to_real; -class gr_complex_to_imag; -class gr_complex_to_mag; -class gr_complex_to_mag_squared; -class gr_complex_to_arg; - -typedef boost::shared_ptr<gr_complex_to_float> gr_complex_to_float_sptr; -typedef boost::shared_ptr<gr_complex_to_real> gr_complex_to_real_sptr; -typedef boost::shared_ptr<gr_complex_to_imag> gr_complex_to_imag_sptr; -typedef boost::shared_ptr<gr_complex_to_mag> gr_complex_to_mag_sptr; -typedef boost::shared_ptr<gr_complex_to_mag_squared> gr_complex_to_mag_squared_sptr; -typedef boost::shared_ptr<gr_complex_to_arg> gr_complex_to_arg_sptr; - -GR_CORE_API gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen=1); -GR_CORE_API gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen=1); -GR_CORE_API gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen=1); -GR_CORE_API gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen=1); -GR_CORE_API gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen=1); -GR_CORE_API gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen=1); - -/*! - * \brief convert a stream of gr_complex to 1 or 2 streams of float - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_float : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen); - gr_complex_to_float (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, real out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_real : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen); - gr_complex_to_real (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, imaginary out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_imag : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen); - gr_complex_to_imag (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, magnitude out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_mag : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_mag_sptr - gr_make_complex_to_mag (unsigned int vlen); - gr_complex_to_mag (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, magnitude squared out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_mag_squared : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen); - gr_complex_to_mag_squared (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -/*! - * \brief complex in, angle out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) - */ -class GR_CORE_API gr_complex_to_arg : public gr_sync_block -{ - friend GR_CORE_API gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen); - gr_complex_to_arg (unsigned int vlen); - - unsigned int d_vlen; - - public: - virtual int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_GR_COMPLEX_TO_XXX_H */ diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.i b/gnuradio-core/src/lib/general/gr_complex_to_xxx.i deleted file mode 100644 index 372b0e8b58..0000000000 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.i +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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. - */ - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_float); -gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen=1); -class gr_complex_to_float : public gr_sync_block -{ - gr_complex_to_float (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_real); -gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen=1); -class gr_complex_to_real : public gr_sync_block -{ - gr_complex_to_real (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_imag); -gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen=1); -class gr_complex_to_imag : public gr_sync_block -{ - gr_complex_to_imag (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_mag); -gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen=1); -class gr_complex_to_mag : public gr_sync_block -{ - gr_complex_to_mag (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_mag_squared); -gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen=1); -class gr_complex_to_mag_squared : public gr_sync_block -{ - gr_complex_to_mag_squared (unsigned int vlen); -}; - -GR_SWIG_BLOCK_MAGIC(gr,complex_to_arg); -gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen=1); -class gr_complex_to_arg : public gr_sync_block -{ - gr_complex_to_arg (unsigned int vlen); -}; - diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py b/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py deleted file mode 100755 index 946c0d7f88..0000000000 --- a/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2007,2010 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 math - -class test_complex_ops (gr_unittest.TestCase): - - def setUp (self): - self.tb = gr.top_block () - - def tearDown (self): - self.tb = None - - def test_complex_to_float_1 (self): - src_data = (0, 1, -1, 3+4j, -3-4j, -3+4j) - expected_result = (0, 1, -1, 3, -3, -3) - src = gr.vector_source_c (src_data) - op = gr.complex_to_float () - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () # run the graph and wait for it to finish - actual_result = dst.data () # fetch the contents of the sink - self.assertFloatTuplesAlmostEqual (expected_result, actual_result) - - def test_complex_to_float_2 (self): - src_data = (0, 1, -1, 3+4j, -3-4j, -3+4j) - expected_result0 = (0, 1, -1, 3, -3, -3) - expected_result1 = (0, 0, 0, 4, -4, 4) - src = gr.vector_source_c (src_data) - op = gr.complex_to_float () - dst0 = gr.vector_sink_f () - dst1 = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect ((op, 0), dst0) - self.tb.connect ((op, 1), dst1) - self.tb.run () - actual_result = dst0.data () - self.assertFloatTuplesAlmostEqual (expected_result0, actual_result) - actual_result = dst1.data () - self.assertFloatTuplesAlmostEqual (expected_result1, actual_result) - - def test_complex_to_real (self): - src_data = (0, 1, -1, 3+4j, -3-4j, -3+4j) - expected_result = (0, 1, -1, 3, -3, -3) - src = gr.vector_source_c (src_data) - op = gr.complex_to_real () - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - actual_result = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, actual_result) - - def test_complex_to_imag (self): - src_data = (0, 1, -1, 3+4j, -3-4j, -3+4j) - expected_result = (0, 0, 0, 4, -4, 4) - src = gr.vector_source_c (src_data) - op = gr.complex_to_imag () - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - actual_result = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, actual_result,5) - - def test_complex_to_mag (self): - src_data = (0, 1, -1, 3+4j, -3-4j, -3+4j) - expected_result = (0, 1, 1, 5, 5, 5) - src = gr.vector_source_c (src_data) - op = gr.complex_to_mag () - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - actual_result = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, actual_result,5) - - def test_complex_to_mag_squared (self): - src_data = (0, 1, -1, 3+4j, -3-4j, -3+4j) - expected_result = (0, 1, 1, 25, 25, 25) - src = gr.vector_source_c (src_data) - op = gr.complex_to_mag_squared () - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - actual_result = dst.data () - self.assertFloatTuplesAlmostEqual (expected_result, actual_result,5) - - def test_complex_to_arg (self): - pi = math.pi - input_data = (0, pi/6, pi/4, pi/2, 3*pi/4, 7*pi/8, - -pi/6, -pi/4, -pi/2, -3*pi/4, -7*pi/8) - - expected_result = (0.0, # 0 - 0.52382522821426392, # pi/6 - 0.78539806604385376, # pi/4 - 1.5707963705062866, # pi/2 - 2.3561947345733643, # 3pi/4 - 2.7491819858551025, # 7pi/8 - -0.52382522821426392, # -pi/6 - -0.78539806604385376, # -pi/4 - -1.5707963705062866, # -pi/2 - -2.3561947345733643, # -3pi/4 - -2.7491819858551025) # -7pi/8 - - src_data = tuple ([math.cos (x) + math.sin (x) * 1j for x in input_data]) - src = gr.vector_source_c (src_data) - op = gr.complex_to_arg () - dst = gr.vector_sink_f () - self.tb.connect (src, op) - self.tb.connect (op, dst) - self.tb.run () - actual_result = dst.data () - - self.assertFloatTuplesAlmostEqual (expected_result, actual_result, 3) - - -if __name__ == '__main__': - gr_unittest.run(test_complex_ops, "test_complex_ops.xml") - |