summaryrefslogtreecommitdiff
path: root/gr-wavelet
diff options
context:
space:
mode:
authorJohnathan Corgan <jcorgan@corganenterprises.com>2012-04-13 23:04:06 -0700
committerJohnathan Corgan <jcorgan@corganenterprises.com>2012-04-21 13:20:39 -0700
commit9d56b9ba3b006e70f442001b54c66bcdb891a3b4 (patch)
tree2ca3379f5e5b714e16a363f07db7553559df7d7e /gr-wavelet
parente717c7caeb04047c502f1447b0ea8be3dc4e8579 (diff)
wavelet: transition to namespace C++ API
Diffstat (limited to 'gr-wavelet')
-rw-r--r--gr-wavelet/CMakeLists.txt2
-rw-r--r--gr-wavelet/include/wavelet/CMakeLists.txt12
-rw-r--r--gr-wavelet/include/wavelet/api.h (renamed from gr-wavelet/include/wavelet/wavelet_api.h)0
-rw-r--r--gr-wavelet/include/wavelet/squash_ff.h (renamed from gr-wavelet/include/wavelet/wavelet_squash_ff.h)34
-rw-r--r--gr-wavelet/include/wavelet/wavelet_ff.h (renamed from gr-wavelet/include/wavelet/wavelet_wavelet_ff.h)35
-rw-r--r--gr-wavelet/include/wavelet/wvps_ff.h (renamed from gr-wavelet/include/wavelet/wavelet_wvps_ff.h)31
-rw-r--r--gr-wavelet/lib/CMakeLists.txt6
-rw-r--r--gr-wavelet/lib/squash_ff_impl.cc98
-rw-r--r--gr-wavelet/lib/squash_ff_impl.h (renamed from gr-wavelet/lib/wavelet_squash_ff_impl.h)56
-rw-r--r--gr-wavelet/lib/wavelet_ff_impl.cc110
-rw-r--r--gr-wavelet/lib/wavelet_ff_impl.h (renamed from gr-wavelet/lib/wavelet_wavelet_ff_impl.h)53
-rw-r--r--gr-wavelet/lib/wavelet_squash_ff_impl.cc93
-rw-r--r--gr-wavelet/lib/wavelet_wavelet_ff_impl.cc103
-rw-r--r--gr-wavelet/lib/wavelet_wvps_ff_impl.cc98
-rw-r--r--gr-wavelet/lib/wvps_ff_impl.cc103
-rw-r--r--gr-wavelet/lib/wvps_ff_impl.h (renamed from gr-wavelet/lib/wavelet_wvps_ff_impl.h)29
-rw-r--r--gr-wavelet/swig/wavelet_swig.i24
17 files changed, 461 insertions, 426 deletions
diff --git a/gr-wavelet/CMakeLists.txt b/gr-wavelet/CMakeLists.txt
index 555c326d11..a488c47e91 100644
--- a/gr-wavelet/CMakeLists.txt
+++ b/gr-wavelet/CMakeLists.txt
@@ -37,7 +37,7 @@ GR_REGISTER_COMPONENT("gr-wavelet" ENABLE_GR_WAVELET
GR_SET_GLOBAL(GR_WAVELET_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/lib
- ${CMAKE_CURRENT_SOURCE_DIR}/include/wavelet
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
)
########################################################################
diff --git a/gr-wavelet/include/wavelet/CMakeLists.txt b/gr-wavelet/include/wavelet/CMakeLists.txt
index a37a3b0cd8..43c1603d15 100644
--- a/gr-wavelet/include/wavelet/CMakeLists.txt
+++ b/gr-wavelet/include/wavelet/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -21,11 +21,11 @@
# Install header files
########################################################################
install(FILES
- wavelet_api.h
- wavelet_squash_ff.h
- wavelet_wavelet_ff.h
- wavelet_wvps_ff.h
- DESTINATION ${GR_INCLUDE_DIR}/gnuradio
+ api.h
+ squash_ff.h
+ wavelet_ff.h
+ wvps_ff.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/wavelet
COMPONENT "wavelet_devel"
)
diff --git a/gr-wavelet/include/wavelet/wavelet_api.h b/gr-wavelet/include/wavelet/api.h
index 68b2c04d78..68b2c04d78 100644
--- a/gr-wavelet/include/wavelet/wavelet_api.h
+++ b/gr-wavelet/include/wavelet/api.h
diff --git a/gr-wavelet/include/wavelet/wavelet_squash_ff.h b/gr-wavelet/include/wavelet/squash_ff.h
index 5824969162..4d1aeb3c3c 100644
--- a/gr-wavelet/include/wavelet/wavelet_squash_ff.h
+++ b/gr-wavelet/include/wavelet/squash_ff.h
@@ -23,23 +23,29 @@
#ifndef INCLUDED_WAVELET_SQUASH_FF_H
#define INCLUDED_WAVELET_SQUASH_FF_H
-#include <wavelet_api.h>
+#include <wavelet/api.h>
#include <gr_sync_block.h>
-/*!
- * \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> wavelet_squash_ff_sptr;
+namespace gr {
+ namespace wavelet {
-WAVELET_API wavelet_squash_ff_sptr wavelet_make_squash_ff(const std::vector<float> &igrid,
- const std::vector<float> &ogrid);
+ class WAVELET_API squash_ff : virtual public gr_sync_block
+ {
+ public:
+
+ // gr::wavelet::squash_ff::sptr
+ typedef boost::shared_ptr<squash_ff> sptr;
+
+ /*!
+ * \brief implements cheap resampling of spectrum directly from
+ * spectral points, using gsl interpolation
+ * \ingroup misc
+ */
+ static WAVELET_API sptr make(const std::vector<float> &igrid,
+ const std::vector<float> &ogrid);
+ };
-class WAVELET_API wavelet_squash_ff : virtual public gr_sync_block
-{
- // No public API methods visible
-};
+ } /* namespace wavelet */
+} /* namespace gr */
#endif
diff --git a/gr-wavelet/include/wavelet/wavelet_wavelet_ff.h b/gr-wavelet/include/wavelet/wavelet_ff.h
index 7d60dbdad1..71e959f88a 100644
--- a/gr-wavelet/include/wavelet/wavelet_wavelet_ff.h
+++ b/gr-wavelet/include/wavelet/wavelet_ff.h
@@ -19,28 +19,33 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
+
#ifndef INCLUDED_WAVELET_WAVELET_FF_H
#define INCLUDED_WAVELET_WAVELET_FF_H
-#include <wavelet_api.h>
+#include <wavelet/api.h>
#include <gr_sync_block.h>
-class wavelet_wavelet_ff;
-typedef boost::shared_ptr<wavelet_wavelet_ff> wavelet_wavelet_ff_sptr;
+namespace gr {
+ namespace wavelet {
-WAVELET_API wavelet_wavelet_ff_sptr
-wavelet_make_wavelet_ff(int size = 1024,
- int order = 20,
- bool forward = true);
+ class WAVELET_API wavelet_ff : virtual public gr_sync_block
+ {
+ public:
-/*!
- * \brief compute wavelet transform using gsl routines
- * \ingroup wavelet_blk
- */
+ // gr::wavelet::wavelet_ff:sptr
+ typedef boost::shared_ptr<wavelet_ff> sptr;
+
+ /*!
+ * \brief compute wavelet transform using gsl routines
+ * \ingroup wavelet_blk
+ */
+ static WAVELET_API sptr make(int size = 1024,
+ int order = 20,
+ bool forward = true);
+ };
-class WAVELET_API wavelet_wavelet_ff : virtual public gr_sync_block
-{
- // No public API methods visible
-};
+ } /* namespace wavelet */
+} /* namespace gr */
#endif /* INCLUDED_WAVELET_WAVELET_FF_H */
diff --git a/gr-wavelet/include/wavelet/wavelet_wvps_ff.h b/gr-wavelet/include/wavelet/wvps_ff.h
index 4e2889b52a..8b955db65f 100644
--- a/gr-wavelet/include/wavelet/wavelet_wvps_ff.h
+++ b/gr-wavelet/include/wavelet/wvps_ff.h
@@ -23,22 +23,29 @@
#ifndef INCLUDED_WAVELET_WVPS_FF_H
#define INCLUDED_WAVELET_WVPS_FF_H
-#include <wavelet_api.h>
+#include <wavelet/api.h>
#include <gr_sync_decimator.h>
class wavelet_wvps_ff;
-typedef boost::shared_ptr<wavelet_wvps_ff> wavelet_wvps_ff_sptr;
-WAVELET_API wavelet_wvps_ff_sptr
-wavelet_make_wvps_ff(int ilen);
+namespace gr {
+ namespace wavelet {
-/*!
- * \brief computes the Wavelet Power Spectrum from a set of wavelet coefficients
- * \ingroup wavelet_blk
- */
-class WAVELET_API wavelet_wvps_ff : virtual public gr_sync_block
-{
- // No public API methods visible
-};
+ class WAVELET_API wvps_ff : virtual public gr_sync_block
+ {
+ public:
+
+ // gr::wavelet::wvps_ff::sptr
+ typedef boost::shared_ptr<wvps_ff> sptr;
+
+ /*!
+ * \brief computes the Wavelet Power Spectrum from a set of wavelet coefficients
+ * \ingroup wavelet_blk
+ */
+ static WAVELET_API sptr make(int ilen);
+ };
+
+ } /* namespace wavelet */
+} /* namespace gr */
#endif /* INCLUDED_WAVELET_WVPS_FF_H */
diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt
index f0d9068b75..76da7e5347 100644
--- a/gr-wavelet/lib/CMakeLists.txt
+++ b/gr-wavelet/lib/CMakeLists.txt
@@ -40,9 +40,9 @@ link_directories(${GSL_LIBRARY_DIRS})
# Setup library
########################################################################
list(APPEND gr_wavelet_sources
- wavelet_squash_ff_impl.cc
- wavelet_wavelet_ff_impl.cc
- wavelet_wvps_ff_impl.cc
+ squash_ff_impl.cc
+ wavelet_ff_impl.cc
+ wvps_ff_impl.cc
)
list(APPEND wavelet_libs
diff --git a/gr-wavelet/lib/squash_ff_impl.cc b/gr-wavelet/lib/squash_ff_impl.cc
new file mode 100644
index 0000000000..081ac900f5
--- /dev/null
+++ b/gr-wavelet/lib/squash_ff_impl.cc
@@ -0,0 +1,98 @@
+/* -*- 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 <stdexcept>
+#include <squash_ff_impl.h>
+#include <gr_io_signature.h>
+
+// expect input vector of igrid.size y-values,
+// produce output vector of ogrid.size y-values
+
+namespace gr {
+ namespace wavelet {
+
+ squash_ff::sptr squash_ff::make(const std::vector<float> &igrid,
+ const std::vector<float> &ogrid)
+ {
+ return gnuradio::get_initial_sptr(new squash_ff_impl(igrid, ogrid));
+ }
+
+ squash_ff_impl::squash_ff_impl(const std::vector<float> &igrid,
+ const std::vector<float> &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
+ }
+
+ squash_ff_impl::~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
+ 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;
+ }
+
+ } /* namespace wavelet */
+} /* namespace gr */
diff --git a/gr-wavelet/lib/wavelet_squash_ff_impl.h b/gr-wavelet/lib/squash_ff_impl.h
index dac50ddf2a..b6ddb45363 100644
--- a/gr-wavelet/lib/wavelet_squash_ff_impl.h
+++ b/gr-wavelet/lib/squash_ff_impl.h
@@ -23,36 +23,38 @@
#ifndef INCLUDED_WAVELET_SQUASH_FF_IMPL_H
#define INCLUDED_WAVELET_SQUASH_FF_IMPL_H
-#include <wavelet_api.h>
-#include <wavelet_squash_ff.h>
+#include <wavelet/api.h>
+#include <wavelet/squash_ff.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_interp.h>
#include <gsl/gsl_spline.h>
-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<float> &igrid,
- const std::vector<float> &ogrid);
-
- friend WAVELET_API wavelet_squash_ff_sptr
- wavelet_make_squash_ff(const std::vector<float> &igrid,
- const std::vector<float> &ogrid);
-
- public:
- ~wavelet_squash_ff_impl();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
+namespace gr {
+ namespace wavelet {
+
+ class WAVELET_API squash_ff_impl : public 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;
+
+ public:
+ squash_ff_impl(const std::vector<float> &igrid,
+ const std::vector<float> &ogrid);
+
+ ~squash_ff_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace wavelet */
+} /* namespace gr */
#endif /* INCLUDED_WAVELET_WAVELET_FF_IMPL_H */
diff --git a/gr-wavelet/lib/wavelet_ff_impl.cc b/gr-wavelet/lib/wavelet_ff_impl.cc
new file mode 100644
index 0000000000..73fc8c5440
--- /dev/null
+++ b/gr-wavelet/lib/wavelet_ff_impl.cc
@@ -0,0 +1,110 @@
+/* -*- 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 <stdexcept>
+#include <wavelet_ff_impl.h>
+#include <gr_io_signature.h>
+
+#include <stdio.h>
+
+// NB in this version, only Daubechies wavelets
+// order is wavelet length, even, 2...20
+
+namespace gr {
+ namespace wavelet {
+
+ wavelet_ff::sptr wavelet_ff::make(int size,
+ int order,
+ bool forward)
+ {
+ return gnuradio::get_initial_sptr(new wavelet_ff_impl(size, order, forward));
+ }
+
+ wavelet_ff_impl::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_ff_impl::~wavelet_ff_impl()
+ {
+ gsl_wavelet_free(d_wavelet);
+ gsl_wavelet_workspace_free(d_workspace);
+ free((char *) d_temp);
+ }
+
+ int
+ 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;
+ }
+
+ } /* namespace wavelet */
+} /* namespace gr */
diff --git a/gr-wavelet/lib/wavelet_wavelet_ff_impl.h b/gr-wavelet/lib/wavelet_ff_impl.h
index dc33a4184e..bec3935f33 100644
--- a/gr-wavelet/lib/wavelet_wavelet_ff_impl.h
+++ b/gr-wavelet/lib/wavelet_ff_impl.h
@@ -22,34 +22,35 @@
#ifndef INCLUDED_WAVELET_WAVELET_FF_IMPL_H
#define INCLUDED_WAVELET_WAVELET_FF_IMPL_H
-#include <wavelet_wavelet_ff.h>
+#include <wavelet/wavelet_ff.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_wavelet.h>
-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);
-};
+namespace gr {
+ namespace wavelet {
+
+ class WAVELET_API wavelet_ff_impl : public wavelet_ff
+ {
+ int d_size;
+ int d_order;
+ bool d_forward;
+ gsl_wavelet *d_wavelet;
+ gsl_wavelet_workspace *d_workspace;
+ double *d_temp;
+
+ public:
+ wavelet_ff_impl(int size,
+ int order,
+ bool forward);
+
+ ~wavelet_ff_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace wavelet */
+} /* namespace gr */
#endif /* INCLUDED_WAVELET_WAVELET_FF_IMPL_H */
diff --git a/gr-wavelet/lib/wavelet_squash_ff_impl.cc b/gr-wavelet/lib/wavelet_squash_ff_impl.cc
deleted file mode 100644
index 89494a9c39..0000000000
--- a/gr-wavelet/lib/wavelet_squash_ff_impl.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 <stdexcept>
-#include <wavelet_squash_ff_impl.h>
-#include <gr_io_signature.h>
-
-// 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<float> &igrid,
- const std::vector<float> &ogrid)
-{
- return gnuradio::get_initial_sptr(new wavelet_squash_ff_impl(igrid, ogrid));
-}
-
-wavelet_squash_ff_impl::wavelet_squash_ff_impl(const std::vector<float> &igrid,
- const std::vector<float> &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_wavelet_ff_impl.cc b/gr-wavelet/lib/wavelet_wavelet_ff_impl.cc
deleted file mode 100644
index ccc1a6d8f7..0000000000
--- a/gr-wavelet/lib/wavelet_wavelet_ff_impl.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 <stdexcept>
-#include <wavelet_wavelet_ff_impl.h>
-#include <gr_io_signature.h>
-
-#include <stdio.h>
-
-// 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_wvps_ff_impl.cc b/gr-wavelet/lib/wavelet_wvps_ff_impl.cc
deleted file mode 100644
index b86859b0ae..0000000000
--- a/gr-wavelet/lib/wavelet_wvps_ff_impl.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 <wavelet_wvps_ff_impl.h>
-#include <gr_io_signature.h>
-#include <string.h>
-
-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<<e;
- float sum = 0.0;
-
- for (int l = 0; l < m; l++)
- sum += (in[k+l]*in[k+l]);
-
- out[e] = scl*sum;
- k += m;
- }
- }
-
- in += d_ilen;
- out += d_olen;
- }
-
- return noutput_items;
-}
diff --git a/gr-wavelet/lib/wvps_ff_impl.cc b/gr-wavelet/lib/wvps_ff_impl.cc
new file mode 100644
index 0000000000..6e886bff4e
--- /dev/null
+++ b/gr-wavelet/lib/wvps_ff_impl.cc
@@ -0,0 +1,103 @@
+/* -*- 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 <wvps_ff_impl.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+namespace gr {
+ namespace wavelet {
+
+ static int
+ ceil_log2(int k)
+ {
+ int m = 0;
+ for (int n = k-1; n > 0; n >>= 1) m++;
+ return m;
+ }
+
+ wvps_ff::sptr wvps_ff::make(int ilen)
+ {
+ return gnuradio::get_initial_sptr(new wvps_ff_impl(ilen));
+ }
+
+ wvps_ff_impl::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
+ 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<<e;
+ float sum = 0.0;
+
+ for (int l = 0; l < m; l++)
+ sum += (in[k+l]*in[k+l]);
+
+ out[e] = scl*sum;
+ k += m;
+ }
+ }
+
+ in += d_ilen;
+ out += d_olen;
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace wavelet */
+} /* namespace gr */
diff --git a/gr-wavelet/lib/wavelet_wvps_ff_impl.h b/gr-wavelet/lib/wvps_ff_impl.h
index 553469fde9..ab64395d24 100644
--- a/gr-wavelet/lib/wavelet_wvps_ff_impl.h
+++ b/gr-wavelet/lib/wvps_ff_impl.h
@@ -23,22 +23,25 @@
#ifndef INCLUDED_WAVELET_WVPS_FF_IMPL_H
#define INCLUDED_WAVELET_WVPS_FF_IMPL_H
-#include <wavelet_wvps_ff.h>
+#include <wavelet/wvps_ff.h>
-class WAVELET_API wavelet_wvps_ff_impl : public wavelet_wvps_ff
-{
- int d_ilen;
- int d_olen;
+namespace gr {
+ namespace wavelet {
- friend WAVELET_API wavelet_wvps_ff_sptr
- wavelet_make_wvps_ff(int ilen);
+ class WAVELET_API wvps_ff_impl : public wvps_ff
+ {
+ int d_ilen;
+ int d_olen;
- wavelet_wvps_ff_impl(int ilen);
+ public:
+ wvps_ff_impl(int ilen);
- public:
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace wavelet */
+}/* namespace gr */
#endif /* INCLUDED_WAVELET_WVPS_FF_IMPL_H */
diff --git a/gr-wavelet/swig/wavelet_swig.i b/gr-wavelet/swig/wavelet_swig.i
index b04efc508d..40fe3f9b5e 100644
--- a/gr-wavelet/swig/wavelet_swig.i
+++ b/gr-wavelet/swig/wavelet_swig.i
@@ -28,21 +28,15 @@
%include "wavelet_swig_doc.i"
%{
-#include "wavelet_squash_ff.h"
-#include "wavelet_wavelet_ff.h"
-#include "wavelet_wvps_ff.h"
+#include "wavelet/squash_ff.h"
+#include "wavelet/wavelet_ff.h"
+#include "wavelet/wvps_ff.h"
%}
-%include "wavelet_squash_ff.h"
-%include "wavelet_wavelet_ff.h"
-%include "wavelet_wvps_ff.h"
+%include "wavelet/squash_ff.h"
+%include "wavelet/wavelet_ff.h"
+%include "wavelet/wvps_ff.h"
-GR_SWIG_BLOCK_MAGIC(wavelet,squash_ff);
-wavelet_squash_ff_sptr wavelet_make_squash_ff(const std::vector<float> &igrid,
- const std::vector<float> &ogrid);
-
-GR_SWIG_BLOCK_MAGIC(wavelet,wavelet_ff);
-wavelet_wavelet_ff_sptr wavelet_make_wavelet_ff(int size, int order, bool forward);
-
-GR_SWIG_BLOCK_MAGIC(wavelet,wvps_ff);
-wavelet_wvps_ff_sptr wavelet_make_wvps_ff(int ilen);
+GR_SWIG_BLOCK_MAGIC2(wavelet, squash_ff);
+GR_SWIG_BLOCK_MAGIC2(wavelet, wavelet_ff);
+GR_SWIG_BLOCK_MAGIC2(wavelet, wvps_ff);