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));
50 map<
G4int, map<G4int, G4double> >* cache)
57 if(l<0 || m<-l || m>l)
return 0;
66 G4double value = (m%2 ? -1. : 1.) * EvalAssocLegendrePoly(l, -m, x);
81 if(m==0)
return 0.5*(3.*x2 - 1.);
82 if(m==1)
return -3.*x*sqrt(1.-x2);
86 if(m==0)
return 0.5*(5.*x*x2 - 3.*
x);
87 if(m==1)
return -1.5*(5.*x2-1.)*sqrt(1.-x2);
88 if(m==2)
return 15.*x*(1.-
x2);
89 return -15.*(1.-
x2)*sqrt(1.-x2);
92 if(m==0)
return 0.125*(35.*x2*x2 - 30.*x2 + 3.);
93 if(m==1)
return -2.5*(7.*x*x2-3.*
x)*sqrt(1.-x2);
94 if(m==2)
return 7.5*(7.*x2-1.)*(1.-
x2);
95 if(m==3)
return -105.*x*(1.-
x2)*sqrt(1.-x2);
96 return 105.*(1. - 2.*x2 + x2*
x2);
102 if(m==l)
return (l%2 ? -1. : 1.) *
105 if(m==l-1)
return x*(2.*
G4double(m)+1.)*EvalAssocLegendrePoly(m,m,x);
108 if(cache != NULL && cache->count(l) > 0 && (*cache)[l].count(m) > 0) {
109 return (*cache)[l][
m];
126 G4cout <<
"G4LegendrePolynomial::GetCoefficient(): "
127 <<
"I refuse to make a Legendre Polynomial of order "
131 while(fCoefficients.size() < orderMax+1) {
132 size_t order = fCoefficients.size();
133 fCoefficients.resize(order+1);
134 if(order <= 1) fCoefficients[order].push_back(1.);
136 for(
size_t iCoeff = 0; iCoeff < order+1; ++iCoeff) {
137 if((order % 2) == (iCoeff % 2)) {
139 if(iCoeff <= order-2) coeff -= fCoefficients[order-2][iCoeff/2]*
G4double(order-1);
140 if(iCoeff > 0) coeff += fCoefficients[order-1][(iCoeff-1)/2]*
G4double(2*order-1);
142 fCoefficients[order].push_back(coeff);
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4double factorial(G4int Z) const
G4double EvalLegendrePoly(G4int order, G4double x)
G4double G4Log(G4double x)
G4double EvalAssocLegendrePoly(G4int l, G4int m, G4double x, std::map< G4int, std::map< G4int, G4double > > *cache=NULL)
static constexpr double m
static G4Pow * GetInstance()
const XML_Char int const XML_Char * value
G4double logfactorial(G4int Z) const
void BuildUpToOrder(size_t order)
G4GLOB_DLL std::ostream G4cout
Float_t x2[n_points_geant4]
G4double GetCoefficient(size_t i, size_t order)