|
||||
File indexing completed on 2025-01-18 09:59:05
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4SimpleIntegration 0027 // 0028 // Class description: 0029 // 0030 // Class for realisation of simple numerical methodes for integration of 0031 // functions with signature: double f(double). The methods based mainly on 0032 // algorithms given in the book: 0033 // An introduction to NUMERICAL METHODS IN C++, 0034 // B.H. Flowers, Claredon Press, Oxford, 1995. 0035 0036 // Author: V.Grichine, 26.03.1997 0037 // -------------------------------------------------------------------- 0038 #ifndef G4SIMPLEINTEGRATION_HH 0039 #define G4SIMPLEINTEGRATION_HH 1 0040 0041 #include "G4Types.hh" 0042 0043 using function = G4double (*)(G4double); 0044 0045 class G4SimpleIntegration 0046 { 0047 public: 0048 explicit G4SimpleIntegration(function pFunction); 0049 0050 G4SimpleIntegration(function pFunction, G4double pTolerance); 0051 0052 ~G4SimpleIntegration() = default; 0053 0054 G4SimpleIntegration(const G4SimpleIntegration&) = delete; 0055 G4SimpleIntegration& operator=(const G4SimpleIntegration&) = delete; 0056 // Private copy constructor and assignment operator. 0057 0058 // Simple integration methods: 0059 // Trapezoidal, MidPoint, Gauss and Simpson(double a,double b,int n) 0060 // - integrate function pointed by fFunction from a to b by n iterations, 0061 // i.e. with Step (b-a)/n according to the correspondent method. 0062 0063 G4double Trapezoidal(G4double xInitial, G4double xFinal, 0064 G4int iterationNumber); 0065 0066 G4double MidPoint(G4double xInitial, G4double xFinal, G4int iterationNumber); 0067 0068 G4double Gauss(G4double xInitial, G4double xFinal, G4int iterationNumber); 0069 0070 G4double Simpson(G4double xInitial, G4double xFinal, G4int iterationNumber); 0071 0072 // Adaptive Gauss integration with accuracy ~ fTolerance 0073 0074 G4double AdaptGaussIntegration(G4double xInitial, G4double xFinal); 0075 // Integrate function from a to be with accuracy <= fTolerance 0076 0077 protected: 0078 G4double Gauss(G4double xInitial, G4double xFinal); 0079 0080 void AdaptGauss(G4double xInitial, G4double xFinal, G4double& sum, 0081 G4int& depth); 0082 0083 private: 0084 function fFunction; // pointer to the function to be integrated 0085 G4double fTolerance = 0.0001; // accuracy of integration 0086 const G4int fMaxDepth = 100; // constant maximum iteration depth 0087 }; 0088 0089 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |