Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions
MuonCalib::Legendre Namespace Reference

Functions

constexpr double coeff (const unsigned l, const unsigned k)
 Calculates the n-th coefficient of the legendre polynomial series. More...
 
template<unsigned l, unsigned k>
constexpr double polySum (const double x)
 Assembles the sum of the legendre monomials. More...
 
template<unsigned l, unsigned k, unsigned d>
constexpr double derivativeSum (const double x)
 Assembles the n-th derivative of the legendre polynomial. More...
 
constexpr double derivativeSum (const unsigned l, const unsigned d, const double x)
 Assembles the n-th derivative of a legendre polynomial at run time. More...
 
constexpr double polySum (const unsigned l, const double x)
 Assembles the legendre polynomial at run-time. More...
 
template<unsigned l>
constexpr double poly (const double x)
 Evaluates the n-th Legendre polynomial at x. More...
 
template<unsigned l, unsigned d>
constexpr double derivative (const double x)
 Evaluates the d-th derivative of the n-th Legendre polynomial at x. More...
 

Function Documentation

◆ coeff()

constexpr double MuonCalib::Legendre::coeff ( const unsigned  l,
const unsigned  k 
)
constexpr

Calculates the n-th coefficient of the legendre polynomial series.

Parameters
lOrder of the legendre polynomial
kCoefficient insides the polynomial representation

Definition at line 92 of file LegendrePoly.h.

92  {
93  if (k %2 != l %2) {
94  return 0.;
95  } else if (k > 1) {
96  const double a_k = -(1.*(l- k +2)*(l+ k-1)) / (1.*(k * (k-1))) * coeff(l, k-2);
97  return a_k;
98  } else {
99  unsigned fl = (l - l %2) /2;
100  unsigned long binom = binomial(l,fl) * binomial(2*l - 2*fl,l);
101  return (fl % 2 ? -1. : 1.) * pow(0.5, l) * (1.*binom);
102  }
103  }

◆ derivative()

template<unsigned l, unsigned d>
constexpr double MuonCalib::Legendre::derivative ( const double  x)
constexpr

Evaluates the d-th derivative of the n-th Legendre polynomial at x.

Parameters
lOrder of the Legendre polynomial
dOrder of the respective derivative
xPoint of evaluation [-1;1]

Definition at line 164 of file LegendrePoly.h.

164  {
165  return derivativeSum<l,l,d>(x);
166  }

◆ derivativeSum() [1/2]

template<unsigned l, unsigned k, unsigned d>
constexpr double MuonCalib::Legendre::derivativeSum ( const double  x)
constexpr

Assembles the n-th derivative of the legendre polynomial.

Parameters
lOrder of the legendre polynomial
kTerm in the polynomial to add
dOrder of the derivative
xPoint of evaluation [-1,1]

Definition at line 123 of file LegendrePoly.h.

123  {
124  if constexpr(k <= l && k>=d) {
125  constexpr unsigned long powFac = factorial(k) / factorial(k-d);
126  const double a_n = coeff(l,k) * powFac;
127  return a_n *pow<k-d>(x) + derivativeSum<l, k-2, d>(x);
128  } else {
129  return 0.;
130  }
131  }

◆ derivativeSum() [2/2]

constexpr double MuonCalib::Legendre::derivativeSum ( const unsigned  l,
const unsigned  d,
const double  x 
)
constexpr

Assembles the n-th derivative of a legendre polynomial at run time.

Parameters
lOrder of the legendre polynomial
dOrder of the derivative
xPoint of evaluation [-1,1]

Definition at line 136 of file LegendrePoly.h.

136  {
137  double sum{0.};
138  for (int k=l; k>= static_cast<int>(d) && k >=0; k-=2) {
139  const double a_n = coeff(l,k) * factorial(k) / factorial(k-d);
140  sum += a_n * pow(x,k-d);
141  }
142  return sum;
143  }

◆ poly()

template<unsigned l>
constexpr double MuonCalib::Legendre::poly ( const double  x)
constexpr

Evaluates the n-th Legendre polynomial at x.

Parameters
lOrder of the Legendre polynoimal
xPoint of evaluation [-1;1]

Definition at line 156 of file LegendrePoly.h.

156  {
157  return polySum<l,l>(x);
158  }

◆ polySum() [1/2]

template<unsigned l, unsigned k>
constexpr double MuonCalib::Legendre::polySum ( const double  x)
constexpr

Assembles the sum of the legendre monomials.

Parameters
lOrder of the legendre polynomial
kTerm in the polynomial to add to the sum
xPoint of evaluation [-1,1]

Definition at line 109 of file LegendrePoly.h.

109  {
110  const double a_n = coeff(l,k);
111  if constexpr (k > 1) {
112  return a_n* pow<k>(x) + polySum<l, k-2>(x);
113  } else{
114  return a_n*pow<k>(x);
115  }
116  }

◆ polySum() [2/2]

constexpr double MuonCalib::Legendre::polySum ( const unsigned  l,
const double  x 
)
constexpr

Assembles the legendre polynomial at run-time.

Definition at line 145 of file LegendrePoly.h.

145  {
146  double sum{0.};
147  for (unsigned k = l%2; k<=l; k+=2) {
148  sum += pow(x,k) * coeff(l,k);
149  }
150  return sum;
151  }
MuonCalib::factorial
constexpr unsigned long factorial(const int n)
Evaluated the n-th factorial at compile time.
Definition: LegendrePoly.h:51
CLHEP::binom
double binom(int n, int k)
Definition: RandBinomialFixedP.cxx:19
hist_file_dump.d
d
Definition: hist_file_dump.py:143
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
MuonCalib::Legendre::polySum
constexpr double polySum(const unsigned l, const double x)
Assembles the legendre polynomial at run-time.
Definition: LegendrePoly.h:145
x
#define x
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
MuonCalib::Legendre::coeff
constexpr double coeff(const unsigned l, const unsigned k)
Calculates the n-th coefficient of the legendre polynomial series.
Definition: LegendrePoly.h:92
MuonCalib::binomial
constexpr unsigned long binomial(const unsigned n, const unsigned k)
Calculates the binomial coefficient at compile time.
Definition: LegendrePoly.h:60
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
fitman.k
k
Definition: fitman.py:528