42 : fFunction(pFunction)
44 , fChebyshevCof(new
G4double[fNumber])
45 , fMean(0.5 * (b + a))
46 , fDiff(0.5 * (b - a))
54 for(i = 0; i < fNumber; ++i)
56 rootSum = std::cos(cof * (i + 0.5));
57 tempFunction[i] = fFunction(rootSum * fDiff + fMean);
59 for(j = 0; j < fNumber; ++j)
64 for(i = 0; i < fNumber; ++i)
66 rootSum += tempFunction[i] * std::cos(cofj * (i + 0.5));
68 fChebyshevCof[j] = weight * rootSum;
70 delete[] tempFunction;
83 : fFunction(pFunction)
85 , fChebyshevCof(new
G4double[fNumber])
86 , fMean(0.5 * (b + a))
87 , fDiff(0.5 * (b - a))
91 G4Exception(
"G4ChebyshevApproximation::G4ChebyshevApproximation()",
100 for(i = 0; i < fNumber; ++i)
102 rootSum = std::cos(cof * (i + 0.5));
103 tempFunction[i] = fFunction(rootSum * fDiff + fMean);
105 for(j = 0; j < fNumber; ++j)
110 for(i = 0; i < fNumber; ++i)
112 rootSum += tempFunction[i] * std::cos(cofj * (i + 0.5));
114 fChebyshevCof[j] = weight * rootSum;
118 for(i = 1; i <= mx; ++i)
122 for(j = 0; j < fNumber; ++j)
124 fChebyshevCof[j] = tempFunction[j];
127 delete[] tempFunction;
138 : fFunction(pFunction)
140 , fChebyshevCof(new
G4double[fNumber])
141 , fMean(0.5 * (b + a))
142 , fDiff(0.5 * (b - a))
150 for(i = 0; i < fNumber; ++i)
152 rootSum = std::cos(cof * (i + 0.5));
153 tempFunction[i] = fFunction(rootSum * fDiff + fMean);
155 for(j = 0; j < fNumber; ++j)
160 for(i = 0; i < fNumber; ++i)
162 rootSum += tempFunction[i] * std::cos(cofj * (i + 0.5));
164 fChebyshevCof[j] = weight * rootSum;
169 for(j = 0; j < fNumber; ++j)
171 fChebyshevCof[j] = tempFunction[j];
173 delete[] tempFunction;
207 G4double evaluate = 0.0, evaluate2 = 0.0, temp = 0.0, xReduced = 0.0,
210 if((x - fMean + fDiff) * (x - fMean - fDiff) > 0.0)
212 G4Exception(
"G4ChebyshevApproximation::ChebyshevEvaluation()",
215 xReduced = (x - fMean) / fDiff;
216 xReduced2 = 2.0 * xReduced;
217 for(
G4int i = fNumber - 1; i >= 1; --i)
220 evaluate = xReduced2 * evaluate - evaluate2 + fChebyshevCof[i];
223 return xReduced * evaluate - evaluate2 + 0.5 * fChebyshevCof[0];
258 G4double cof = 0.5 * fDiff, sum = 0.0, factor = 1.0;
259 for(
G4int i = 1; i < fNumber - 1; ++i)
261 integralCof[i] = cof * (fChebyshevCof[i - 1] - fChebyshevCof[i + 1]) / i;
262 sum += factor * integralCof[i];
265 integralCof[fNumber - 1] = cof * fChebyshevCof[fNumber - 2] / (fNumber - 1);
266 sum += factor * integralCof[fNumber - 1];
267 integralCof[0] = 2.0 * sum;