G4VGaussianQuadrature.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // Implementation file for G4VGaussianQuadrature virtual base class
00030 //
00031 
00032 #include "G4ios.hh"
00033 #include "globals.hh"
00034 #include "G4VGaussianQuadrature.hh"
00035 
00036 G4VGaussianQuadrature::G4VGaussianQuadrature( function pFunction )
00037   : fFunction(pFunction), fAbscissa(0), fWeight(0), fNumber(0)
00038 {
00039 }
00040 
00041 // -------------------------------------------------------------------
00042 //
00043 // Virtual destructor which deletes dynamically allocated memory
00044 //
00045 
00046 G4VGaussianQuadrature::~G4VGaussianQuadrature() 
00047 {
00048    delete[] fAbscissa ;
00049    delete[] fWeight   ;
00050 }
00051 
00052 // -------------------------- Access functions ----------------------------------
00053 
00054 G4double
00055 G4VGaussianQuadrature::GetAbscissa(G4int index) const
00056 {
00057    return fAbscissa[index] ;
00058 }
00059 
00060 G4double
00061 G4VGaussianQuadrature::GetWeight(G4int index) const
00062 {
00063    return fWeight[index] ;
00064 }
00065 
00066 G4int G4VGaussianQuadrature::GetNumber() const
00067 {
00068    return fNumber ;
00069 }
00070 
00071 // ----------------------------------------------------------------------------
00072 //
00073 // Auxiliary function which returns the value of std::log(gamma-function(x))
00074 //
00075 
00076 G4double 
00077 G4VGaussianQuadrature::GammaLogarithm(G4double xx)
00078 {
00079 
00080 // Returns the value ln(Gamma(xx) for xx > 0.  Full accuracy is obtained for 
00081 // xx > 1. For 0 < xx < 1. the reflection formula (6.1.4) can be used first.
00082 // (Adapted from Numerical Recipes in C)
00083 
00084   static G4double cof[6] = { 76.18009172947146,     -86.50532032941677,
00085                              24.01409824083091,      -1.231739572450155,
00086                               0.1208650973866179e-2, -0.5395239384953e-5  } ;
00087   G4double x = xx - 1.0;
00088   G4double tmp = x + 5.5;
00089   tmp -= (x + 0.5) * std::log(tmp);
00090   G4double ser = 1.000000000190015;
00091 
00092   for ( size_t j = 0; j <= 5; j++ )
00093   {
00094     x += 1.0;
00095     ser += cof[j]/x;
00096   }
00097   return -tmp + std::log(2.5066282746310005*ser);
00098 }

Generated on Mon May 27 17:50:13 2013 for Geant4 by  doxygen 1.4.7