Import Geant4 7.1.0 source tree
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4SimpleIntegration.cc,v 1.5 2004/11/12 17:38:33 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-03 $
|
||||
// $Id: G4SimpleIntegration.cc,v 1.6 2005/03/15 19:11:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
//
|
||||
// Implementation file for simple integration methods
|
||||
//
|
||||
@@ -35,21 +35,21 @@ G4int G4SimpleIntegration::fMaxDepth = 100 ;
|
||||
|
||||
|
||||
G4SimpleIntegration::G4SimpleIntegration( function pFunction )
|
||||
: fFunction(pFunction),
|
||||
fTolerance(.0001)
|
||||
{
|
||||
fFunction = pFunction ;
|
||||
}
|
||||
|
||||
G4SimpleIntegration::G4SimpleIntegration( function pFunction,
|
||||
G4double pTolerance)
|
||||
G4double pTolerance)
|
||||
: fFunction(pFunction),
|
||||
fTolerance(pTolerance)
|
||||
{
|
||||
fFunction = pFunction ;
|
||||
fTolerance = pTolerance ;
|
||||
}
|
||||
|
||||
|
||||
G4SimpleIntegration::~G4SimpleIntegration()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
// Simple integration methods
|
||||
@@ -57,13 +57,12 @@ G4SimpleIntegration::~G4SimpleIntegration()
|
||||
G4double
|
||||
G4SimpleIntegration::Trapezoidal(G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4int iterationNumber )
|
||||
G4int iterationNumber )
|
||||
{
|
||||
G4int i ;
|
||||
G4double Step = (xFinal - xInitial)/iterationNumber ;
|
||||
G4double mean = (fFunction(xInitial) + fFunction(xFinal))*0.5 ;
|
||||
G4double x = xInitial ;
|
||||
for(i=1;i<iterationNumber;i++)
|
||||
for(G4int i=1;i<iterationNumber;i++)
|
||||
{
|
||||
x += Step ;
|
||||
mean += fFunction(x) ;
|
||||
@@ -74,13 +73,12 @@ G4SimpleIntegration::Trapezoidal(G4double xInitial,
|
||||
G4double
|
||||
G4SimpleIntegration::MidPoint(G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4int iterationNumber )
|
||||
G4int iterationNumber )
|
||||
{
|
||||
G4int i ;
|
||||
G4double Step = (xFinal - xInitial)/iterationNumber ;
|
||||
G4double x = xInitial + 0.5*Step;
|
||||
G4double mean = fFunction(x) ;
|
||||
for(i=1;i<iterationNumber;i++)
|
||||
for(G4int i=1;i<iterationNumber;i++)
|
||||
{
|
||||
x += Step ;
|
||||
mean += fFunction(x) ;
|
||||
@@ -91,15 +89,14 @@ G4SimpleIntegration::MidPoint(G4double xInitial,
|
||||
G4double
|
||||
G4SimpleIntegration::Gauss(G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4int iterationNumber )
|
||||
G4int iterationNumber )
|
||||
{
|
||||
G4int i ;
|
||||
G4double x ;
|
||||
G4double x=0.;
|
||||
static G4double root = 1.0/std::sqrt(3.0) ;
|
||||
G4double Step = (xFinal - xInitial)/(2.0*iterationNumber) ;
|
||||
G4double delta = Step*root ;
|
||||
G4double mean = 0.0 ;
|
||||
for(i=0;i<iterationNumber;i++)
|
||||
for(G4int i=0;i<iterationNumber;i++)
|
||||
{
|
||||
x = (2*i + 1)*Step ;
|
||||
mean += (fFunction(x+delta) + fFunction(x-delta)) ;
|
||||
@@ -110,15 +107,14 @@ G4SimpleIntegration::Gauss(G4double xInitial,
|
||||
G4double
|
||||
G4SimpleIntegration::Simpson(G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4int iterationNumber )
|
||||
G4int iterationNumber )
|
||||
{
|
||||
G4int i ;
|
||||
G4double Step = (xFinal - xInitial)/iterationNumber ;
|
||||
G4double x = xInitial ;
|
||||
G4double xPlus = xInitial + 0.5*Step ;
|
||||
G4double mean = (fFunction(xInitial) + fFunction(xFinal))*0.5 ;
|
||||
G4double sum = fFunction(xPlus) ;
|
||||
for(i=1;i<iterationNumber;i++)
|
||||
for(G4int i=1;i<iterationNumber;i++)
|
||||
{
|
||||
x += Step ;
|
||||
xPlus += Step ;
|
||||
@@ -142,7 +138,7 @@ G4SimpleIntegration::AdaptGaussIntegration( G4double xInitial,
|
||||
AdaptGauss(xInitial,xFinal,sum,depth) ;
|
||||
return sum ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double
|
||||
G4SimpleIntegration::Gauss( G4double xInitial,
|
||||
@@ -162,12 +158,13 @@ G4SimpleIntegration::Gauss( G4double xInitial,
|
||||
void
|
||||
G4SimpleIntegration::AdaptGauss( G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4double& sum,
|
||||
G4int& depth )
|
||||
G4double& sum,
|
||||
G4int& depth )
|
||||
{
|
||||
if(depth >fMaxDepth)
|
||||
{
|
||||
G4Exception("Function varies too rapidly in G4SimpleIntegration::AdaptGauss") ;
|
||||
G4Exception("G4SimpleIntegration::AdaptGauss()", "Error",
|
||||
FatalException, "Function varies too rapidly !") ;
|
||||
}
|
||||
G4double xMean = (xInitial + xFinal)/2.0 ;
|
||||
G4double leftHalf = Gauss(xInitial,xMean) ;
|
||||
|
||||
Reference in New Issue
Block a user