3 * Copyright (C) 2004 Ivo Alxneit
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <gsl/gsl_errno.h>
23 #include <gsl/gsl_wavelet.h>
26 gsl_wavelet_alloc (const gsl_wavelet_type * T, size_t k)
30 gsl_wavelet *w = (gsl_wavelet *) malloc (sizeof (gsl_wavelet));
34 GSL_ERROR_VAL ("failed to allocate space for wavelet struct",
40 status = (T->init) (&(w->h1), &(w->g1), &(w->h2), &(w->g2),
41 &(w->nc), &(w->offset), k);
46 GSL_ERROR_VAL ("invalid wavelet member", GSL_EINVAL, 0);
53 gsl_wavelet_free (gsl_wavelet * w)
59 gsl_wavelet_name (const gsl_wavelet * w)
65 /* Let's not export this for now (BJG) */
68 gsl_wavelet_print (const gsl_wavelet * w)
73 printf ("Wavelet type: %s\n", w->type->name);
76 (" h1(%d):%12.8f g1(%d):%12.8f h2(%d):%12.8f g2(%d):%12.8f\n",
77 0, w->h1[0], 0, w->g1[0], 0, w->h2[0], 0, w->g2[0]);
79 for (i = 1; i < (n < 10 ? n : 10); i++)
82 (" h1(%d):%12.8f g1(%d):%12.8f h2(%d):%12.8f g2(%d):%12.8f\n",
83 i, w->h1[i], i, w->g1[i], i, w->h2[i], i, w->g2[i]);
89 ("h1(%d):%12.8f g1(%d):%12.8f h2(%d):%12.8f g2(%d):%12.8f\n",
90 i, w->h1[i], i, w->g1[i], i, w->h2[i], i, w->g2[i]);
95 gsl_wavelet_workspace *
96 gsl_wavelet_workspace_alloc (size_t n)
98 gsl_wavelet_workspace *work;
102 GSL_ERROR_VAL ("length n must be positive integer", GSL_EDOM, 0);
105 work = (gsl_wavelet_workspace *) malloc (sizeof (gsl_wavelet_workspace));
109 GSL_ERROR_VAL ("failed to allocate struct", GSL_ENOMEM, 0);
113 work->scratch = (double *) malloc (n * sizeof (double));
115 if (work->scratch == NULL)
117 /* error in constructor, prevent memory leak */
119 GSL_ERROR_VAL ("failed to allocate scratch space", GSL_ENOMEM, 0);
126 gsl_wavelet_workspace_free (gsl_wavelet_workspace * work)
128 /* release scratch space */
129 free (work->scratch);
130 work->scratch = NULL;