20#include "../ui/error.hpp"
22#include <gsl/gsl_wavelet.h>
28 gsl_wavelet* wavelet =
nullptr;
29 gsl_wavelet_workspace* workspace =
nullptr;
31 size_t sze = 1 << (size_t)std::log2(data.size());
34 if (sze != data.size())
43 wavelet = gsl_wavelet_alloc(gsl_wavelet_haar, 2);
46 if (k < 4 || k > 20 || k % 2)
48 wavelet = gsl_wavelet_alloc(gsl_wavelet_daubechies, k);
53 wavelet = gsl_wavelet_alloc(gsl_wavelet_haar_centered, 2);
56 if (k < 4 || k > 20 || k % 2)
58 wavelet = gsl_wavelet_alloc(gsl_wavelet_daubechies_centered, k);
61 wavelet = gsl_wavelet_alloc(gsl_wavelet_haar, 2);
64 wavelet = gsl_wavelet_alloc(gsl_wavelet_haar_centered, 2);
67 if (k != 103 && k != 105 && !(k >= 202 && k <= 208 && !(k % 2)) && !(k >= 301 && k <= 309 && k % 2))
69 wavelet = gsl_wavelet_alloc(gsl_wavelet_bspline, k);
72 if (k != 103 && k != 105 && !(k >= 202 && k <= 208 && !(k % 2)) && !(k >= 301 && k <= 309 && k % 2))
74 wavelet = gsl_wavelet_alloc(gsl_wavelet_bspline_centered, k);
79 if (wavelet ==
nullptr)
85 workspace = gsl_wavelet_workspace_alloc(data.size());
89 gsl_wavelet_transform_forward(wavelet, &data[0], 1, data.size(), workspace);
91 gsl_wavelet_transform_inverse(wavelet, &data[0], 1, data.size(), workspace);
94 gsl_wavelet_free(wavelet);
95 gsl_wavelet_workspace_free(workspace);
101 int nLevels = log2(vWaveletData.size());
102 int nTimePoints = vWaveletData.size() / 2;
104 wavelet.
setSize(nTimePoints, nLevels+3);
105 double* data =
new double[nTimePoints];
106 const double* output =
nullptr;
109 for (
int i = -1; i < nLevels; i++)
116 const double* axis_out = axis.
get_line();
117 for (
int i = 0; i < nTimePoints; i++)
119 wavelet.
setValue(i, 0, axis_out[i]);
123 for (
int i = 0; i <= nLevels; i++)
128 for (
int j = 0; j < nTimePoints; j++)
130 wavelet.
setValue(j, nLevels-i+2, vWaveletData[i]);
136 for (
int k = 0; k < (1 << ((i-1))); k++)
138 data[k] = vWaveletData[(1 << (i-1))+k];
146 for (
int j = 0; j < nTimePoints; j++)
148 wavelet.
setValue(j, nLevels-i+2, output[j]);
This data container is a copy- efficient table to interchange data between Kernel and GUI.
void setValue(size_t i, size_t j, const mu::value_type &_dValue)
This member function sets the data to the table. It will resize the table automatically,...
void setSize(size_t i, size_t j)
This member function simply redirects the control to setMinSize().
const Sample * get_line()
bool put_line(const Sample *Psrc)
Common exception class for all exceptions thrown in NumeRe.
@ INVALID_WAVELET_COEFFICIENT
static size_t invalid_position
void calculateWavelet(std::vector< double > &data, WaveletType _type, int k, int dir)
NumeRe::Table decodeWaveletData(const std::vector< double > &vWaveletData, const std::vector< double > &vAxisData)