20 #ifndef ROOT_Math_ChebyshevPol 21 #define ROOT_Math_ChebyshevPol 23 #include <sys/types.h> 34 template<
int N>
double T(
double x) {
35 return (2.0 * x * T<N-1>(x)) -
T<
N-2>(
x);
38 template<>
double T<0> (double );
39 template<>
double T<1> (
double x);
40 template<>
double T<2> (
double x);
41 template<>
double T<3> (
double x);
43 template<
int N>
double Eval(
double x,
const double *
c) {
44 return c[
N]*T<N>(
x) + Eval<N-1>(x,c);
47 template<>
double Eval<0> (double ,
const double *
c);
48 template<>
double Eval<1> (
double x,
const double *
c);
49 template<>
double Eval<2> (
double x,
const double *
c);
50 template<>
double Eval<3> (
double x,
const double *
c);
64 return c0 + c1*x + c2*(2.0*x*x - 1.0);
70 return c4*Chebyshev::T<4>(
x) +
Chebyshev3(x,c0,c1,c2,c3);
72 inline double Chebyshev5(
double x,
double c0,
double c1,
double c2,
double c3,
double c4,
double c5) {
73 return c5*Chebyshev::T<5>(
x) +
Chebyshev4(x,c0,c1,c2,c3,c4);
75 inline double Chebyshev6(
double x,
double c0,
double c1,
double c2,
double c3,
double c4,
double c5,
double c6) {
76 return c6*Chebyshev::T<6>(
x) +
Chebyshev5(x,c0,c1,c2,c3,c4,c5);
78 inline double Chebyshev7(
double x,
double c0,
double c1,
double c2,
double c3,
double c4,
double c5,
double c6,
double c7) {
79 return c7*Chebyshev::T<7>(
x) +
Chebyshev6(x,c0,c1,c2,c3,c4,c5,c6);
81 inline double Chebyshev8(
double x,
double c0,
double c1,
double c2,
double c3,
double c4,
double c5,
double c6,
double c7,
double c8) {
82 return c8*Chebyshev::T<8>(
x) +
Chebyshev7(x,c0,c1,c2,c3,c4,c5,c6,c7);
84 inline double Chebyshev9(
double x,
double c0,
double c1,
double c2,
double c3,
double c4,
double c5,
double c6,
double c7,
double c8,
double c9) {
85 return c9*Chebyshev::T<9>(
x) +
Chebyshev8(x,c0,c1,c2,c3,c4,c5,c6,c7,c8);
87 inline double Chebyshev10(
double x,
double c0,
double c1,
double c2,
double c3,
double c4,
double c5,
double c6,
double c7,
double c8,
double c9,
double c10) {
88 return c10*Chebyshev::T<10>(
x) +
Chebyshev9(x,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9);
97 if (n == 2)
return Chebyshev2(x,c[0],c[1],c[2]);
98 if (n == 3)
return Chebyshev3(x,c[0],c[1],c[2],c[3]);
99 if (n == 4)
return Chebyshev4(x,c[0],c[1],c[2],c[3],c[4]);
100 if (n == 5)
return Chebyshev5(x,c[0],c[1],c[2],c[3],c[4],c[5]);
116 for (i = n; i >= 1; i--)
119 d1 = y2 * d1 - d2 + c[i];
123 return x * d1 - d2 + c[0];
148 #endif // ROOT_Math_Chebyshev double Chebyshev3(double x, double c0, double c1, double c2, double c3)
Namespace for new ROOT classes and functions.
double Eval< 1 >(double x, const double *c)
double Chebyshev2(double x, double c0, double c1, double c2)
double Chebyshev8(double x, double c0, double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8)
double Chebyshev5(double x, double c0, double c1, double c2, double c3, double c4, double c5)
TRObject operator()(const T1 &t1) const
double Eval< 2 >(double x, const double *c)
double Chebyshev6(double x, double c0, double c1, double c2, double c3, double c4, double c5, double c6)
double Chebyshev4(double x, double c0, double c1, double c2, double c3, double c4)
double Chebyshev9(double x, double c0, double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8, double c9)
double Eval< 0 >(double, const double *c)
double ChebyshevN(unsigned int n, double x, const double *c)
double Chebyshev7(double x, double c0, double c1, double c2, double c3, double c4, double c5, double c6, double c7)
ChebyshevPol(unsigned int n)
Namespace for new Math classes and functions.
double Eval(double x, const double *c)
double Eval< 3 >(double x, const double *c)
double Chebyshev0(double, double c0)
double Chebyshev1(double x, double c0, double c1)
double Chebyshev10(double x, double c0, double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8, double c9, double c10)