35#define INCLXX_IN_GEANT4_MODE 1
62 nodes.push_back(firstNode);
63 G4int skippedNodes = 0;
64 for(
unsigned i = 1; i < nNodes; i++) {
74 nodes.push_back(node);
91 for(
unsigned i = 0; i < x.size(); ++i)
98 void InverseInterpolationTable::initDerivatives() {
99 for(
unsigned i = 0; i < nodes.size()-1; i++) {
100 if((nodes.at(i+1).getX() - nodes.at(i).getX()) == 0.0)
101 nodes[i].setYPrime(0.0);
103 nodes[i].setYPrime((nodes.at(i+1).getY() - nodes.at(i).getY())/(nodes.at(i+1).getX() - nodes.at(i).getX()));
105 nodes.back().setYPrime(nodes.at(nodes.size()-2).getYPrime());
108 void InverseInterpolationTable::setFunctionDomain() {
110 if(nodes.front()>nodes.back()) {
111 xMin = nodes.back().getX();
112 xMax = nodes.front().getX();
114 xMin = nodes.front().getX();
115 xMax = nodes.back().getX();
121 std::vector<InterpolationNode>::const_iterator iter =
122 std::lower_bound(nodes.begin(), nodes.end(), x);
124 if(iter==nodes.begin())
125 return nodes.front().getY();
127 if(iter==nodes.end())
128 return nodes.back().getY();
130 std::vector<InterpolationNode>::const_iterator previousIter = iter - 1;
131 const G4double dx = x - previousIter->getX();
132 return previousIter->getY() + previousIter->getYPrime()*dx;
137 for(std::vector<InterpolationNode>::const_iterator n=nodes.begin(); n!=nodes.end(); ++n)
138 message += n->print();
Simple interpolation table for the inverse of a IFunction1D functor.
virtual G4double getXMaximum() const
Return the maximum allowed value of the independent variable.
G4double xMin
Minimum value of the independent variable.
G4double xMax
Maximum value of the independent variable.
virtual G4double getXMinimum() const
Return the minimum allowed value of the independent variable.
InverseInterpolationTable(IFunction1D const &f, const unsigned int nNodes=30)
G4double operator()(const G4double x) const
Compute the value of the function.
std::string print() const