From 269691c7d45675382bafbdf8a56f0682f1927fd9 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 1 Apr 2012 16:18:40 -0700 Subject: wavelet: converted blocks to private implementation pattern --- gr-wavelet/include/wavelet/wavelet_squash_ff.h | 33 ++------ gr-wavelet/include/wavelet/wavelet_wavelet_ff.h | 29 +------ gr-wavelet/include/wavelet/wavelet_wvps_ff.h | 17 +--- gr-wavelet/lib/CMakeLists.txt | 7 +- gr-wavelet/lib/wavelet_squash_ff.cc | 93 --------------------- gr-wavelet/lib/wavelet_squash_ff_impl.cc | 93 +++++++++++++++++++++ gr-wavelet/lib/wavelet_squash_ff_impl.h | 58 +++++++++++++ gr-wavelet/lib/wavelet_wavelet_ff.cc | 103 ------------------------ gr-wavelet/lib/wavelet_wavelet_ff_impl.cc | 103 ++++++++++++++++++++++++ gr-wavelet/lib/wavelet_wavelet_ff_impl.h | 55 +++++++++++++ gr-wavelet/lib/wavelet_wvps_ff.cc | 98 ---------------------- gr-wavelet/lib/wavelet_wvps_ff_impl.cc | 98 ++++++++++++++++++++++ gr-wavelet/lib/wavelet_wvps_ff_impl.h | 44 ++++++++++ 13 files changed, 464 insertions(+), 367 deletions(-) delete mode 100644 gr-wavelet/lib/wavelet_squash_ff.cc create mode 100644 gr-wavelet/lib/wavelet_squash_ff_impl.cc create mode 100644 gr-wavelet/lib/wavelet_squash_ff_impl.h delete mode 100644 gr-wavelet/lib/wavelet_wavelet_ff.cc create mode 100644 gr-wavelet/lib/wavelet_wavelet_ff_impl.cc create mode 100644 gr-wavelet/lib/wavelet_wavelet_ff_impl.h delete mode 100644 gr-wavelet/lib/wavelet_wvps_ff.cc create mode 100644 gr-wavelet/lib/wavelet_wvps_ff_impl.cc create mode 100644 gr-wavelet/lib/wavelet_wvps_ff_impl.h diff --git a/gr-wavelet/include/wavelet/wavelet_squash_ff.h b/gr-wavelet/include/wavelet/wavelet_squash_ff.h index 99ecf93ca..c79f513c6 100644 --- a/gr-wavelet/include/wavelet/wavelet_squash_ff.h +++ b/gr-wavelet/include/wavelet/wavelet_squash_ff.h @@ -20,49 +20,26 @@ * Boston, MA 02110-1301, USA. */ -#ifndef INCLUDED_WAVELET_SQUASH_FF_H_ -# define INCLUDED_WAVELET_SQUASH_FF_H_ +#ifndef INCLUDED_WAVELET_SQUASH_FF_H +#define INCLUDED_WAVELET_SQUASH_FF_H #include #include -#include -#include -#include + /*! * \brief implements cheap resampling of spectrum directly from * spectral points, using gsl interpolation * \ingroup misc */ - class wavelet_squash_ff; typedef boost::shared_ptr wavelet_squash_ff_sptr; WAVELET_API wavelet_squash_ff_sptr wavelet_make_squash_ff(const std::vector &igrid, const std::vector &ogrid); -class WAVELET_API wavelet_squash_ff : public gr_sync_block +class WAVELET_API wavelet_squash_ff : virtual public gr_sync_block { - friend WAVELET_API wavelet_squash_ff_sptr wavelet_make_squash_ff(const std::vector &igrid, - const std::vector &ogrid); - - size_t d_inum; - size_t d_onum; - double *d_igrid; - double *d_iwork; - double *d_ogrid; - - gsl_interp_accel *d_accel; - gsl_spline *d_spline; - - wavelet_squash_ff(const std::vector &igrid, - const std::vector &ogrid); - - public: - ~wavelet_squash_ff(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + // No public API methods visible }; #endif diff --git a/gr-wavelet/include/wavelet/wavelet_wavelet_ff.h b/gr-wavelet/include/wavelet/wavelet_wavelet_ff.h index 9b1f3fe0e..ef920f163 100644 --- a/gr-wavelet/include/wavelet/wavelet_wavelet_ff.h +++ b/gr-wavelet/include/wavelet/wavelet_wavelet_ff.h @@ -23,12 +23,8 @@ #define INCLUDED_WAVELET_WAVELET_FF_H #include -#include #include -#include -#include - class wavelet_wavelet_ff; typedef boost::shared_ptr wavelet_wavelet_ff_sptr; @@ -42,30 +38,9 @@ wavelet_make_wavelet_ff(int size = 1024, * \ingroup wavelet_blk */ -class WAVELET_API wavelet_wavelet_ff : public gr_sync_block +class WAVELET_API wavelet_wavelet_ff : virtual public gr_sync_block { - int d_size; - int d_order; - bool d_forward; - gsl_wavelet *d_wavelet; - gsl_wavelet_workspace *d_workspace; - double *d_temp; - - friend WAVELET_API wavelet_wavelet_ff_sptr - wavelet_make_wavelet_ff(int size, - int order, - bool forward); - - wavelet_wavelet_ff(int size, - int order, - bool forward); - -public: - ~wavelet_wavelet_ff(); - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + // No public API methods visible }; #endif /* INCLUDED_WAVELET_WAVELET_FF_H */ diff --git a/gr-wavelet/include/wavelet/wavelet_wvps_ff.h b/gr-wavelet/include/wavelet/wavelet_wvps_ff.h index ec6ed0c34..061f42323 100644 --- a/gr-wavelet/include/wavelet/wavelet_wvps_ff.h +++ b/gr-wavelet/include/wavelet/wavelet_wvps_ff.h @@ -36,22 +36,9 @@ wavelet_make_wvps_ff(int ilen); * \brief computes the Wavelet Power Spectrum from a set of wavelet coefficients * \ingroup wavelet_blk */ -class WAVELET_API wavelet_wvps_ff : public gr_sync_block +class WAVELET_API wavelet_wvps_ff : virtual public gr_sync_block { - friend WAVELET_API wavelet_wvps_ff_sptr - wavelet_make_wvps_ff(int ilen); - - int d_ilen; - int d_olen; - - protected: - wavelet_wvps_ff(int ilen); - - public: - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - + // No public API methods visible }; #endif /* INCLUDED_WAVELET_WVPS_FF_H */ diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt index 51a5d3989..dd5e1500d 100644 --- a/gr-wavelet/lib/CMakeLists.txt +++ b/gr-wavelet/lib/CMakeLists.txt @@ -23,6 +23,7 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${GR_WAVELET_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) @@ -36,9 +37,9 @@ link_directories(${Boost_LIBRARY_DIRS}) # Setup library ######################################################################## list(APPEND gr_wavelet_sources - wavelet_squash_ff.cc - wavelet_wavelet_ff.cc - wavelet_wvps_ff.cc + wavelet_squash_ff_impl.cc + wavelet_wavelet_ff_impl.cc + wavelet_wvps_ff_impl.cc ) list(APPEND wavelet_libs diff --git a/gr-wavelet/lib/wavelet_squash_ff.cc b/gr-wavelet/lib/wavelet_squash_ff.cc deleted file mode 100644 index 9316d34fe..000000000 --- a/gr-wavelet/lib/wavelet_squash_ff.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 -#include -#include - -// expect input vector of igrid.size y-values, -// produce output vector of ogrid.size y-values - -wavelet_squash_ff_sptr -wavelet_make_squash_ff(const std::vector &igrid, - const std::vector &ogrid) -{ - return gnuradio::get_initial_sptr(new wavelet_squash_ff(igrid, ogrid)); -} - -wavelet_squash_ff::wavelet_squash_ff(const std::vector &igrid, - const std::vector &ogrid) - : gr_sync_block("squash_ff", - gr_make_io_signature(1, 1, sizeof(float) * igrid.size()), - gr_make_io_signature(1, 1, sizeof(float) * ogrid.size())) -{ - d_inum = igrid.size(); - d_onum = ogrid.size(); - d_igrid = (double *) malloc(d_inum * sizeof(double)); - d_iwork = (double *) malloc(d_inum * sizeof(double)); - d_ogrid = (double *) malloc(d_onum * sizeof(double)); - for (unsigned int i = 0; i < d_inum; i++) - d_igrid[i] = igrid[i]; - for (unsigned int i = 0; i < d_onum; i++) - d_ogrid[i] = ogrid[i]; - - d_accel = gsl_interp_accel_alloc(); - d_spline = gsl_spline_alloc(gsl_interp_cspline, d_inum); // FIXME check w/ Frank -} - -wavelet_squash_ff::~wavelet_squash_ff() -{ - free((char *) d_igrid); - free((char *) d_iwork); - free((char *) d_ogrid); - gsl_interp_accel_free(d_accel); - gsl_spline_free(d_spline); -} - -int -wavelet_squash_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - for (int count = 0; count < noutput_items; count++) { - - for (unsigned int i = 0; i < d_inum; i++) - d_iwork[i] = in[i]; - - gsl_spline_init(d_spline, d_igrid, d_iwork, d_inum); - - for (unsigned int i = 0; i < d_onum; i++) - out[i] = gsl_spline_eval(d_spline, d_ogrid[i], d_accel); - - in += d_inum; - out += d_onum; - } - - return noutput_items; -} diff --git a/gr-wavelet/lib/wavelet_squash_ff_impl.cc b/gr-wavelet/lib/wavelet_squash_ff_impl.cc new file mode 100644 index 000000000..23f1a5e2f --- /dev/null +++ b/gr-wavelet/lib/wavelet_squash_ff_impl.cc @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 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 +#include +#include + +// expect input vector of igrid.size y-values, +// produce output vector of ogrid.size y-values + +wavelet_squash_ff_sptr +wavelet_make_squash_ff(const std::vector &igrid, + const std::vector &ogrid) +{ + return gnuradio::get_initial_sptr(new wavelet_squash_ff_impl(igrid, ogrid)); +} + +wavelet_squash_ff_impl::wavelet_squash_ff_impl(const std::vector &igrid, + const std::vector &ogrid) + : gr_sync_block("squash_ff", + gr_make_io_signature(1, 1, sizeof(float) * igrid.size()), + gr_make_io_signature(1, 1, sizeof(float) * ogrid.size())) +{ + d_inum = igrid.size(); + d_onum = ogrid.size(); + d_igrid = (double *) malloc(d_inum * sizeof(double)); + d_iwork = (double *) malloc(d_inum * sizeof(double)); + d_ogrid = (double *) malloc(d_onum * sizeof(double)); + for (unsigned int i = 0; i < d_inum; i++) + d_igrid[i] = igrid[i]; + for (unsigned int i = 0; i < d_onum; i++) + d_ogrid[i] = ogrid[i]; + + d_accel = gsl_interp_accel_alloc(); + d_spline = gsl_spline_alloc(gsl_interp_cspline, d_inum); // FIXME check w/ Frank +} + +wavelet_squash_ff_impl::~wavelet_squash_ff_impl() +{ + free((char *) d_igrid); + free((char *) d_iwork); + free((char *) d_ogrid); + gsl_interp_accel_free(d_accel); + gsl_spline_free(d_spline); +} + +int +wavelet_squash_ff_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + for (int count = 0; count < noutput_items; count++) { + + for (unsigned int i = 0; i < d_inum; i++) + d_iwork[i] = in[i]; + + gsl_spline_init(d_spline, d_igrid, d_iwork, d_inum); + + for (unsigned int i = 0; i < d_onum; i++) + out[i] = gsl_spline_eval(d_spline, d_ogrid[i], d_accel); + + in += d_inum; + out += d_onum; + } + + return noutput_items; +} diff --git a/gr-wavelet/lib/wavelet_squash_ff_impl.h b/gr-wavelet/lib/wavelet_squash_ff_impl.h new file mode 100644 index 000000000..806f13e40 --- /dev/null +++ b/gr-wavelet/lib/wavelet_squash_ff_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,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_WAVELET_SQUASH_FF_IMPL_H +#define INCLUDED_WAVELET_SQUASH_FF_IMPL_H + +#include +#include +#include +#include +#include + +class WAVELET_API wavelet_squash_ff_impl : public wavelet_squash_ff +{ + size_t d_inum; + size_t d_onum; + double *d_igrid; + double *d_iwork; + double *d_ogrid; + + gsl_interp_accel *d_accel; + gsl_spline *d_spline; + + wavelet_squash_ff_impl(const std::vector &igrid, + const std::vector &ogrid); + + friend WAVELET_API wavelet_squash_ff_sptr + wavelet_make_squash_ff(const std::vector &igrid, + const std::vector &ogrid); + + public: + ~wavelet_squash_ff_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_WAVELET_WAVELET_FF_IMPL_H */ diff --git a/gr-wavelet/lib/wavelet_wavelet_ff.cc b/gr-wavelet/lib/wavelet_wavelet_ff.cc deleted file mode 100644 index 3f4354f31..000000000 --- a/gr-wavelet/lib/wavelet_wavelet_ff.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 tewavelet 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 -#include -#include - -#include - -// NB in this version, only Daubechies wavelets -// order is wavelet length, even, 2...20 - -wavelet_wavelet_ff_sptr -wavelet_make_wavelet_ff(int size, - int order, - bool forward) -{ - return gnuradio::get_initial_sptr(new wavelet_wavelet_ff(size, order, forward)); -} - -wavelet_wavelet_ff::wavelet_wavelet_ff(int size, int order, bool forward) - : gr_sync_block("wavelet_ff", - gr_make_io_signature(1, 1, size * sizeof(float)), - gr_make_io_signature(1, 1, size * sizeof(float))), - d_size(size), - d_order(order), - d_forward(forward) -{ - d_wavelet = gsl_wavelet_alloc(gsl_wavelet_daubechies, d_order); - if (d_wavelet == NULL) - throw std::runtime_error("can't allocate wavelet"); - d_workspace = gsl_wavelet_workspace_alloc(d_size); - if (d_workspace == NULL) - throw std::runtime_error("can't allocate wavelet workspace"); - d_temp = (double *) malloc(d_size*sizeof(double)); - if (d_workspace == NULL) - throw std::runtime_error("can't allocate wavelet double conversion temp"); -} - -wavelet_wavelet_ff::~wavelet_wavelet_ff() -{ - gsl_wavelet_free(d_wavelet); - gsl_wavelet_workspace_free(d_workspace); - free((char *) d_temp); -} - -int -wavelet_wavelet_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - for (int count = 0; count < noutput_items; count++) { - for (int i = 0; i < d_size; i++) - d_temp[i] = in[i]; - - if (d_forward) - gsl_wavelet_transform_forward(d_wavelet, - d_temp, - 1, - d_size, - d_workspace); - else - gsl_wavelet_transform_inverse(d_wavelet, - d_temp, - 1, - d_size, - d_workspace); - - for (int i = 0; i < d_size; i++) - out[i] = d_temp[i]; - - in += d_size; - out += d_size; - } - - return noutput_items; -} diff --git a/gr-wavelet/lib/wavelet_wavelet_ff_impl.cc b/gr-wavelet/lib/wavelet_wavelet_ff_impl.cc new file mode 100644 index 000000000..719f4b53f --- /dev/null +++ b/gr-wavelet/lib/wavelet_wavelet_ff_impl.cc @@ -0,0 +1,103 @@ +/* -*- c++ -*- */ +/* + * Copyright 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 tewavelet 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 +#include +#include + +#include + +// NB in this version, only Daubechies wavelets +// order is wavelet length, even, 2...20 + +wavelet_wavelet_ff_sptr +wavelet_make_wavelet_ff(int size, + int order, + bool forward) +{ + return gnuradio::get_initial_sptr(new wavelet_wavelet_ff_impl(size, order, forward)); +} + +wavelet_wavelet_ff_impl::wavelet_wavelet_ff_impl(int size, int order, bool forward) + : gr_sync_block("wavelet_ff", + gr_make_io_signature(1, 1, size * sizeof(float)), + gr_make_io_signature(1, 1, size * sizeof(float))), + d_size(size), + d_order(order), + d_forward(forward) +{ + d_wavelet = gsl_wavelet_alloc(gsl_wavelet_daubechies, d_order); + if (d_wavelet == NULL) + throw std::runtime_error("can't allocate wavelet"); + d_workspace = gsl_wavelet_workspace_alloc(d_size); + if (d_workspace == NULL) + throw std::runtime_error("can't allocate wavelet workspace"); + d_temp = (double *) malloc(d_size*sizeof(double)); + if (d_workspace == NULL) + throw std::runtime_error("can't allocate wavelet double conversion temp"); +} + +wavelet_wavelet_ff_impl::~wavelet_wavelet_ff_impl() +{ + gsl_wavelet_free(d_wavelet); + gsl_wavelet_workspace_free(d_workspace); + free((char *) d_temp); +} + +int +wavelet_wavelet_ff_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + for (int count = 0; count < noutput_items; count++) { + for (int i = 0; i < d_size; i++) + d_temp[i] = in[i]; + + if (d_forward) + gsl_wavelet_transform_forward(d_wavelet, + d_temp, + 1, + d_size, + d_workspace); + else + gsl_wavelet_transform_inverse(d_wavelet, + d_temp, + 1, + d_size, + d_workspace); + + for (int i = 0; i < d_size; i++) + out[i] = d_temp[i]; + + in += d_size; + out += d_size; + } + + return noutput_items; +} diff --git a/gr-wavelet/lib/wavelet_wavelet_ff_impl.h b/gr-wavelet/lib/wavelet_wavelet_ff_impl.h new file mode 100644 index 000000000..8ad3ef0bf --- /dev/null +++ b/gr-wavelet/lib/wavelet_wavelet_ff_impl.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,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_WAVELET_WAVELET_FF_IMPL_H +#define INCLUDED_WAVELET_WAVELET_FF_IMPL_H + +#include +#include +#include + +class WAVELET_API wavelet_wavelet_ff_impl : public wavelet_wavelet_ff +{ + int d_size; + int d_order; + bool d_forward; + gsl_wavelet *d_wavelet; + gsl_wavelet_workspace *d_workspace; + double *d_temp; + + friend WAVELET_API wavelet_wavelet_ff_sptr + wavelet_make_wavelet_ff(int size, + int order, + bool forward); + + wavelet_wavelet_ff_impl(int size, + int order, + bool forward); + +public: + ~wavelet_wavelet_ff_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_WAVELET_WAVELET_FF_IMPL_H */ diff --git a/gr-wavelet/lib/wavelet_wvps_ff.cc b/gr-wavelet/lib/wavelet_wvps_ff.cc deleted file mode 100644 index 5edc43496..000000000 --- a/gr-wavelet/lib/wavelet_wvps_ff.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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 -#include -#include - -static int -ceil_log2(int k) -{ - int m = 0; - for (int n = k-1; n > 0; n >>= 1) m++; - return m; -} - -wavelet_wvps_ff_sptr -wavelet_make_wvps_ff(int ilen) -{ - return gnuradio::get_initial_sptr(new wavelet_wvps_ff(ilen)); -} - -wavelet_wvps_ff::wavelet_wvps_ff(int ilen) - : gr_sync_block("wvps_ff", - gr_make_io_signature(1, 1, sizeof(float) * ilen), - gr_make_io_signature(1, 1, sizeof(float) * ceil_log2(ilen))), - d_ilen(ilen), d_olen(ceil_log2(ilen)) -{ -} - -// input vector assumed to be output from gsl wavelet computation - -int -wavelet_wvps_ff::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; - - for (int count = 0; count < noutput_items; count++) { - - // any power? - - if (in[0] == 0.0) { - for (int i = 0; i < d_olen; i++) - out[i] = 0.0; - - } else { - - // get power normalization from 0-th wavelet coefficient - - float scl = 1.0/(in[0]*in[0]); - int k = 1; - - // sum powers over sequences of bins, - // sequence lengths in increasing powers of 2 - - for (int e = 0; e < d_olen; e++) { - int m = 01< +#include +#include + +static int +ceil_log2(int k) +{ + int m = 0; + for (int n = k-1; n > 0; n >>= 1) m++; + return m; +} + +wavelet_wvps_ff_sptr +wavelet_make_wvps_ff(int ilen) +{ + return gnuradio::get_initial_sptr(new wavelet_wvps_ff_impl(ilen)); +} + +wavelet_wvps_ff_impl::wavelet_wvps_ff_impl(int ilen) + : gr_sync_block("wvps_ff", + gr_make_io_signature(1, 1, sizeof(float) * ilen), + gr_make_io_signature(1, 1, sizeof(float) * ceil_log2(ilen))), + d_ilen(ilen), d_olen(ceil_log2(ilen)) +{ +} + +// input vector assumed to be output from gsl wavelet computation + +int +wavelet_wvps_ff_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + for (int count = 0; count < noutput_items; count++) { + + // any power? + + if (in[0] == 0.0) { + for (int i = 0; i < d_olen; i++) + out[i] = 0.0; + + } else { + + // get power normalization from 0-th wavelet coefficient + + float scl = 1.0/(in[0]*in[0]); + int k = 1; + + // sum powers over sequences of bins, + // sequence lengths in increasing powers of 2 + + for (int e = 0; e < d_olen; e++) { + int m = 01< + +class WAVELET_API wavelet_wvps_ff_impl : public wavelet_wvps_ff +{ + int d_ilen; + int d_olen; + + friend WAVELET_API wavelet_wvps_ff_sptr + wavelet_make_wvps_ff(int ilen); + + wavelet_wvps_ff_impl(int ilen); + + public: + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_WAVELET_WVPS_FF_IMPL_H */ -- cgit