| 1 |
/* cheb/gsl_chebyshev.h |
| 2 |
* |
| 3 |
* Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman |
| 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_CHEBYSHEV_H__ |
| 21 |
#define __GSL_CHEBYSHEV_H__ |
| 22 |
|
| 23 |
#include "gsl_math.h" |
| 24 |
#include "gsl_mode.h" |
| 25 |
|
| 26 |
#undef __BEGIN_DECLS |
| 27 |
#undef __END_DECLS |
| 28 |
#ifdef __cplusplus |
| 29 |
# define __BEGIN_DECLS extern "C" { |
| 30 |
# define __END_DECLS } |
| 31 |
#else |
| 32 |
# define __BEGIN_DECLS /* empty */ |
| 33 |
# define __END_DECLS /* empty */ |
| 34 |
#endif |
| 35 |
|
| 36 |
__BEGIN_DECLS |
| 37 |
|
| 38 |
|
| 39 |
/* data for a Chebyshev series over a given interval */ |
| 40 |
|
| 41 |
struct gsl_cheb_series_struct { |
| 42 |
|
| 43 |
double * c; /* coefficients */ |
| 44 |
size_t order; /* order of expansion */ |
| 45 |
double a; /* lower interval point */ |
| 46 |
double b; /* upper interval point */ |
| 47 |
|
| 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, |
| 54 |
* order_sp = order. |
| 55 |
* It is used explicitly only by the gsl_cheb_eval_mode |
| 56 |
* functions, which are not meant for casual use. |
| 57 |
*/ |
| 58 |
size_t order_sp; |
| 59 |
|
| 60 |
/* Additional elements not used by specfunc */ |
| 61 |
|
| 62 |
double * f; /* function evaluated at chebyschev points */ |
| 63 |
}; |
| 64 |
typedef struct gsl_cheb_series_struct gsl_cheb_series; |
| 65 |
|
| 66 |
|
| 67 |
/* Calculate a Chebyshev series of specified order over |
| 68 |
* a specified interval, for a given function. |
| 69 |
* Return 0 on failure. |
| 70 |
*/ |
| 71 |
gsl_cheb_series * gsl_cheb_alloc(const size_t order); |
| 72 |
|
| 73 |
/* Free a Chebyshev series previously calculated with gsl_cheb_alloc(). |
| 74 |
*/ |
| 75 |
void gsl_cheb_free(gsl_cheb_series * cs); |
| 76 |
|
| 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. |
| 80 |
* |
| 81 |
*/ |
| 82 |
int gsl_cheb_init(gsl_cheb_series * cs, const gsl_function * func, |
| 83 |
const double a, const double b); |
| 84 |
|
| 85 |
|
| 86 |
/* Evaluate a Chebyshev series at a given point. |
| 87 |
* No errors can occur for a struct obtained from gsl_cheb_new(). |
| 88 |
*/ |
| 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); |
| 92 |
|
| 93 |
|
| 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(). |
| 96 |
*/ |
| 97 |
double gsl_cheb_eval_n(const gsl_cheb_series * cs, const size_t order, |
| 98 |
const double x); |
| 99 |
int gsl_cheb_eval_n_err(const gsl_cheb_series * cs, const size_t order, |
| 100 |
const double x, double * result, double * abserr); |
| 101 |
|
| 102 |
|
| 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(). |
| 107 |
*/ |
| 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); |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
/* Compute the derivative of a Chebyshev series. |
| 114 |
*/ |
| 115 |
int gsl_cheb_calc_deriv(gsl_cheb_series * deriv, const gsl_cheb_series * cs); |
| 116 |
|
| 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}] |
| 121 |
*/ |
| 122 |
int gsl_cheb_calc_integ(gsl_cheb_series * integ, const gsl_cheb_series * cs); |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
__END_DECLS |
| 128 |
|
| 129 |
#endif /* __GSL_CHEBYSHEV_H__ */ |