gsl_bspline.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* bspline/gsl_bspline.h
  2. *
  3. * Copyright (C) 2006 Patrick Alken
  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. #ifndef __GSL_BSPLINE_H__
  20. #define __GSL_BSPLINE_H__
  21. #include <stdlib.h>
  22. #include "gsl_math.h"
  23. #include "gsl_vector.h"
  24. #undef __BEGIN_DECLS
  25. #undef __END_DECLS
  26. #ifdef __cplusplus
  27. # define __BEGIN_DECLS extern "C" {
  28. # define __END_DECLS }
  29. #else
  30. # define __BEGIN_DECLS /* empty */
  31. # define __END_DECLS /* empty */
  32. #endif
  33. __BEGIN_DECLS
  34. typedef struct
  35. {
  36. size_t k; /* spline order */
  37. size_t km1; /* k - 1 (polynomial order) */
  38. size_t l; /* number of polynomial pieces on interval */
  39. size_t nbreak; /* number of breakpoints (l + 1) */
  40. size_t n; /* number of bspline basis functions (l + k - 1) */
  41. gsl_vector *knots; /* knots vector */
  42. gsl_vector *deltal; /* left delta */
  43. gsl_vector *deltar; /* right delta */
  44. gsl_vector *B; /* temporary spline results */
  45. } gsl_bspline_workspace;
  46. gsl_bspline_workspace *
  47. gsl_bspline_alloc(const size_t k, const size_t nbreak);
  48. void gsl_bspline_free(gsl_bspline_workspace *w);
  49. size_t gsl_bspline_ncoeffs (gsl_bspline_workspace * w);
  50. size_t gsl_bspline_order (gsl_bspline_workspace * w);
  51. size_t gsl_bspline_nbreak (gsl_bspline_workspace * w);
  52. double gsl_bspline_breakpoint (size_t i, gsl_bspline_workspace * w);
  53. int
  54. gsl_bspline_knots(const gsl_vector *breakpts, gsl_bspline_workspace *w);
  55. int gsl_bspline_knots_uniform(const double a, const double b,
  56. gsl_bspline_workspace *w);
  57. int
  58. gsl_bspline_eval(const double x, gsl_vector *B,
  59. gsl_bspline_workspace *w);
  60. __END_DECLS
  61. #endif /* __GSL_BSPLINE_H__ */