[833] | 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 | // |
---|
| 27 | // $Id: G4ChebyshevApproximation.hh,v 1.6 2006/06/29 18:59:26 gunter Exp $ |
---|
[1337] | 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[833] | 29 | // |
---|
| 30 | // Class description: |
---|
| 31 | // |
---|
| 32 | // Class creating the Chebyshev approximation for a function pointed by fFunction |
---|
| 33 | // data member. The Chebyshev polinom approximation provides an efficient evaluation |
---|
| 34 | // of minimax polynomial, which (among all polynomials of the same degree) has the |
---|
| 35 | // smallest maximum deviation from the true function. |
---|
| 36 | // The methods based mainly on recommendations given in the book : An introduction to |
---|
| 37 | // NUMERICAL METHODS IN C++, B.H. Flowers, Claredon Press, Oxford, 1995 |
---|
| 38 | // |
---|
| 39 | // ------------------------- MEMBER DATA ------------------------------------ |
---|
| 40 | // |
---|
| 41 | // function fFunction - pointer to a function considered |
---|
| 42 | // G4int fNumber - number of Chebyshev coefficients |
---|
| 43 | // G4double* fChebyshevCof - array of Chebyshev coefficients |
---|
| 44 | // G4double fMean = (a+b)/2 - mean point of interval |
---|
| 45 | // G4double fDiff = (b-a)/2 - half of the interval value |
---|
| 46 | // |
---|
| 47 | // ------------------------ CONSTRUCTORS ---------------------------------- |
---|
| 48 | // |
---|
| 49 | // Constructor for initialisation of the class data members. It creates the array |
---|
| 50 | // fChebyshevCof[0,...,fNumber-1], fNumber = n ; which consists of Chebyshev |
---|
| 51 | // coefficients describing the function pointed by pFunction. The values a and b |
---|
| 52 | // fixe the interval of validity of Chebyshev approximation. |
---|
| 53 | // |
---|
| 54 | // G4ChebyshevApproximation( function pFunction, |
---|
| 55 | // G4int n, |
---|
| 56 | // G4double a, |
---|
| 57 | // G4double b ) |
---|
| 58 | // |
---|
| 59 | // -------------------------------------------------------------------- |
---|
| 60 | // |
---|
| 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 dependence |
---|
| 64 | // between the proper selection of n, m, a and b values to get better accuracy |
---|
| 65 | // of the derivative value. |
---|
| 66 | // |
---|
| 67 | // G4ChebyshevApproximation( function pFunction, |
---|
| 68 | // G4int n, |
---|
| 69 | // G4int m, |
---|
| 70 | // G4double a, |
---|
| 71 | // G4double b ) |
---|
| 72 | // |
---|
| 73 | // ------------------------------------------------------ |
---|
| 74 | // |
---|
| 75 | // Constructor for creation of Chebyshev coefficients for integral |
---|
| 76 | // from pFunction. |
---|
| 77 | // |
---|
| 78 | // G4ChebyshevApproximation( function pFunction, |
---|
| 79 | // G4double a, |
---|
| 80 | // G4double b, |
---|
| 81 | // G4int n ) |
---|
| 82 | // |
---|
| 83 | // --------------------------------------------------------------- |
---|
| 84 | // |
---|
| 85 | // Destructor deletes the array of Chebyshev coefficients |
---|
| 86 | // |
---|
| 87 | // ~G4ChebyshevApproximation() |
---|
| 88 | // |
---|
| 89 | // ----------------------------- METHODS ---------------------------------- |
---|
| 90 | // |
---|
| 91 | // Access function for Chebyshev coefficients |
---|
| 92 | // |
---|
| 93 | // G4double GetChebyshevCof(G4int number) const |
---|
| 94 | // |
---|
| 95 | // -------------------------------------------------------------- |
---|
| 96 | // |
---|
| 97 | // Evaluate the value of fFunction at the point x via the Chebyshev coefficients |
---|
| 98 | // fChebyshevCof[0,...,fNumber-1] |
---|
| 99 | // |
---|
| 100 | // G4double ChebyshevEvaluation(G4double x) const |
---|
| 101 | // |
---|
| 102 | // ------------------------------------------------------------------ |
---|
| 103 | // |
---|
| 104 | // Returns the array derCof[0,...,fNumber-2], the Chebyshev coefficients of the |
---|
| 105 | // derivative of the function whose coefficients are fChebyshevCof |
---|
| 106 | // |
---|
| 107 | // void DerivativeChebyshevCof(G4double derCof[]) const |
---|
| 108 | // |
---|
| 109 | // ------------------------------------------------------------------------ |
---|
| 110 | // |
---|
| 111 | // This function produces the array integralCof[0,...,fNumber-1] , the Chebyshev |
---|
| 112 | // coefficients of the integral of the function whose coefficients are |
---|
| 113 | // fChebyshevCof. The constant of integration is set so that the integral vanishes |
---|
| 114 | // at the point (fMean - fDiff) |
---|
| 115 | // |
---|
| 116 | // void IntegralChebyshevCof(G4double integralCof[]) const |
---|
| 117 | |
---|
| 118 | // --------------------------- HISTORY -------------------------------------- |
---|
| 119 | // |
---|
| 120 | // 24.04.97 V.Grichine ( Vladimir.Grichine@cern.ch ) |
---|
| 121 | |
---|
| 122 | #ifndef G4CHEBYSHEVAPPROXIMATION_HH |
---|
| 123 | #define G4CHEBYSHEVAPPROXIMATION_HH |
---|
| 124 | |
---|
| 125 | #include "globals.hh" |
---|
| 126 | |
---|
| 127 | typedef G4double (*function)(G4double) ; |
---|
| 128 | |
---|
| 129 | class G4ChebyshevApproximation |
---|
| 130 | { |
---|
| 131 | public: // with description |
---|
| 132 | |
---|
| 133 | G4ChebyshevApproximation( function pFunction, |
---|
| 134 | G4int n, |
---|
| 135 | G4double a, |
---|
| 136 | G4double b ) ; |
---|
| 137 | // |
---|
| 138 | // Constructor for creation of Chebyshev coefficients for m-derivative |
---|
| 139 | // from pFunction. The value of m ! MUST BE ! < n , because the result |
---|
| 140 | // array of fChebyshevCof will be of (n-m) size. |
---|
| 141 | |
---|
| 142 | G4ChebyshevApproximation( function pFunction, |
---|
| 143 | G4int n, |
---|
| 144 | G4int m, |
---|
| 145 | G4double a, |
---|
| 146 | G4double b ) ; |
---|
| 147 | // |
---|
| 148 | // Constructor for creation of Chebyshev coefficients for integral |
---|
| 149 | // from pFunction. |
---|
| 150 | |
---|
| 151 | G4ChebyshevApproximation( function pFunction, |
---|
| 152 | G4double a, |
---|
| 153 | G4double b, |
---|
| 154 | G4int n ) ; |
---|
| 155 | |
---|
| 156 | ~G4ChebyshevApproximation() ; |
---|
| 157 | |
---|
| 158 | // Access functions |
---|
| 159 | |
---|
| 160 | G4double GetChebyshevCof(G4int number) const ; |
---|
| 161 | |
---|
| 162 | // Methods |
---|
| 163 | |
---|
| 164 | G4double ChebyshevEvaluation(G4double x) const ; |
---|
| 165 | void DerivativeChebyshevCof(G4double derCof[]) const ; |
---|
| 166 | void IntegralChebyshevCof(G4double integralCof[]) const ; |
---|
| 167 | |
---|
| 168 | private: |
---|
| 169 | |
---|
| 170 | G4ChebyshevApproximation(const G4ChebyshevApproximation&); |
---|
| 171 | G4ChebyshevApproximation& operator=(const G4ChebyshevApproximation&); |
---|
| 172 | |
---|
| 173 | private: |
---|
| 174 | |
---|
| 175 | function fFunction ; |
---|
| 176 | G4int fNumber ; |
---|
| 177 | G4double* fChebyshevCof ; |
---|
| 178 | G4double fMean ; |
---|
| 179 | G4double fDiff ; |
---|
| 180 | }; |
---|
| 181 | |
---|
| 182 | #endif |
---|