1 /* cheb/gsl_chebyshev.h
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
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.
20 #ifndef __GSL_CHEBYSHEV_H__
21 #define __GSL_CHEBYSHEV_H__
23 #include <gsl/gsl_math.h>
24 #include <gsl/gsl_mode.h>
29 # define __BEGIN_DECLS extern "C" {
30 # define __END_DECLS }
32 # define __BEGIN_DECLS /* empty */
33 # define __END_DECLS /* empty */
39 /* data for a Chebyshev series over a given interval */
41 struct gsl_cheb_series_struct {
43 double * c; /* coefficients */
44 size_t order; /* order of expansion */
45 double a; /* lower interval point */
46 double b; /* upper interval point */
48 /* The following exists (mostly) for the benefit
49 * of the implementation. It is an effective single
50 * precision order, for use in single precision
51 * evaluation. Users can use it if they like, but
52 * only they know how to calculate it, since it is
53 * specific to the approximated function. By default,
55 * It is used explicitly only by the gsl_cheb_eval_mode
56 * functions, which are not meant for casual use.
60 /* Additional elements not used by specfunc */
62 double * f; /* function evaluated at chebyschev points */
64 typedef struct gsl_cheb_series_struct gsl_cheb_series;
67 /* Calculate a Chebyshev series of specified order over
68 * a specified interval, for a given function.
69 * Return 0 on failure.
71 gsl_cheb_series * gsl_cheb_alloc(const size_t order);
73 /* Free a Chebyshev series previously calculated with gsl_cheb_alloc().
75 void gsl_cheb_free(gsl_cheb_series * cs);
77 /* Calculate a Chebyshev series using the storage provided.
78 * Uses the interval (a,b) and the order with which it
79 * was initially created.
82 int gsl_cheb_init(gsl_cheb_series * cs, const gsl_function * func,
83 const double a, const double b);
86 /* Evaluate a Chebyshev series at a given point.
87 * No errors can occur for a struct obtained from gsl_cheb_new().
89 double gsl_cheb_eval(const gsl_cheb_series * cs, const double x);
90 int gsl_cheb_eval_err(const gsl_cheb_series * cs, const double x,
91 double * result, double * abserr);
94 /* Evaluate a Chebyshev series at a given point, to (at most) the given order.
95 * No errors can occur for a struct obtained from gsl_cheb_new().
97 double gsl_cheb_eval_n(const gsl_cheb_series * cs, const size_t order,
99 int gsl_cheb_eval_n_err(const gsl_cheb_series * cs, const size_t order,
100 const double x, double * result, double * abserr);
103 /* Evaluate a Chebyshev series at a given point, using the default
104 * order for double precision mode(s) and the single precision
105 * order for other modes.
106 * No errors can occur for a struct obtained from gsl_cheb_new().
108 double gsl_cheb_eval_mode(const gsl_cheb_series * cs, const double x, gsl_mode_t mode);
109 int gsl_cheb_eval_mode_e(const gsl_cheb_series * cs, const double x, gsl_mode_t mode, double * result, double * abserr);
113 /* Compute the derivative of a Chebyshev series.
115 int gsl_cheb_calc_deriv(gsl_cheb_series * deriv, const gsl_cheb_series * cs);
117 /* Compute the integral of a Chebyshev series. The
118 * integral is fixed by the condition that it equals zero at
119 * the left end-point, ie it is precisely
120 * Integrate[cs(t; a,b), {t, a, x}]
122 int gsl_cheb_calc_integ(gsl_cheb_series * integ, const gsl_cheb_series * cs);
129 #endif /* __GSL_CHEBYSHEV_H__ */