36 if(order >= fCoefficients.size()) BuildUpToOrder(order);
37 if(order >= fCoefficients.size() ||
38 i/2 >= fCoefficients[order].size() ||
39 (i%2) != order %2)
return 0;
40 return fCoefficients[order][i/2];
46 return (EvalAssocLegendrePoly(order,0,x));
51 if(l<0 || m<-l || m>l)
return 0;
60 * EvalAssocLegendrePoly(l, -m, x);
71 if(m==0)
return 0.5*(3.*x2 - 1.);
72 if(m==1)
return -3.*x*sqrt(1.-x2);
76 if(m==0)
return 0.5*(5.*x*x2 - 3.*
x);
77 if(m==1)
return -1.5*(5.*x2-1.)*sqrt(1.-x2);
78 if(m==2)
return 15.*x*(1.-x2);
79 return -15.*(1.-x2)*sqrt(1.-x2);
82 if(m==0)
return 0.125*(35.*x2*x2 - 30.*x2 + 3.);
83 if(m==1)
return -2.5*(7.*x*x2-3.*
x)*sqrt(1.-x2);
84 if(m==2)
return 7.5*(7.*x2-1.)*(1.-x2);
85 if(m==3)
return -105.*x*(1.-x2)*sqrt(1.-x2);
86 return 105.*(1. - 2.*x2 + x2*x2);
92 if(m==l)
return (l%2 ? -1. : 1.) *
95 if(m==l-1)
return x*(2.*
G4double(m)+1.)*EvalAssocLegendrePoly(m,m,x);
98 return (x*
G4double(2*l-1)*EvalAssocLegendrePoly(l-1,m,x) -
105 G4cout <<
"G4LegendrePolynomial::GetCoefficient(): "
106 <<
"I refuse to make a Legendre Polynomial of order "
110 while(fCoefficients.size() < orderMax+1) {
111 size_t order = fCoefficients.size();
112 fCoefficients.resize(order+1);
113 if(order <= 1) fCoefficients[order].push_back(1.);
115 for(
size_t iCoeff = 0; iCoeff < order+1; ++iCoeff) {
116 if((order % 2) == (iCoeff % 2)) {
118 if(iCoeff <= order-2) coeff -= fCoefficients[order-2][iCoeff/2]*
G4double(order-1);
119 if(iCoeff > 0) coeff += fCoefficients[order-1][(iCoeff-1)/2]*
G4double(2*order-1);
121 fCoefficients[order].push_back(coeff);
static G4Pow * GetInstance()
G4double EvalLegendrePoly(G4int order, G4double x)
G4GLOB_DLL std::ostream G4cout
static constexpr double m
G4double factorial(G4int Z) const
G4double G4Log(G4double x)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4double EvalAssocLegendrePoly(G4int l, G4int m, G4double x)
G4double logfactorial(G4int Z) const
void BuildUpToOrder(size_t order)
G4double GetCoefficient(size_t i, size_t order)