gsl_wavelet__haar.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #include "gsl__config.h"
  20. #include "gsl_errno.h"
  21. #include "gsl_math.h"
  22. #include "gsl_wavelet.h"
  23. static const double ch_2[2] = { M_SQRT1_2, M_SQRT1_2 };
  24. static const double cg_2[2] = { M_SQRT1_2, -(M_SQRT1_2) };
  25. static int
  26. haar_init (const double **h1, const double **g1, const double **h2,
  27. const double **g2, size_t * nc, size_t * offset,
  28. const size_t member)
  29. {
  30. if (member != 2)
  31. {
  32. return GSL_FAILURE;
  33. }
  34. *h1 = ch_2;
  35. *g1 = cg_2;
  36. *h2 = ch_2;
  37. *g2 = cg_2;
  38. *nc = 2;
  39. *offset = 0;
  40. return GSL_SUCCESS;
  41. }
  42. static int
  43. haar_centered_init (const double **h1, const double **g1, const double **h2,
  44. const double **g2, size_t * nc, size_t * offset,
  45. const size_t member)
  46. {
  47. if (member != 2)
  48. {
  49. return GSL_FAILURE;
  50. }
  51. *h1 = ch_2;
  52. *g1 = cg_2;
  53. *h2 = ch_2;
  54. *g2 = cg_2;
  55. *nc = 2;
  56. *offset = 1;
  57. return GSL_SUCCESS;
  58. }
  59. static const gsl_wavelet_type haar_type = {
  60. "haar",
  61. &haar_init
  62. };
  63. static const gsl_wavelet_type haar_centered_type = {
  64. "haar-centered",
  65. &haar_centered_init
  66. };
  67. const gsl_wavelet_type *gsl_wavelet_haar = &haar_type;
  68. const gsl_wavelet_type *gsl_wavelet_haar_centered = &haar_centered_type;