|
Packit |
67cb25 |
/* cheb/gsl_chebyshev.h
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
* Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
67cb25 |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
67cb25 |
* the Free Software Foundation; either version 3 of the License, or (at
|
|
Packit |
67cb25 |
* your option) any later version.
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
* This program is distributed in the hope that it will be useful, but
|
|
Packit |
67cb25 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
67cb25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
67cb25 |
* General Public License for more details.
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
* You should have received a copy of the GNU General Public License
|
|
Packit |
67cb25 |
* along with this program; if not, write to the Free Software
|
|
Packit |
67cb25 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#ifndef __GSL_CHEBYSHEV_H__
|
|
Packit |
67cb25 |
#define __GSL_CHEBYSHEV_H__
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#include <gsl/gsl_math.h>
|
|
Packit |
67cb25 |
#include <gsl/gsl_mode.h>
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#undef __BEGIN_DECLS
|
|
Packit |
67cb25 |
#undef __END_DECLS
|
|
Packit |
67cb25 |
#ifdef __cplusplus
|
|
Packit |
67cb25 |
# define __BEGIN_DECLS extern "C" {
|
|
Packit |
67cb25 |
# define __END_DECLS }
|
|
Packit |
67cb25 |
#else
|
|
Packit |
67cb25 |
# define __BEGIN_DECLS /* empty */
|
|
Packit |
67cb25 |
# define __END_DECLS /* empty */
|
|
Packit |
67cb25 |
#endif
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
__BEGIN_DECLS
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* data for a Chebyshev series over a given interval */
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
struct gsl_cheb_series_struct {
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
double * c; /* coefficients */
|
|
Packit |
67cb25 |
size_t order; /* order of expansion */
|
|
Packit |
67cb25 |
double a; /* lower interval point */
|
|
Packit |
67cb25 |
double b; /* upper interval point */
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* The following exists (mostly) for the benefit
|
|
Packit |
67cb25 |
* of the implementation. It is an effective single
|
|
Packit |
67cb25 |
* precision order, for use in single precision
|
|
Packit |
67cb25 |
* evaluation. Users can use it if they like, but
|
|
Packit |
67cb25 |
* only they know how to calculate it, since it is
|
|
Packit |
67cb25 |
* specific to the approximated function. By default,
|
|
Packit |
67cb25 |
* order_sp = order.
|
|
Packit |
67cb25 |
* It is used explicitly only by the gsl_cheb_eval_mode
|
|
Packit |
67cb25 |
* functions, which are not meant for casual use.
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
size_t order_sp;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Additional elements not used by specfunc */
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
double * f; /* function evaluated at chebyschev points */
|
|
Packit |
67cb25 |
};
|
|
Packit |
67cb25 |
typedef struct gsl_cheb_series_struct gsl_cheb_series;
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Calculate a Chebyshev series of specified order over
|
|
Packit |
67cb25 |
* a specified interval, for a given function.
|
|
Packit |
67cb25 |
* Return 0 on failure.
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
gsl_cheb_series * gsl_cheb_alloc(const size_t order);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Free a Chebyshev series previously calculated with gsl_cheb_alloc().
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
void gsl_cheb_free(gsl_cheb_series * cs);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Calculate a Chebyshev series using the storage provided.
|
|
Packit |
67cb25 |
* Uses the interval (a,b) and the order with which it
|
|
Packit |
67cb25 |
* was initially created.
|
|
Packit |
67cb25 |
*
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
int gsl_cheb_init(gsl_cheb_series * cs, const gsl_function * func,
|
|
Packit |
67cb25 |
const double a, const double b);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Return the order, size of coefficient array and coefficient array ptr */
|
|
Packit |
67cb25 |
size_t gsl_cheb_order (const gsl_cheb_series * cs);
|
|
Packit |
67cb25 |
size_t gsl_cheb_size (const gsl_cheb_series * cs);
|
|
Packit |
67cb25 |
double *gsl_cheb_coeffs (const gsl_cheb_series * cs);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Evaluate a Chebyshev series at a given point.
|
|
Packit |
67cb25 |
* No errors can occur for a struct obtained from gsl_cheb_new().
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
double gsl_cheb_eval(const gsl_cheb_series * cs, const double x);
|
|
Packit |
67cb25 |
int gsl_cheb_eval_err(const gsl_cheb_series * cs, const double x,
|
|
Packit |
67cb25 |
double * result, double * abserr);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Evaluate a Chebyshev series at a given point, to (at most) the given order.
|
|
Packit |
67cb25 |
* No errors can occur for a struct obtained from gsl_cheb_new().
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
double gsl_cheb_eval_n(const gsl_cheb_series * cs, const size_t order,
|
|
Packit |
67cb25 |
const double x);
|
|
Packit |
67cb25 |
int gsl_cheb_eval_n_err(const gsl_cheb_series * cs, const size_t order,
|
|
Packit |
67cb25 |
const double x, double * result, double * abserr);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Evaluate a Chebyshev series at a given point, using the default
|
|
Packit |
67cb25 |
* order for double precision mode(s) and the single precision
|
|
Packit |
67cb25 |
* order for other modes.
|
|
Packit |
67cb25 |
* No errors can occur for a struct obtained from gsl_cheb_new().
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
double gsl_cheb_eval_mode(const gsl_cheb_series * cs, const double x, gsl_mode_t mode);
|
|
Packit |
67cb25 |
int gsl_cheb_eval_mode_e(const gsl_cheb_series * cs, const double x, gsl_mode_t mode, double * result, double * abserr);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Compute the derivative of a Chebyshev series.
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
int gsl_cheb_calc_deriv(gsl_cheb_series * deriv, const gsl_cheb_series * cs);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
/* Compute the integral of a Chebyshev series. The
|
|
Packit |
67cb25 |
* integral is fixed by the condition that it equals zero at
|
|
Packit |
67cb25 |
* the left end-point, ie it is precisely
|
|
Packit |
67cb25 |
* Integrate[cs(t; a,b), {t, a, x}]
|
|
Packit |
67cb25 |
*/
|
|
Packit |
67cb25 |
int gsl_cheb_calc_integ(gsl_cheb_series * integ, const gsl_cheb_series * cs);
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
__END_DECLS
|
|
Packit |
67cb25 |
|
|
Packit |
67cb25 |
#endif /* __GSL_CHEBYSHEV_H__ */
|