| 1 |
tim |
1747 |
/* |
| 2 |
|
|
* Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project |
| 3 |
|
|
* |
| 4 |
|
|
* Contact: oopse@oopse.org |
| 5 |
|
|
* |
| 6 |
|
|
* This program is free software; you can redistribute it and/or |
| 7 |
|
|
* modify it under the terms of the GNU Lesser General Public License |
| 8 |
|
|
* as published by the Free Software Foundation; either version 2.1 |
| 9 |
|
|
* of the License, or (at your option) any later version. |
| 10 |
|
|
* All we ask is that proper credit is given for our work, which includes |
| 11 |
|
|
* - but is not limited to - adding the above copyright notice to the beginning |
| 12 |
|
|
* of your source code files, and to any copyright notice that you may distribute |
| 13 |
|
|
* with programs based on this work. |
| 14 |
|
|
* |
| 15 |
|
|
* This program is distributed in the hope that it will be useful, |
| 16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
|
|
* GNU Lesser General Public License for more details. |
| 19 |
|
|
* |
| 20 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
| 21 |
|
|
* along with this program; if not, write to the Free Software |
| 22 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 23 |
|
|
* |
| 24 |
|
|
*/ |
| 25 |
|
|
|
| 26 |
|
|
#include "math/ChebyshevPolynomials.hpp" |
| 27 |
|
|
|
| 28 |
|
|
namespace oopse { |
| 29 |
|
|
ChebyshevPolynomials::ChebyshevPolynomials(int maxPower) : maxPower_(maxPower){ |
| 30 |
|
|
|
| 31 |
|
|
assert(maxPower >= 0); |
| 32 |
|
|
GeneratePolynomials(maxPower_); |
| 33 |
|
|
} |
| 34 |
|
|
|
| 35 |
|
|
ChebyshevPolynomials::GeneratePolynomials(int maxPower) { |
| 36 |
tim |
1748 |
|
| 37 |
|
|
GenerateFirstTwoTerms(); |
| 38 |
|
|
|
| 39 |
|
|
DoublePolynomial twoX; |
| 40 |
|
|
twoX.setCoefficient(1, 2.0); |
| 41 |
|
|
|
| 42 |
|
|
//recursive generate the high order term of Chebyshev Polynomials |
| 43 |
|
|
//Cn+1(x) = Cn(x) * 2x - Cn-1(x) |
| 44 |
|
|
for (int i = 2; i <= maxPower; ++i) { |
| 45 |
|
|
DoublePolynomial cn; |
| 46 |
|
|
|
| 47 |
|
|
cn = polyList_[i-1] * twoX - polyList_[i-2]; |
| 48 |
|
|
polyList_.push_back(cn); |
| 49 |
|
|
} |
| 50 |
|
|
} |
| 51 |
|
|
|
| 52 |
|
|
|
| 53 |
|
|
ChebyshevT::GenerateFirstTwoTerms() { |
| 54 |
tim |
1747 |
DoublePolynomial t0; |
| 55 |
|
|
t0.setCoefficient(0, 1.0); |
| 56 |
|
|
polyList_.push_back(t0); |
| 57 |
|
|
|
| 58 |
|
|
DoublePolynomial t1; |
| 59 |
|
|
t1.setCoefficient(1, 1.0); |
| 60 |
tim |
1748 |
polyList_.push_back(t1); |
| 61 |
|
|
} |
| 62 |
tim |
1747 |
|
| 63 |
tim |
1748 |
ChebyshevU::GenerateFirstTwoTerms() { |
| 64 |
|
|
DoublePolynomial u0; |
| 65 |
|
|
u0.setCoefficient(0, 1.0); |
| 66 |
|
|
polyList_.push_back(u0); |
| 67 |
tim |
1747 |
|
| 68 |
tim |
1748 |
DoublePolynomial u1; |
| 69 |
|
|
u1.setCoefficient(1, 2.0); |
| 70 |
|
|
polyList_.push_back(u1); |
| 71 |
tim |
1747 |
} |
| 72 |
|
|
|
| 73 |
|
|
} //end namespace oopse |