Main Page | Alphabetical List | Class List | File List | Class Members | File Members

gsl_chebyshev.h

Go to the documentation of this file.
00001 /* cheb/gsl_chebyshev.h
00002  * 
00003  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
00004  * 
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or (at
00008  * your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 #ifndef __GSL_CHEBYSHEV_H__
00021 #define __GSL_CHEBYSHEV_H__
00022 
00023 #include <vector>
00024 #include <gsl/gsl_mode.h>
00025 typedef std::vector<double> Dvector;
00026 
00027 #undef __BEGIN_DECLS
00028 #undef __END_DECLS
00029 #ifdef __cplusplus
00030 
00031 #ifdef NEVER
00032 # define __BEGIN_DECLS extern "C" {
00033 # define __END_DECLS }
00034 #else
00035 # define __BEGIN_DECLS /* empty */
00036 # define __END_DECLS /* empty */
00037 #endif
00038 #endif
00039 
00040 # define __BEGIN_DECLS /* empty */
00041 # define __END_DECLS /* empty */
00042 
00043 __BEGIN_DECLS
00044 
00045 
00046 /* data for a Chebyshev series over a given interval */
00047 
00048 struct gsl_cheb_series_struct {
00049 
00050   double * c;   /* coefficients                */
00051   size_t order; /* order of expansion          */
00052   double a;     /* lower interval point        */
00053   double b;     /* upper interval point        */
00054 
00055   /* The following exists (mostly) for the benefit
00056    * of the implementation. It is an effective single
00057    * precision order, for use in single precision
00058    * evaluation. Users can use it if they like, but
00059    * only they know how to calculate it, since it is
00060    * specific to the approximated function. By default,
00061    * order_sp = order.
00062    * It is used explicitly only by the gsl_cheb_eval_mode
00063    * functions, which are not meant for casual use.
00064    */
00065   size_t order_sp;
00066 
00067   /* Additional elements not used by specfunc */
00068 
00069   double * f;   /* function evaluated at chebyschev points  */
00070 };
00071 typedef struct gsl_cheb_series_struct gsl_cheb_series;
00072 
00073 /* Calculate a Chebyshev series of specified order over
00074  * a specified interval, for a given function.
00075  * Return 0 on failure.
00076  */
00077 gsl_cheb_series * gsl_cheb_alloc(const size_t order);
00078 
00079 /* Free a Chebyshev series previously calculated with gsl_cheb_alloc().
00080  */
00081 void gsl_cheb_free(gsl_cheb_series * cs);
00082 
00083 /* Calculate a Chebyshev series using the storage provided.
00084  * Uses the interval (a,b) and the order with which it
00085  * was initially created.
00086  *
00087  */
00088 int gsl_cheb_init(gsl_cheb_series * cs, double (*func)(double),
00089                   const double a, const double b);
00090 
00091 int gsl_cheb_init(gsl_cheb_series * cs, double (*func)(double, Dvector),
00092                   Dvector pars, const double a, const double b);
00093 
00094 /* Evaluate a Chebyshev series at a given point.
00095  * No errors can occur for a struct obtained from gsl_cheb_new().
00096  */
00097 double gsl_cheb_eval(const gsl_cheb_series * cs, const double x);
00098 int gsl_cheb_eval_err(const gsl_cheb_series * cs, const double x, 
00099                       double * result, double * abserr);
00100 
00101 /* Evaluate a Chebyshev series at a given point, to (at most) the given order.
00102  * No errors can occur for a struct obtained from gsl_cheb_new().
00103  */
00104 double gsl_cheb_eval_n(const gsl_cheb_series * cs, const size_t order, 
00105                        const double x);
00106 int gsl_cheb_eval_n_err(const gsl_cheb_series * cs, const size_t order, 
00107                         const double x, double * result, double * abserr);
00108 
00109 /* Evaluate a Chebyshev series at a given point, using the default
00110  * order for double precision mode(s) and the single precision
00111  * order for other modes.
00112  * No errors can occur for a struct obtained from gsl_cheb_new().
00113  */
00114 double gsl_cheb_eval_mode(const gsl_cheb_series * cs, double x, gsl_mode_t mode);
00115 int gsl_cheb_eval_mode_e(const gsl_cheb_series * cs, const double x, gsl_mode_t mode, double * result, double * abserr);
00116 
00117 /* Compute the derivative of a Chebyshev series.
00118  */
00119 int gsl_cheb_calc_deriv(gsl_cheb_series * deriv, const gsl_cheb_series * cs);
00120 
00121 /* Compute the integral of a Chebyshev series. The
00122  * integral is fixed by the condition that it equals zero at
00123  * the left end-point, ie it is precisely
00124  *       Integrate[cs(t; a,b), {t, a, x}]
00125  */
00126 int gsl_cheb_calc_integ(gsl_cheb_series * integ, const gsl_cheb_series * cs);
00127 
00128 __END_DECLS
00129 
00130 #endif /* __GSL_CHEBYSHEV_H__ */

Generated on Wed Feb 25 15:03:16 2004 for SpecialFunctions by doxygen 1.3.4