G4DataInterpolation.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // Class description:
00030 //
00031 // The class consists of some methods for data interpolations and extrapolations.
00032 // The methods based mainly on recommendations given in the book : An introduction to
00033 // NUMERICAL METHODS IN C++, B.H. Flowers, Claredon Press, Oxford, 1995
00034 // 
00035 // ------------------------------ Data members: ---------------------------------
00036 //
00037 //              fArgument and fFunction - pointers to data table to be interpolated
00038 //                                        for y[i] and x[i] respectively
00039 //              fNumber - the corresponding table size
00040 // ......
00041 // G4DataInterpolation( G4double pX[], G4double pY[], G4int number    )
00042 //
00043 // Constructor for initializing of fArgument, fFunction and fNumber data members:
00044 // ......
00045 // G4DataInterpolation( G4double pX[], G4double pY[], G4int number,
00046 //                      G4double pFirstDerStart, G4double pFirstDerFinish  ) 
00047 //
00048 // Constructor for cubic spline interpolation. It creates the array 
00049 // fSecondDerivative[0,...fNumber-1] which is used in this interpolation by
00050 // the function: 
00051 // ....
00052 // ~G4DataInterpolation() 
00053 //
00054 // Destructor deletes dynamically created arrays for data members: fArgument,
00055 // fFunction and fSecondDerivative, all have dimension of fNumber
00056 //
00057 // ------------------------------ Methods: ----------------------------------------
00058 //
00059 // G4double PolynomInterpolation(G4double pX, G4double& deltaY ) const
00060 //
00061 // This function returns the value P(pX), where P(x) is polynom of fNumber-1 degree
00062 // such that P(fArgument[i]) = fFunction[i], for i = 0, ..., fNumber-1  .
00063 // ........
00064 // void PolIntCoefficient( G4double cof[]) const 
00065 //
00066 // Given arrays fArgument[0,..,fNumber-1] and fFunction[0,..,fNumber-1] , this
00067 // function calculates an array of coefficients. The coefficients don't provide
00068 // usually (fNumber>10) better accuracy for polynom interpolation, as compared with
00069 // PolynomInterpolation function. They could be used instead for derivate 
00070 // calculations and some other applications.
00071 // .........
00072 // G4double RationalPolInterpolation(G4double pX, G4double& deltaY ) const 
00073 //
00074 // The function returns diagonal rational function (Bulirsch and Stoer algorithm
00075 // of Neville type) Pn(x)/Qm(x) where P and Q are polynoms.
00076 // Tests showed the method is not stable and hasn't advantage if compared with
00077 // polynomial interpolation
00078 // ................
00079 // G4double CubicSplineInterpolation(G4double pX) const 
00080 //
00081 // Cubic spline interpolation in point pX for function given by the table:
00082 // fArgument, fFunction. The constructor, which creates fSecondDerivative, must be
00083 // called before. The function works optimal, if sequential calls are in random
00084 // values of pX.
00085 // ..................
00086 // G4double FastCubicSpline(G4double pX, G4int index) const 
00087 //
00088 // Return cubic spline interpolation in the point pX which is located between
00089 // fArgument[index] and fArgument[index+1]. It is usually called in sequence of
00090 // known from external analysis values of index.
00091 // .........
00092 // G4int LocateArgument(G4double pX) const 
00093 //
00094 // Given argument pX, returns index k, so that pX bracketed by fArgument[k] and
00095 // fArgument[k+1]
00096 // ......................
00097 // void CorrelatedSearch( G4double pX, G4int& index ) const 
00098 //
00099 // Given a value pX, returns a value 'index' such that pX is between fArgument[index]
00100 // and fArgument[index+1]. fArgument MUST BE MONOTONIC, either increasing or
00101 // decreasing. If index = -1 or fNumber, this indicates that pX is out of range.
00102 // The value index on input is taken as the initial approximation for index on
00103 // output.
00104 
00105 // --------------------------------- History: --------------------------------------
00106 //
00107 //  3.4.97 V.Grichine (Vladimir.Grichine@cern.ch)
00108 //
00109 
00110 
00111 #ifndef G4DATAINTERPOLATION_HH
00112 #define G4DATAINTERPOLATION_HH
00113 
00114 #include "globals.hh"
00115 
00116 class G4DataInterpolation
00117 {
00118 public:
00119             G4DataInterpolation( G4double pX[], 
00120                                  G4double pY[], 
00121                                  G4int number    );
00122 
00123 // Constructor for cubic spline interpolation. It creates fSecond Deivative array 
00124 // as well as fArgument and fFunction
00125                                  
00126             G4DataInterpolation( G4double pX[], 
00127                                  G4double pY[], 
00128                                  G4int number,
00129                                  G4double pFirstDerStart,
00130                                  G4double pFirstDerFinish  ) ;
00131 
00132            ~G4DataInterpolation() ;
00133            
00134             G4double PolynomInterpolation( G4double pX,
00135                                            G4double& deltaY ) const ;
00136             
00137             void PolIntCoefficient( G4double cof[]) const ;
00138 
00139             G4double RationalPolInterpolation( G4double pX,
00140                                                G4double& deltaY ) const ;
00141 
00142             G4double CubicSplineInterpolation( G4double pX ) const ;                                  
00143 
00144             G4double FastCubicSpline( G4double pX, 
00145                                       G4int index ) const ;
00146 
00147             G4int LocateArgument( G4double pX ) const ;
00148             
00149             void CorrelatedSearch( G4double pX,
00150                                    G4int& index ) const ;
00151                            
00152 private:
00153 
00154            G4DataInterpolation(const G4DataInterpolation&);
00155            G4DataInterpolation& operator=(const G4DataInterpolation&);
00156 
00157 private:
00158            G4double* fArgument ;
00159            G4double* fFunction ;
00160            G4double* fSecondDerivative ;
00161            G4int     fNumber ;
00162 } ;
00163 
00164 #endif

Generated on Mon May 27 17:47:59 2013 for Geant4 by  doxygen 1.4.7