|
||||
File indexing completed on 2025-01-18 09:58:01
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 // G4ChebyshevApproximation 0027 // 0028 // Class description: 0029 // 0030 // Class creating the Chebyshev approximation for a function pointed by 0031 // fFunction data member. The Chebyshev polinom approximation provides an 0032 // efficient evaluation of minimax polynomial, which (among all polynomials of 0033 // the same degree) has the smallest maximum deviation from the true function. 0034 // The methods based mainly on recommendations given in the book : An 0035 // introduction to NUMERICAL METHODS IN C++, B.H. Flowers, Claredon Press, 0036 // Oxford, 1995 0037 0038 // Author: V.Grichine, 24.04.1997 0039 // -------------------------------------------------------------------- 0040 #ifndef G4CHEBYSHEVAPPROXIMATION_HH 0041 #define G4CHEBYSHEVAPPROXIMATION_HH 1 0042 0043 #include "globals.hh" 0044 0045 using function = G4double (*)(G4double); 0046 0047 class G4ChebyshevApproximation 0048 { 0049 public: 0050 G4ChebyshevApproximation(function pFunction, G4int n, G4double a, G4double b); 0051 // Constructor for creation of Chebyshev coefficients for m-derivative 0052 // from pFunction. The value of m ! MUST BE ! < n , because the result 0053 // array of fChebyshevCof will be of (n-m) size. 0054 // It creates the array fChebyshevCof[0,...,fNumber-1], fNumber = n ; 0055 // which consists of Chebyshev coefficients describing the function pointed 0056 // by pFunction. The values a and b fixe the interval of validity of 0057 // Chebyshev approximation. 0058 0059 G4ChebyshevApproximation(function pFunction, G4int n, G4int m, G4double a, 0060 G4double b); 0061 // Constructor for creation of Chebyshev coefficients for m-derivative 0062 // from pFunction. The value of m ! MUST BE ! < n , because the result 0063 // array of fChebyshevCof will be of (n-m) size. There is a definite 0064 // dependence between the proper selection of n, m, a and b values to get 0065 // better accuracy of the derivative value. 0066 0067 G4ChebyshevApproximation(function pFunction, G4double a, G4double b, G4int n); 0068 // Constructor for creation of Chebyshev coefficients for integral 0069 // from pFunction. 0070 0071 ~G4ChebyshevApproximation(); 0072 // Destructor deletes the array of Chebyshev coefficients 0073 0074 G4ChebyshevApproximation(const G4ChebyshevApproximation&) = delete; 0075 G4ChebyshevApproximation& operator=(const G4ChebyshevApproximation&) = delete; 0076 // Copy constructor and assignment operator not allowed. 0077 0078 G4double GetChebyshevCof(G4int number) const; 0079 // Access function for Chebyshev coefficients 0080 0081 G4double ChebyshevEvaluation(G4double x) const; 0082 // Evaluate the value of fFunction at the point x via the Chebyshev 0083 // coefficients fChebyshevCof[0,...,fNumber-1] 0084 0085 void DerivativeChebyshevCof(G4double derCof[]) const; 0086 // Returns the array derCof[0,...,fNumber-2], the Chebyshev coefficients 0087 // of the derivative of the function whose coefficients are fChebyshevCof 0088 0089 void IntegralChebyshevCof(G4double integralCof[]) const; 0090 // This function produces the array integralCof[0,...,fNumber-1] , the 0091 // Chebyshev coefficients of the integral of the function whose coefficients 0092 // are fChebyshevCof. The constant of integration is set so that the integral 0093 // vanishes at the point (fMean - fDiff) 0094 0095 private: 0096 function fFunction; // pointer to a function considered 0097 G4int fNumber; // number of Chebyshev coefficients 0098 G4double* fChebyshevCof; // array of Chebyshev coefficients 0099 G4double fMean; // (a+b)/2 - mean point of interval 0100 G4double fDiff; // (b-a)/2 - half of the interval value 0101 }; 0102 0103 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |