37 std::vector<double>
params,
43 if (params.size() < 1) {
44 throw std::runtime_error(
"ChebyshevPolynomial called with empty vector");
47 std::ostringstream os;
48 os <<
"ChebyshevPolynomial minX=" << minX <<
" >= " << maxX <<
"=maxX";
49 throw std::runtime_error(os.str());
51 _initialize(minX, maxX);
61 _initialize(-1.0, 1.0);
83 double xPrime = (x + _offset) * _scale;
85 if ((xPrime < -1.0) || (xPrime > 1.0)) {
86 return std::numeric_limits<double>::quiet_NaN();
94 }
else if (order == 1) {
97 double cshPrev = this->
params[order];
98 double csh = (2 * xPrime * this->
params[order]) + this->
params[order-1];
99 for (
int i = order - 2; i > 0; --i) {
100 double cshNext = (2 * xPrime * csh) + this->
params[i] - cshPrev;
104 return (xPrime * csh) + this->
params[0] - cshPrev;
123 void _initialize(
double minX,
double maxX) {
126 _scale = 2.0 / (_maxX - _minX);
127 _offset = -(_minX + _maxX) * 0.5;
131 std::ostream &
operator<<(std::ostream &os, ChebyshevPolynomial
const &cheby);
ChebyshevPolynomial(std::vector< double > params, double minX=-1, double maxX=1)
std::vector< double > params
std::string __repr__() const
double operator()(double x) const
std::ostream & operator<<(std::ostream &os, ChebyshevPolynomial const &cheby)
unsigned int getOrder() const