#include <G4LinInterpolator.hh>
Inheritance diagram for G4LinInterpolator:
Public Member Functions | |
G4LinInterpolator () | |
~G4LinInterpolator () | |
G4double | Calculate (G4double point, G4int bin, const G4DataVector &energies, const G4DataVector &data) const |
G4IInterpolator * | Clone () const |
Definition at line 50 of file G4LinInterpolator.hh.
G4LinInterpolator::G4LinInterpolator | ( | ) |
G4LinInterpolator::~G4LinInterpolator | ( | ) |
G4double G4LinInterpolator::Calculate | ( | G4double | point, | |
G4int | bin, | |||
const G4DataVector & | energies, | |||
const G4DataVector & | data | |||
) | const [virtual] |
Implements G4IInterpolator.
Definition at line 54 of file G4LinInterpolator.cc.
00057 { 00058 G4int nBins = data.size() - 1; 00059 G4double value = 0.; 00060 if (x < points[0]) 00061 { 00062 value = 0.; 00063 } 00064 else if (bin < nBins) 00065 { 00066 G4double e1 = points[bin]; 00067 G4double e2 = points[bin+1]; 00068 G4double d1 = data[bin]; 00069 G4double d2 = data[bin+1]; 00070 value = d1 + (d2 - d1)*(x - e1)/(e2 - e1); 00071 } 00072 else 00073 { 00074 value = data[nBins]; 00075 } 00076 return value; 00077 }
G4IInterpolator * G4LinInterpolator::Clone | ( | ) | const [virtual] |
Implements G4IInterpolator.
Definition at line 51 of file G4LinInterpolator.cc.
00052 { return new G4LinInterpolator; }