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