|
||||
File indexing completed on 2025-01-18 09:58:05
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 // G4DataInterpolation 0027 // 0028 // Class description: 0029 // 0030 // The class consists of some methods for data interpolations and 0031 // extrapolations. The methods based mainly on recommendations given in the 0032 // book: An introduction to NUMERICAL METHODS IN C++, B.H. Flowers, 0033 // Claredon Press, Oxford, 1995. 0034 0035 // Author: V.Grichine, 03.04.1997 0036 // -------------------------------------------------------------------- 0037 #ifndef G4DATAINTERPOLATION_HH 0038 #define G4DATAINTERPOLATION_HH 1 0039 0040 #include "globals.hh" 0041 0042 class G4DataInterpolation 0043 { 0044 public: 0045 G4DataInterpolation(G4double pX[], G4double pY[], G4int number); 0046 // Constructor for initializing data members. 0047 0048 G4DataInterpolation(G4double pX[], G4double pY[], G4int number, 0049 G4double pFirstDerStart, G4double pFirstDerFinish); 0050 // Constructor for cubic spline interpolation. It creates fSecond Deivative 0051 // array as well as fArgument and fFunction. 0052 0053 ~G4DataInterpolation(); 0054 // Destructor deletes dynamically created arrays for data members: fArgument, 0055 // fFunction and fSecondDerivative, all have dimension of fNumber. 0056 0057 G4DataInterpolation(const G4DataInterpolation&) = delete; 0058 G4DataInterpolation& operator=(const G4DataInterpolation&) = delete; 0059 // Copy constructor and assignement operator not allowed. 0060 0061 G4double PolynomInterpolation(G4double pX, G4double& deltaY) const; 0062 // This function returns the value P(pX), where P(x) is polynom of fNumber-1 0063 // degree such that P(fArgument[i]) = fFunction[i], for i = 0, ..., fNumber-1. 0064 0065 void PolIntCoefficient(G4double cof[]) const; 0066 // Given arrays fArgument[0,..,fNumber-1] and fFunction[0,..,fNumber-1], this 0067 // function calculates an array of coefficients. 0068 // The coefficients don't provide usually (fNumber>10) better accuracy for 0069 // polynom interpolation, as compared with PolynomInterpolation() function. 0070 // They could be used instead for derivate calculations and some other 0071 // applications. 0072 0073 G4double RationalPolInterpolation(G4double pX, G4double& deltaY) const; 0074 // The function returns diagonal rational function (Bulirsch and Stoer 0075 // algorithm of Neville type) Pn(x)/Qm(x) where P and Q are polynoms. 0076 // Tests showed the method is not stable and hasn't advantage if compared 0077 // with polynomial interpolation. 0078 0079 G4double CubicSplineInterpolation(G4double pX) const; 0080 // Cubic spline interpolation in point pX for function given by the table: 0081 // fArgument, fFunction. The constructor, which creates fSecondDerivative, 0082 // must be called before. The function works optimal, if sequential calls 0083 // are in random values of pX. 0084 0085 G4double FastCubicSpline(G4double pX, G4int index) const; 0086 // Return cubic spline interpolation in the point pX which is located between 0087 // fArgument[index] and fArgument[index+1]. It is usually called in sequence 0088 // of known from external analysis values of index. 0089 0090 G4int LocateArgument(G4double pX) const; 0091 // Given argument pX, returns index k, so that pX bracketed by fArgument[k] 0092 // and fArgument[k+1]. 0093 0094 void CorrelatedSearch(G4double pX, G4int& index) const; 0095 // Given a value pX, returns a value 'index' such that pX is between 0096 // fArgument[index] and fArgument[index+1]. fArgument MUST BE MONOTONIC, 0097 // either increasing or decreasing. If index = -1 or fNumber, this indicates 0098 // that pX is out of range. The value index on input is taken as the initial 0099 // approximation for index on output. 0100 0101 private: 0102 // pointers to data table to be interpolated for y[i] and x[i] respectively 0103 G4double* fArgument = nullptr; 0104 G4double* fFunction = nullptr; 0105 0106 G4double* fSecondDerivative = nullptr; 0107 0108 G4int fNumber = 0; // the corresponding table size 0109 }; 0110 0111 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |