#include <G4ChebyshevApproximation.hh>
|
| G4ChebyshevApproximation (function pFunction, G4int n, G4double a, G4double b) |
|
| G4ChebyshevApproximation (function pFunction, G4int n, G4int m, G4double a, G4double b) |
|
| G4ChebyshevApproximation (function pFunction, G4double a, G4double b, G4int n) |
|
| ~G4ChebyshevApproximation () |
|
G4double | GetChebyshevCof (G4int number) const |
|
G4double | ChebyshevEvaluation (G4double x) const |
|
void | DerivativeChebyshevCof (G4double derCof[]) const |
|
void | IntegralChebyshevCof (G4double integralCof[]) const |
|
Definition at line 39 of file G4ChebyshevApproximation.cc.
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 ;
static constexpr double pi
Definition at line 80 of file G4ChebyshevApproximation.cc.
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 ;
void DerivativeChebyshevCof(G4double derCof[]) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static constexpr double pi
Definition at line 133 of file G4ChebyshevApproximation.cc.
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 ;
static constexpr double pi
void IntegralChebyshevCof(G4double integralCof[]) const
G4ChebyshevApproximation::~G4ChebyshevApproximation |
( |
| ) |
|
Definition at line 207 of file G4ChebyshevApproximation.cc.
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] ;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void G4ChebyshevApproximation::DerivativeChebyshevCof |
( |
G4double |
derCof[] | ) |
const |
Definition at line 234 of file G4ChebyshevApproximation.cc.
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++)
G4double G4ChebyshevApproximation::GetChebyshevCof |
( |
G4int |
number | ) |
const |
Definition at line 191 of file G4ChebyshevApproximation.cc.
193 if(number < 0 && number >= fNumber)
195 G4Exception(
"G4ChebyshevApproximation::GetChebyshevCof()",
198 return fChebyshevCof[number] ;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void G4ChebyshevApproximation::IntegralChebyshevCof |
( |
G4double |
integralCof[] | ) |
const |
Definition at line 259 of file G4ChebyshevApproximation.cc.
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 ;
The documentation for this class was generated from the following files: