![]() |
|
|||
File indexing completed on 2025-02-21 10:03:47
0001 /* cheb/gsl_chebyshev.h 0002 * 0003 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 3 of the License, or (at 0008 * your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, but 0011 * WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef __GSL_CHEBYSHEV_H__ 0021 #define __GSL_CHEBYSHEV_H__ 0022 0023 #include <stdlib.h> 0024 #include <gsl/gsl_math.h> 0025 #include <gsl/gsl_mode.h> 0026 0027 #undef __BEGIN_DECLS 0028 #undef __END_DECLS 0029 #ifdef __cplusplus 0030 # define __BEGIN_DECLS extern "C" { 0031 # define __END_DECLS } 0032 #else 0033 # define __BEGIN_DECLS /* empty */ 0034 # define __END_DECLS /* empty */ 0035 #endif 0036 0037 __BEGIN_DECLS 0038 0039 0040 /* data for a Chebyshev series over a given interval */ 0041 0042 struct gsl_cheb_series_struct { 0043 0044 double * c; /* coefficients */ 0045 size_t order; /* order of expansion */ 0046 double a; /* lower interval point */ 0047 double b; /* upper interval point */ 0048 0049 /* The following exists (mostly) for the benefit 0050 * of the implementation. It is an effective single 0051 * precision order, for use in single precision 0052 * evaluation. Users can use it if they like, but 0053 * only they know how to calculate it, since it is 0054 * specific to the approximated function. By default, 0055 * order_sp = order. 0056 * It is used explicitly only by the gsl_cheb_eval_mode 0057 * functions, which are not meant for casual use. 0058 */ 0059 size_t order_sp; 0060 0061 /* Additional elements not used by specfunc */ 0062 0063 double * f; /* function evaluated at chebyschev points */ 0064 }; 0065 typedef struct gsl_cheb_series_struct gsl_cheb_series; 0066 0067 0068 /* Calculate a Chebyshev series of specified order over 0069 * a specified interval, for a given function. 0070 * Return 0 on failure. 0071 */ 0072 gsl_cheb_series * gsl_cheb_alloc(const size_t order); 0073 0074 /* Free a Chebyshev series previously calculated with gsl_cheb_alloc(). 0075 */ 0076 void gsl_cheb_free(gsl_cheb_series * cs); 0077 0078 /* Calculate a Chebyshev series using the storage provided. 0079 * Uses the interval (a,b) and the order with which it 0080 * was initially created. 0081 * 0082 */ 0083 int gsl_cheb_init(gsl_cheb_series * cs, const gsl_function * func, 0084 const double a, const double b); 0085 0086 /* Return the order, size of coefficient array and coefficient array ptr */ 0087 size_t gsl_cheb_order (const gsl_cheb_series * cs); 0088 size_t gsl_cheb_size (const gsl_cheb_series * cs); 0089 double *gsl_cheb_coeffs (const gsl_cheb_series * cs); 0090 0091 /* Evaluate a Chebyshev series at a given point. 0092 * No errors can occur for a struct obtained from gsl_cheb_new(). 0093 */ 0094 double gsl_cheb_eval(const gsl_cheb_series * cs, const double x); 0095 int gsl_cheb_eval_err(const gsl_cheb_series * cs, const double x, 0096 double * result, double * abserr); 0097 0098 0099 /* Evaluate a Chebyshev series at a given point, to (at most) the given order. 0100 * No errors can occur for a struct obtained from gsl_cheb_new(). 0101 */ 0102 double gsl_cheb_eval_n(const gsl_cheb_series * cs, const size_t order, 0103 const double x); 0104 int gsl_cheb_eval_n_err(const gsl_cheb_series * cs, const size_t order, 0105 const double x, double * result, double * abserr); 0106 0107 0108 /* Evaluate a Chebyshev series at a given point, using the default 0109 * order for double precision mode(s) and the single precision 0110 * order for other modes. 0111 * No errors can occur for a struct obtained from gsl_cheb_new(). 0112 */ 0113 double gsl_cheb_eval_mode(const gsl_cheb_series * cs, const double x, gsl_mode_t mode); 0114 int gsl_cheb_eval_mode_e(const gsl_cheb_series * cs, const double x, gsl_mode_t mode, double * result, double * abserr); 0115 0116 0117 0118 /* Compute the derivative of a Chebyshev series. 0119 */ 0120 int gsl_cheb_calc_deriv(gsl_cheb_series * deriv, const gsl_cheb_series * cs); 0121 0122 /* Compute the integral of a Chebyshev series. The 0123 * integral is fixed by the condition that it equals zero at 0124 * the left end-point, ie it is precisely 0125 * Integrate[cs(t; a,b), {t, a, x}] 0126 */ 0127 int gsl_cheb_calc_integ(gsl_cheb_series * integ, const gsl_cheb_series * cs); 0128 0129 0130 0131 0132 __END_DECLS 0133 0134 #endif /* __GSL_CHEBYSHEV_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |