G4SimpleIntegration.hh

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 // Class description:
00030 //
00031 // Class for realisation of simple numerical methodes for integration of
00032 // functions with signature: double f(double). The methods based mainly on
00033 // algorithms given in the book :
00034 //   An introduction to NUMERICAL METHODS IN C++,
00035 //   B.H. Flowers, Claredon Press, Oxford, 1995.
00036 //
00037 // --------------------------- Member data ----------------------------
00038 //
00039 //   fFunction       - pointer to the function to be integrated
00040 //   fTolerance      - accuracy of integration in Adaptive Gauss method
00041 //   fMaxDepth = 100 - constant maximum iteration depth for
00042 //                     Adaptive Gauss method
00043 //
00044 // --------------------------- Methods --------------------------------
00045 //
00046 //   Trapezoidal, MidPoint, Gauss and Simpson(double a,double b,int n)
00047 //   - integrate function pointed by fFunction from a to b by n iterations,
00048 //     i.e. with Step (b-a)/n according to the correspondent method.
00049 //
00050 //   AdaptGausIntegration(double a, double b)
00051 //   - integrate function from a to be with accuracy <= fTolerance 
00052 
00053 // ----------------------------- History ------------------------------ 
00054 //
00055 //  26.03.97   V.Grichine ( Vladimir.Grichine@cern.ch )
00056 
00057 #ifndef G4SIMPLEINTEGRATION_HH
00058 #define G4SIMPLEINTEGRATION_HH
00059 
00060 #include "G4Types.hh"
00061 
00062 typedef G4double (*function)(G4double) ;
00063 
00064 class G4SimpleIntegration
00065 {
00066   public:
00067 
00068        explicit G4SimpleIntegration( function pFunction ) ;
00069        
00070        G4SimpleIntegration( function pFunction,
00071                             G4double pTolerance ) ;
00072        
00073       ~G4SimpleIntegration() ;
00074        
00075        // Simple integration methods
00076        
00077        G4double Trapezoidal(G4double xInitial,
00078                             G4double xFinal,
00079                             G4int iterationNumber ) ;
00080 
00081        G4double    MidPoint(G4double xInitial,
00082                             G4double xFinal,
00083                             G4int iterationNumber ) ;
00084 
00085        G4double       Gauss(G4double xInitial,
00086                             G4double xFinal,
00087                             G4int iterationNumber ) ;
00088 
00089        G4double     Simpson(G4double xInitial,
00090                             G4double xFinal,
00091                             G4int iterationNumber ) ;
00092 
00093        // Adaptive Gauss integration with accuracy ~ fTolerance
00094 
00095        G4double       AdaptGaussIntegration( G4double xInitial,
00096                                              G4double xFinal   ) ;
00097        
00098   protected:
00099 
00100        G4double       Gauss( G4double xInitial,
00101                              G4double xFinal   ) ;
00102 
00103        void      AdaptGauss( G4double xInitial,
00104                              G4double xFinal,
00105                              G4double& sum,
00106                              G4int& depth      ) ;
00107   private:
00108 
00109        G4SimpleIntegration(const G4SimpleIntegration&);
00110        G4SimpleIntegration& operator=(const G4SimpleIntegration&);
00111          // Private copy constructor and assignment operator.
00112 
00113   private:
00114 
00115         function fFunction ;
00116         G4double fTolerance ;
00117         static G4int fMaxDepth ;
00118 };
00119 
00120 #endif

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