| 1 |
#ifndef _ChebyshevSeries_h_ |
| 2 |
#define _ChebyshevSeries_h_ |
| 3 |
/* ChebyshevSeries.h |
| 4 |
* |
| 5 |
* Copyright (C) 2020 David Weenink |
| 6 |
* |
| 7 |
* This code is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 10 |
* your option) any later version. |
| 11 |
* |
| 12 |
* This code is distributed in the hope that it will be useful, but |
| 13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "FunctionSeries.h" |
| 22 |
#include "Polynomial.h" |
| 23 |
|
| 24 |
/* |
| 25 |
A ChebyshevSeries p(x) on a domain [xmin,xmax] is defined as the |
| 26 |
following linear combination of Chebyshev polynomials T[k](x') of |
| 27 |
degree k-1 and domain [-1, 1]: |
| 28 |
p(x) = sum (k=1..numberOfCoefficients, c[k]*T[k](x')) - c[1] / 2, where |
| 29 |
x' = (2 * x - xmin - xmax) / (xmax - xmin) |
| 30 |
This is equivalent to: |
| 31 |
p(x) = c[1] /2 + sum (k=2..numberOfCoefficients, c[k]*T[k](x')) |
| 32 |
*/ |
| 33 |
|
| 34 |
Thing_define (ChebyshevSeries, FunctionSeries) { |
| 35 |
// overridden methods: |
| 36 |
public: |
| 37 |
virtual double v_evaluate (double x); |
| 38 |
virtual void v_evaluateTerms (double x, VEC terms); |
| 39 |
virtual void v_getExtrema (double x1, double x2, double *xmin, double *ymin, double *xmax, double *ymax); |
| 40 |
}; |
| 41 |
|
| 42 |
autoChebyshevSeries ChebyshevSeries_create (double xmin, double xmax, integer numberOfPolynomials); |
| 43 |
|
| 44 |
autoChebyshevSeries ChebyshevSeries_createWithCoefficients (double xmin, double xmax, constVECVU const& coefficients); |
| 45 |
|
| 46 |
autoPolynomial ChebyshevSeries_to_Polynomial (ChebyshevSeries me); |
| 47 |
|
| 48 |
|
| 49 |
#endif /* _ChebyshevSeries_h_ */ |