Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4INCLInverseInterpolationTable.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// INCL++ intra-nuclear cascade model
27// Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28// Davide Mancusi, CEA
29// Alain Boudard, CEA
30// Sylvie Leray, CEA
31// Joseph Cugnon, University of Liege
32//
33// INCL++ revision: v5.1.8
34//
35#define INCLXX_IN_GEANT4_MODE 1
36
37#include "globals.hh"
38
39/** \file G4INCLInverseInterpolationTable.hh
40 * \brief Simple interpolation table for the inverse of a IFunction1D functor
41 *
42 * \date 16 July 2012
43 * \author Davide Mancusi
44 */
45
46#ifndef G4INCLINVERSEINTERPOLATIONTABLE_HH_
47#define G4INCLINVERSEINTERPOLATIONTABLE_HH_
48
49#include "G4INCLIFunction1D.hh"
50#include <algorithm>
51#include <functional>
52#include <sstream>
53
54namespace G4INCL {
55
56 // Forward declaration
57 class InverseInterpolationTable;
58
59 /// \brief Interpolation node
61 public:
62 InterpolationNode(const G4double x0, const G4double y0, const G4double yPrime0) :
63 x(x0),
64 y(y0),
65 yPrime(yPrime0)
66 {}
67
68 virtual ~InterpolationNode() {}
69
71 return (x < rhs.x);
72 }
73
75 return (x <= rhs.x);
76 }
77
79 return (x > rhs.x);
80 }
81
83 return (x >= rhs.x);
84 }
85
86 /// \brief Overloaded comparison operator for STL algorithms
87 friend G4bool operator<(const InterpolationNode &lhs, const G4double rhs) {
88 return lhs.x < rhs;
89 }
90
91 G4double getX() const { return x; }
92 G4double getY() const { return y; }
93 G4double getYPrime() const { return yPrime; }
94
95 void setX(const G4double x0) { x=x0; }
96 void setY(const G4double y0) { y=y0; }
97 void setYPrime(const G4double yPrime0) { yPrime=yPrime0; }
98
99 std::string print() const {
100 std::stringstream message;
101 message << "x, y, yPrime: " << x << '\t' << y << '\t' << yPrime << std::endl;
102 return message.str();
103 }
104
105 protected:
106 /// \brief abscissa
108 /// \brief function value
110 /// \brief function derivative
112 };
113
114 /// \brief Class for interpolating the inverse of a 1-dimensional function
116 public:
117 InverseInterpolationTable(IFunction1D const &f, const unsigned int nNodes=30);
118 InverseInterpolationTable(std::vector<G4double> const &x, std::vector<G4double> const &y);
120
121 unsigned int getNumberOfNodes() const { return nodes.size(); }
122
123 std::vector<G4double> getNodeAbscissae() const {
124 std::vector<G4double> x(nodes.size());
125 std::transform(nodes.begin(), nodes.end(), x.begin(),
126 std::mem_fun_ref(&InterpolationNode::getX));
127 return x;
128 }
129
130 std::vector<G4double> getNodeValues() const {
131 std::vector<G4double> y(nodes.size());
132 std::transform(nodes.begin(), nodes.end(), y.begin(),
133 std::mem_fun_ref(&InterpolationNode::getY));
134 return y;
135 }
136
137 G4double operator()(const G4double x) const;
138
139 std::string print() const;
140
141 private:
142 /// \brief Initialise the values of the node derivatives
143 void initDerivatives();
144
145 /// \brief Set the function domain
146 void setFunctionDomain();
147
148 /// \brief Interpolating nodes
149 std::vector<InterpolationNode> nodes;
150
151 };
152
153}
154
155#endif // G4INCLINVERSEINTERPOLATIONTABLE_HH_
Functor for 1-dimensional mathematical functions.
double G4double
Definition: G4Types.hh:64
bool G4bool
Definition: G4Types.hh:67
G4bool operator>(const InterpolationNode &rhs) const
G4bool operator<=(const InterpolationNode &rhs) const
InterpolationNode(const G4double x0, const G4double y0, const G4double yPrime0)
void setYPrime(const G4double yPrime0)
G4bool operator>=(const InterpolationNode &rhs) const
G4bool operator<(const InterpolationNode &rhs) const
friend G4bool operator<(const InterpolationNode &lhs, const G4double rhs)
Overloaded comparison operator for STL algorithms.
Class for interpolating the inverse of a 1-dimensional function.
G4double operator()(const G4double x) const
Compute the value of the function.
std::vector< G4double > getNodeAbscissae() const