File indexing completed on 2025-01-18 09:58:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #define INCLXX_IN_GEANT4_MODE 1
0035
0036 #include "globals.hh"
0037
0038
0039
0040
0041
0042
0043
0044
0045 #ifndef G4INCLINTERPOLATIONTABLE_HH_
0046 #define G4INCLINTERPOLATIONTABLE_HH_
0047
0048 #include "G4INCLIFunction1D.hh"
0049 #include <algorithm>
0050 #include <functional>
0051 #include <sstream>
0052
0053 namespace G4INCL {
0054
0055
0056 class InterpolationNode {
0057 public:
0058 InterpolationNode(const G4double x0, const G4double y0, const G4double yPrime0) :
0059 x(x0),
0060 y(y0),
0061 yPrime(yPrime0)
0062 {}
0063
0064 virtual ~InterpolationNode() {}
0065
0066 G4bool operator<(const InterpolationNode &rhs) const {
0067 return (x < rhs.x);
0068 }
0069
0070 G4bool operator<=(const InterpolationNode &rhs) const {
0071 return (x <= rhs.x);
0072 }
0073
0074 G4bool operator>(const InterpolationNode &rhs) const {
0075 return (x > rhs.x);
0076 }
0077
0078 G4bool operator>=(const InterpolationNode &rhs) const {
0079 return (x >= rhs.x);
0080 }
0081
0082 G4double getX() const { return x; }
0083 G4double getY() const { return y; }
0084 G4double getYPrime() const { return yPrime; }
0085
0086 void setX(const G4double x0) { x=x0; }
0087 void setY(const G4double y0) { y=y0; }
0088 void setYPrime(const G4double yPrime0) { yPrime=yPrime0; }
0089
0090 std::string print() const {
0091 std::stringstream message;
0092 message << "x, y, yPrime: " << x << '\t' << y << '\t' << yPrime << '\n';
0093 return message.str();
0094 }
0095
0096 protected:
0097
0098 G4double x;
0099
0100 G4double y;
0101
0102 G4double yPrime;
0103 };
0104
0105
0106 class InterpolationTable : public IFunction1D {
0107 public:
0108 InterpolationTable(std::vector<G4double> const &x, std::vector<G4double> const &y);
0109 virtual ~InterpolationTable() {}
0110
0111 std::size_t getNumberOfNodes() const { return nodes.size(); }
0112
0113 std::vector<G4double> getNodeAbscissae() const;
0114
0115 std::vector<G4double> getNodeValues() const;
0116
0117 G4double operator()(const G4double x) const;
0118
0119 std::string print() const;
0120
0121 protected:
0122 InterpolationTable();
0123
0124
0125 void initDerivatives();
0126
0127
0128 std::vector<InterpolationNode> nodes;
0129
0130 };
0131
0132 }
0133
0134 #endif