I got some troubles to use wavelet api from the GSL libraries. Each time i try, the program does crash. I'm using MinGW32 binaries (from gnuwin32), static version.
Here's an example (coming from the gsl doc - i just replaced the file reading part by a simple array). I had this problem with gnuwin32 binaries, AND with compiled from scratch binaries.
Any clues ?
include <stdio.h>
include <math.h>
include <gsl/gsl_sort.h>
include <gsl/gsl_wavelet.h>
int main (int argc, char argv)
{
int i,n=256,nc=20;
double data=(double)malloc(nsizeof (double));
double abscoeff = (double)malloc (n * sizeof (double));
size_t p = (size_t*)malloc (n * sizeof (size_t));
for (i=0;i<256;i++) data[i]=(double)i;
gsl_wavelet w = gsl_wavelet_alloc (gsl_wavelet_daubechies, 4);
gsl_wavelet_workspace work = gsl_wavelet_workspace_alloc (n);
gsl_wavelet_transform_forward (w, data, 1, n, work);
for (i = 0; i < n; i++)
{
abscoeff[i] = fabs (data[i]);
}
gsl_sort_index (p, abscoeff, 1, n);
for (i = 0; (i + nc) < n; i++)
data[p[i]] = 0;
gsl_wavelet_transform_inverse (w, data, 1, n, work);
for (i = 0; i < n; i++)
{
printf ("%g\n", data[i]);
}
}
Jean-Pierre Gervasoni
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I got some troubles to use wavelet api from the GSL libraries. Each time i try, the program does crash. I'm using MinGW32 binaries (from gnuwin32), static version.
Here's an example (coming from the gsl doc - i just replaced the file reading part by a simple array). I had this problem with gnuwin32 binaries, AND with compiled from scratch binaries.
Any clues ?
include <stdio.h>
include <math.h>
include <gsl/gsl_sort.h>
include <gsl/gsl_wavelet.h>
int main (int argc, char argv)
{
int i,n=256,nc=20;
double data=(double)malloc(nsizeof (double));
double abscoeff = (double)malloc (n * sizeof (double));
size_t p = (size_t*)malloc (n * sizeof (size_t));
for (i=0;i<256;i++) data[i]=(double)i;
gsl_wavelet w = gsl_wavelet_alloc (gsl_wavelet_daubechies, 4);
gsl_wavelet_workspace work = gsl_wavelet_workspace_alloc (n);
gsl_wavelet_transform_forward (w, data, 1, n, work);
for (i = 0; i < n; i++)
{
abscoeff[i] = fabs (data[i]);
}
gsl_sort_index (p, abscoeff, 1, n);
for (i = 0; (i + nc) < n; i++)
data[p[i]] = 0;
gsl_wavelet_transform_inverse (w, data, 1, n, work);
for (i = 0; i < n; i++)
{
printf ("%g\n", data[i]);
}
}
Jean-Pierre Gervasoni