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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /global/HEPNumerics/src/G4GaussLaguerreQ.cc (Version 11.3.0) and /global/HEPNumerics/src/G4GaussLaguerreQ.cc (Version 7.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 // G4GaussLaguerreQ class implementation       << 
 27 //                                                 23 //
 28 // Author: V.Grichine, 13.05.1997              <<  24 // $Id: G4GaussLaguerreQ.cc,v 1.5 2004/11/12 17:38:33 gcosmo Exp $
 29 // ------------------------------------------- <<  25 // GEANT4 tag $Name: geant4-07-00-patch-01 $
 30                                                <<  26 //
 31 #include "G4GaussLaguerreQ.hh"                     27 #include "G4GaussLaguerreQ.hh"
 32                                                    28 
                                                   >>  29 
                                                   >>  30 
 33 // -------------------------------------------     31 // ------------------------------------------------------------
 34 //                                                 32 //
 35 // Constructor for Gauss-Laguerre quadrature m     33 // Constructor for Gauss-Laguerre quadrature method: integral from zero to
 36 // infinity of std::pow(x,alpha)*std::exp(-x)* <<  34 // infinity of std::pow(x,alpha)*std::exp(-x)*f(x). The value of nLaguerre sets the accuracy.
 37 // The value of nLaguerre sets the accuracy.   <<  35 // The constructor creates arrays fAbscissa[0,..,nLaguerre-1] and 
 38 // The constructor creates arrays fAbscissa[0, <<  36 // fWeight[0,..,nLaguerre-1] . 
 39 // fWeight[0,..,nLaguerre-1] .                 << 
 40 //                                                 37 //
 41                                                    38 
 42 G4GaussLaguerreQ::G4GaussLaguerreQ(function pF <<  39 G4GaussLaguerreQ::G4GaussLaguerreQ( function pFunction,
 43                                    G4int nLagu <<  40             G4double alpha,
 44   : G4VGaussianQuadrature(pFunction)           <<  41                   G4int nLaguerre      ) 
                                                   >>  42    : G4VGaussianQuadrature(pFunction)
 45 {                                                  43 {
 46   const G4double tolerance = 1.0e-10;          <<  44    const G4double tolerance = 1.0e-10 ;
 47   const G4int maxNumber    = 12;               <<  45    const G4int maxNumber = 12 ;
 48   G4int i = 1, k = 1;                          <<  46    G4int i, j, k ;
 49   G4double newton0 = 0.0, newton1 = 0.0, temp1 <<  47    G4double newton=0.;
 50            temp = 0.0, cofi = 0.0;             <<  48    G4double newton1, temp1, temp2, temp3, temp, cofi ;
 51                                                <<  49 
 52   fNumber   = nLaguerre;                       <<  50    fNumber = nLaguerre ;
 53   fAbscissa = new G4double[fNumber];           <<  51    fAbscissa = new G4double[fNumber] ;
 54   fWeight   = new G4double[fNumber];           <<  52    fWeight   = new G4double[fNumber] ;
 55                                                <<  53       
 56   for(i = 1; i <= fNumber; ++i)  // Loop over  <<  54    for(i=1;i<=fNumber;i++)      // Loop over the desired roots
 57   {                                            <<  55    {
 58     if(i == 1)                                 <<  56       if(i == 1)
 59     {                                          <<  57       {
 60       newton0 = (1.0 + alpha) * (3.0 + 0.92 *  <<  58    newton = (1.0 + alpha)*(3.0 + 0.92*alpha)/(1.0 + 2.4*fNumber + 1.8*alpha) ;
 61                 (1.0 + 2.4 * fNumber + 1.8 * a <<  59       }
 62     }                                          <<  60       else if(i == 2)
 63     else if(i == 2)                            <<  61       {
 64     {                                          <<  62    newton += (15.0 + 6.25*alpha)/(1.0 + 0.9*alpha + 2.5*fNumber) ;
 65       newton0 += (15.0 + 6.25 * alpha) / (1.0  <<  63       }
 66     }                                          <<  64       else
 67     else                                       <<  65       {
 68     {                                          <<  66    cofi = i - 2 ;
 69       cofi = i - 2;                            <<  67    newton += ((1.0+2.55*cofi)/(1.9*cofi) + 1.26*cofi*alpha/(1.0+3.5*cofi))*
 70       newton0 += ((1.0 + 2.55 * cofi) / (1.9 * <<  68              (newton - fAbscissa[i-3])/(1.0 + 0.3*alpha) ;
 71                   1.26 * cofi * alpha / (1.0 + <<  69       }
 72                  (newton0 - fAbscissa[i - 3])  <<  70       for(k=1;k<=maxNumber;k++)
 73     }                                          << 
 74     for(k = 1; k <= maxNumber; ++k)            << 
 75     {                                          << 
 76       temp1 = 1.0;                             << 
 77       temp2 = 0.0;                             << 
 78       for(G4int j = 1; j <= fNumber; ++j)      << 
 79       {                                            71       {
 80         temp3 = temp2;                         <<  72    temp1 = 1.0 ;
 81         temp2 = temp1;                         <<  73    temp2 = 0.0 ;
 82         temp1 =                                <<  74    for(j=1;j<=fNumber;j++)
 83           ((2 * j - 1 + alpha - newton0) * tem <<  75    {
                                                   >>  76       temp3 = temp2 ;
                                                   >>  77       temp2 = temp1 ;
                                                   >>  78       temp1 = ((2*j - 1 + alpha - newton)*temp2 - (j - 1 + alpha)*temp3)/j ;
                                                   >>  79    }
                                                   >>  80    temp = (fNumber*temp1 - (fNumber +alpha)*temp2)/newton ;
                                                   >>  81    newton1 = newton ;
                                                   >>  82    newton  = newton1 - temp1/temp ;
                                                   >>  83          if(std::fabs(newton - newton1) <= tolerance) 
                                                   >>  84    {
                                                   >>  85       break ;
                                                   >>  86    }
 84       }                                            87       }
 85       temp    = (fNumber * temp1 - (fNumber +  <<  88       if(k > maxNumber)
 86       newton1 = newton0;                       << 
 87       newton0 = newton1 - temp1 / temp;        << 
 88       if(std::fabs(newton0 - newton1) <= toler << 
 89       {                                            89       {
 90         break;                                 <<  90    G4Exception("Too many iterations in Gauss-Laguerre constructor") ;
 91       }                                            91       }
 92     }                                          <<  92    
 93     if(k > maxNumber)                          <<  93       fAbscissa[i-1] =  newton ;
 94     {                                          <<  94       fWeight[i-1] = -std::exp(GammaLogarithm(alpha + fNumber) - 
 95       G4Exception("G4GaussLaguerreQ::G4GaussLa <<  95         GammaLogarithm((G4double)fNumber))/(temp*fNumber*temp2) ;
 96                   FatalException,              <<  96    }
 97                   "Too many iterations in Gaus << 
 98     }                                          << 
 99                                                << 
100     fAbscissa[i - 1] = newton0;                << 
101     fWeight[i - 1]   = -std::exp(GammaLogarith << 
102                                GammaLogarithm( << 
103                      (temp * fNumber * temp2); << 
104   }                                            << 
105 }                                                  97 }
106                                                    98 
107 // -------------------------------------------     99 // -----------------------------------------------------------------
108 //                                                100 //
109 // Gauss-Laguerre method for integration of    << 101 // Gauss-Laguerre method for integration of std::pow(x,alpha)*std::exp(-x)*pFunction(x)
110 // std::pow(x,alpha)*std::exp(-x)*pFunction(x) << 102 // from zero up to infinity. pFunction is evaluated in fNumber points for which
111 // from zero up to infinity. pFunction is eval << 103 // fAbscissa[i] and fWeight[i] arrays were created in
112 // for which fAbscissa[i] and fWeight[i] array << 
113 // G4VGaussianQuadrature(double,int) construct    104 // G4VGaussianQuadrature(double,int) constructor
114                                                   105 
115 G4double G4GaussLaguerreQ::Integral() const    << 106 G4double 
                                                   >> 107 G4GaussLaguerreQ::Integral() const 
116 {                                                 108 {
117   G4double integral = 0.0;                     << 109    G4int i ;
118   for(G4int i = 0; i < fNumber; ++i)           << 110    G4double integral = 0.0 ;
119   {                                            << 111    for(i=0;i<fNumber;i++)
120     integral += fWeight[i] * fFunction(fAbscis << 112    {
121   }                                            << 113       integral += fWeight[i]*fFunction(fAbscissa[i]) ;
122   return integral;                             << 114    }
                                                   >> 115    return integral ;
123 }                                                 116 }
124                                                   117