summaryrefslogtreecommitdiff
path: root/gr-wavelet/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-wavelet/lib')
-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
10 files changed, 386 insertions, 363 deletions
diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt
index 9594f6a6ac..2d4382b765 100644
--- a/gr-wavelet/lib/CMakeLists.txt
+++ b/gr-wavelet/lib/CMakeLists.txt
@@ -38,9 +38,9 @@ add_definitions(${GSL_DEFINITIONS})
# 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 */