43 : fFunction(pFunction), fNumber(n),
44 fChebyshevCof(new
G4double[fNumber]),
45 fMean(0.5*(b+a)), fDiff(0.5*(b-a))
53 for (i=0;i<fNumber;i++)
55 rootSum = std::cos(cof*(i+0.5)) ;
56 tempFunction[i]= fFunction(rootSum*fDiff+fMean) ;
58 for (j=0;j<fNumber;j++)
63 for (i=0;i<fNumber;i++)
65 rootSum += tempFunction[i]*std::cos(cofj*(i+0.5)) ;
67 fChebyshevCof[j] = weight*rootSum ;
69 delete[] tempFunction ;
83 : fFunction(pFunction), fNumber(nx),
84 fChebyshevCof(new
G4double[fNumber]),
85 fMean(0.5*(b+a)), fDiff(0.5*(b-a))
89 G4Exception(
"G4ChebyshevApproximation::G4ChebyshevApproximation()",
98 for (i=0;i<fNumber;i++)
100 rootSum = std::cos(cof*(i+0.5)) ;
101 tempFunction[i] = fFunction(rootSum*fDiff+fMean) ;
103 for (j=0;j<fNumber;j++)
108 for (i=0;i<fNumber;i++)
110 rootSum += tempFunction[i]*std::cos(cofj*(i+0.5)) ;
112 fChebyshevCof[j] = weight*rootSum ;
120 for(j=0;j<fNumber;j++)
122 fChebyshevCof[j] = tempFunction[j] ;
125 delete[] tempFunction ;
137 : fFunction(pFunction), fNumber(n),
138 fChebyshevCof(new
G4double[fNumber]),
139 fMean(0.5*(b+a)), fDiff(0.5*(b-a))
147 for (i=0;i<fNumber;i++)
149 rootSum = std::cos(cof*(i+0.5)) ;
150 tempFunction[i]= fFunction(rootSum*fDiff+fMean) ;
152 for (j=0;j<fNumber;j++)
157 for (i=0;i<fNumber;i++)
159 rootSum += tempFunction[i]*std::cos(cofj*(i+0.5)) ;
161 fChebyshevCof[j] = weight*rootSum ;
166 for(j=0;j<fNumber;j++)
168 fChebyshevCof[j] = tempFunction[j] ;
170 delete[] tempFunction ;
181 delete[] fChebyshevCof ;
193 if(number < 0 && number >= fNumber)
195 G4Exception(
"G4ChebyshevApproximation::GetChebyshevCof()",
198 return fChebyshevCof[number] ;
209 G4double evaluate = 0.0, evaluate2 = 0.0, temp = 0.0,
210 xReduced = 0.0, xReduced2 = 0.0 ;
212 if ((x-fMean+fDiff)*(x-fMean-fDiff) > 0.0)
214 G4Exception(
"G4ChebyshevApproximation::ChebyshevEvaluation()",
217 xReduced = (x-fMean)/fDiff ;
218 xReduced2 = 2.0*xReduced ;
219 for (
G4int i=fNumber-1;i>=1;i--)
222 evaluate = xReduced2*evaluate - evaluate2 + fChebyshevCof[i] ;
225 return xReduced*evaluate - evaluate2 + 0.5*fChebyshevCof[0] ;
237 derCof[fNumber-1] = 0.0 ;
238 derCof[fNumber-2] = 2*(fNumber-1)*fChebyshevCof[fNumber-1] ;
239 for(
G4int i=fNumber-3;i>=0;i--)
241 derCof[i] = derCof[i+2] + 2*(i+1)*fChebyshevCof[i+1] ;
243 for(
G4int j=0;j<fNumber;j++)
261 G4double cof = 0.5*fDiff, sum = 0.0, factor = 1.0 ;
262 for(
G4int i=1;i<fNumber-1;i++)
264 integralCof[i] = cof*(fChebyshevCof[i-1] - fChebyshevCof[i+1])/i ;
265 sum += factor*integralCof[i] ;
268 integralCof[fNumber-1] = cof*fChebyshevCof[fNumber-2]/(fNumber-1) ;
269 sum += factor*integralCof[fNumber-1] ;
270 integralCof[0] = 2.0*sum ;
std::vector< ExP01TrackerHit * > a
G4double GetChebyshevCof(G4int number) const
G4ChebyshevApproximation(function pFunction, G4int n, G4double a, G4double b)
G4double ChebyshevEvaluation(G4double x) const
void DerivativeChebyshevCof(G4double derCof[]) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static constexpr double pi
~G4ChebyshevApproximation()
void IntegralChebyshevCof(G4double integralCof[]) const