Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4GaussJacobiQ Class Reference

#include <G4GaussJacobiQ.hh>

Inheritance diagram for G4GaussJacobiQ:
Collaboration diagram for G4GaussJacobiQ:

Public Member Functions

 G4GaussJacobiQ (function pFunction, G4double alpha, G4double beta, G4int nJacobi)
 
G4double Integral () const
 
- Public Member Functions inherited from G4VGaussianQuadrature
 G4VGaussianQuadrature (function pFunction)
 
virtual ~G4VGaussianQuadrature ()
 
G4double GetAbscissa (G4int index) const
 
G4double GetWeight (G4int index) const
 
G4int GetNumber () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4VGaussianQuadrature
G4double GammaLogarithm (G4double xx)
 
- Protected Attributes inherited from G4VGaussianQuadrature
function fFunction
 
G4doublefAbscissa
 
G4doublefWeight
 
G4int fNumber
 

Detailed Description

Definition at line 62 of file G4GaussJacobiQ.hh.

Constructor & Destructor Documentation

G4GaussJacobiQ::G4GaussJacobiQ ( function  pFunction,
G4double  alpha,
G4double  beta,
G4int  nJacobi 
)

Definition at line 37 of file G4GaussJacobiQ.cc.

41  : G4VGaussianQuadrature(pFunction)
42 
43 {
44  const G4double tolerance = 1.0e-12 ;
45  const G4double maxNumber = 12 ;
46  G4int i=1, k=1 ;
47  G4double root=0.;
48  G4double alphaBeta=0.0, alphaReduced=0.0, betaReduced=0.0,
49  root1=0.0, root2=0.0, root3=0.0 ;
50  G4double a=0.0, b=0.0, c=0.0,
51  newton1=0.0, newton2=0.0, newton3=0.0, newton0=0.0,
52  temp=0.0, rootTemp=0.0 ;
53 
54  fNumber = nJacobi ;
55  fAbscissa = new G4double[fNumber] ;
56  fWeight = new G4double[fNumber] ;
57 
58  for (i=1;i<=nJacobi;i++)
59  {
60  if (i == 1)
61  {
62  alphaReduced = alpha/nJacobi ;
63  betaReduced = beta/nJacobi ;
64  root1 = (1.0+alpha)*(2.78002/(4.0+nJacobi*nJacobi)+
65  0.767999*alphaReduced/nJacobi) ;
66  root2 = 1.0+1.48*alphaReduced+0.96002*betaReduced
67  + 0.451998*alphaReduced*alphaReduced
68  + 0.83001*alphaReduced*betaReduced ;
69  root = 1.0-root1/root2 ;
70  }
71  else if (i == 2)
72  {
73  root1=(4.1002+alpha)/((1.0+alpha)*(1.0+0.155998*alpha)) ;
74  root2=1.0+0.06*(nJacobi-8.0)*(1.0+0.12*alpha)/nJacobi ;
75  root3=1.0+0.012002*beta*(1.0+0.24997*std::fabs(alpha))/nJacobi ;
76  root -= (1.0-root)*root1*root2*root3 ;
77  }
78  else if (i == 3)
79  {
80  root1=(1.67001+0.27998*alpha)/(1.0+0.37002*alpha) ;
81  root2=1.0+0.22*(nJacobi-8.0)/nJacobi ;
82  root3=1.0+8.0*beta/((6.28001+beta)*nJacobi*nJacobi) ;
83  root -= (fAbscissa[0]-root)*root1*root2*root3 ;
84  }
85  else if (i == nJacobi-1)
86  {
87  root1=(1.0+0.235002*beta)/(0.766001+0.118998*beta) ;
88  root2=1.0/(1.0+0.639002*(nJacobi-4.0)/(1.0+0.71001*(nJacobi-4.0))) ;
89  root3=1.0/(1.0+20.0*alpha/((7.5+alpha)*nJacobi*nJacobi)) ;
90  root += (root-fAbscissa[nJacobi-4])*root1*root2*root3 ;
91  }
92  else if (i == nJacobi)
93  {
94  root1 = (1.0+0.37002*beta)/(1.67001+0.27998*beta) ;
95  root2 = 1.0/(1.0+0.22*(nJacobi-8.0)/nJacobi) ;
96  root3 = 1.0/(1.0+8.0*alpha/((6.28002+alpha)*nJacobi*nJacobi)) ;
97  root += (root-fAbscissa[nJacobi-3])*root1*root2*root3 ;
98  }
99  else
100  {
101  root = 3.0*fAbscissa[i-2]-3.0*fAbscissa[i-3]+fAbscissa[i-4] ;
102  }
103  alphaBeta = alpha + beta ;
104  for (k=1;k<=maxNumber;k++)
105  {
106  temp = 2.0 + alphaBeta ;
107  newton1 = (alpha-beta+temp*root)/2.0 ;
108  newton2 = 1.0 ;
109  for (G4int j=2;j<=nJacobi;j++)
110  {
111  newton3 = newton2 ;
112  newton2 = newton1 ;
113  temp = 2*j+alphaBeta ;
114  a = 2*j*(j+alphaBeta)*(temp-2.0) ;
115  b = (temp-1.0)*(alpha*alpha-beta*beta+temp*(temp-2.0)*root) ;
116  c = 2.0*(j-1+alpha)*(j-1+beta)*temp ;
117  newton1 = (b*newton2-c*newton3)/a ;
118  }
119  newton0 = (nJacobi*(alpha - beta - temp*root)*newton1 +
120  2.0*(nJacobi + alpha)*(nJacobi + beta)*newton2)/
121  (temp*(1.0 - root*root)) ;
122  rootTemp = root ;
123  root = rootTemp - newton1/newton0 ;
124  if (std::fabs(root-rootTemp) <= tolerance)
125  {
126  break ;
127  }
128  }
129  if (k > maxNumber)
130  {
131  G4Exception("G4GaussJacobiQ::G4GaussJacobiQ()", "OutOfRange",
132  FatalException, "Too many iterations in constructor.") ;
133  }
134  fAbscissa[i-1] = root ;
135  fWeight[i-1] = std::exp(GammaLogarithm((G4double)(alpha+nJacobi)) +
136  GammaLogarithm((G4double)(beta+nJacobi)) -
137  GammaLogarithm((G4double)(nJacobi+1.0)) -
138  GammaLogarithm((G4double)(nJacobi + alphaBeta + 1.0)))
139  *temp*std::pow(2.0,alphaBeta)/(newton0*newton2) ;
140  }
141 }
G4VGaussianQuadrature(function pFunction)
int G4int
Definition: G4Types.hh:78
G4double GammaLogarithm(G4double xx)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
static const G4double alpha

Here is the call graph for this function:

Member Function Documentation

G4double G4GaussJacobiQ::Integral ( ) const

Definition at line 152 of file G4GaussJacobiQ.cc.

153 {
154  G4double integral = 0.0 ;
155  for(G4int i=0;i<fNumber;i++)
156  {
157  integral += fWeight[i]*fFunction(fAbscissa[i]) ;
158  }
159  return integral ;
160 }
int G4int
Definition: G4Types.hh:78
double G4double
Definition: G4Types.hh:76

The documentation for this class was generated from the following files: