Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes
G4GaussJacobiQ Class Reference

#include <G4GaussJacobiQ.hh>

Inheritance diagram for G4GaussJacobiQ:
G4VGaussianQuadrature

Public Member Functions

 G4GaussJacobiQ (const G4GaussJacobiQ &)=delete
 
 G4GaussJacobiQ (function pFunction, G4double alpha, G4double beta, G4int nJacobi)
 
G4double GetAbscissa (G4int index) const
 
G4int GetNumber () const
 
G4double GetWeight (G4int index) const
 
G4double Integral () const
 
G4GaussJacobiQoperator= (const G4GaussJacobiQ &)=delete
 

Protected Member Functions

G4double GammaLogarithm (G4double xx)
 

Protected Attributes

G4doublefAbscissa = nullptr
 
function fFunction
 
G4int fNumber = 0
 
G4doublefWeight = nullptr
 

Detailed Description

Definition at line 43 of file G4GaussJacobiQ.hh.

Constructor & Destructor Documentation

◆ G4GaussJacobiQ() [1/2]

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

Definition at line 38 of file G4GaussJacobiQ.cc.

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

References alpha, anonymous_namespace{G4PionRadiativeDecayChannel.cc}::beta, G4VGaussianQuadrature::fAbscissa, FatalException, G4VGaussianQuadrature::fNumber, G4VGaussianQuadrature::fWeight, G4Exception(), and G4VGaussianQuadrature::GammaLogarithm().

◆ G4GaussJacobiQ() [2/2]

G4GaussJacobiQ::G4GaussJacobiQ ( const G4GaussJacobiQ )
delete

Member Function Documentation

◆ GammaLogarithm()

G4double G4VGaussianQuadrature::GammaLogarithm ( G4double  xx)
protectedinherited

Definition at line 70 of file G4VGaussianQuadrature.cc.

71{
72 // Returns the value ln(Gamma(xx) for xx > 0. Full accuracy is obtained for
73 // xx > 1. For 0 < xx < 1. the reflection formula (6.1.4) can be used first.
74 // (Adapted from Numerical Recipes in C)
75
76 static const G4double cof[6] = { 76.18009172947146, -86.50532032941677,
77 24.01409824083091, -1.231739572450155,
78 0.1208650973866179e-2, -0.5395239384953e-5 };
79 G4double x = xx - 1.0;
80 G4double tmp = x + 5.5;
81 tmp -= (x + 0.5) * std::log(tmp);
82 G4double ser = 1.000000000190015;
83
84 for(size_t j = 0; j <= 5; ++j)
85 {
86 x += 1.0;
87 ser += cof[j] / x;
88 }
89 return -tmp + std::log(2.5066282746310005 * ser);
90}

Referenced by G4GaussJacobiQ(), and G4GaussLaguerreQ::G4GaussLaguerreQ().

◆ GetAbscissa()

G4double G4VGaussianQuadrature::GetAbscissa ( G4int  index) const
inherited

Definition at line 53 of file G4VGaussianQuadrature.cc.

54{
55 return fAbscissa[index];
56}

References G4VGaussianQuadrature::fAbscissa.

◆ GetNumber()

G4int G4VGaussianQuadrature::GetNumber ( ) const
inherited

Definition at line 63 of file G4VGaussianQuadrature.cc.

63{ return fNumber; }

References G4VGaussianQuadrature::fNumber.

◆ GetWeight()

G4double G4VGaussianQuadrature::GetWeight ( G4int  index) const
inherited

Definition at line 58 of file G4VGaussianQuadrature.cc.

59{
60 return fWeight[index];
61}

References G4VGaussianQuadrature::fWeight.

◆ Integral()

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}

References G4VGaussianQuadrature::fAbscissa, G4VGaussianQuadrature::fFunction, G4VGaussianQuadrature::fNumber, and G4VGaussianQuadrature::fWeight.

◆ operator=()

G4GaussJacobiQ & G4GaussJacobiQ::operator= ( const G4GaussJacobiQ )
delete

Field Documentation

◆ fAbscissa

G4double* G4VGaussianQuadrature::fAbscissa = nullptr
protectedinherited

◆ fFunction

function G4VGaussianQuadrature::fFunction
protectedinherited

◆ fNumber

G4int G4VGaussianQuadrature::fNumber = 0
protectedinherited

◆ fWeight

G4double* G4VGaussianQuadrature::fWeight = nullptr
protectedinherited

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