G4INCLInverseInterpolationTable.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // INCL++ intra-nuclear cascade model
00027 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
00028 // Davide Mancusi, CEA
00029 // Alain Boudard, CEA
00030 // Sylvie Leray, CEA
00031 // Joseph Cugnon, University of Liege
00032 //
00033 #define INCLXX_IN_GEANT4_MODE 1
00034 
00035 #include "globals.hh"
00036 
00044 #ifndef G4INCLINVERSEINTERPOLATIONTABLE_HH_
00045 #define G4INCLINVERSEINTERPOLATIONTABLE_HH_
00046 
00047 #include "G4INCLIFunction1D.hh"
00048 #include <algorithm>
00049 #include <functional>
00050 #include <sstream>
00051 
00052 namespace G4INCL {
00053 
00054   // Forward declaration
00055   class InverseInterpolationTable;
00056 
00058   class InterpolationNode {
00059     public:
00060       InterpolationNode(const G4double x0, const G4double y0, const G4double yPrime0) :
00061         x(x0),
00062         y(y0),
00063         yPrime(yPrime0)
00064     {}
00065 
00066       virtual ~InterpolationNode() {}
00067 
00068       G4bool operator<(const InterpolationNode &rhs) const {
00069         return (x < rhs.x);
00070       }
00071 
00072       G4bool operator<=(const InterpolationNode &rhs) const {
00073         return (x <= rhs.x);
00074       }
00075 
00076       G4bool operator>(const InterpolationNode &rhs) const {
00077         return (x > rhs.x);
00078       }
00079 
00080       G4bool operator>=(const InterpolationNode &rhs) const {
00081         return (x >= rhs.x);
00082       }
00083 
00085       friend G4bool operator<(const InterpolationNode &lhs, const G4double rhs) {
00086         return lhs.x < rhs;
00087       }
00088 
00089       G4double getX() const { return x; }
00090       G4double getY() const { return y; }
00091       G4double getYPrime() const { return yPrime; }
00092 
00093       void setX(const G4double x0) { x=x0; }
00094       void setY(const G4double y0) { y=y0; }
00095       void setYPrime(const G4double yPrime0) { yPrime=yPrime0; }
00096 
00097       std::string print() const {
00098         std::stringstream message;
00099         message << "x, y, yPrime: " << x << '\t' << y << '\t' << yPrime << std::endl;
00100         return message.str();
00101       }
00102 
00103     protected:
00105       G4double x;
00107       G4double y;
00109       G4double yPrime;
00110   };
00111 
00113   class InverseInterpolationTable : public IFunction1D {
00114     public:
00115       InverseInterpolationTable(IFunction1D const &f, const unsigned int nNodes=30);
00116       InverseInterpolationTable(std::vector<G4double> const &x, std::vector<G4double> const &y);
00117       virtual ~InverseInterpolationTable() {}
00118 
00119       unsigned int getNumberOfNodes() const { return nodes.size(); }
00120 
00121       std::vector<G4double> getNodeAbscissae() const {
00122         std::vector<G4double> x(nodes.size());
00123         std::transform(nodes.begin(), nodes.end(), x.begin(),
00124             std::mem_fun_ref(&InterpolationNode::getX));
00125         return x;
00126       }
00127 
00128       std::vector<G4double> getNodeValues() const {
00129         std::vector<G4double> y(nodes.size());
00130         std::transform(nodes.begin(), nodes.end(), y.begin(),
00131             std::mem_fun_ref(&InterpolationNode::getY));
00132         return y;
00133       }
00134 
00135       G4double operator()(const G4double x) const;
00136 
00137       std::string print() const;
00138 
00139     private:
00141       void initDerivatives();
00142 
00144       void setFunctionDomain();
00145 
00147       std::vector<InterpolationNode> nodes;
00148 
00149   };
00150 
00151 }
00152 
00153 #endif // G4INCLINVERSEINTERPOLATIONTABLE_HH_

Generated on Mon May 27 17:48:35 2013 for Geant4 by  doxygen 1.4.7