| 1 |
/* wavelet/haar.c |
| 2 |
* |
| 3 |
* Copyright (C) 2004 Ivo Alxneit |
| 4 |
* |
| 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. |
| 9 |
* |
| 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. |
| 14 |
* |
| 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. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "gsl__config.h" |
| 21 |
#include "gsl_errno.h" |
| 22 |
#include "gsl_math.h" |
| 23 |
#include "gsl_wavelet.h" |
| 24 |
|
| 25 |
static const double ch_2[2] = { M_SQRT1_2, M_SQRT1_2 }; |
| 26 |
static const double cg_2[2] = { M_SQRT1_2, -(M_SQRT1_2) }; |
| 27 |
|
| 28 |
static int |
| 29 |
haar_init (const double **h1, const double **g1, const double **h2, |
| 30 |
const double **g2, size_t * nc, size_t * offset, |
| 31 |
const size_t member) |
| 32 |
{ |
| 33 |
if (member != 2) |
| 34 |
{ |
| 35 |
return GSL_FAILURE; |
| 36 |
} |
| 37 |
|
| 38 |
*h1 = ch_2; |
| 39 |
*g1 = cg_2; |
| 40 |
*h2 = ch_2; |
| 41 |
*g2 = cg_2; |
| 42 |
|
| 43 |
*nc = 2; |
| 44 |
*offset = 0; |
| 45 |
|
| 46 |
return GSL_SUCCESS; |
| 47 |
} |
| 48 |
|
| 49 |
static int |
| 50 |
haar_centered_init (const double **h1, const double **g1, const double **h2, |
| 51 |
const double **g2, size_t * nc, size_t * offset, |
| 52 |
const size_t member) |
| 53 |
{ |
| 54 |
if (member != 2) |
| 55 |
{ |
| 56 |
return GSL_FAILURE; |
| 57 |
} |
| 58 |
|
| 59 |
*h1 = ch_2; |
| 60 |
*g1 = cg_2; |
| 61 |
*h2 = ch_2; |
| 62 |
*g2 = cg_2; |
| 63 |
|
| 64 |
*nc = 2; |
| 65 |
*offset = 1; |
| 66 |
|
| 67 |
return GSL_SUCCESS; |
| 68 |
} |
| 69 |
|
| 70 |
static const gsl_wavelet_type haar_type = { |
| 71 |
"haar", |
| 72 |
&haar_init |
| 73 |
}; |
| 74 |
|
| 75 |
static const gsl_wavelet_type haar_centered_type = { |
| 76 |
"haar-centered", |
| 77 |
&haar_centered_init |
| 78 |
}; |
| 79 |
|
| 80 |
const gsl_wavelet_type *gsl_wavelet_haar = &haar_type; |
| 81 |
const gsl_wavelet_type *gsl_wavelet_haar_centered = &haar_centered_type; |