Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // G4ChebyshevApproximation 27 // 28 // Class description: 29 // 30 // Class creating the Chebyshev approximation for a function pointed by 31 // fFunction data member. The Chebyshev polinom approximation provides an 32 // efficient evaluation of minimax polynomial, which (among all polynomials of 33 // the same degree) has the smallest maximum deviation from the true function. 34 // The methods based mainly on recommendations given in the book : An 35 // introduction to NUMERICAL METHODS IN C++, B.H. Flowers, Claredon Press, 36 // Oxford, 1995 37 38 // Author: V.Grichine, 24.04.1997 39 // -------------------------------------------------------------------- 40 #ifndef G4CHEBYSHEVAPPROXIMATION_HH 41 #define G4CHEBYSHEVAPPROXIMATION_HH 1 42 43 #include "globals.hh" 44 45 using function = G4double (*)(G4double); 46 47 class G4ChebyshevApproximation 48 { 49 public: 50 G4ChebyshevApproximation(function pFunction, G4int n, G4double a, G4double b); 51 // Constructor for creation of Chebyshev coefficients for m-derivative 52 // from pFunction. The value of m ! MUST BE ! < n , because the result 53 // array of fChebyshevCof will be of (n-m) size. 54 // It creates the array fChebyshevCof[0,...,fNumber-1], fNumber = n ; 55 // which consists of Chebyshev coefficients describing the function pointed 56 // by pFunction. The values a and b fixe the interval of validity of 57 // Chebyshev approximation. 58 59 G4ChebyshevApproximation(function pFunction, G4int n, G4int m, G4double a, 60 G4double b); 61 // Constructor for creation of Chebyshev coefficients for m-derivative 62 // from pFunction. The value of m ! MUST BE ! < n , because the result 63 // array of fChebyshevCof will be of (n-m) size. There is a definite 64 // dependence between the proper selection of n, m, a and b values to get 65 // better accuracy of the derivative value. 66 67 G4ChebyshevApproximation(function pFunction, G4double a, G4double b, G4int n); 68 // Constructor for creation of Chebyshev coefficients for integral 69 // from pFunction. 70 71 ~G4ChebyshevApproximation(); 72 // Destructor deletes the array of Chebyshev coefficients 73 74 G4ChebyshevApproximation(const G4ChebyshevApproximation&) = delete; 75 G4ChebyshevApproximation& operator=(const G4ChebyshevApproximation&) = delete; 76 // Copy constructor and assignment operator not allowed. 77 78 G4double GetChebyshevCof(G4int number) const; 79 // Access function for Chebyshev coefficients 80 81 G4double ChebyshevEvaluation(G4double x) const; 82 // Evaluate the value of fFunction at the point x via the Chebyshev 83 // coefficients fChebyshevCof[0,...,fNumber-1] 84 85 void DerivativeChebyshevCof(G4double derCof[]) const; 86 // Returns the array derCof[0,...,fNumber-2], the Chebyshev coefficients 87 // of the derivative of the function whose coefficients are fChebyshevCof 88 89 void IntegralChebyshevCof(G4double integralCof[]) const; 90 // This function produces the array integralCof[0,...,fNumber-1] , the 91 // Chebyshev coefficients of the integral of the function whose coefficients 92 // are fChebyshevCof. The constant of integration is set so that the integral 93 // vanishes at the point (fMean - fDiff) 94 95 private: 96 function fFunction; // pointer to a function considered 97 G4int fNumber; // number of Chebyshev coefficients 98 G4double* fChebyshevCof; // array of Chebyshev coefficients 99 G4double fMean; // (a+b)/2 - mean point of interval 100 G4double fDiff; // (b-a)/2 - half of the interval value 101 }; 102 103 #endif 104