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