Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4ChebyshevApproximation.hh,v 2.0 1998/07/02 17:31:58 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// Class creating the Chebyshev approximation for a function pointed by fFunction
|
||||
// data member. The Chebyshev polinom approximation provides an efficient evaluation
|
||||
// of minimax polynomial, which (among all polynomials of the same degree) has the
|
||||
// smallest maximum deviation from the true function.
|
||||
// The methods based mainly on recommendations given in the book : An introduction to
|
||||
// NUMERICAL METHODS IN C++, B.H. Flowers, Claredon Press, Oxford, 1995
|
||||
//
|
||||
// ------------------------- MEMBER DATA ------------------------------------
|
||||
//
|
||||
// function fFunction - pointer to a function considered
|
||||
// G4int fNumber - number of Chebyshev coefficients
|
||||
// G4double* fChebyshevCof - array of Chebyshev coefficients
|
||||
// G4double fMean = (a+b)/2 - mean point of interval
|
||||
// G4double fDiff = (b-a)/2 - half of the interval value
|
||||
//
|
||||
// ------------------------ CONSTRUCTORS ----------------------------------
|
||||
//
|
||||
// Constructor for initialisation of the class data members. It creates the array
|
||||
// fChebyshevCof[0,...,fNumber-1], fNumber = n ; which consists of Chebyshev
|
||||
// coefficients describing the function pointed by pFunction. The values a and b
|
||||
// fixe the interval of validity of Chebyshev approximation.
|
||||
//
|
||||
// G4ChebyshevApproximation( function pFunction,
|
||||
// G4int n,
|
||||
// G4double a,
|
||||
// G4double b )
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
// Constructor for creation of Chebyshev coefficients for m-derivative
|
||||
// from pFunction. The value of m ! MUST BE ! < n , because the result
|
||||
// array of fChebyshevCof will be of (n-m) size. There is a definite dependence
|
||||
// between the proper selection of n, m, a and b values to get better accuracy
|
||||
// of the derivative value.
|
||||
//
|
||||
// G4ChebyshevApproximation( function pFunction,
|
||||
// G4int n,
|
||||
// G4int m,
|
||||
// G4double a,
|
||||
// G4double b )
|
||||
//
|
||||
// ------------------------------------------------------
|
||||
//
|
||||
// Constructor for creation of Chebyshev coefficients for integral
|
||||
// from pFunction.
|
||||
//
|
||||
// G4ChebyshevApproximation( function pFunction,
|
||||
// G4double a,
|
||||
// G4double b,
|
||||
// G4int n )
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// Destructor deletes the array of Chebyshev coefficients
|
||||
//
|
||||
// ~G4ChebyshevApproximation()
|
||||
//
|
||||
// ----------------------------- METHODS ----------------------------------
|
||||
//
|
||||
// Access function for Chebyshev coefficients
|
||||
//
|
||||
// G4double GetChebyshevCof(G4int number) const
|
||||
//
|
||||
// --------------------------------------------------------------
|
||||
//
|
||||
// Evaluate the value of fFunction at the point x via the Chebyshev coefficients
|
||||
// fChebyshevCof[0,...,fNumber-1]
|
||||
//
|
||||
// G4double ChebyshevEvaluation(G4double x) const
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Returns the array derCof[0,...,fNumber-2], the Chebyshev coefficients of the
|
||||
// derivative of the function whose coefficients are fChebyshevCof
|
||||
//
|
||||
// void DerivativeChebyshevCof(G4double derCof[]) const
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
// This function produces the array integralCof[0,...,fNumber-1] , the Chebyshev
|
||||
// coefficients of the integral of the function whose coefficients are
|
||||
// fChebyshevCof. The constant of integration is set so that the integral vanishes
|
||||
// at the point (fMean - fDiff)
|
||||
//
|
||||
// void IntegralChebyshevCof(G4double integralCof[]) const
|
||||
//
|
||||
// --------------------------- HISTORY --------------------------------------
|
||||
//
|
||||
// 24.04.97 V.Grichine ( Vladimir.Grichine@cern.ch )
|
||||
|
||||
#ifndef G4CHEBYSHEVAPPROXIMATION_HH
|
||||
#define G4CHEBYSHEVAPPROXIMATION_HH
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
typedef G4double (*function)(G4double) ;
|
||||
|
||||
class G4ChebyshevApproximation
|
||||
{
|
||||
public:
|
||||
G4ChebyshevApproximation( function pFunction,
|
||||
G4int n,
|
||||
G4double a,
|
||||
G4double b ) ;
|
||||
|
||||
// Constructor for creation of Chebyshev coefficients for m-derivative
|
||||
// from pFunction. The value of m ! MUST BE ! < n , because the result
|
||||
// array of fChebyshevCof will be of (n-m) size.
|
||||
|
||||
G4ChebyshevApproximation( function pFunction,
|
||||
G4int n,
|
||||
G4int m,
|
||||
G4double a,
|
||||
G4double b ) ;
|
||||
|
||||
// Constructor for creation of Chebyshev coefficients for integral
|
||||
// from pFunction.
|
||||
|
||||
G4ChebyshevApproximation( function pFunction,
|
||||
G4double a,
|
||||
G4double b,
|
||||
G4int n ) ;
|
||||
|
||||
|
||||
|
||||
~G4ChebyshevApproximation() ;
|
||||
|
||||
// Access functions
|
||||
|
||||
G4double GetChebyshevCof(G4int number) const ;
|
||||
|
||||
// Methods
|
||||
|
||||
G4double ChebyshevEvaluation(G4double x) const ;
|
||||
|
||||
void DerivativeChebyshevCof(G4double derCof[]) const ;
|
||||
|
||||
void IntegralChebyshevCof(G4double integralCof[]) const ;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
function fFunction ;
|
||||
G4int fNumber ;
|
||||
G4double* fChebyshevCof ;
|
||||
G4double fMean ;
|
||||
G4double fDiff ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,141 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4DataInterpolation.hh,v 2.0 1998/07/02 17:31:40 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// The class consists of some methods for data interpolations and extrapolations.
|
||||
// The methods based mainly on recommendations given in the book : An introduction to
|
||||
// NUMERICAL METHODS IN C++, B.H. Flowers, Claredon Press, Oxford, 1995
|
||||
//
|
||||
// ------------------------------ Data members: ---------------------------------
|
||||
//
|
||||
// fArgument and fFunction - pointers to data table to be interpolated
|
||||
// for y[i] and x[i] respectively
|
||||
// fNumber - the corresponding table size
|
||||
// ......
|
||||
// G4DataInterpolation( G4double pX[], G4double pY[], G4int number )
|
||||
//
|
||||
// Constructor for initializing of fArgument, fFunction and fNumber data members:
|
||||
// ......
|
||||
// G4DataInterpolation( G4double pX[], G4double pY[], G4int number,
|
||||
// G4double pFirstDerStart, G4double pFirstDerFinish )
|
||||
//
|
||||
// Constructor for cubic spline interpolation. It creates the array
|
||||
// fSecondDerivative[0,...fNumber-1] which is used in this interpolation by
|
||||
// the function:
|
||||
// ....
|
||||
// ~G4DataInterpolation()
|
||||
//
|
||||
// Destructor deletes dynamically created arrays for data members: fArgument,
|
||||
// fFunction and fSecondDerivative, all have dimension of fNumber
|
||||
//
|
||||
// ------------------------------ Methods: ----------------------------------------
|
||||
//
|
||||
// G4double PolynomInterpolation(G4double pX, G4double& deltaY ) const
|
||||
//
|
||||
// This function returns the value P(pX), where P(x) is polynom of fNumber-1 degree
|
||||
// such that P(fArgument[i]) = fFunction[i], for i = 0, ..., fNumber-1 .
|
||||
// ........
|
||||
// void PolIntCoefficient( G4double cof[]) const
|
||||
//
|
||||
// Given arrays fArgument[0,..,fNumber-1] and fFunction[0,..,fNumber-1] , this
|
||||
// function calculates an array of coefficients. The coefficients don't provide
|
||||
// usually (fNumber>10) better accuracy for polynom interpolation, as compared with
|
||||
// PolynomInterpolation function. They could be used instead for derivate
|
||||
// calculations and some other applications.
|
||||
// .........
|
||||
// G4double RationalPolInterpolation(G4double pX, G4double& deltaY ) const
|
||||
//
|
||||
// The function returns diagonal rational function (Bulirsch and Stoer algorithm
|
||||
// of Neville type) Pn(x)/Qm(x) where P and Q are polynoms.
|
||||
// Tests showed the method is not stable and hasn't advantage if compared with
|
||||
// polynomial interpolation
|
||||
// ................
|
||||
// G4double CubicSplineInterpolation(G4double pX) const
|
||||
//
|
||||
// Cubic spline interpolation in point pX for function given by the table:
|
||||
// fArgument, fFunction. The constructor, which creates fSecondDerivative, must be
|
||||
// called before. The function works optimal, if sequential calls are in random
|
||||
// values of pX.
|
||||
// ..................
|
||||
// G4double FastCubicSpline(G4double pX, G4int index) const
|
||||
//
|
||||
// Return cubic spline interpolation in the point pX which is located between
|
||||
// fArgument[index] and fArgument[index+1]. It is usually called in sequence of
|
||||
// known from external analysis values of index.
|
||||
// .........
|
||||
// G4int LocateArgument(G4double pX) const
|
||||
//
|
||||
// Given argument pX, returns index k, so that pX bracketed by fArgument[k] and
|
||||
// fArgument[k+1]
|
||||
// ......................
|
||||
// void CorrelatedSearch( G4double pX, G4int& index ) const
|
||||
//
|
||||
// Given a value pX, returns a value 'index' such that pX is between fArgument[index]
|
||||
// and fArgument[index+1]. fArgument MUST BE MONOTONIC, either increasing or
|
||||
// decreasing. If index = -1 or fNumber, this indicates that pX is out of range.
|
||||
// The value index on input is taken as the initial approximation for index on
|
||||
// output.
|
||||
//
|
||||
// --------------------------------- History: --------------------------------------
|
||||
//
|
||||
// 3.4.97 V.Grichine (Vladimir.Grichine@cern.ch)
|
||||
//
|
||||
|
||||
|
||||
#ifndef G4DATAINTERPOLATION_HH
|
||||
#define G4DATAINTERPOLATION_HH
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
class G4DataInterpolation
|
||||
{
|
||||
public:
|
||||
G4DataInterpolation( G4double pX[],
|
||||
G4double pY[],
|
||||
G4int number );
|
||||
|
||||
// Constructor for cubic spline interpolation. It creates fSecond Deivative array
|
||||
// as well as fArgument and fFunction
|
||||
|
||||
G4DataInterpolation( G4double pX[],
|
||||
G4double pY[],
|
||||
G4int number,
|
||||
G4double pFirstDerStart,
|
||||
G4double pFirstDerFinish ) ;
|
||||
|
||||
~G4DataInterpolation() ;
|
||||
|
||||
G4double PolynomInterpolation( G4double pX,
|
||||
G4double& deltaY ) const ;
|
||||
|
||||
void PolIntCoefficient( G4double cof[]) const ;
|
||||
|
||||
G4double RationalPolInterpolation( G4double pX,
|
||||
G4double& deltaY ) const ;
|
||||
|
||||
G4double CubicSplineInterpolation( G4double pX ) const ;
|
||||
|
||||
G4double FastCubicSpline( G4double pX,
|
||||
G4int index ) const ;
|
||||
|
||||
G4int LocateArgument( G4double pX ) const ;
|
||||
|
||||
void CorrelatedSearch( G4double pX,
|
||||
G4int& index ) const ;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
G4double* fArgument ;
|
||||
G4double* fFunction ;
|
||||
G4double* fSecondDerivative ;
|
||||
G4int fNumber ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4GaussChebyshevQ.hh,v 2.0 1998/07/02 17:31:43 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// Class for Gauss-Chebyshev quadrature method
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
// iteration method (by bisection Newton algorithm). Constant values for initial
|
||||
// approximations were derived from the book: M. Abramowitz, I. Stegun, Handbook
|
||||
// of mathematical functions, DOVER Publications INC, New York 1965 ; chapters 9,
|
||||
// 10, and 22 .
|
||||
//
|
||||
// ------------------------------ CONSTRUCTORS ----------------------------
|
||||
//
|
||||
// Constructor for Gauss-Chebyshev quadrature method
|
||||
//
|
||||
// G4GaussChebyshevQuadrature( function pFunction,
|
||||
// G4int nChebyshev )
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------- METHODS -----------------------------------
|
||||
//
|
||||
// Integrates function pointed by fFunction from a to b by Gauss-Chebyshev quadrature
|
||||
// method
|
||||
//
|
||||
// G4double Integral(G4double a, G4double b) const
|
||||
//
|
||||
// ------------------------------- HISTORY --------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
#ifndef G4GAUSSCHEBYSHEVQ_HH
|
||||
#define G4GAUSSCHEBYSHEVQ_HH
|
||||
|
||||
#include "G4VGaussianQuadrature.hh"
|
||||
|
||||
class G4GaussChebyshevQ : public G4VGaussianQuadrature
|
||||
{
|
||||
public:
|
||||
// Constructor/destructor
|
||||
|
||||
G4GaussChebyshevQ( function pFunction,
|
||||
G4int nChebyshev ) ;
|
||||
|
||||
~G4GaussChebyshevQ() ;
|
||||
|
||||
// Methods
|
||||
|
||||
G4double Integral(G4double a, G4double b) const ;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4GaussHermiteQ.hh,v 2.0 1998/07/02 17:31:47 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
// iteration method (by bisection Newton algorithm). Constant values for initial
|
||||
// approximations were derived from the book: M. Abramowitz, I. Stegun, Handbook
|
||||
// of mathematical functions, DOVER Publications INC, New York 1965 ; chapters 9,
|
||||
// 10, and 22 .
|
||||
//
|
||||
// --------------------------------------------------------------------------
|
||||
//
|
||||
// Constructor for Gauss-Hermite quadrature method . The function GaussHermite
|
||||
// should be called then
|
||||
//
|
||||
// G4GaussHermiteQ( function pFunction, G4int nHermite )
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Gauss-Hermite method for integration of exp(-x*x)*nFunction(x) from minus infinity
|
||||
// to plus infinity .
|
||||
//
|
||||
// G4double Integral() const
|
||||
//
|
||||
//
|
||||
// ------------------------------- HISTORY -------------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
#ifndef G4GAUSSHERMITEQ_HH
|
||||
#define G4GAUSSHERMITEQ_HH
|
||||
|
||||
#include "G4VGaussianQuadrature.hh"
|
||||
|
||||
class G4GaussHermiteQ : public G4VGaussianQuadrature
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
|
||||
G4GaussHermiteQ( function pFunction, G4int nHermite ) ;
|
||||
|
||||
// Methods
|
||||
|
||||
G4double Integral() const ;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4GaussJacobiQ.hh,v 2.0 1998/07/02 17:31:49 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
// iteration method (by bisection Newton algorithm). Constant values for initial
|
||||
// approximations were derived from the book: M. Abramowitz, I. Stegun, Handbook
|
||||
// of mathematical functions, DOVER Publications INC, New York 1965 ; chapters 9,
|
||||
// 10, and 22 .
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Constructor for Gauss-Jacobi integration method.
|
||||
//
|
||||
// G4GaussJacobiQ( function pFunction,
|
||||
// G4double alpha,
|
||||
// G4double beta,
|
||||
// G4int nJacobi )
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Gauss-Jacobi method for integration of ((1-x)^alpha)*((1+x)^beta)*pFunction(x)
|
||||
// from minus unit to plus unit .
|
||||
//
|
||||
// G4double Integral() const
|
||||
//
|
||||
// ------------------------------- HISTORY -------------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
#ifndef G4GAUSSJACOBIQ_HH
|
||||
#define G4GAUSSJACOBIQ_HH
|
||||
|
||||
#include "G4VGaussianQuadrature.hh"
|
||||
|
||||
class G4GaussJacobiQ : public G4VGaussianQuadrature
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
|
||||
G4GaussJacobiQ( function pFunction,
|
||||
G4double alpha,
|
||||
G4double beta,
|
||||
G4int nJacobi ) ;
|
||||
|
||||
// Methods
|
||||
|
||||
G4double Integral() const ;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4GaussLaguerreQ.hh,v 2.0 1998/07/02 17:31:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// Class for realization of Gauss-Laguerre quadrature method
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
// iteration method (by bisection Newton algorithm). Constant values for initial
|
||||
// approximations were derived from the book: M. Abramowitz, I. Stegun, Handbook
|
||||
// of mathematical functions, DOVER Publications INC, New York 1965 ; chapters 9,
|
||||
// 10, and 22 .
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// Constructor for Gauss-Laguerre quadrature method: integral from zero to
|
||||
// infinity of pow(x,alpha)*exp(-x)*f(x). The value of nLaguerre sets the accuracy.
|
||||
// The constructor creates arrays fAbscissa[0,..,nLaguerre-1] and
|
||||
// fWeight[0,..,nLaguerre-1] . The function GaussLaguerre(f) should be called
|
||||
// then with any f .
|
||||
//
|
||||
// G4GaussLaguerreQ( function pFunction,
|
||||
// G4double alpha,
|
||||
// G4int nLaguerre )
|
||||
//
|
||||
//
|
||||
// -------------------------------------------------------------------------
|
||||
//
|
||||
// Gauss-Laguerre method for integration of pow(x,alpha)*exp(-x)*pFunction(x)
|
||||
// from zero up to infinity. pFunction is evaluated in fNumber points for which
|
||||
// fAbscissa[i] and fWeight[i] arrays were created in constructor
|
||||
//
|
||||
// G4double Integral() const
|
||||
//
|
||||
// ------------------------------- HISTORY --------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
#ifndef G4GAUSSLAGUERREQ_HH
|
||||
#define G4GAUSSLAGUERREQ_HH
|
||||
|
||||
#include "G4VGaussianQuadrature.hh"
|
||||
|
||||
class G4GaussLaguerreQ : public G4VGaussianQuadrature
|
||||
{
|
||||
public:
|
||||
G4GaussLaguerreQ( function pFunction,
|
||||
G4double alpha,
|
||||
G4int nLaguerre ) ;
|
||||
|
||||
// Methods
|
||||
|
||||
G4double Integral() const ;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4GaussLegendreQ.hh,v 2.1 1998/07/12 02:58:44 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// Class for Gauss-Legendre integration method
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
// iteration method (by bisection Newton algorithm). Constant values for initial
|
||||
// approximations were derived from the book: M. Abramowitz, I. Stegun, Handbook
|
||||
// of mathematical functions, DOVER Publications INC, New York 1965 ; chapters 9,
|
||||
// 10, and 22 .
|
||||
//
|
||||
// ------------------------- CONSTRUCTORS: -------------------------------
|
||||
//
|
||||
// Constructor for GaussLegendre quadrature method. The value nLegendre set the
|
||||
// accuracy required, i.e the number of points where the function pFunction will
|
||||
// be evaluated during integration. The constructor creates the arrays for
|
||||
// abscissas and weights that used in Gauss-Legendre quadrature method.
|
||||
// The values a and b are the limits of integration of the pFunction.
|
||||
//
|
||||
// G4GaussLegendreQ( function pFunction,
|
||||
// G4int nLegendre )
|
||||
//
|
||||
// -------------------------- METHODS: ---------------------------------------
|
||||
//
|
||||
// Returns the integral of the function to be pointed by fFunction between a and b,
|
||||
// by 2*fNumber point Gauss-Legendre integration: the function is evaluated exactly
|
||||
// 2*fNumber Times at interior points in the range of integration. Since the weights
|
||||
// and abscissas are, in this case, symmetric around the midpoint of the range of
|
||||
// integration, there are actually only fNumber distinct values of each.
|
||||
//
|
||||
// G4double Integral(G4double a, G4double b) const
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
// Returns the integral of the function to be pointed by fFunction between a and b,
|
||||
// by ten point Gauss-Legendre integration: the function is evaluated exactly
|
||||
// ten Times at interior points in the range of integration. Since the weights
|
||||
// and abscissas are, in this case, symmetric around the midpoint of the range of
|
||||
// integration, there are actually only five distinct values of each
|
||||
//
|
||||
// G4double
|
||||
// QuickIntegral(G4double a, G4double b) const
|
||||
//
|
||||
// ---------------------------------------------------------------------
|
||||
//
|
||||
// Returns the integral of the function to be pointed by fFunction between a and b,
|
||||
// by 96 point Gauss-Legendre integration: the function is evaluated exactly
|
||||
// ten Times at interior points in the range of integration. Since the weights
|
||||
// and abscissas are, in this case, symmetric around the midpoint of the range of
|
||||
// integration, there are actually only five distinct values of each
|
||||
//
|
||||
// G4double
|
||||
// AccurateIntegral(G4double a, G4double b) const
|
||||
//
|
||||
// ------------------------------- HISTORY --------------------------------
|
||||
//
|
||||
// 13.05.97 V.Grichine (Vladimir.Grichine@cern.chz0
|
||||
|
||||
#ifndef G4GAUSSLEGENDREQ_HH
|
||||
#define G4GAUSSLEGENDREQ_HH
|
||||
|
||||
#include "G4VGaussianQuadrature.hh"
|
||||
|
||||
class G4GaussLegendreQ : public G4VGaussianQuadrature
|
||||
{
|
||||
public:
|
||||
G4GaussLegendreQ( function pFunction ) ;
|
||||
|
||||
|
||||
G4GaussLegendreQ( function pFunction,
|
||||
G4int nLegendre ) ;
|
||||
|
||||
// Methods
|
||||
|
||||
G4double Integral(G4double a, G4double b) const ;
|
||||
|
||||
G4double QuickIntegral(G4double a, G4double b) const ;
|
||||
|
||||
G4double AccurateIntegral(G4double a, G4double b) const ;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4SimpleIntegration.hh,v 2.1 1998/07/12 02:58:44 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// Class for realisation of simple numerical methodes for integration of functions
|
||||
// with signature: double f(double). The methods based mainly on algorithms given in
|
||||
// the book : An introduction to NUMERICAL METHODS IN C++, B.H. Flowers, Claredon
|
||||
// Press, Oxford, 1995
|
||||
//
|
||||
// --------------------------- Member data: -------------------------------------
|
||||
//
|
||||
// fFunction - pointer to the function to be integrated
|
||||
// fTolerance - accuracy of integration in Adaptive Gauss method
|
||||
// fMaxDepth = 100 - constant maximum iteration depth for
|
||||
// Adaptive Gauss method
|
||||
//
|
||||
// --------------------------- Methods: -----------------------------------------
|
||||
//
|
||||
// Trapezoidal, MidPoint, Gauss,
|
||||
// and Simpson(double a,double b,int n) - integrate function pointed
|
||||
// by fFunction from a to b by n iterations, i.e. with Step (b-a)/n
|
||||
// according to the correspondent method
|
||||
//
|
||||
// AdaptGausIntegration(double a, double b) - integrate function from a to be with
|
||||
// accuracy <= fTolerance
|
||||
//
|
||||
// ----------------------------- History: ----------------------------------------
|
||||
//
|
||||
// 26.03.97 V.Grichine ( Vladimir.Grichine@cern.ch )
|
||||
|
||||
#ifndef G4SIMPLEINTEGRATION_HH
|
||||
#define G4SIMPLEINTEGRATION_HH
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
typedef G4double (*function)(G4double) ;
|
||||
|
||||
class G4SimpleIntegration
|
||||
{
|
||||
public:
|
||||
G4SimpleIntegration( function pFunction ) ;
|
||||
|
||||
G4SimpleIntegration( function pFunction,
|
||||
G4double pTolerance ) ;
|
||||
|
||||
~G4SimpleIntegration() ;
|
||||
|
||||
// Simple integration methods
|
||||
|
||||
G4double Trapezoidal(G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4int iterationNumber ) ;
|
||||
|
||||
G4double MidPoint(G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4int iterationNumber ) ;
|
||||
|
||||
G4double Gauss(G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4int iterationNumber ) ;
|
||||
|
||||
G4double Simpson(G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4int iterationNumber ) ;
|
||||
|
||||
// Adaptive Gauss integration with accuracy ~ fTolerance
|
||||
|
||||
G4double AdaptGaussIntegration( G4double xInitial,
|
||||
G4double xFinal ) ;
|
||||
|
||||
|
||||
protected:
|
||||
G4double Gauss( G4double xInitial,
|
||||
G4double xFinal ) ;
|
||||
|
||||
void AdaptGauss( G4double xInitial,
|
||||
G4double xFinal,
|
||||
G4double& sum,
|
||||
G4int& depth ) ;
|
||||
|
||||
private:
|
||||
|
||||
function fFunction ;
|
||||
G4double fTolerance ;
|
||||
static G4int fMaxDepth ;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 GEANT4 collaboration.
|
||||
//
|
||||
// By copying, distributing or modifying the Program (or any work
|
||||
// based on the Program) you indicate your acceptance of this statement,
|
||||
// and all its terms.
|
||||
//
|
||||
// $Id: G4VGaussianQuadrature.hh,v 2.0 1998/07/02 17:31:56 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// Base Class for realisation of numerical methodes for integration of functions
|
||||
// with signature double f(double) by Gaussian quadrature methods
|
||||
// Roots of ortogonal polynoms and corresponding weights are calculated based on
|
||||
// iteration method (by bisection Newton algorithm). Constant values for initial
|
||||
// approximations were derived from the book: M. Abramowitz, I. Stegun, Handbook
|
||||
// of mathematical functions, DOVER Publications INC, New York 1965 ; chapters 9,
|
||||
// 10, and 22 .
|
||||
//
|
||||
// ---------------------------- Member data: ----------------------------------
|
||||
//
|
||||
// fFunction - pointer to the function to be integrated
|
||||
// fNumber - the number of points in fAbscissa and fWeight arrays
|
||||
// fAbscissa - array of abscissas, where function will be evaluated
|
||||
// fWeight - array of corresponding weights
|
||||
//
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// Auxiliary function which returns the value of log(gamma-function(x))
|
||||
//
|
||||
// G4double
|
||||
// GammaLogarithm(G4double xx)
|
||||
//
|
||||
// ------------------------------------------------------------------------------
|
||||
//
|
||||
// History:
|
||||
// 18.04.97 V.Grichine ( Vladimir.Grichine@cern.ch )
|
||||
|
||||
#ifndef G4VGAUSSIANQUADRATURE_HH
|
||||
#define G4VGAUSSIANQUADRATURE_HH
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
typedef G4double (*function)(G4double) ;
|
||||
|
||||
class G4VGaussianQuadrature
|
||||
{
|
||||
public:
|
||||
// Base constructor
|
||||
|
||||
G4VGaussianQuadrature( function pFunction ) ;
|
||||
|
||||
// Virtual destructor
|
||||
|
||||
virtual ~G4VGaussianQuadrature() ;
|
||||
|
||||
// Access functions:
|
||||
|
||||
G4double GetAbscissa(G4int index) const ;
|
||||
|
||||
G4double GetWeight(G4int index) const ;
|
||||
|
||||
G4int GetNumber() const { return fNumber ; }
|
||||
|
||||
// Methods:
|
||||
|
||||
// virtual G4double DefiniteIntegral( G4double a,
|
||||
// G4double b ) const = 0 ;
|
||||
|
||||
// virtual G4double Integral() const = 0 ;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
G4double GammaLogarithm(G4double xx) ;
|
||||
|
||||
// Data members common for GaussianQuadrature family
|
||||
|
||||
function fFunction ;
|
||||
G4double* fAbscissa ;
|
||||
G4double* fWeight ;
|
||||
G4int fNumber ;
|
||||
private:
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user